/* Design tokens — reference dataviz palette (light + dark). */
:root {
  color-scheme: light dark;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* blue  — total users */
  --series-2: #1baf7a;   /* aqua  — transacting */
  --nodata: #f0efec;
  --delta-up: #006300;
  --delta-down: #d03b3b;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --nodata: #383835;
    --delta-up: #0ca30c;
    --delta-down: #e66767;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; font-size: 15px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
}
.topbar nav a:hover { background: var(--nodata); }
.topbar nav a.active { color: var(--text-primary); font-weight: 600; background: var(--nodata); }

main { padding: 16px 20px 32px; max-width: 1400px; margin: 0 auto; }

/* Filter row — one row above the charts */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { color: var(--text-muted); font-size: 12px; }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-1);
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  padding: 6px 12px;
  cursor: pointer;
}
.segmented button:hover { background: var(--nodata); }
.segmented button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.month-slider { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.month-slider input[type=range] { flex: 1; accent-color: var(--accent); }
.month-label {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 76px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

/* Map layout */
.map-layout { display: flex; gap: 16px; align-items: flex-start; }
.map-msg {
  background: var(--nodata);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.map-main { flex: 1 1 auto; min-width: 0; }
#map svg { display: block; width: 100%; height: auto; }
.country-path { stroke: var(--surface-1); stroke-width: 0.5; cursor: pointer; }
.country-path:hover { stroke: var(--text-primary); stroke-width: 1; }
.country-path.selected { stroke: var(--text-primary); stroke-width: 1.2; }

.legend { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--text-muted); font-size: 12px; }
.legend-bar { width: 180px; height: 10px; border-radius: 5px; border: 1px solid var(--border); }
.legend-note { margin-left: 8px; }

/* Detail side panel */
.panel { width: 360px; flex: 0 0 360px; }
.panel h2 { margin: 0 0 2px; font-size: 17px; }
.panel .subtitle { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.panel .stat-row { display: flex; gap: 18px; margin: 10px 0 14px; }
.stat .stat-value { font-size: 20px; font-weight: 650; }
.stat .stat-label { font-size: 11px; color: var(--text-muted); }
.panel h3 { font-size: 12px; color: var(--text-secondary); margin: 14px 0 4px; font-weight: 600; }
.panel .empty { color: var(--text-muted); padding: 30px 0; text-align: center; }
.panel-close {
  float: right; border: 0; background: transparent; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 2px 6px;
}
.panel-close:hover { color: var(--text-primary); }

/* Tooltip */
.viz-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  padding: 8px 10px;
  font-size: 12px;
  z-index: 50;
  display: none;
  max-width: 240px;
}
.viz-tooltip .tt-title { font-weight: 650; margin-bottom: 3px; }
.viz-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-secondary); }
.viz-tooltip .tt-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Line charts */
.chart-svg text { font-family: inherit; }
.axis-label { fill: var(--text-muted); font-size: 10px; }
.grid-line { stroke: var(--gridline); stroke-width: 1; }
.base-line { stroke: var(--baseline); stroke-width: 1; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.direct-label { font-size: 10px; font-weight: 600; fill: var(--text-secondary); }
.crosshair { stroke: var(--baseline); stroke-dasharray: 3 3; }

/* Table view */
.table-tools { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.search-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font: inherit;
  padding: 7px 12px;
  width: 220px;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 8px 10px; text-align: right; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--baseline);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table thead th:hover { color: var(--text-primary); }
.data-table tbody td {
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
.data-table tbody tr:hover { background: var(--nodata); cursor: pointer; }
.country-cell { display: flex; align-items: center; gap: 8px; }
.country-code { color: var(--text-muted); font-size: 11px; }
.delta-up { color: var(--delta-up); }
.delta-down { color: var(--delta-down); }
.delta-flat { color: var(--text-muted); }
.spark { display: block; }
.count-note { color: var(--text-muted); font-size: 12px; }

@media (max-width: 900px) {
  .map-layout { flex-direction: column; }
  .panel { width: 100%; flex: 1 1 auto; }
}
