:root {
  --bg: #0b0f17; --surface: #111723; --surface-2: #182032; --line: #232c40; --text: #e8ecf4; --muted: #8d97ad;
  --dem: #5b97ff; --rep: #ff6b6b; --oth: #a3acc0; --accent: #5b97ff;
  --dem-1: #3a5683; --dem-2: #3f78e0; --dem-3: #6aa6ff;
  --rep-1: #86424a; --rep-2: #d44a52; --rep-3: #ff7272;
  --map-neutral: #2b3345; --map-nodata: #161c2a; --map-border: rgba(255, 255, 255, .22); --map-state: rgba(255, 255, 255, .5);
  --c1: #f4b860; --c2: #34c3a0; --c3: #e879a9; --c4: #a78bfa; --c5: #8d97ad;
  --seq-teal: ["#14262f", "#14566b", "#1b93a0", "#6fd8bd", "#e4fad0"];
  --seq-blue: ["#14223d", "#1d4a8a", "#2f7fd1", "#7cc0f0", "#d8efff"];
  --seq-green: ["#142a1f", "#1b5a3a", "#2d9a5c", "#8bd98a", "#eafbd0"];
  --seq-amber: ["#2a2012", "#6b4513", "#b8791a", "#f0b84a", "#fff1c9"];
  --seq-violet: ["#1d1a33", "#3d3585", "#6a5ad0", "#a79cf5", "#ece8ff"];
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f7; --line: #dfe4ee; --text: #131a2a; --muted: #5d6880;
  --dem: #1f5fe0; --rep: #d6303a; --oth: #6f788c; --accent: #1f5fe0;
  --dem-1: #a9c4f5; --dem-2: #5b8ff0; --dem-3: #1d4ed8;
  --rep-1: #f2b1b1; --rep-2: #ec6b6b; --rep-3: #c01f2f;
  --map-neutral: #e4e7ee; --map-nodata: #f0f2f6; --map-border: rgba(0, 0, 0, .18); --map-state: rgba(0, 0, 0, .45);
  --c1: #c98a1b; --c2: #0f9d7f; --c3: #cf4a86; --c4: #7c5cf0; --c5: #7a8396;
  --seq-teal: ["#e6f6f1", "#a5dccf", "#4fb3a8", "#1d7f8b", "#10485c"];
  --seq-blue: ["#e8f1fb", "#b7d3f2", "#6ba5e0", "#2f6fb5", "#14407a"];
  --seq-green: ["#eaf6e8", "#b6e0b0", "#5fb86a", "#2a8247", "#12502b"];
  --seq-amber: ["#fdf3dc", "#f6d58b", "#e3a43a", "#b06f12", "#6b400a"];
  --seq-violet: ["#efecfb", "#cfc7f4", "#9d8fe6", "#6552c4", "#382a86"];
  --shadow: 0 10px 30px rgba(20, 30, 60, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f7; --line: #dfe4ee; --text: #131a2a; --muted: #5d6880;
    --dem: #1f5fe0; --rep: #d6303a; --oth: #6f788c; --accent: #1f5fe0;
    --dem-1: #a9c4f5; --dem-2: #5b8ff0; --dem-3: #1d4ed8; --rep-1: #f2b1b1; --rep-2: #ec6b6b; --rep-3: #c01f2f;
    --map-neutral: #e4e7ee; --map-nodata: #f0f2f6; --map-border: rgba(0, 0, 0, .18); --map-state: rgba(0, 0, 0, .45);
    --c1: #c98a1b; --c2: #0f9d7f; --c3: #cf4a86; --c4: #7c5cf0; --c5: #7a8396;
    --seq-teal: ["#e6f6f1", "#a5dccf", "#4fb3a8", "#1d7f8b", "#10485c"];
    --seq-blue: ["#e8f1fb", "#b7d3f2", "#6ba5e0", "#2f6fb5", "#14407a"];
    --seq-green: ["#eaf6e8", "#b6e0b0", "#5fb86a", "#2a8247", "#12502b"];
    --seq-amber: ["#fdf3dc", "#f6d58b", "#e3a43a", "#b06f12", "#6b400a"];
    --seq-violet: ["#efecfb", "#cfc7f4", "#9d8fe6", "#6552c4", "#382a86"];
    --shadow: 0 10px 30px rgba(20, 30, 60, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 22px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
h4 { font-size: 12px; margin: 14px 0 8px; color: var(--muted); }
code, kbd { font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.muted { color: var(--muted); }
.dem-t { color: var(--dem); } .rep-t { color: var(--rep); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header */
.top { display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 56px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); flex: none; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand img { display: block; border-radius: 8px; }
.brand b { color: var(--dem); }
.tabs { display: flex; gap: 2px; }
.tabs a { padding: 7px 13px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.on { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.tab-btn { background: none; border: 0; padding: 7px 13px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tab-btn:hover { color: var(--text); background: var(--surface-2); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 10px; }
.dlg header { display: flex; justify-content: space-between; align-items: center; }
.dlg p { margin: 0; }
.dlg .mail { color: var(--accent); font-weight: 600; text-decoration: underline; }
.dlg .small { font-size: 12px; }
.dlg #contact-fields { display: flex; flex-direction: column; gap: 12px; }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.dlg label small { font-weight: 400; }
.dlg input[type=text], .dlg input[type=email], .dlg textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 9px 11px; font: inherit; font-size: 14px; width: 100%; }
.dlg textarea { resize: vertical; min-height: 120px; max-height: 40vh; }
.dlg input:focus, .dlg textarea:focus { border-color: var(--accent); outline: none; }
.dlg .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.dlg #contact-status { min-height: 18px; font-size: 13px; color: var(--muted); }
.dlg #contact-status.err { color: var(--rep); }
.dlg footer { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 2px; }
.dlg footer .muted { margin-right: auto; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: default; }
.search { margin-left: auto; position: relative; display: flex; align-items: center; width: min(340px, 36vw); color: var(--muted); }
.search svg { position: absolute; left: 11px; pointer-events: none; }
.search input { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 8px 12px 8px 33px; font: inherit; }
.search input::placeholder { color: var(--muted); }
#search-results { position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; max-height: 60vh; overflow: auto; }
#search-results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); display: flex; gap: 8px; align-items: center; }
#search-results li:hover, #search-results li.active { background: var(--surface-2); }
#search-results li.active { box-shadow: inset 2px 0 0 var(--accent); }
#search-results .k { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 44px; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.on { color: var(--accent); border-color: var(--accent); }

main { flex: 1; min-height: 0; position: relative; }
.view { height: 100%; }
.view[hidden] { display: none; }

/* ---------- map view */
.map-view { display: grid; grid-template-columns: minmax(0, 1fr) 420px; }
.stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--surface-2) 65%, var(--bg)), var(--bg)); overflow: hidden; }
.bar { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; padding: 12px 14px 0; z-index: 5; flex: none; }
#map { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
#panel .note { flex-basis: auto; margin: 0; font-size: 12px; color: var(--c1); }
.update-bar { position: fixed; left: 18px; bottom: 18px; max-width: calc(100vw - 36px); z-index: 60; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; }
.update-bar[hidden] { display: none; }
.live-chip { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.live-chip[hidden] { display: none; }
.live-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c2); box-shadow: 0 0 0 0 color-mix(in srgb, var(--c2) 60%, transparent); animation: pulse 2s infinite; }
.live-chip.stale i { background: var(--c1); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.map-btn { position: absolute; top: 12px; right: 14px; z-index: 6; display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; }
.map-btn:hover { border-color: var(--accent); }
.map-btn[hidden] { display: none; }
svg.map { width: 100%; height: 100%; touch-action: none; cursor: grab; }
svg.map:active { cursor: grabbing; }
.map .counties path { stroke: var(--map-border); stroke-width: .35; vector-effect: non-scaling-stroke; transition: fill .45s ease, opacity .3s; cursor: pointer; }
.map .state-fills { display: none; }
.map .state-fills path { stroke: none; transition: fill .45s ease, opacity .3s; cursor: pointer; }
.level-state .state-fills { display: inline; }
.level-state .counties { display: none; }
.map .district-fills { display: none; }
.map .district-fills path { stroke: var(--map-border); stroke-width: .5; vector-effect: non-scaling-stroke; transition: fill .45s ease, opacity .3s; cursor: pointer; }
.map .district-fills path.out { opacity: .28; }
.level-district .district-fills { display: inline; }
.level-district .counties, .level-district .state-fills { display: none; }
.map .counties path.out, .map .state-fills path.out { opacity: .28; }
.map .state-borders { fill: none; stroke: var(--map-state); stroke-width: .8; vector-effect: non-scaling-stroke; pointer-events: none; stroke-linejoin: round; }
.map .nation-border { fill: none; stroke: var(--map-state); stroke-width: 1.1; vector-effect: non-scaling-stroke; pointer-events: none; }
.map .selection { fill: none; stroke: var(--text); stroke-width: 2.2; vector-effect: non-scaling-stroke; pointer-events: none; stroke-linejoin: round; }
.map .hover-ring { fill: none; stroke: var(--text); stroke-width: 1.2; opacity: .85; vector-effect: non-scaling-stroke; pointer-events: none; }

.controls { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.controls .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg-ctl { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg-ctl[hidden] { display: none; }
.seg-ctl button { background: none; border: 0; padding: 5px 11px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.seg-ctl button:hover { color: var(--text); }
.seg-ctl button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.seg-ctl.years button { padding: 5px 9px; font-variant-numeric: tabular-nums; }
select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 7px 10px; font: inherit; max-width: 240px; }
.note { margin: 0; font-size: 12px; color: var(--c1); flex-basis: 100%; }
.legend-card { position: absolute; right: 14px; bottom: 14px; width: 250px; padding: 9px 14px 8px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 5; }
.lg-title { font-size: 12px; font-weight: 600; margin-bottom: 7px; }
.lg-bar { height: 8px; border-radius: 4px; }
.lg-ticks { position: relative; height: 16px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.lg-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.lg-ticks span:first-child { transform: translateX(0); } .lg-ticks span:last-child { transform: translateX(-100%); }
.lg-nodata { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.lg-nodata i { width: 10px; height: 10px; border-radius: 3px; background: var(--map-nodata); border: 1px solid var(--line); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); z-index: 10; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); display: inline-block; vertical-align: -3px; margin-right: 8px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- side panel */
#panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 16px 18px 28px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { cursor: pointer; } .crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs i { font-style: normal; opacity: .6; } .crumbs span { color: var(--text); }
.p-head p { margin: 2px 0 0; }
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 12px; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; font-weight: 500; }
.btn:hover { border-color: var(--accent); }
.swing-line { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.kv span { display: block; font-size: 11px; color: var(--muted); } .kv b { font-size: 15px; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 5px 1px 8px; }
.kv .dot:first-child { margin-left: 0; }
.dot.dem { background: var(--dem); } .dot.rep { background: var(--rep); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list.scroll { max-height: 320px; overflow-y: auto; }
.list.cmp li { display: grid; grid-template-columns: 1fr 84px 46px; gap: 10px; align-items: center; }
.list.cmp li.active { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 2px 0 0 var(--accent); }
.cmp-bar { display: block; height: 8px; background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 4px; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; background: var(--c2); border-radius: 0 4px 4px 0; }
.list.cmp li.active .cmp-bar i { background: var(--accent); }
.list.cmp b { text-align: right; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.list li:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.list li span { min-width: 0; } .list li small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .two h4 { margin-top: 0; }

/* ---------- charts */
.resultbar .rb-top, .resultbar .rb-bot { display: flex; justify-content: space-between; align-items: baseline; font-variant-numeric: tabular-nums; }
.resultbar .rb-top { font-size: 15px; margin-bottom: 8px; } .resultbar .margin { font-weight: 700; font-size: 17px; }
.resultbar .rb-bot { font-size: 12px; margin-top: 7px; color: var(--muted); }
.rb-bar { display: flex; gap: 2px; height: 14px; }
.seg { display: block; min-width: 2px; }
.rb-bar .seg:first-child, .comp-bar .seg:first-child { border-radius: 7px 0 0 7px; } .rb-bar .seg:last-child, .comp-bar .seg:last-child { border-radius: 0 7px 7px 0; }
.rb-bar .seg:only-child { border-radius: 7px; }
.seg.dem { background: var(--dem); } .seg.rep { background: var(--rep); } .seg.oth { background: var(--oth); }
.comp-bar { display: flex; gap: 2px; height: 12px; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; }
.legend li { display: flex; align-items: center; gap: 7px; font-size: 12px; } .legend li span { color: var(--muted); flex: 1; } .legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend b { font-variant-numeric: tabular-nums; font-weight: 600; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar.dem { fill: var(--dem); } .chart .bar.rep { fill: var(--rep); }
.chart .baseline { stroke: var(--line); stroke-width: 1.5; }
.chart .lbl { fill: var(--text); font-size: 10.5px; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .trend-line { fill: none; stroke: var(--c2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot-pt { fill: var(--c2); stroke: var(--surface-2); stroke-width: 2; }
.chart g:hover .bar { opacity: .82; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hb { display: grid; grid-template-columns: 72px 1fr 52px; align-items: center; gap: 9px; font-size: 12px; }
.hb-l { color: var(--muted); } .hb-v { text-align: right; font-variant-numeric: tabular-nums; }
.hb-t { height: 8px; background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 4px; overflow: hidden; }
.hb-f { display: block; height: 100%; background: var(--c1); border-radius: 0 4px 4px 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.tile span { font-size: 11px; color: var(--muted); display: block; } .tile b { font-size: 16px; font-variant-numeric: tabular-nums; }
.range { display: block; position: relative; height: 6px; margin-top: 7px; background: color-mix(in srgb, var(--text) 9%, transparent); border-radius: 3px; }
.range .med { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--muted); }
.range .dot { position: absolute; top: -2px; width: 10px; height: 10px; margin: 0 0 0 -5px; background: var(--accent); border: 2px solid var(--surface); box-sizing: content-box; }

#tip { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .1s; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 12.5px; box-shadow: var(--shadow); max-width: 280px; line-height: 1.45; }
#tip.on { opacity: 1; }
#tip.pin { pointer-events: auto; max-height: calc(100vh - 16px); overflow-y: auto; }
/* ---------- hover card (state, county, district) */
#tip:has(.hc) { max-width: 330px; width: 306px; padding: 0; overflow: hidden; }
.hc { font-size: 12px; }
.hc > * { padding: 8px 12px; }
.hc > * + * { border-top: 1px solid var(--line); }
.hc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; background: var(--surface-2); }
.hc-head b { display: block; font-size: 14px; line-height: 1.25; }
.hc-head .muted { font-size: 11.5px; }
.hc-badge { flex: none; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; padding: 3px 9px; border-radius: 999px; color: #fff; }
.hc-badge.dem { background: var(--dem); } .hc-badge.rep { background: var(--rep); } .hc-badge.oth { background: var(--oth); }
.hc-line { font-size: 12.5px; }
.hc-bar { display: flex; gap: 2px; height: 9px; border-radius: 5px; overflow: hidden; }
.hc-bar.thin { height: 6px; margin-top: 5px; }
.hc-bar i { display: block; min-width: 1px; }
.hc-bar i.dem { background: var(--dem); } .hc-bar i.rep { background: var(--rep); } .hc-bar i.oth { background: var(--oth); }
.hc-bar i.mail { background: var(--c2); } .hc-bar i.inp { background: var(--c1); }
.hc-bar-l { display: flex; justify-content: space-between; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hc-sub { margin-top: 2px; font-size: 11px; }
.hc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.hc-facts div { display: flex; flex-direction: column; gap: 1px; }
.hc-facts .wide { grid-column: 1 / -1; }
.hc-facts span { font-size: 11px; color: var(--muted); } .hc-facts b { font-size: 13px; }
.hc-meter { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.hc-meter i { height: 6px; border-radius: 3px; opacity: .28; }
.hc-meter i.on { opacity: 1; height: 10px; margin-top: -2px; box-shadow: 0 0 0 1.5px var(--surface); outline: 1.5px solid var(--text); }
.hc-meter i.dem { background: var(--dem); } .hc-meter i.rep { background: var(--rep); } .hc-meter i.oth { background: var(--oth); }
.hc-meter-l { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; }
.hc-trend { display: flex; gap: 10px; align-items: center; }
.hc-spark .zero { stroke: var(--line); stroke-dasharray: 3 3; }
.hc-spark .ln { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linejoin: round; }
.hc-spark circle.dem { fill: var(--dem); } .hc-spark circle.rep { fill: var(--rep); } .hc-spark circle.oth { fill: var(--oth); }
.hc-trend-l { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; min-width: 0; }
.hc-trend-l > span:last-child { display: flex; flex-wrap: wrap; gap: 2px 8px; }
.hc-trend-l em { font-style: normal; font-variant-numeric: tabular-nums; } .hc-trend-l em.dem { color: var(--dem); } .hc-trend-l em.rep { color: var(--rep); }
.hc-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.hc-row + .hc-row { margin-top: 4px; }
.hc-cands { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.hc small { font-weight: 600; opacity: .8; }
.hc-mini { margin-top: 6px; } .hc-mini > span { font-size: 10.5px; color: var(--muted); }
.hc .key { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 4px; }
.hc .key.mail { background: var(--c2); } .hc .key.inp { background: var(--c1); }
.hc-people { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.hc-people div { display: flex; flex-direction: column; } .hc-people span { font-size: 10.5px; color: var(--muted); } .hc-people b { font-size: 12.5px; }
.hc-note { font-size: 11px; } .hc-foot { padding: 6px 10px; }
.hc-open { width: 100%; font: inherit; font-weight: 600; font-size: 12px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--accent); cursor: pointer; }
.hc-open:hover, .hc-open:focus-visible { background: var(--accent); color: #fff; border-color: var(--accent); outline: none; }


/* ---------- other views */
.page { height: 100%; overflow-y: auto; padding: 22px clamp(16px, 4vw, 48px) 48px; }
.page > header { margin-bottom: 18px; } .page > header p { margin: 4px 0 0; max-width: 70ch; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text], .toolbar input[type=search] { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 7px 11px; font: inherit; min-width: 200px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
table.t td { padding: 8px 10px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
table.t td.n, table.t th.n { text-align: right; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); max-width: 640px; margin: 40px auto; }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.race-card { cursor: pointer; transition: border-color .15s, transform .15s; } .race-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.race-card h4 { color: var(--text); font-size: 14px; margin: 0 0 4px; } .race-card .meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.race-card .hist { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); } .race-card .hist h5 { margin: 0 0 4px; font-size: 12px; color: var(--text); } .race-card .hist h5 small { font-weight: 400; }
.cand { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; } .cand b { font-variant-numeric: tabular-nums; }
.scatter-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.scatter-wrap svg { width: 100%; height: auto; display: block; }
.scatter-wrap circle { stroke: var(--surface); stroke-width: .6; cursor: pointer; }
.scatter-wrap circle:hover { stroke: var(--text); stroke-width: 1.6; }
.scatter-wrap .ax { stroke: var(--line); } .scatter-wrap text { fill: var(--muted); font-size: 11px; }
.scatter-wrap .fit { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; opacity: .7; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; } .stat span { font-size: 11px; color: var(--muted); display: block; } .stat b { font-size: 20px; font-variant-numeric: tabular-nums; }

/* ---------- responsive */
@media (max-width: 960px) {
  body { height: auto; min-height: 100%; }
  html, body { height: auto; }
  .top { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .search { order: 5; width: 100%; margin: 0; flex: 1 1 100%; }
  .tabs { order: 4; overflow-x: auto; max-width: 100%; }
  .map-view { grid-template-columns: 1fr; grid-template-rows: 62vh auto; }
  #panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  main, .view, .page { height: auto; }
  #map { min-height: 320px; }
  .legend-card { width: 220px; right: 10px; bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
