/* electionpete — "ballot paper" design system.
   Warm newsprint + heavy ink rules by day, "election night" navy by night.
   Display: Archivo (variable width, run condensed). Data & labels: JetBrains Mono. */

:root {
  --paper: #f2efe6;
  --surface: #fbf9f3;
  --surface-2: #ebe7db;
  --ink: #0f2238;
  --ink-2: #33465d;
  --muted: #6a7686;
  --rule: rgba(15, 34, 56, .14);
  --rule-strong: #0f2238;
  --brand: #0f4876;           /* electionpete blue */
  --signal: #fc7e2f;          /* electionpete orange */
  --signal-ink: #b4520f;
  --brand-light: #b5c2d3;
  --dem: #2856c6;
  --rep: #d63a2a;
  --none: #a59f92;
  --ind: #7a4fd0;
  --lib: #d9971a;
  --grn: #2e9a59;
  --other: #cfc8b8;
  --flag-bg: #fbefc4;
  --flag-bg-hover: #f7e39b;
  --flag-ink: #8a5a00;
  --ticker-bg: #ffffff;
  --ticker-ink: #0f2238;
  --radius: 4px;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b1d31; --surface: #10263e; --surface-2: #17314d; --ink: #eef2f7; --ink-2: #c5d0dd; --muted: #8fa2b8;
    --rule: rgba(238, 242, 247, .12); --rule-strong: #eef2f7; --brand: #7fb0e0; --signal: #ff8a3d; --signal-ink: #ffa366;
    --dem: #4f80ff; --rep: #ff5745; --none: #6c717c; --ind: #a07cf0; --lib: #f0b232; --grn: #3fc27a; --other: #3a4150;
    --flag-bg: #3a2f10; --flag-bg-hover: #4d3d12; --flag-ink: #f5c95c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b1d31; --surface: #10263e; --surface-2: #17314d; --ink: #eef2f7; --ink-2: #c5d0dd; --muted: #8fa2b8;
  --rule: rgba(238, 242, 247, .12); --rule-strong: #eef2f7; --brand: #7fb0e0; --signal: #ff8a3d; --signal-ink: #ffa366;
  --dem: #4f80ff; --rep: #ff5745; --none: #6c717c; --ind: #a07cf0; --lib: #f0b232; --grn: #3fc27a; --other: #3a4150;
  --flag-bg: #3a2f10; --flag-bg-hover: #4d3d12; --flag-ink: #f5c95c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--body);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
/* faint ballot-paper grain */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(var(--rule) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, #000, transparent 420px);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 420px);
}
main, footer, header { position: relative; z-index: 1; }
a { color: var(--brand); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--signal); }
::selection { background: var(--brand-light); color: #0f2238; }
h1 {
  font-family: var(--display); font-stretch: 68%; font-weight: 850; text-transform: uppercase;
  font-size: clamp(40px, 6.4vw, 92px); line-height: .9; letter-spacing: -.01em; margin: 10px 0 14px;
}
h1 .hl { color: var(--signal); }
h2 {
  font-family: var(--mono); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 14px; color: var(--ink);
}
.wrap { max-width: 1520px; margin: 0 auto; padding: 0 32px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }

/* ------------------------------------------------------------ ticker */
.ticker { border-bottom: 1px solid rgba(15, 34, 56, .12); background: var(--ticker-bg); color: var(--ticker-ink); font: 500 11.5px/30px var(--mono); overflow: hidden; white-space: nowrap; position: relative; z-index: 11; }
.ticker-track { display: inline-flex; animation: tick 60s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { padding: 0 22px; display: inline-flex; gap: 8px; align-items: center; }
.ticker-item b { font-weight: 700; }
.ticker-item i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: -2px; }
.ticker .t-DEM b { color: #2856c6; } .ticker .t-REP b { color: #d63a2a; } .ticker .t-NONE b { color: #6f6a5f; }
.ticker .t-brand b { color: #0f4876; }
.ticker [class*="t-m-"] b { color: #fff; padding: 2px 7px; border-radius: 3px; line-height: 1; }
.ticker .t-m-D b { background: #2856c6; } .ticker .t-m-R b { background: #d63a2a; } .ticker .t-m-E b { background: #6f6a5f; }
.ticker-item::after { content: "◆"; margin-left: 44px; opacity: .45; font-size: 8px; }
.ticker-live { color-scheme: light; display: inline-flex; align-items: center; gap: 7px; padding: 0 16px; background: #0f4876; color: #fff; font-weight: 700; letter-spacing: .08em; position: absolute; left: 0; top: 0; bottom: 0; z-index: 1; }
.ticker-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fc7e2f; animation: blink 1.4s ease-in-out infinite; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } .ticker-live::before { animation: none; } }

/* ------------------------------------------------------------ top bar */
.topbar { background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; border-bottom: 2px solid var(--rule-strong); }
.topbar-inner { display: flex; align-items: center; gap: 28px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: block; }
.brand-word { font-family: var(--display); font-stretch: 72%; font-weight: 850; font-size: 27px; letter-spacing: -.01em; line-height: 1; }
.brand-word span { color: var(--signal); }
.nav { display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a, .nav-more summary { color: var(--ink-2); font-weight: 600; font-size: 13.5px; padding: 6px 10px; border-radius: var(--radius); white-space: nowrap; }
.nav a:hover, .nav-more summary:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a.on { color: var(--ink); box-shadow: inset 0 -3px 0 var(--signal); border-radius: 0; }
.nav-more { position: relative; }
.nav-more summary { cursor: pointer; list-style: none; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-menu { position: fixed; margin-top: 8px; background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--radius); box-shadow: 6px 6px 0 var(--rule-strong); padding: 6px; min-width: 200px; display: flex; flex-direction: column; z-index: 30; }
.nav-menu a { color: var(--ink); padding: 7px 10px; }
.topbar-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.kbd-btn, .icon-btn {
  font: 500 12.5px var(--mono); color: var(--muted); background: var(--surface); border: 1.5px solid var(--rule);
  border-radius: var(--radius); height: 34px; display: inline-flex; align-items: center; gap: 10px; padding: 0 10px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.kbd-btn:hover, .icon-btn:hover { border-color: var(--rule-strong); color: var(--ink); }
.kbd-btn kbd { font: 600 10.5px var(--mono); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; color: var(--ink-2); }
.icon-btn { width: 34px; justify-content: center; padding: 0; }
.icon-btn svg { width: 16px; height: 16px; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; } :root[data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: block; } :root:not([data-theme="light"]) .theme-moon { display: none; }
}
@media (max-width: 900px) { .kbd-btn .kbd-label { display: none; } .topbar-inner { gap: 14px; } .brand-word { font-size: 23px; } }

/* ------------------------------------------------------------ hero */
.hero { padding: 40px 0 26px; }
.hero + .tabs { margin-top: 0; }
.eyebrow { font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow a { color: var(--muted); }
.eyebrow a:hover { color: var(--ink); }
.eyebrow::before { content: ""; width: 10px; height: 10px; background: var(--signal); display: inline-block; }
.hero p { margin: 4px 0 0; max-width: 820px; font-size: 15px; }
.hero p.muted { font-family: var(--mono); font-size: 12.5px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.margin-pill {
  font: 800 13px var(--mono); padding: 5px 10px; border-radius: var(--radius); color: #fff; letter-spacing: .02em; white-space: nowrap; display: inline-block;
}
.margin-pill.big { font-size: 26px; padding: 8px 16px; font-family: var(--display); font-stretch: 75%; font-weight: 850; }
.m-D { background: var(--dem); } .m-R { background: var(--rep); } .m-E { background: var(--none); }

/* the read: auto-generated takeaways */
.the-read { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); border: 2px solid var(--rule-strong); background: var(--surface); margin-bottom: 26px; border-radius: var(--radius); overflow: hidden; }
.read-label { grid-column: 1 / -1; font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; padding: 9px 16px; border-bottom: 2px solid var(--rule-strong); display: flex; justify-content: space-between; background: #0f4876; color: #fff; }
.read-label span:last-child { opacity: .6; font-weight: 500; }
.read-item { padding: 16px 18px 18px; border-right: 1px solid var(--rule); }
.read-item:last-child { border-right: 0; }
@media (max-width: 800px) { .the-read { grid-template-columns: 1fr 1fr; } .read-item { border-bottom: 1px solid var(--rule); } }
@media (max-width: 520px) { .the-read { grid-template-columns: 1fr; } .read-item { border-right: 0; } }
.read-big { font-family: var(--display); font-stretch: 70%; font-weight: 850; font-size: 40px; line-height: 1; letter-spacing: -.01em; color: var(--signal-ink); }
.read-text { color: var(--ink-2); margin-top: 6px; font-size: 13.5px; line-height: 1.4; }

section { margin-bottom: 22px; }
.card { background: var(--surface); border: 1.5px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; position: relative; min-width: 0; }
@media (max-width: 760px) { .card { overflow-x: auto; padding: 16px 14px; } }
.card::before { content: ""; position: absolute; left: 0; top: 0; width: 34px; height: 3px; background: var(--signal); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head > .muted.small, .card-head > span.small { font-family: var(--mono); font-size: 11px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* auto-numbered section labels: 01 / REGISTRATION BY PARTY */
main { counter-reset: sec; }
.card > h2::before, .card-head > h2::before {
  counter-increment: sec; content: counter(sec, decimal-leading-zero) " /"; color: var(--signal-ink); margin-right: 8px;
}
h2 a.small { text-transform: none; letter-spacing: 0; font-family: var(--body); font-weight: 600; margin-left: 8px; }

/* ------------------------------------------------------------ KPIs: big condensed numbers between rules */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border-top: 2px solid var(--rule-strong); border-bottom: 1px solid var(--rule); margin-bottom: 26px; }
.kpi { padding: 14px 18px 16px; border-right: 1px solid var(--rule); }
.kpi:first-child { padding-left: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-family: var(--display); font-stretch: 68%; font-weight: 850; font-size: 50px; line-height: 1; letter-spacing: -.005em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font: 12px var(--mono); margin-top: 6px; }
.kpi.k-DEM .kpi-value { color: var(--dem); } .kpi.k-REP .kpi-value { color: var(--rep); }
.kpis-inline { margin-bottom: 16px; border-top-width: 1px; }
.kpis-inline .kpi-value { font-size: 38px; }
@media (max-width: 640px) { .kpi { padding-left: 0; border-right: 0; border-bottom: 1px solid var(--rule); } .kpi-value { font-size: 42px; } }

/* ------------------------------------------------------------ waffle (1 square = 1% of voters) */
.waffle-wrap { display: grid; grid-template-columns: clamp(130px, 42%, 240px) 1fr; gap: clamp(14px, 3%, 28px); align-items: center; }
.waffle { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; aspect-ratio: 1; }
.waffle i { border-radius: 2px; transform: scale(0); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes pop { to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .waffle i { animation: none; transform: none; } }
.waffle-legend { display: flex; flex-direction: column; gap: 2px; }
.wl-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--rule); font-size: 13.5px; }
.wl-row i { width: 12px; height: 12px; border-radius: 2px; align-self: center; }
.wl-pct { font-family: var(--display); font-stretch: 75%; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.wl-n { font: 11.5px var(--mono); color: var(--muted); min-width: 64px; text-align: right; }
@media (max-width: 640px) { .waffle-wrap { grid-template-columns: 1fr; } .waffle { max-width: 240px; } }

/* ------------------------------------------------------------ charts */
.chart-sm { position: relative; height: 250px; }
.chart-lg { position: relative; height: 320px; }

/* ------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font: 700 10.5px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--rule-strong); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.table td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 7px 10px; }
.table-hover tbody tr { cursor: pointer; transition: background .1s; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table-hover tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--signal); }
.num { text-align: right; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { font-size: 10.5px; }
.scroll { max-height: 440px; overflow: auto; }
.scroll.tall { max-height: 600px; }
.lean-d { color: var(--dem); font-weight: 700; }
.lean-r { color: var(--rep); font-weight: 700; }
.chip { font: 500 10.5px var(--mono); background: var(--surface-2); border-radius: 3px; padding: 2px 7px; color: var(--ink-2); white-space: nowrap; text-transform: lowercase; }
.chip-filer { background: var(--brand); color: var(--surface); }
.nowrap { white-space: nowrap; }
tr.muted td { color: var(--muted); }

/* ------------------------------------------------------------ party colors */
.p-DEM { background: var(--dem); } .p-REP { background: var(--rep); } .p-NONE { background: var(--none); }
.p-IND { background: var(--ind); } .p-LIB { background: var(--lib); } .p-GRN { background: var(--grn); }
.p-OTHER { background: var(--other); }
.partybar { display: flex; border-radius: 2px; overflow: hidden; background: var(--surface-2); gap: 1px; }
.partybar span { display: block; height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font: 11.5px var(--mono); color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* lean meter: where a district sits between D and R */
.lean-meter { position: relative; height: 10px; background: linear-gradient(90deg, var(--dem), color-mix(in srgb, var(--dem) 20%, var(--surface-2)) 45%, var(--surface-2) 50%, color-mix(in srgb, var(--rep) 20%, var(--surface-2)) 55%, var(--rep)); border-radius: 2px; min-width: 120px; }
.lean-meter::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink); opacity: .4; }
.lean-meter b { position: absolute; top: -4px; width: 6px; height: 18px; margin-left: -3px; background: var(--ink); border: 2px solid var(--surface); border-radius: 1px; box-sizing: content-box; }

/* ------------------------------------------------------------ contests */
.contests { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 16px; }
.contest { border: 1.5px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); transition: border-color .15s, transform .15s; }
.contest:hover { border-color: var(--rule-strong); }
.contest-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; align-items: baseline; }
.contest-name { font-weight: 750; font-size: 14.5px; line-height: 1.25; }
.contest-head .muted.small { font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.cand { margin: 8px 0; }
.cand-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.cand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand.lead .cand-name { font-weight: 700; }
.cand.lead .cand-name::after { content: "✓"; color: var(--signal-ink); font-weight: 900; margin-left: 6px; }
.cand-num { font: 12px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { height: 8px; background: var(--surface-2); border-radius: 1px; overflow: hidden; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--none); opacity: .45; transform-origin: left; animation: grow .7s cubic-bezier(.2, .8, .2, 1) both; }
.meter span.lead { opacity: 1; }
.meter span:not([class*="p-"]) { background: var(--brand); }
.meter .p-DEM { background: var(--dem); } .meter .p-REP { background: var(--rep); }
.meter .p-LBR, .meter .p-LIB { background: var(--lib); } .meter .p-GRN { background: var(--grn); }
@keyframes grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .meter span { animation: none; } }
.show-all { margin-top: 16px; }
.show-all summary { cursor: pointer; color: var(--brand); font-weight: 600; margin-bottom: 14px; }
.tag { font: 700 9.5px var(--mono); border-radius: 2px; padding: 1px 4px; margin-right: 7px; color: #fff; vertical-align: 1px; background: var(--none); }
.p-DEM-t { background: var(--dem); } .p-REP-t { background: var(--rep); }

/* ------------------------------------------------------------ tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1.5px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s; }
.tile:hover { border-color: var(--rule-strong); text-decoration: none; transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--signal); }
.tile-n { font-family: var(--display); font-stretch: 70%; font-weight: 850; font-size: 34px; line-height: 1; }
.tile-l { color: var(--muted); font: 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }

.notice { background: var(--flag-bg); border-left: 4px solid var(--signal); color: var(--flag-ink); border-radius: 2px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.inline-form select, select.pick {
  font: 600 12.5px var(--mono); padding: 7px 30px 7px 10px; border-radius: var(--radius); border: 1.5px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer;
}

/* ------------------------------------------------------------ footer */
.footer { margin-top: 48px; border-top: 2px solid var(--rule-strong); padding-top: 28px; padding-bottom: 40px; display: grid; grid-template-columns: auto 1fr; gap: 40px; align-items: start; }
.footer-word { font-family: var(--display); font-stretch: 65%; font-weight: 900; font-size: clamp(56px, 9vw, 120px); line-height: .8; letter-spacing: -.02em; text-transform: lowercase; color: var(--ink); }
.footer-word span { color: var(--signal); }
.footer-note { font: 11.5px/1.7 var(--mono); color: var(--muted); max-width: 720px; }
.footer-note b { color: var(--ink-2); }
@media (max-width: 800px) { .footer { grid-template-columns: 1fr; gap: 16px; } }

/* ------------------------------------------------------------ campaign finance */
.search, .palette-input {
  font: 500 14px var(--body); padding: 9px 12px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); min-width: 280px; background: var(--surface); color: var(--ink);
}
.search:focus, .palette-input:focus { outline: none; box-shadow: 3px 3px 0 var(--signal); }
.flag { display: inline-block; min-width: 18px; text-align: center; font: 700 11px var(--mono); color: var(--flag-ink); background: var(--flag-bg); border-radius: 999px; padding: 0 6px; }
.row-flag td { background: var(--flag-bg); }
.table-hover tbody tr.row-flag:hover td { background: var(--flag-bg-hover); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--flag-bg); border: 1px solid var(--signal); vertical-align: -1px; margin-right: 4px; }
.incounty { color: var(--brand); font-weight: 600; }
.tabs { display: flex; gap: 0; margin: -10px 0 22px; border-bottom: 2px solid var(--rule-strong); overflow-x: auto; }
.tabs a { color: var(--muted); font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .07em; padding: 10px 16px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; background: var(--surface-2); }
.tabs a.on { color: var(--paper); background: var(--ink); }
.toggle { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; cursor: pointer; }
.toggle input { accent-color: var(--signal); width: 15px; height: 15px; }
.also { font-size: 12px; color: var(--muted); }
.also a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule); }
.also a:hover { text-decoration-color: var(--signal); }
.mismatch { color: var(--signal-ink); font-weight: 700; }

/* ------------------------------------------------------------ command palette */
.palette { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(11, 29, 49, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.palette.open { display: flex; }
.palette-box { width: min(640px, 100%); background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--signal); overflow: hidden; animation: drop .18s ease-out; }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }
.palette-input { width: 100%; border: 0; border-bottom: 2px solid var(--rule-strong); border-radius: 0; font-size: 17px; padding: 16px 18px; min-width: 0; }
.palette-input:focus { box-shadow: none; }
.palette-list { max-height: 52vh; overflow: auto; margin: 0; padding: 6px; list-style: none; }
.palette-list li a { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 9px 12px; border-radius: 3px; color: var(--ink); align-items: baseline; }
.palette-list li a:hover, .palette-list li.sel a { background: var(--surface-2); text-decoration: none; box-shadow: inset 3px 0 0 var(--signal); }
.palette-kind { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.palette-t { font-weight: 600; }
.palette-s { display: block; font: 11.5px var(--mono); color: var(--muted); }
.palette-empty { padding: 18px; color: var(--muted); font: 12.5px var(--mono); }
.palette-foot { border-top: 1px solid var(--rule); padding: 8px 14px; font: 11px var(--mono); color: var(--muted); display: flex; gap: 16px; }

/* page entrance */
main > * { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
main > *:nth-child(2) { animation-delay: .04s; } main > *:nth-child(3) { animation-delay: .08s; }
main > *:nth-child(4) { animation-delay: .12s; } main > *:nth-child(5) { animation-delay: .16s; }
@keyframes rise { from { transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { main > * { animation: none; } }
th[aria-sort="ascending"]::after { content: " ▲"; color: var(--signal-ink); }
th[aria-sort="descending"]::after { content: " ▼"; color: var(--signal-ink); }
.hero h1.long { font-size: clamp(32px, 4.4vw, 64px); line-height: .95; }
.tabs + .kpis { border-top: 0; }
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; gap: 8px 14px; }
  .nav { order: 3; width: 100%; margin: 0 -10px; padding-bottom: 4px; }
  .hero-row > div[style] { text-align: left !important; }
  .hero-row > div[style] > div[style*="text-align"] { text-align: left !important; }
  .hero { padding-top: 26px; }
}
@media (max-width: 520px) { .read-label span:last-child { display: none; } }

/* ------------------------------------------------------------ shift view */
.shift-picker { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin: 0 0 26px; padding: 16px 18px; background: var(--surface); border: 1.5px solid var(--rule); border-radius: var(--radius); }
.shift-picker label { display: flex; flex-direction: column; gap: 6px; flex: 1 1 280px; min-width: 0; }
.shift-picker label span { font: 700 10.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.shift-picker select.pick { width: 100%; text-overflow: ellipsis; }
.shift-picker .swap { height: 34px; width: 40px; display: inline-grid; place-items: center; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); color: var(--ink); font-size: 18px; flex: 0 0 auto; }
.shift-picker .swap:hover { background: var(--surface-2); text-decoration: none; }
.shift-picker > a.small { align-self: center; }

.arrow-legend { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.arrow-legend span { display: inline-flex; gap: 8px; align-items: center; }
.ar-d, .ar-r { stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.ar-d { stroke: var(--dem); } .ar-r { stroke: var(--rep); }
.arrow-field { display: flex; flex-wrap: wrap; gap: 14px 18px; }
.af-group { display: flex; flex-direction: column; gap: 5px; }
.af-name { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-tiles { display: flex; flex-wrap: wrap; gap: 3px; max-width: 260px; }
.af-tile { width: 40px; height: 40px; border-radius: 3px; border: 1px solid var(--rule); display: block; animation: pop .35s cubic-bezier(.3, 1.4, .5, 1) backwards; }
.af-tile svg { width: 100%; height: 100%; display: block; }
.af-tile:hover { border-color: var(--rule-strong); transform: scale(1.12); position: relative; z-index: 2; box-shadow: 0 4px 12px rgba(15, 34, 56, .25); }
@media (prefers-reduced-motion: reduce) { .af-tile { animation: none; } }

.divbar { position: relative; height: 10px; background: var(--surface-2); border-radius: 2px; min-width: 100px; }
.divbar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink); opacity: .45; }
.divbar span { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.divbar .to-d { background: var(--dem); } .divbar .to-r { background: var(--rep); }

/* ------------------------------------------------------------ data stamp + methodology */
.stamp { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--rule); }
.stamp span::before { content: "●"; color: var(--grn); margin-right: 6px; font-size: 8px; vertical-align: 2px; }
.nav-menu-sep { border-top: 1px solid var(--rule); margin-top: 4px; padding-top: 9px !important; }
.prose-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
@media (max-width: 1000px) { .prose-grid { grid-template-columns: 1fr; } }
.prose { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.prose dl { margin: 0; }
.prose dt { font-weight: 750; color: var(--ink); margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.prose dt:first-child { margin-top: 0; }
.prose dd { margin: 4px 0 0; }
.prose ul { margin: 0; padding-left: 18px; }
.prose li { margin: 8px 0; }
.prose b { color: var(--ink); }
.hero > p:not(.muted) { font-size: 17px; color: var(--ink-2); }
.card { scroll-margin-top: 84px; }
.anchor { margin-left: 10px; color: var(--muted); opacity: 0; font: 700 11.5px var(--mono); text-transform: none; letter-spacing: 0; transition: opacity .15s; }
.card:hover .anchor, .anchor:focus { opacity: 1; }
.anchor:hover { color: var(--brand); text-decoration: none; }
.anchor.done { opacity: 1; color: var(--grn); }
@media (hover: none) { .anchor { opacity: .6; } }

/* ------------------------------------------------------------ error page */
.error-hero { padding: 56px 0 80px; }
.error-code { font-family: var(--display); font-stretch: 62%; font-weight: 900; font-size: clamp(120px, 22vw, 280px); line-height: .8; color: transparent; -webkit-text-stroke: 2px var(--rule-strong); letter-spacing: -.02em; margin: 18px 0 8px; }
.error-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.btn { display: inline-flex; align-items: center; gap: 10px; font: 700 14px var(--body); padding: 11px 18px; border-radius: var(--radius); background: #0f4876; color: #fff; border: 2px solid #0f4876; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn kbd { font: 600 11px var(--mono); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; color: var(--muted); }

/* ------------------------------------------------------------ first-visit disclaimer (modal) */
.disclaimer { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px 16px; background: rgba(11, 29, 49, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); overflow-y: auto; }
.disclaimer[hidden] { display: none; }
.disclaimer-box { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--radius); box-shadow: 10px 10px 0 #0f4876; padding: 30px 34px 28px; color: var(--ink-2); animation: drop .3s ease-out; margin: auto; }
.disclaimer-title { font-family: var(--display); font-stretch: 68%; font-weight: 850; text-transform: uppercase; letter-spacing: -.005em; font-size: clamp(34px, 6vw, 52px); line-height: .92; color: var(--ink); margin: 6px 0 18px; }
.disclaimer-title span { color: var(--brand); }
.disclaimer-body p { font-size: 16.5px; line-height: 1.55; margin: 0 0 12px; color: var(--ink); }
.disclaimer-terms { font-size: 13.5px; margin: 14px 0 18px; color: var(--muted); }
.nc-head { font: 700 11.5px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink); display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.nc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--grn) 25%, transparent); }
.nc-list { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.nc-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); font: 12.5px var(--mono); }
.nc-list span { color: var(--muted); white-space: nowrap; }
.nc-list b { color: var(--ink); text-align: right; font-weight: 600; }
.nc-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
body.modal-open { overflow: hidden; }
@media (max-width: 560px) {
  .disclaimer-box { padding: 22px 20px; box-shadow: 6px 6px 0 #0f4876; }
  .disclaimer-body p { font-size: 15px; }
  .nc-list li { flex-direction: column; gap: 2px; } .nc-list b { text-align: left; }
  .nc-actions .btn { flex: 1 1 100%; justify-content: center; }
}
@media print { .disclaimer { display: none !important; } }
.disclaimer-quote { border-left: 4px solid var(--brand); padding: 4px 0 4px 16px; margin: 0 0 14px; color: var(--ink); }

/* arrow field hover: spotlight the tile, card follows the cursor */
.arrow-field.hovering .af-tile:not(.hot) { opacity: .45; filter: saturate(.6); }
.af-tile { transition: opacity .15s, filter .15s, transform .15s, box-shadow .15s; }
.af-tile.hot { transform: scale(1.22); position: relative; z-index: 3; border-color: var(--rule-strong); box-shadow: 3px 3px 0 var(--dem); }
.af-tile.hot.is-r { box-shadow: 3px 3px 0 var(--rep); }
.af-tip { position: fixed; z-index: 150; pointer-events: none; width: 310px; background: var(--surface); border: 2px solid var(--rule-strong); border-radius: var(--radius); box-shadow: 6px 6px 0 var(--dem); padding: 12px 14px 10px; opacity: 0; transform: translateY(4px) scale(.98); transition: opacity .12s, transform .12s; }
.af-tip.to-r { box-shadow: 6px 6px 0 var(--rep); }
.af-tip.show { opacity: 1; transform: none; }
.af-tip-kicker { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.af-tip-name { font-weight: 750; font-size: 15px; color: var(--ink); line-height: 1.25; margin: 3px 0 8px; }
.af-tip-shift { font-family: var(--display); font-stretch: 70%; font-weight: 850; font-size: 34px; line-height: 1; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.af-tip.to-d .af-tip-shift { color: var(--dem); } .af-tip.to-r .af-tip-shift { color: var(--rep); }
.af-tip-shift small { font: 500 11px var(--mono); color: var(--muted); flex-basis: 100%; margin-top: 2px; }
.af-tip-arrow { font-family: var(--body); font-size: 24px; }
.af-tip-rows { margin-top: 10px; border-top: 1px solid var(--rule); }
.af-tip-rows div { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.af-tip-rows span:not(.margin-pill) { font: 11px var(--mono); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-tip-rows em { grid-column: 1 / -1; font: normal 10.5px var(--mono); color: var(--muted); }
.af-tip-rows .margin-pill { font-size: 11.5px; padding: 3px 8px; }
.af-tip-foot { font: 600 10.5px var(--mono); color: var(--brand); margin-top: 8px; }
@media (hover: none) { .af-tip { display: none; } }
@media (prefers-reduced-motion: reduce) { .af-tip, .af-tile { transition: none; } }
