/* ============================================================
 * ATLAS — clean working UI
 * ============================================================ */

:root {
  --bg-0: #07090d;
  --bg-1: #0e1320;
  --bg-2: #161d2e;
  --bg-3: #1f2840;
  --line: #2a3450;
  --line-2: #3a4566;
  --text: #e8eef7;
  --text-2: #b6c0d4;
  --muted: #98a4bc;
  --muted-2: #c9d2e3;
  --accent: #5fb4ff;
  --accent-2: #f0c674;
  --accent-3: #c89af0;
  --ok: #6ed99a;
  --warn: #f0a96d;
  --bad: #ff7a8a;
  --glass: rgba(14, 19, 32, 0.78);
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
img, svg { max-width: 100%; }
table { table-layout: auto; word-break: break-word; }
.long-text, p, li, td, th, .stat-name, .stat-method, .label, .value, .desc, .v, .l {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

body {
  display: grid;
  grid-template-rows: auto auto 1fr 32px;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(95,180,255,.08), transparent 60%),
    radial-gradient(ellipse 60% 70% at 100% 100%, rgba(200,154,240,.06), transparent 60%),
    radial-gradient(ellipse 70% 50% at 0% 90%, rgba(240,198,116,.05), transparent 60%),
    var(--bg-0);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: "Space Grotesk", sans-serif; letter-spacing: -0.02em; margin: 0; }
.kbd, code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.92em; }
.muted { color: var(--muted); }

/* ============= TOPBAR ============= */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 0 20px;
  height: 60px;
  background: linear-gradient(180deg, rgba(14,19,32,.95), rgba(14,19,32,.85));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: #07090d; font-weight: 700;
  box-shadow: 0 4px 14px rgba(95,180,255,.4);
}
.brand h1 {
  font-size: 18px; letter-spacing: 5px; font-weight: 700;
  background: linear-gradient(90deg, var(--text), var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand .tag {
  font-size: 11px; color: var(--muted);
  border-left: 1px solid var(--line); padding-left: 12px;
  text-transform: uppercase; letter-spacing: 1px;
}

.topbar-center { display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Search */
.search-wrap { position: relative; width: 360px; max-width: 100%; }
#search {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 14px 9px 36px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c879c' stroke-width='2.2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat; background-position: 12px center;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
#search:focus {
  outline: none; border-color: var(--accent);
  background-color: var(--bg-2);
  box-shadow: 0 0 0 4px rgba(95,180,255,.18);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #0c1018;
  border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 16px 50px rgba(0,0,0,.7), 0 0 0 1px rgba(95,180,255,.06);
  max-height: 460px; overflow-y: auto;
  display: none; z-index: 60;
  color: var(--text);
}
.sr-item {
  background: transparent;
}
.sr-item:hover, .sr-item.active {
  background: rgba(95,180,255,.16);
  color: var(--text);
}
.sr-item .meta { color: var(--muted-2); }
.sr-head {
  background: #050709;
  color: var(--accent);
}
.search-results.open { display: block; }
.sr-head {
  padding: 8px 14px; font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  background: rgba(0,0,0,.25); border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.sr-item {
  padding: 9px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.sr-item:hover, .sr-item.active { background: rgba(95,180,255,.1); color: var(--accent); }
.sr-item:last-child { border-bottom: none; }
.sr-item .icon { width: 22px; text-align: center; opacity: .85; }
.sr-item .meta { color: var(--muted); font-size: 11px; margin-top: 1px; }

/* View toggle */
.view-toggle {
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.vt-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.vt-btn:hover { color: var(--text); }
.vt-btn.active {
  background: var(--bg-3);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}

/* Buttons */
.btn {
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.btn:hover {
  border-color: var(--accent);
  background: rgba(95,180,255,.1);
  color: var(--accent);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  width: 36px; height: 36px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.btn.ghost:hover { background: var(--bg-1); border-color: var(--line); color: var(--text); }
.btn.primary {
  background: linear-gradient(135deg, rgba(95,180,255,.18), rgba(200,154,240,.14));
  border-color: rgba(95,180,255,.5);
  color: var(--accent-2);
  box-shadow: 0 0 16px rgba(95,180,255,.18);
}
.btn.primary:hover {
  background: linear-gradient(135deg, rgba(95,180,255,.3), rgba(200,154,240,.22));
  color: #fff;
}
.link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.link-button:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Deep dives dropdown */
.dd-wrap { position: relative; }
.dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 320px;
  background: #0c1018;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 16px 50px rgba(0,0,0,.7), 0 0 0 1px rgba(95,180,255,.06);
  z-index: 60;
  display: none;
  max-height: 80vh;
  overflow-y: auto;
}
.dd-menu.open { display: block; }
.dd-section {
  padding: 8px 10px 4px;
  font-size: 9.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}
.dd-section:first-child { border-top: none; margin-top: 0; }
.dd-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12.5px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s;
}
.dd-item:hover {
  background: rgba(95,180,255,.12);
  color: var(--accent);
  padding-left: 16px;
}

/* ============= MAIN ============= */
.main {
  display: grid;
  grid-template-columns: 1fr 440px;
  height: auto;
  min-height: 0;
}
.canvas {
  position: relative;
  background:
    radial-gradient(ellipse at center, rgba(13,20,32,1), rgba(7,9,13,1));
  overflow: hidden;
  border-right: 1px solid var(--line);
}
.pane { position: absolute; inset: 0; display: none; }
.pane.active { display: block; }
#globe, #us-map { width: 100%; height: 100%; }
#us-map svg { width: 100%; height: 100%; display: block; cursor: grab; }
#us-map svg:active { cursor: grabbing; }
.zoom-layer { will-change: transform; }

/* US states */
@keyframes spin {
  0%   { opacity: 0.4; transform: scale(0.85); }
  50%  { opacity: 1;   transform: scale(1.05); }
  100% { opacity: 0.4; transform: scale(0.85); }
}

.us-state {
  /* Default fill set inline as SVG attribute, NOT here, so JS .style("fill",...) can override */
  stroke: #2a3450;
  stroke-width: 0.7;
  cursor: pointer;
  transition: fill .25s, stroke .15s;
}
.us-state:not([style*="fill"]) {
  /* Fallback default for unstyled states */
  fill: #1d2840;
}
.us-state:hover {
  stroke: var(--accent-2);
  stroke-width: 1.6;
  filter: drop-shadow(0 0 10px rgba(240,198,116,.5));
}
.us-state.selected {
  stroke: var(--accent-2);
  stroke-width: 2.2;
  filter: drop-shadow(0 0 14px rgba(240,198,116,.7));
}
.us-state-label {
  font-family: "Space Grotesk", sans-serif;
  font-size: 9.5px;
  fill: rgba(232,238,247,.85);
  pointer-events: none;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}

/* Map zoom buttons */
.map-zoom-ctrl {
  position: absolute;
  right: 16px; top: 16px;
  display: flex; flex-direction: column;
  gap: 4px;
  z-index: 5;
}
.map-zoom-ctrl button {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
  font-family: "Space Grotesk";
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
}
.map-zoom-ctrl button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(95,180,255,.15);
}

/* List view */
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  font-size: 13px;
  flex-wrap: wrap;
}
.list-toolbar strong { font-family: "Space Grotesk"; font-size: 14px; }
.list-controls {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.list-controls input,
.list-controls select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
}
.list-controls input { width: 160px; }
.list-controls input:focus,
.list-controls select:focus { outline: none; border-color: var(--accent); }
.list-controls button {
  width: 32px; height: 32px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
.list-controls button:hover { border-color: var(--accent); color: var(--accent); }

.list-body {
  position: absolute;
  top: 64px; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  padding: 14px 18px 30px;
}
.list-row {
  display: grid;
  grid-template-columns: 32px 1fr 80px 120px;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all .15s;
  align-items: center;
  min-width: 0;
}
.list-row:hover {
  transform: translateX(3px);
  border-color: var(--accent);
  box-shadow: -3px 0 16px rgba(95,180,255,.08);
}
.list-row .rank {
  font-family: "JetBrains Mono";
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.list-row .name {
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.list-row .name .code {
  font-family: "JetBrains Mono";
  font-size: 10.5px;
  color: var(--muted);
  margin-left: 6px;
}
.list-row .pop {
  color: var(--muted);
  font-family: "JetBrains Mono";
  font-size: 11.5px;
  text-align: right;
}
.list-row .metric-val {
  font-family: "Space Grotesk";
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Layer bar */
.layer-bar {
  position: absolute;
  top: 16px; left: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 11px;
  display: flex; align-items: center; gap: 8px;
  z-index: 5;
}
.layer-bar label { color: var(--muted); }
.layer-bar select {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
}

/* Map legend */
.map-legend {
  position: absolute;
  left: 16px; bottom: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 11.5px;
  color: var(--muted);
  max-width: 290px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.map-legend strong {
  color: var(--text);
  font-family: "Space Grotesk";
  font-size: 12.5px;
  display: block;
  margin-bottom: 4px;
}
.map-legend .gradient {
  height: 8px;
  background: linear-gradient(90deg, #6ed99a, #f0c674, #ff7a8a);
  border-radius: 4px;
  margin: 8px 0 4px;
}
.map-legend .gradient.inv,
.map-legend .gradient.high-good {
  background: linear-gradient(90deg, #ff7a8a, #f0c674, #6ed99a);
}
.map-legend .gradient.high-bad {
  background: linear-gradient(90deg, #6ed99a, #f0c674, #ff7a8a);
}
.map-legend .gradient.neutral {
  background: linear-gradient(90deg, #1d2840, #5fb4ff, #f0c674);
}
.map-legend .scale { display: flex; justify-content: space-between; font-family: "JetBrains Mono"; font-size: 10px; }

/* Hint pill */
.hint-pill {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 5;
  font-feature-settings: "tnum";
}

/* Globe HUD */
.globe-hud {
  position: absolute;
  top: 16px; left: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 11px;
  max-width: 260px;
  z-index: 5;
}
.globe-hud strong {
  display: block;
  font-family: "Space Grotesk";
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.globe-hud .legend-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0; font-size: 11px;
}
.globe-hud .line {
  width: 22px; height: 2px;
  border-radius: 1px;
  box-shadow: 0 0 6px currentColor;
}
.globe-hud .globe-tip {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 10.5px;
  line-height: 1.55;
}
.globe-stats-panel {
  position: absolute;
  bottom: 16px; right: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 11.5px;
  max-width: 320px;
  z-index: 5;
  color: var(--text-2);
}
.globe-stats-panel strong {
  font-family: "Space Grotesk";
  font-size: 12.5px;
  color: var(--accent-2);
  display: block;
  margin-bottom: 2px;
}

/* ============= RIGHT PANEL ============= */
.panel {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  overflow-y: auto;
}

/* HERO landing */
.hero {
  padding: 24px 20px;
}
.hero h1 {
  font-size: 26px;
  margin: 0 0 4px;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--text), var(--accent) 60%, var(--accent-3));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1.15;
}
.hero p.sub { color: var(--muted); font-size: 13px; margin: 4px 0 18px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.hero-tile {
  background: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  overflow: hidden;
}
.hero-tile::before {
  content: "";
  position: absolute; top: 0; left: 0; width: 3px; height: 100%;
  background: var(--accent);
  opacity: .8;
}
.hero-tile.gold::before { background: var(--accent-2); }
.hero-tile.green::before { background: var(--ok); }
.hero-tile.purple::before { background: var(--accent-3); }
.hero-tile.coral::before { background: var(--bad); }
.hero-tile.orange::before { background: var(--warn); }
.hero-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(95,180,255,.15);
}
.hero-tile .icon {
  font-size: 22px;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 12px rgba(95,180,255,.4));
}
.hero-tile .label {
  font-size: 9.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-tile .value {
  font-family: "Space Grotesk";
  font-size: 20px;
  font-weight: 700;
  margin: 2px 0 5px;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.hero-tile .desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.hero-tile.span2 { grid-column: span 2; }
.hero-tile.featured {
  background: linear-gradient(135deg, rgba(95,180,255,.18), rgba(200,154,240,.1));
  border: 1px solid rgba(95,180,255,.4);
}
.hero-tile.featured .value { font-size: 26px; }

/* State / country detail */
.detail-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(95,180,255,.1), rgba(240,198,116,.04), transparent);
}
.detail-header .flag { font-size: 32px; }
.detail-header h2 { font-size: 22px; }
.detail-header .sub {
  color: var(--muted); font-size: 11.5px;
  font-family: "JetBrains Mono"; margin-top: 4px;
}
.detail-header .actions {
  margin-left: auto;
  display: flex; gap: 6px;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px 4px;
}
.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 10px 14px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.kpi::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 3px; height: 100%; background: var(--accent);
  box-shadow: 0 0 10px currentColor;
}
.kpi.r::before { background: var(--bad); color: var(--bad); }
.kpi.g::before { background: var(--ok); color: var(--ok); }
.kpi.y::before { background: var(--accent-2); color: var(--accent-2); }
.kpi.p::before { background: var(--accent-3); color: var(--accent-3); }
.kpi .label {
  font-size: 9.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .value {
  font-family: "Space Grotesk";
  font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 3px; letter-spacing: -0.02em;
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Tabs */
.tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 6px 11px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 11.5px;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.tab.active {
  background: var(--bg-2);
  color: var(--accent);
  border-color: var(--accent);
  border-bottom-color: var(--bg-2);
}
.tab:hover:not(.active) { color: var(--text); }

.tab-content { padding: 14px 16px; }

/* Stat card */
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: transform .12s, box-shadow .12s;
  overflow: hidden;
  color: var(--text);
  font-family: inherit;
}
button.stat {
  color: var(--text);
  font-family: inherit;
}
button.stat .stat-name,
.data-table strong,
.stat strong {
  color: var(--text);
}
.data-table td { color: var(--text-2); }
.data-table .muted,
.stat .muted { color: var(--muted); }
.money-note {
  background: rgba(240,198,116,.08);
  border: 1px solid rgba(240,198,116,.2);
  border-left: 3px solid var(--accent-2);
  border-radius: 6px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  padding: 9px 11px;
  margin: 8px 0 10px;
}
.record-badge {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--accent-2);
  border-radius: 5px;
  padding: 3px 7px;
  font-family: "JetBrains Mono";
  font-size: 10px;
  line-height: 1.35;
  margin: 2px 0 5px;
}
.stat:hover {
  transform: translateX(2px);
  box-shadow: -2px 0 12px rgba(95,180,255,.06);
}
.stat.warn { border-left-color: var(--warn); }
.stat.stale { border-left-color: var(--accent-3); }
.stat-head {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 10px;
  flex-wrap: wrap;
}
.stat-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1 1 60%;
  min-width: 0;
}
.stat-value {
  font-family: "Space Grotesk";
  font-size: 15px;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  flex: 0 1 auto;
  max-width: 100%;
  word-break: break-word;
}
.stat-trust {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  padding: 3px 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: "JetBrains Mono";
  letter-spacing: 0.2px;
}
.stat-trust.ok { color: var(--ok); border-color: rgba(110,217,154,.3); }
.stat-trust.warn { color: var(--warn); border-color: rgba(240,169,109,.3); }
.stat-trust.stale { color: var(--accent-3); border-color: rgba(200,154,240,.3); }
.stat-trust .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.stat-meta { font-size: 10.5px; color: var(--muted); margin-top: 6px; font-family: "JetBrains Mono"; }
.stat-method { font-size: 11.5px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }
.stat-sources { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.src-link {
  font-size: 10.5px;
  background: var(--bg-1);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line);
  transition: all .12s;
}
.src-link:hover {
  background: var(--accent);
  color: var(--bg-0);
}

.subhead {
  color: var(--muted);
  font-size: 10.5px;
  font-family: "Space Grotesk";
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 18px 0 8px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.subhead::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* Tables */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 6px; border-radius: 6px; }
.data-table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 12px; font-feature-settings: "tnum"; table-layout: auto; }
.data-table th, .data-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  min-width: 70px;
}
.data-table th { white-space: normal; min-width: 90px; }
/* Wide content cells get more breathing room */
.data-table td:not(.num):not(.mono) { min-width: 110px; line-height: 1.45; }
.data-table th {
  color: var(--muted); font-weight: 600;
  text-transform: uppercase; font-size: 9.5px; letter-spacing: 1.2px;
  background: var(--bg-1);
}
.data-table td.num {
  text-align: right;
  font-family: "JetBrains Mono";
  color: var(--accent-2);
  font-weight: 500;
}
.data-table tbody tr:hover { background: rgba(95,180,255,.04); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(840px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px 30px;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-card h2 { font-size: 24px; margin-bottom: 6px; letter-spacing: -0.02em; padding-right: 50px; }
.modal-card p { overflow-wrap: anywhere; }

/* Data quality banner */
.data-quality {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(110,217,154,.08), rgba(95,180,255,.06));
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  margin: 10px 0 18px;
  font-size: 11.5px;
  color: var(--text-2);
  align-items: center;
}
.data-quality .dq-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: "JetBrains Mono";
  font-size: 10.5px;
}
.data-quality .dq-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 6px var(--ok);
}
.data-quality .dq-pill.warn .dot { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.data-quality .dq-asof { color: var(--muted); font-family: "JetBrains Mono"; font-size: 10.5px; }
.data-quality .dq-spacer { flex: 1; }
.data-quality .dq-sources {
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 600;
}
.modal-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 12px -8px 18px;
  padding: 10px 14px 12px;
  background: rgba(12,16,24,.985);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
}
.modal-card { scroll-padding-top: 74px; }
.modal-card .subhead { scroll-margin-top: 84px; }
.modal-nav-label {
  color: var(--muted);
  font-family: "JetBrains Mono";
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin: 0 0 6px 2px;
}
.modal-nav-items {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.modal-nav button {
  flex: 0 0 auto;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-2);
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 10.5px;
  cursor: pointer;
}
.modal-nav button:hover {
  color: var(--accent);
  border-color: rgba(95,180,255,.45);
  background: var(--bg-3);
}
.party-bar {
  display: flex;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  background: #0e1320;
  margin-top: 7px;
}
.party-bar .d { background: #3b82f6; }
.party-bar .r { background: #ef4444; }
.party-bar-label {
  display: flex;
  justify-content: space-between;
  font-family: "JetBrains Mono";
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}
.influence-note {
  background: rgba(240,198,116,.08);
  border: 1px solid rgba(240,198,116,.18);
  border-left: 3px solid var(--accent-2);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 10px 12px;
}
.influence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}
.influence-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 13px;
  min-width: 0;
}
.influence-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.influence-card h3 {
  font-size: 14px;
  margin: 0;
  letter-spacing: 0;
}
.influence-card-head span {
  color: var(--accent-2);
  font-family: "JetBrains Mono";
  font-size: 10px;
  white-space: nowrap;
}
.influence-card p {
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.55;
  margin: 7px 0 9px;
}
.mini-kv {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
  font-size: 11px;
}
.mini-kv span, .mini-label {
  color: var(--muted);
  font-family: "JetBrains Mono";
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.mini-kv strong { color: var(--accent-2); }
.mini-label { margin-top: 9px; }
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}
.pill-row span,
.pill-row button {
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text-2);
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 10.5px;
  line-height: 1.3;
  text-align: left;
}
.pill-row button {
  cursor: pointer;
  font-family: inherit;
}
.pill-row button:hover {
  color: var(--accent);
  border-color: rgba(95,180,255,.45);
}
.conclusion-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.conclusion-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  border-radius: 8px;
  padding: 12px 13px;
}
.conclusion-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.conclusion-head h3 {
  font-size: 14px;
  line-height: 1.3;
  margin: 0;
  letter-spacing: 0;
}
.conclusion-head span {
  font-family: "JetBrains Mono";
  font-size: 12px;
  white-space: nowrap;
}
.conclusion-card p {
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 8px 0;
}
.quartile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.quartile-grid > div {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.quartile-grid span,
.quartile-grid small {
  display: block;
  color: var(--muted);
  font-family: "JetBrains Mono";
  font-size: 10px;
  line-height: 1.4;
}
.quartile-grid strong {
  display: block;
  color: var(--accent-2);
  font-family: "Space Grotesk";
  font-size: 17px;
  margin: 2px 0;
}
.bill-context {
  margin: 9px 0;
  padding: 9px 10px;
  background: rgba(95,180,255,.05);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 6px;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: transparent; border: none;
  color: var(--muted);
  font-size: 26px; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 6px;
  font-family: inherit;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }

/* Hero stat row inside modals */
.hero-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.hero-row .stat-tile {
  background: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  padding: 12px 14px;
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}
.hero-row .v {
  font-family: "Space Grotesk";
  font-size: 20px;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.02em;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.hero-row .l {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Compare */
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px;
}
.cmp-col {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.cmp-col h3 { color: var(--accent); font-size: 15px; }
.cmp-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  font-size: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.cmp-row .lbl { color: var(--muted); }
.cmp-row .val {
  font-family: "JetBrains Mono";
  text-align: right;
  min-width: 70px;
  color: var(--accent-2);
}
.cmp-row .val.win { color: var(--ok); font-weight: 700; }
.cmp-row .val.lose { color: var(--bad); }

/* Sankey */
.sankey-wrap { background: var(--bg-0); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.sankey-wrap text { fill: var(--text-2); font-size: 11px; font-family: "Inter"; }

/* Help */
.kbd {
  display: inline-block;
  padding: 1px 7px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: "JetBrains Mono";
  font-size: 11px;
  color: var(--text-2);
}
.kbd-row { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }

/* Explainer card — used in big-picture modals */
.explainer {
  background: linear-gradient(135deg, rgba(95,180,255,.07), rgba(200,154,240,.05));
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  border-radius: 8px;
  margin: 10px 0 16px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
}
.explainer::before {
  content: "💡 What this means";
  display: block;
  font-family: "Space Grotesk";
  font-size: 10.5px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}
.info-icon-foot {
  display: inline-block;
  width: 14px; height: 14px; line-height: 14px;
  text-align: center;
  background: var(--accent);
  color: var(--bg-0);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}

/* ============= MOBILE RESPONSIVE ============= */
@media (max-width: 900px) {
  body { grid-template-rows: auto auto 1fr 32px; overflow: auto; }
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 8px;
    padding: 8px 10px;
  }
  .brand h1 { font-size: 16px; }
  .brand .tag { display: none; }
  .topbar-center { grid-column: 1 / -1; order: 3; }
  .topbar-center .search-wrap { width: 100%; max-width: none; }
  #search { width: 100%; }
  .topbar-right { gap: 4px; }
  .view-toggle .vt-btn { font-size: 10.5px; padding: 4px 7px; }
  #dd-btn { font-size: 11.5px; padding: 5px 9px; }
  /* Main: stack canvas above panel on mobile */
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: 280px 1fr;
    height: auto;
    overflow: visible;
  }
  .canvas {
    height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .panel {
    min-height: 60vh;
    border-top: 1px solid var(--line);
  }
  /* Map controls + dropdown menu — full-width on mobile */
  #color-by-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  #color-by-bar select { width: 100%; }
  .dd-menu {
    position: fixed !important;
    top: 56px !important;
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  /* Modal: nearly full-screen on mobile */
  .modal-card {
    width: 96vw;
    max-width: 96vw;
    max-height: 92vh;
    padding: 18px 14px;
  }
  .modal-nav-items { gap: 4px; }
  .modal-nav button { font-size: 10px; padding: 4px 7px; max-width: 180px; }
  /* List rows: collapse to single-column on mobile */
  .list-row {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto;
    gap: 4px;
    padding: 10px 12px;
  }
  .list-row .pop, .list-row .metric-val { text-align: left !important; }
  /* Data tables: smaller font + horizontal scroll already enabled */
  .data-table { min-width: 480px; font-size: 11px; }
  .data-table th, .data-table td { padding: 5px 7px; min-width: 60px; }
  /* Politicians toolbar */
  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 12px;
  }
  .list-controls { flex-wrap: wrap; gap: 5px; }
  .list-controls select, .list-controls input { font-size: 12px; padding: 5px 7px; flex: 1 1 45%; min-width: 0; }
  /* Hero grids */
  .hero-row { grid-template-columns: 1fr 1fr !important; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  /* Globe HUD overlap — minimize on mobile */
  .globe-hud, .globe-stats-panel {
    font-size: 10px;
    max-width: 200px;
    padding: 8px 10px;
  }
  .globe-hud strong { font-size: 11px; }
  /* Footer wraps */
  .footer { height: auto; padding: 8px 12px; font-size: 10.5px; gap: 6px; line-height: 1.4; }
}

/* Very small phones */
@media (max-width: 480px) {
  .canvas { height: 240px; }
  .modal-card { padding: 14px 10px; }
  .kpi-grid, .hero-row { grid-template-columns: 1fr !important; }
  .brand h1 { font-size: 14px; }
  .view-toggle .vt-btn span,
  .view-toggle .vt-btn { font-size: 0; padding: 6px 8px; }
  .view-toggle .vt-btn::first-letter { font-size: 14px; }
  /* Show only emoji on view-toggle to save space */
}

/* Election 2026 countdown banner */
.election-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 14px;
  background: linear-gradient(90deg, rgba(240,198,116,.08), rgba(95,180,255,.08));
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-2);
  font-family: "Inter", system-ui, sans-serif;
}
.election-banner .countdown {
  color: var(--accent-2);
  font-weight: 700;
  font-family: "JetBrains Mono";
  letter-spacing: 0.02em;
}
.election-banner a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
  padding-bottom: 1px;
}
.election-banner a:hover { color: var(--text); border-color: var(--text); }
@media (max-width: 700px) {
  .election-banner { font-size: 10.5px; padding: 5px 10px; gap: 8px; }
}

/* Footer */
.footer {
  height: 32px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 0 20px;
  background: var(--bg-0);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted-2);
  font-family: "Inter", system-ui, sans-serif;
  letter-spacing: 0.02em;
}
.footer .sep { color: var(--line-2); margin: 0 4px; }
.footer .kbd {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--bg-1);
  color: var(--text-2);
  font-family: "JetBrains Mono";
  font-size: 10px;
  margin: 0 2px;
}
.info-icon-foot {
  color: var(--accent);
  font-weight: 700;
  margin: 0 2px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

/* Responsive */
@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr 380px; }
  .search-wrap { width: 280px; }
  .list-toolbar { align-items: flex-start; gap: 8px; }
  .list-controls { justify-content: flex-start; }
}
@media (max-width: 800px) {
  .main { grid-template-columns: 1fr; }
  .panel {
    display: block;
    order: -1;
    max-height: none;
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: 2;
  }
  .canvas { min-height: 460px; position: relative; z-index: 1; }
  .topbar { grid-template-columns: 1fr; align-items: stretch; height: auto; min-height: 60px; padding: 8px 16px; gap: 8px; }
  .brand { flex-wrap: wrap; }
  .brand .tag { flex-basis: 100%; border-left: 0; padding-left: 44px; margin-top: -8px; }
  .topbar-right { flex-wrap: wrap; }
  .search-wrap { width: 100%; }
  .list-body { top: 112px; }
  .list-row {
    grid-template-columns: 1fr !important;
    gap: 6px;
    align-items: start;
  }
  .list-row .pop,
  .list-row .metric-val { text-align: left !important; }
  .modal-card { width: 94vw; max-height: 88vh; }
}
