*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 2rem 0 1.5rem;
  box-shadow: var(--shadow);
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.header-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.language-switcher {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--bg);
}

.language-switcher button {
  appearance: none;
  min-width: 2.5rem;
  border: 0;
  border-radius: 0.38rem;
  padding: 0.35rem 0.55rem;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
}

.language-switcher button:hover,
.language-switcher button:focus-visible {
  color: var(--accent);
}

.language-switcher button.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.updated {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

.controls {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0 1rem;
  flex-wrap: wrap;
}

.controls input,
.controls select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9375rem;
  background: var(--surface);
  color: var(--text);
}

.controls input {
  flex: 1;
  min-width: 200px;
}

.controls input:focus,
.controls select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

thead {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover .column-sort {
  color: var(--accent);
}

thead th + th {
  border-left: 2px solid var(--border);
}

tbody td + td {
  border-left: 1px solid #eef0f3;
}

.column-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.column-sort:hover {
  color: var(--accent);
}

.column-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.column-sort::after {
  content: " \2195";
  opacity: 0.3;
  font-size: 0.75rem;
}

.sorted-asc .column-sort::after {
  content: " \2191";
  opacity: 1;
  color: var(--accent);
}

.sorted-desc .column-sort::after {
  content: " \2193";
  opacity: 1;
  color: var(--accent);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #f3f4f6;
}

.broker-name {
  font-weight: 600;
  min-width: 210px;
}

.broker-link,
.license-link {
  display: block;
  width: fit-content;
  color: var(--accent);
  text-decoration: none;
}

.broker-link:hover,
.license-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.methodology {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

.methodology h2 {
  font-size: 1rem;
  margin-bottom: 0.7rem;
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.methodology p {
  font-size: 0.82rem;
}

.methodology strong,
.methodology span {
  display: block;
}

.methodology span {
  color: #475569;
  margin-top: 0.15rem;
}

.methodology a {
  color: var(--accent);
}

.broker-name span,
.broker-name small,
.access-cell span,
.access-cell small,
.regulation,
.foreign-note {
  display: block;
}

.license-cell {
  min-width: 220px;
}

.license-badge {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.license-local {
  background: #dcfce7;
  color: #166534;
}

.license-global {
  background: #fef3c7;
  color: #92400e;
}

.license-link,
.regulation {
  font-size: 0.84rem;
}

.broker-type,
.access-cell small,
.foreign-note {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 0.2rem;
}

.access-cell {
  min-width: 190px;
}

.access-badge {
  display: inline-block !important;
  width: fit-content;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: #eef2ff;
  color: #3730a3;
}

.access-licensed_indonesia {
  background: #dcfce7;
  color: #166534;
}

.access-online_account_indonesia {
  background: #dbeafe;
  color: #1e40af;
}

.access-accepts_indonesia {
  background: #fef3c7;
  color: #92400e;
}

.foreign-note {
  color: #b45309;
}

.metric-cell {
  min-width: 145px;
}

.metric-value,
.metric-note,
.metric-source {
  display: block;
}

.metric-value {
  font-weight: 600;
}

.metric-value-link {
  width: fit-content;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.metric-value-link:hover {
  color: var(--accent-hover);
}

.metric-note,
.metric-source {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.metric-source {
  width: fit-content;
  text-decoration: none;
}

.metric-source:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.metric-source-third-party {
  color: #b45309;
}

.metric-source-third-party:hover {
  color: #92400e;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
}

.source-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.source-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.source-proof {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.loading,
.error,
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

.error {
  color: var(--danger);
}

.retry-button {
  appearance: none;
  margin-left: 0.35rem;
  border: 1px solid var(--accent);
  border-radius: 0.45rem;
  padding: 0.35rem 0.65rem;
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.retry-button:hover,
.retry-button:focus-visible {
  background: #eff6ff;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.toggle-incomplete {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.toggle-incomplete:hover,
.toggle-incomplete:focus-visible {
  border-color: var(--accent);
  background: #eff6ff;
}

.toggle-incomplete[hidden] {
  display: none;
}

.count {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0 0 0 auto;
}

.footer {
  margin-top: auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer p {
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
}

@media (max-width: 900px) {
  .methodology-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .header h1 {
    font-size: 1.375rem;
  }

  .header-topline {
    align-items: flex-start;
  }

  th, td {
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
  }

  .controls {
    flex-direction: column;
  }

  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .count {
    margin-left: 0;
  }

  .methodology-grid {
    grid-template-columns: 1fr;
  }

  .controls input {
    min-width: unset;
  }
}
