:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --head: #1a1d23;
  --ink: #1a1d23;
  --muted: #646b78;
  --faint: #9aa1ab;
  --line: #e3e6ea;
  --line-2: #eef0f3;
  --accent: #004aad;
  --accent-soft: #e4ecf8;
  --brand-ink: #3d3b3a;
  --dem: #1d4ed8;
  --rep: #c5302a;
  --dem-lt: #6b90e4;
  --rep-lt: #e2837b;
  --other: #6b7280;
  --flag: #d9a441;
  --flag-bg: #fbfaf6;
  --called: #1a7f4b;
  --warn: #b06a00;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(26, 29, 35, 0.05);
  --shadow: 0 1px 3px rgba(26, 29, 35, 0.06), 0 6px 16px rgba(26, 29, 35, 0.05);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

header.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 4px 28px 0;
  /* Two rows: the title and the controls on top, the nav beneath. The bar
     reports its height as --bar-h (common.js) for sticky table headers. */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
}

header.bar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--head);
}
header.bar h1 .sub { font-weight: 400; color: var(--muted); }

.nav { display: flex; gap: 2px; order: 3; flex: 1 1 100%; padding-bottom: 6px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  padding: 7px 13px;
  border-radius: var(--radius);
}
.nav a:hover { color: var(--head); background: var(--line-2); }
.nav a.active { color: #fff; font-weight: 600; background: var(--accent); }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
  min-height: 40px;
}

.controls label { color: var(--muted); }
header.bar .controls .meta { color: var(--faint); font-weight: 500; }

/* toggle switch (header "Hide pre-primary IE") */
.switch { display:inline-flex; align-items:center; gap:8px; font-size:13px; color:var(--ink); cursor:pointer; user-select:none; }
.switch input { position:absolute; opacity:0; width:0; height:0; }
.switch .track { width:34px; height:19px; border-radius:999px; background:#cdd2da; position:relative; transition:background .15s; flex-shrink:0; }
.switch .track::after { content:""; position:absolute; top:2px; left:2px; width:15px; height:15px; border-radius:50%; background:#fff; transition:transform .15s; box-shadow:0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background:var(--accent); }
.switch input:checked + .track::after { transform:translateX(15px); }
.switch input:focus-visible + .track { box-shadow:0 0 0 3px var(--accent-soft); }

button {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
button:hover { border-color: #c9d1da; background: #fafbfc; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-sm); }
button.primary:hover { background: #003a87; border-color: #003a87; }
button.danger { color: var(--rep); border-color: var(--rep); }
button:disabled { opacity: 0.5; cursor: default; }
button.small { padding: 4px 10px; font-size: 12px; }

input[type="number"], input[type="text"], input[type="date"], select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  background: var(--panel);
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input[type="number"]:focus, input[type="text"]:focus, input[type="date"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="number"] { width: 72px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
.status-on { background: #e3f4ea; color: var(--called); }
.status-off { background: #eef0f3; color: var(--muted); }

.meta { color: var(--muted); font-size: 12px; }

main { padding: 24px 24px 64px; max-width: 1440px; }

.grid {
  display: grid;
  /* min(100%, 340px) lets a column shrink below 340 on a narrow phone instead
     of forcing the card wider than the screen. */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card.has-called { border-color: var(--called); }
.card.alert { border-color: var(--warn); }
.card.updated { background: #fff7da; }   /* soft yellow: new data since last seen */
.card.updated:hover { cursor: pointer; }

.alert-line {
  margin: 6px 0 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
}

.tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag-called { background: #e3f4ea; color: var(--called); }
.tag-risk   { background: #fbe6d2; color: var(--warn); }
.tag-ahead  { background: #e7edf6; color: var(--accent); }
.tag-proj   { background: transparent; color: var(--accent); border: 1px dashed var(--accent); }

/* highlight-group chips + emphasis */
.chip {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  margin-left: 7px;
}
.chip-key    { background: var(--accent-soft); color: #2f4b7c; }
.chip-target { background: #f0e9f7; color: #6b3fa0; }
.chip-open   { background: #e2f3f1; color: #1f7a6e; }

.card.highlighted { border-left: 4px solid var(--accent); }
tr.highlighted td { background: #eef3fb; }

table.sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border-spacing: 0;
  box-shadow: var(--shadow-sm);
}
table.sheet th {
  background: #f6f8fb;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
table.sheet td { background: var(--panel); border-top: 1px solid var(--line-2); }
table.sheet td, table.sheet th { padding: 11px 14px; }
table.sheet tbody tr:hover td { background: #fafbfc; }
/* District map (Leaflet) */
.dmap {
  float: right;
  width: min(46%, 460px);
  height: 320px;
  margin: 0 0 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: #eef0f3;
}
.leaflet-container { font: inherit; background: #eef0f3; }
@media (max-width: 720px) {
  .dmap { float: none; width: 100%; margin: 0 0 14px; }
}

/* Itemized finance: segmented controls, search, scrollable sortable table */
.item-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-b { border: none; border-right: 1px solid var(--line); background: var(--panel); color: var(--muted); padding: 6px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg-b:last-child { border-right: none; }
.seg-b:hover { color: var(--head); background: var(--line-2); }
.seg-b.active { background: var(--accent); color: #fff; }
.item-bar input[type="search"] { flex: 1; min-width: 180px; max-width: 320px; padding: 7px 11px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; font-size: 13px; }
.item-bar input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#itemized .sheet-wrap, #ie-itemized .sheet-wrap { max-height: 480px; overflow-y: auto; }
.itable thead th { position: sticky; top: 0; z-index: 1; }
.tag497 { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 20px; background: var(--accent-soft); color: #2f4b7c; white-space: nowrap; vertical-align: 1px; }

.muted-cell { color: var(--muted); font-style: italic; }
tr.called-row td { background: #eef7f1; }

/* timeline */
.tl { max-width: 860px; }
.tl-event { position: relative; border-left: 3px solid var(--line); padding: 8px 28px 10px 12px; margin-bottom: 10px; }
.tl-del { position: absolute; top: 4px; right: 0; border: none; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; cursor: pointer; border-radius: 4px; }
.tl-del:hover { color: var(--rep); background: #fbe9e9; }
.tl-event.k-call { border-left-color: var(--called); }
.tl-event.k-uncall { border-left-color: var(--muted); }
.tl-event.k-race_set { border-left-color: var(--accent); }
.tl-event.k-batch { border-left-color: var(--warn); }
.tl-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tl-summary { font-weight: 600; margin-top: 2px; }
.tl-detail { color: var(--muted); font-size: 13px; margin-top: 5px; line-height: 1.7; }
.tl-empty { color: var(--muted); font-style: italic; padding: 16px 0; }
.tl-list { margin-top: 6px; column-width: 300px; column-gap: 28px; }
.tl-list-item {
  break-inside: avoid;
  font-size: 13px;
  color: var(--ink);
  padding: 2px 0;
  line-height: 1.5;
  border-bottom: 1px solid #f0f2f5;
}
tr.called-row td:first-child { box-shadow: inset 3px 0 0 var(--called); }

.chart-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.chart-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--head); }
.chart-wrap { position: relative; height: 320px; }

a.contest-link { color: inherit; text-decoration: none; }
a.contest-link:hover { color: var(--accent); text-decoration: underline; }

.need-ok { color: var(--called); font-weight: 700; }
.need-no { color: var(--muted); }
#math-body table.detail td.num div { font-variant-numeric: tabular-nums; }

/* Head-to-head log */
.h2h-yes { color: var(--called); font-weight: 700; }
.h2h-no { color: var(--warn); font-weight: 700; }

.card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}
.card h3 { font-size: 15px; margin: 0; font-weight: 600; color: var(--head); }

/* Polling page: many district cards on one page, so each one runs tighter
   than the standard .card padding/spacing. */
.poll-card { padding: 12px 16px; }
.poll-card .title-row { margin-bottom: 4px; }
.poll-card h3 { font-size: 13.5px; }
.poll-card .poll-line.compact { margin-top: 4px; padding-top: 0; border-top: none; }
.poll-card .chart-lbl { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

.called-badge {
  background: var(--called);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

.cand {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid #f0f2f5;
}
.cand:first-of-type { border-top: 0; }
.party-dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-dem { background: var(--dem); }
.dot-rep { background: var(--rep); }
.dot-other { background: var(--other); }
.cand .name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.cand .name .inc { color: var(--warn); font-weight: 700; margin-left: 4px; }
.cand .votes { color: var(--muted); font-variant-numeric: tabular-nums; }
.cand .pct { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.cand.advance .name { font-weight: 700; }

.reporting { color: var(--muted); font-size: 12px; margin-top: 8px; }
.stamp { color: var(--muted); font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }

.notice {
  background: #fff7da;
  border: 1px solid #ece1b3;
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  padding: 11px 15px;
  margin: 12px 16px 0;
}
.notice b { color: var(--warn); }
.notice .called-badge { vertical-align: middle; margin: 0 1px; }

/* Calmer note (no loud amber) for informational disclaimers. */
.notice-calm {
  background: #eef2f7;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 14px;
  margin: 12px 16px 0;
}
.notice-calm b { color: var(--accent); font-size: 16px; }
.notice-calm .called-badge { vertical-align: middle; margin: 0 1px; }

/* Projected percent on the Projections sheet: prominent, not muted. */
.ppct { font-weight: 700; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; margin-left: 3px; }

table.detail:not(.sheet) { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.detail.sheet { width: 100%; margin-top: 6px; }
table.detail th, table.detail td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2); }
table.detail th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.detail td.num, table.detail th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.detail tr.advance td { font-weight: 700; }
table.detail tfoot td { color: var(--muted); border-top: 2px solid var(--line); }
table.detail th.sortable { cursor: pointer; user-select: none; }
table.detail th.sortable:hover { color: var(--accent); }
table.detail th.sort-active { text-decoration: underline; }
table.detail tr.statewide-row td { font-weight: 700; background: #f7f8fa; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 14px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  min-width: 136px;
  box-shadow: var(--shadow-sm);
}
.stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--head); letter-spacing: -0.015em; }

#county-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}
.county-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.cc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cc-name { font-weight: 700; }
.cc-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cc-cand { display: grid; grid-template-columns: 9px 1fr auto auto; align-items: center; gap: 8px; padding: 5px 0 2px; }
.cc-cand .nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cc-cand .nm .inc { color: var(--warn); font-weight: 700; }
.cc-cand .v { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cc-cand .p { font-weight: 650; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.cc-cand.lead .nm { font-weight: 700; }
.cc-bar { height: 4px; border-radius: 2px; background: #eef0f3; overflow: hidden; margin-bottom: 4px; }
.cc-bar > span { display: block; height: 100%; border-radius: 2px; }
.fill-dem { background: var(--dem); }
.fill-rep { background: var(--rep); }
.fill-other { background: var(--other); }

.hist {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 18px;
}
.hist b { color: var(--ink); }

.empty { color: var(--muted); font-style: italic; padding: 6px 0; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 0.96; }

/* Sheet tables (Summary, Projections) scroll horizontally within this wrapper
   on narrow screens instead of pushing the page out. Wrapping keeps the table's
   own border-spacing (row dividers) untouched. */
.sheet-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 600px) {
  main { padding: 14px 12px 48px; }
  .chart-box, .card { padding: 12px 12px; }
  /* Wide tables (the update log has ~10 columns) scroll horizontally inside
     their own box instead of pushing the white box past the screen edge. The
     Summary sheet keeps its own layout. */
  table.detail:not(.sheet) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* --- Campaign Dashboard components -------------------------------------- */
/* Money/figures in monospace tabular numerals (the finance-table house style). */
.cand-money .coh, .cand-money .lcr .lcr-v, .fin-row .val, .stat b,
table.detail td.num, table.sheet td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* home: fixed bottom feed of 72h activity across the flagged districts */
.activity-bar { position:fixed; left:0; right:0; bottom:0; z-index:6; background:var(--panel); border-top:1px solid var(--line); box-shadow:0 -2px 12px rgba(26,29,35,0.08); display:flex; flex-direction:column; max-height:min(38vh, 320px); }
.ab-head { padding:9px 28px; font-size:11px; font-weight:600; letter-spacing:0.04em; text-transform:uppercase; color:var(--muted); border-bottom:1px solid var(--line-2); display:flex; align-items:center; gap:9px; flex-shrink:0; cursor:pointer; user-select:none; }
.ab-head:hover { color:var(--ink); }
.ab-head:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.ab-chev { margin-left:auto; width:8px; height:8px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:translateY(-2px) rotate(45deg); transition:transform 0.28s ease; }
.activity-bar.collapsed .ab-chev { transform:translateY(2px) rotate(-135deg); }
.activity-bar.collapsed .ab-head { border-bottom-color:transparent; }
/* Fold: the list sits in a grid row that animates 1fr -> 0fr. */
.ab-body { flex:1; min-height:0; display:grid; grid-template-rows:1fr; }
.activity-bar.anim .ab-body { transition:grid-template-rows 0.28s ease; }
.activity-bar.collapsed .ab-body { grid-template-rows:0fr; }
.ab-inner { min-height:0; overflow:hidden; display:flex; flex-direction:column; }
main { transition:padding-bottom 0.28s ease; }
.ab-count { font-family:var(--mono); background:var(--accent-soft); color:var(--accent); border-radius:20px; padding:1px 8px; font-size:11px; letter-spacing:0; }
.ab-list { overflow-y:auto; min-height:0; flex:1; }
.ab-item { display:flex; align-items:baseline; gap:14px; padding:8px 28px; font-size:13px; border-bottom:1px solid var(--line-2); }
.ab-item:last-child { border-bottom:none; }
.ab-ad { font-family:var(--mono); font-weight:600; font-size:12px; color:var(--ink); flex-shrink:0; width:46px; }
.ab-main { flex:1; color:var(--ink); }
.ab-main .ab-amt { font-family:var(--mono); font-weight:700; }
.ab-main .ab-donor { font-weight:500; }
.ab-date { color:var(--faint); font-size:12px; white-space:nowrap; flex-shrink:0; }
.ab-empty { padding:13px 28px; color:var(--faint); font-style:italic; font-size:13px; }

.home-filters { display:flex; align-items:center; gap:16px; margin-bottom:18px; font-size:13px; }
.home-filters .hf-label { color:var(--muted); font-weight:500; }
.home-filters label { display:inline-flex; align-items:center; gap:6px; cursor:pointer; color:var(--ink); }
.home-filters input { accent-color:var(--accent); width:15px; height:15px; }

/* All districts page: campaign-finance table (Claude Design import) */
.dist-head { display:flex; flex-wrap:wrap; gap:16px; align-items:center; justify-content:space-between; margin-bottom:18px; }
.dist-title { margin:0; font-size:19px; font-weight:700; letter-spacing:-0.01em; color:var(--head); }
.dist-meta { margin-top:4px; font-size:12.5px; color:var(--muted); }
.dist-tabs { display:flex; gap:8px; }
.dist-tab { background:var(--panel); color:var(--muted); border:1px solid var(--line); padding:6px 14px; border-radius:var(--radius); cursor:pointer; font:inherit; font-size:13px; font-weight:600; }
.dist-tab:hover { color:var(--head); }
.dist-tab.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.fx-drop { position:relative; }
.fx-drop-btn::after { content:""; display:inline-block; margin-left:7px; vertical-align:middle; border:4px solid transparent; border-top-color:currentColor; border-bottom:0; }
.fx-menu { display:none; position:absolute; top:100%; left:0; z-index:20; min-width:100%; padding:4px 0; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); box-shadow:0 4px 14px rgba(0,0,0,.12); }
.fx-drop:hover:not(.shut) .fx-menu, .fx-drop.open .fx-menu { display:block; }
.fx-menu-item { display:block; width:100%; padding:7px 14px; background:none; border:0; text-align:left; cursor:pointer; font:inherit; font-size:13px; font-weight:600; color:var(--muted); }
.fx-menu-item:hover { color:var(--head); background:var(--line-2); }
.fx-menu-item.active { color:var(--head); }

.dtable-wrap { background:var(--panel); }
.dtable { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--line); }
.dtable th { text-align:left; padding:10px 16px; font-size:11px; letter-spacing:0.04em; text-transform:uppercase; color:var(--muted); font-weight:600; background:var(--panel); border-bottom:1px solid var(--line); cursor:pointer; user-select:none; white-space:nowrap; position:sticky; top:var(--bar-h, 56px); z-index:2; }
.dtable th:hover { color:var(--head); }
.dtable th.num { text-align:right; }
.dtable td.num { text-align:right; font-variant-numeric:tabular-nums; }
.dtable th.rk-div, .dtable td.rk-div { border-left:1px solid var(--line); }
.dtable th.ctr { text-align:center; }
.dtable td { padding:11px 16px; border-bottom:1px solid var(--line-2); vertical-align:middle; font-size:13px; color:var(--ink); }
.dtable tbody tr:last-child td { border-bottom:none; }
.dtable tbody tr:hover td { background:#f4f6f8; }
.dtable tr.flagged td { background:var(--flag-bg); }
.dtable tr.flagged td:first-child { box-shadow:inset 2px 0 0 var(--flag); }
.dnum { font-family:var(--mono); font-weight:600; font-size:13px; color:var(--ink); white-space:nowrap; text-decoration:none; }
.dnum:hover { color:var(--accent); }
.dcands { display:flex; flex-direction:column; gap:4px; }
.dcand { display:flex; align-items:baseline; gap:7px; }
.dcand .tag { font-family:var(--mono); font-size:11px; font-weight:700; width:14px; flex-shrink:0; }
.dcand .nm { font-weight:500; font-size:13.5px; color:var(--ink); }
.dunop { font-size:11px; color:var(--faint); font-style:italic; }
.dcash-col { display:flex; flex-direction:column; gap:4px; align-items:flex-end; }
.dcash-col span { font-family:var(--mono); font-size:13px; font-weight:500; font-variant-numeric:tabular-nums; }
.dcash-col .muted { color:var(--faint); font-weight:400; font-style:italic; }
.dnet { text-align:right; font-family:var(--mono); font-size:13px; font-weight:500; white-space:nowrap; font-variant-numeric:tabular-nums; }
.dnet span { font-weight:600; }
.dtable td.dmono { font-family:var(--mono); font-size:13px; font-weight:500; }
.dlate { text-align:right; font-family:var(--mono); font-size:12.5px; color:var(--muted); white-space:nowrap; font-variant-numeric:tabular-nums; }
.dctr { text-align:center; }
.dctr input { width:16px; height:16px; cursor:pointer; accent-color:var(--accent); }
.dsort { color:var(--accent); }
.dist-empty { padding:48px 24px; text-align:center; font-size:14px; color:var(--muted); background:var(--panel); border-top:1px solid var(--line-2); }
@media (max-width:680px){ .dtable-wrap { overflow-x:auto; } .dtable th { position:static; } }

/* Ranks page: a wide metric grid on the dtable base. */
.rtable-wrap { overflow-x:auto; }
.rtable th { padding:10px 10px; position:static; }
.rtable td { padding:9px 10px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.rtable th.rk-div, .rtable td.rk-div { border-left:1px solid var(--line); }
.lean-d { color:var(--dem); font-weight:600; }
.lean-r { color:var(--rep); font-weight:600; }
.lean-even { color:var(--muted); font-weight:600; }
.rk-na { color:var(--faint); }
.rk-score { font-family:var(--mono); font-weight:600; }


.race-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:16px; }
.race-head .ad { font-size:19px; font-weight:700; letter-spacing:-0.02em; color:var(--accent); }

.cand-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width:520px){ .cand-grid { grid-template-columns:1fr; } }
.cand-box { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius-lg); padding:16px 18px; box-shadow:var(--shadow-sm); }
.cand-box .cn { font-size:15px; font-weight:650; margin-bottom:10px; color:var(--head); }
.cand-box .cn .inc { color:var(--warn); font-weight:700; font-size:11px; margin-left:4px; }
.pty-dem { color:var(--dem); } .pty-rep { color:var(--rep); } .pty-oth { color:var(--other); }

.fin-row { display:flex; justify-content:space-between; gap:8px; font-size:13px; padding:4px 0; }
.fin-row .lbl { color:var(--muted); }
.fin-row .val { font-weight:600; font-variant-numeric:tabular-nums; }
.fin-row .val .muted { color:var(--muted); font-weight:400; font-style:italic; }

.cand-box.solo { display:flex; align-items:center; justify-content:center; color:var(--muted); font-style:italic; }

/* home race card: activity-led, with a money footer per candidate */
.activity { margin-bottom:16px; }
.act-event { background:var(--accent-soft); border-left:3px solid var(--accent); border-radius:0 8px 8px 0; padding:10px 14px; margin-bottom:8px; }
.act-event:last-child { margin-bottom:0; }
.act-main { font-size:13.5px; line-height:1.5; color:var(--ink); }
.act-main .amt { font-weight:700; color:var(--head); }
.act-src { color:var(--muted); font-size:11.5px; margin-top:1px; }
.act-quiet { color:var(--faint); font-size:13px; margin-bottom:16px; padding:2px 0; }

.cand-foot { display:grid; grid-template-columns:1fr 1fr; gap:18px; border-top:1px solid var(--line-2); padding-top:16px; }
.cand-money .nm { font-size:14px; font-weight:600; margin-bottom:7px; }
.cand-money .nm .pty { color:var(--faint); font-weight:500; }
.cand-money .nm .inc { color:var(--warn); font-weight:700; font-size:9.5px; letter-spacing:0.04em; margin-left:5px; vertical-align:1px; }
.cand-money .coh { font-size:21px; font-weight:700; color:var(--head); font-variant-numeric:tabular-nums; letter-spacing:-0.015em; line-height:1.1; }
.cand-money .coh-lbl { font-size:11px; color:var(--faint); margin-top:2px; }
.cand-money .lcr { font-size:12px; color:var(--muted); margin-top:7px; }
.cand-money .lcr .lcr-v { color:var(--ink); font-weight:600; font-variant-numeric:tabular-nums; }
.cand-money .ln.muted { font-size:12.5px; color:var(--faint); font-style:italic; margin-top:6px; }
.cand-money.solo { grid-column:1/-1; text-align:center; color:var(--muted); font-style:italic; }

.poll-ballots { display:flex; gap:28px; flex-wrap:wrap; margin-top:14px; }
.poll-sec-h { font-weight:650; font-size:13px; margin-bottom:8px; }
.poll-share { display:flex; flex-direction:column; gap:3px; font-size:12px; color:var(--muted); margin-bottom:8px; max-width:200px; }
.poll-undec { font-size:12px; color:var(--muted); margin-top:4px; font-weight:600; }

.poll-del { border:none; background:none; color:var(--muted); font-size:12px; padding:2px 6px; cursor:pointer; border-radius:4px; }
.poll-del:hover { color:var(--rep); background:#fbe9e9; }
.poll-del:disabled { opacity:0.5; cursor:default; }

.poll-line { margin-top:14px; padding-top:13px; border-top:1px solid var(--line-2); font-size:12.5px; color:var(--faint); }
.poll-line b { color:var(--ink); font-weight:600; }
.poll-line .none { font-style:italic; }

/* tabs on the district page */
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--line); margin:22px 0 18px; flex-wrap:wrap; }
.tab { font-size:14px; padding:10px 15px; color:var(--muted); cursor:pointer; border:none; background:none; border-bottom:2px solid transparent; margin-bottom:-1px; }
.tab:hover { color:var(--head); }
.tab.active { color:var(--head); font-weight:600; border-bottom-color:var(--accent); }
.panel { display:none; } .panel.active { display:block; }

#poll-upload.drop-on { outline:2px dashed var(--accent); outline-offset:-2px; }
.formgrid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr)); gap:14px 16px; align-items:end; }
.formgrid label { display:flex; flex-direction:column; gap:5px; font-size:12px; font-weight:500; color:var(--muted); }
.formgrid input, .formgrid select { font:inherit; }

/* --- Forecast page ------------------------------------------------------- */
.fc-headline { display:flex; flex-wrap:wrap; align-items:center; gap:22px 40px; padding:20px 22px; margin-bottom:16px; }
.fc-big { display:flex; align-items:baseline; gap:12px; }
.fc-num { font-size:44px; font-weight:700; color:var(--dem); letter-spacing:-1px; }
.fc-big-lab { font-size:13px; color:var(--muted); max-width:150px; line-height:1.3; }
.fc-stats { display:flex; flex-wrap:wrap; gap:14px 30px; margin-left:auto; }
.fc-stats > div { display:flex; flex-direction:column; gap:2px; }
.fc-stat { font-size:19px; font-weight:600; color:var(--ink); }
.fc-stat-lab { font-size:11px; color:var(--muted); }
.fc-card { padding:18px 22px; margin-bottom:16px; }
.fc-move-chart { max-width:720px; margin:6px 0 4px; }
.mv-range { position:relative; height:20px; margin-top:2px; }
.mv-track { position:absolute; left:0; right:0; top:8px; height:4px; border-radius:2px; background:var(--line); }
.mv-fill { position:absolute; top:0; bottom:0; border-radius:2px; background:var(--accent); }
.mv-range input { position:absolute; top:0; left:-9px; width:calc(100% + 18px); height:20px; margin:0; padding:0; background:none; pointer-events:none; -webkit-appearance:none; appearance:none; }
.mv-range input::-webkit-slider-runnable-track { height:20px; background:none; }
.mv-range input::-moz-range-track { height:20px; background:none; }
.mv-range input::-webkit-slider-thumb { -webkit-appearance:none; box-sizing:border-box; width:18px; height:18px; margin-top:1px; border-radius:50%; background:var(--panel); border:2px solid var(--accent); cursor:ew-resize; pointer-events:auto; }
.mv-range input::-moz-range-thumb { box-sizing:border-box; width:18px; height:18px; border-radius:50%; background:var(--panel); border:2px solid var(--accent); cursor:ew-resize; pointer-events:auto; }
.fc-pm-table { max-width:560px; }
.fc-pm-table td.num { text-align:right; font-variant-numeric:tabular-nums; }
.fc-h { font-size:13px; font-weight:600; text-transform:uppercase; letter-spacing:.4px; color:var(--muted); margin:0 0 12px; }
.fc-hist { width:100%; height:auto; }
.fc-bar { fill:var(--accent-soft); }
.fc-bar-ci { fill:var(--dem); }
.fc-tick { fill:var(--faint); font-size:10.5px; }
.fc-thresh { stroke:var(--muted); stroke-width:1; stroke-dasharray:3 3; }
.fc-thresh-lab { fill:var(--muted); font-size:10.5px; }
.fc-bands { display:grid; grid-template-columns:repeat(7, 1fr); gap:10px; }
.fc-band-head { font-size:11.5px; font-weight:600; color:var(--muted); margin-bottom:7px; white-space:nowrap; }
.fc-band-n { color:var(--faint); font-weight:500; margin-left:3px; }
.fc-chips { display:flex; flex-wrap:wrap; gap:4px; }
.fc-chip { display:inline-block; min-width:26px; text-align:center; padding:3px 4px; border-radius:4px; font-size:11.5px; font-weight:600; text-decoration:none; }
.fc-safed   { background:var(--dem); color:#fff; }
.fc-likelyd { background:var(--dem-lt); color:#fff; }
.fc-leand   { background:#ccd9f6; color:#173a8f; }
.fc-tossup  { background:#e6e6e2; color:var(--ink); }
.fc-leanr   { background:#f3d2ce; color:#8f2620; }
.fc-likelyr { background:var(--rep-lt); color:#fff; }
.fc-safer   { background:var(--rep); color:#fff; }
.fc-chip:hover { outline:2px solid var(--head); outline-offset:1px; }
.fc-comp { width:100%; max-width:640px; height:auto; }
.fc-grid { stroke:var(--line-2); stroke-width:1; }
.fc-grid.mid { stroke:var(--muted); stroke-width:1.5; }
.fc-int { stroke:var(--faint); stroke-width:2.5; stroke-linecap:round; }
.fc-med-d { fill:var(--dem); }
.fc-med-r { fill:var(--rep); }
.fc-win { fill:var(--ink); font-size:11.5px; font-weight:600; }
.fc-lab { fill:var(--ink); font-size:11.5px; font-weight:600; }
a:hover .fc-lab { fill:var(--accent); }
.fc-wx-name { fill:var(--ink); font-size:11.5px; }
.fc-tip { position:fixed; z-index:50; max-width:300px; background:var(--head); color:#fff; font-size:12px; line-height:1.55; padding:10px 13px; border-radius:6px; white-space:pre-line; pointer-events:none; box-shadow:0 4px 14px rgba(0,0,0,.25); }
.fc-tip::first-line { font-weight:600; }
.fc-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.fc-scroll .fc-hist { min-width:560px; }
.fc-scroll .fc-comp { min-width:520px; }
.fc-actual { stroke:var(--flag); stroke-width:2; }
.fc-actual-lab { fill:var(--flag); font-size:10.5px; font-weight:600; }
.fc-actual-num { color:var(--flag); }
.fc-act-dot { fill:var(--flag); stroke:var(--head); stroke-width:1; }
.fc-chip-miss { outline:2px solid var(--flag); outline-offset:1px; }
/* Closest race tab */
.cl-ranks { display:flex; flex-direction:column; gap:6px; max-width:560px; }
.cl-row { display:flex; align-items:center; gap:10px; }
.cl-lab { font-family:var(--mono); font-size:12px; font-weight:600; width:46px; flex:none; color:var(--ink); text-decoration:none; }
.cl-track { flex:1; background:var(--line-2); border-radius:3px; height:12px; }
.cl-fill { height:12px; background:var(--accent); border-radius:3px; }
.cl-pct { width:44px; flex:none; text-align:right; font-size:12px; font-variant-numeric:tabular-nums; color:var(--ink); }
.cl-margin { width:52px; flex:none; text-align:right; font-size:12px; }
.cl-grid { display:flex; flex-wrap:wrap; gap:4px; }
.cl-gcell { width:46px; padding:5px 0 4px; text-align:center; border-radius:4px; cursor:pointer; display:flex; flex-direction:column; gap:1px; }
.cl-gcell.cl-dead { cursor:default; }
.cl-gnum { font-size:13px; font-weight:600; line-height:1.1; }
.cl-gwin { font-size:10.5px; line-height:1.1; opacity:.85; }
.cl-gcell.sel { outline:2px solid var(--head); outline-offset:1px; }
.fc-strip { position:fixed; left:0; right:0; bottom:0; z-index:60; background:var(--head); color:#fff; font-size:12.5px; line-height:1.55; padding:12px 16px; padding-bottom:calc(12px + env(safe-area-inset-bottom)); white-space:pre-line; box-shadow:0 -4px 14px rgba(0,0,0,.25); }
.fc-strip div::first-line { font-weight:600; }
.fc-strip a { display:inline-block; margin-top:6px; color:#a9c2f8; font-weight:600; text-decoration:none; }
.cl-curvesvg { width:100%; height:auto; display:block; }
.fc-scroll .cl-curvesvg { min-width:480px; }
.cl-area-d { fill:var(--dem-lt); fill-opacity:.55; }
.cl-area-r { fill:var(--rep-lt); fill-opacity:.55; }
.cl-base { stroke:var(--line); stroke-width:1; }
.cl-tie { stroke:var(--muted); stroke-width:1; stroke-dasharray:3 3; }
.cl-hoverbar { stroke:var(--muted); stroke-width:1; }
.fc-model-state { font-size:19px; font-weight:600; color:var(--ink); margin:2px 0 4px; }
#fm-runs { width:auto; min-width:340px; }
@media (max-width: 900px) { .fc-bands { grid-template-columns:repeat(4, 1fr); } }

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 720px) {
  header.bar { padding:6px 12px 0; gap:6px 10px; }
  .controls { min-height:0; }
  header.bar h1 { font-size:15px; }
  .controls { gap:8px; }
  /* The nav row scrolls sideways if needed instead of wrapping. */
  .nav { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .nav a { white-space:nowrap; padding:6px 10px; }
  .dist-tabs { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .dist-tab { white-space:nowrap; }
  .fx-tabs { overflow:visible; flex-wrap:wrap; }
}
@media (max-width: 600px) {
  .fc-headline { padding:14px 14px; gap:10px 24px; }
  .fc-num { font-size:34px; }
  .fc-stats { margin-left:0; gap:10px 22px; }
  .fc-stat { font-size:16px; }
  .fc-bands { grid-template-columns:repeat(2, 1fr); }
  .fc-band-head { white-space:normal; }
}

/* Ranks + counties: fixed ordinal column, renumbered by DOM order so it
   tracks sorts. */
#rtable tbody, .ct-table tbody { counter-reset: rkord; }
#rtable tbody tr, .ct-table tbody tr.ct-row { counter-increment: rkord; }
#rtable td.rk-ord::before, .ct-table td.rk-ord::before { content: counter(rkord); }
#rtable .rk-ord, .ct-table .rk-ord { color: var(--muted, #888); font-variant-numeric: tabular-nums; width: 2.2em; }

/* Counties: one ranked board per party, side by side; each county row
   toggles a detail row. */
.ct-cols { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr)); gap:16px; max-width:880px; align-items:start; }
.ct-table tr.ct-row { cursor:pointer; }
.ct-table tr.ct-detail > td { background:var(--bg); padding:8px 12px; }

/* Polls toggle: both boards occupy the same grid cell so the page height
   and scroll position never jump when switching. */
.fc-pv-stack { display: grid; }
.fc-pv-stack > .fc-pv { grid-area: 1 / 1; min-width: 0; }
.fc-pv.off { visibility: hidden; }

/* Histogram: invisible full-height hit target so short bars still hover. */
.fc-bar-hit { fill: transparent; }

/* District Polling tab: informed/uninformed side by side, stacked on mobile. */
.poll-2col { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width: 760px) { .poll-2col { grid-template-columns:1fr; } }

/* --- Polling vocabulary -------------------------------------------------- */
.vocab-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.vocab-row input { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; background: transparent; min-width: 200px; }
.vocab-row input:hover, .vocab-row input:focus { border-color: var(--line); background: #fff; }
.vocab-row input::placeholder { color: var(--faint); }
.vocab-dim { margin-top: 12px; }
.vocab-dim-h { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
button.link { border: none; background: none; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer; }
button.link:hover { color: var(--rep); }

/* --- Poll review screen ---------------------------------------------------- */
.pr-split { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.4fr); gap: 16px; }
@media (max-width: 1100px) { .pr-split { grid-template-columns: minmax(0, 1fr); } }
.pr-src { min-width: 0; }
.pr-src img { max-width: 100%; border: 1px solid var(--line); }
.pr-grid-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--line); }
.pr-grid { border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-grid th { color: var(--muted); font-weight: 500; padding: 2px 6px; border-right: 1px solid var(--line-2); text-align: right; background: #fafbfc; position: sticky; left: 0; }
.pr-grid td { padding: 2px 6px; border-bottom: 1px solid var(--line-2); border-right: 1px solid #f2f4f7; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.pr-grid tr.hl td { background: #fff5d6; }
.pr-parsed { min-width: 0; }
.pr-q { margin-bottom: 18px; }
.pr-qhead { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.pr-qhead input, .pr-qhead select { font: inherit; font-size: 12px; padding: 3px 6px; }
.pr-qhead .pr-wide { flex: 1; min-width: 160px; }
.pr-cells { font-size: 12px; }
.pr-cells th input { font: inherit; font-size: 11px; width: 92px; padding: 2px 4px; }
.pr-cells td input[data-f=response_option] { font: inherit; font-size: 12px; width: 150px; padding: 2px 4px; }
.pr-cells td select { font: inherit; font-size: 12px; }
.pr-cells td.pr-v { min-width: 44px; cursor: text; }
.pr-cells td.pr-v:focus { outline: 2px solid var(--accent); background: #fffbe8; }
.pr-cells .pr-nrow td { color: var(--muted); font-size: 11px; }
.pr-cells th, .pr-cells td { padding: 4px 6px; }
.pr-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
.pr-qname { font-weight: 650; font-size: 13px; margin-right: 6px; }
.pr-opt { white-space: nowrap; font-size: 13px; }
.pr-opt-l { color: var(--muted); }
.pr-opt-v { font-variant-numeric: tabular-nums; font-weight: 600; }
.pr-line .pr-more { margin-left: auto; }
.pr-detail { margin-top: 10px; }
.field-missing { outline: 2px solid var(--rep); }
input.poll-edit { font: inherit; font-size: 13px; padding: 3px 5px; border: 1px solid transparent; border-radius: 4px; background: transparent; width: 130px; }
input.poll-edit.num { width: 70px; text-align: right; }
input.poll-edit:hover, input.poll-edit:focus { border-color: var(--line); background: #fff; }

/* Click-to-expand poll detail (district Polling tab) */
tr[data-detail] { cursor: pointer; }
.poll-detail-row td { background: var(--bg); padding: 8px 10px 8px 22px; }
.pd-q { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 2px 0; font-size: 13px; }
.pd-l { font-weight: 650; min-width: 220px; }
.pd-v { color: var(--muted); }
.pd-v b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.pd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pd-chip { font: inherit; font-size: 12px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer; }
.pd-chip:hover { border-color: var(--accent); color: var(--accent); }
.poll-detail-box { margin-top: 6px; padding: 8px 10px; background: var(--bg); border-radius: 6px; }

/* Polling board (Polling page) and the shared district polling block */
.btn-link { font-size: 13px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius); padding: 6px 12px; text-decoration: none; background: var(--panel); }
.btn-link:hover { background: var(--accent-soft); }
.bbar { display: flex; height: 20px; border-radius: 3px; overflow: hidden; font-size: 11.5px; font-weight: 600; line-height: 20px; text-align: center; color: #fff; font-variant-numeric: tabular-nums; }
.bbar span { overflow: hidden; white-space: nowrap; }
.bbar .bb-d { background: var(--dem); }
.bbar .bb-r { background: var(--rep); }
.bbar .bb-u { background: #c3c9d0; color: #3a4048; }
.pb { width: 100%; border-collapse: collapse; font-size: 13px; }
.pb th { font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: left; padding: 8px 8px 6px; }
.pb th.num, .pb td.num { text-align: right; }
.pb td { padding: 9px 8px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.pb .pb-bar { width: 38%; min-width: 220px; }
.pb .faint { color: var(--faint); }
.pb-row { cursor: pointer; }
.pb-row:hover td { background: var(--bg); }
.pb-row.open td { background: var(--bg); border-bottom: none; }
.pb-detail td { background: var(--bg); padding: 4px 14px 16px; border-top: none; }
/* width:0 + min-width:100% keeps the charts from widening the table. */
.pb-x { display: flex; flex-direction: column; gap: 10px; width: 0; min-width: 100%; }
.pb-c { min-width: 0; }
.pb-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; max-width: 1100px; }
.pb-charts > svg { grid-column: 1 / -1; max-width: 760px; }
.pb-charts svg { display: block; }
.pb-ct { font-size: 12px; font-weight: 600; color: var(--head); margin-bottom: 2px; }
.pb-all td { vertical-align: middle; }
.pb-all td:nth-child(2), .pb-all td:nth-child(6), .pb-all td:nth-child(7) { white-space: nowrap; }
.pb-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pb-pick select { font: inherit; font-size: 12.5px; max-width: min(100%, 420px); }
.pb-log { margin-top: 0; }
span.pd-chip { cursor: default; }
.tag-tl { display: inline-block; font-size: 10.5px; font-weight: 600; color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 0 7px; line-height: 15px; vertical-align: 1px; }

/* --- Poll changes (Mini only) ------------------------------------------- */
@font-face { font-family: "Libre Franklin"; src: url("slides/fonts/libre-franklin-roman.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("slides/fonts/libre-franklin-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
.pc { font-family: "Libre Franklin", var(--sans); font-size: 13px; }
.pc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.pc-chip { font-size: 12.5px; font-weight: 500; padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); text-decoration: none; }
.pc-chip small { color: var(--faint); font-weight: 400; margin-left: 5px; font-size: 11px; }
.pc-chip:hover { border-color: var(--ink); }
.pc-chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pc-chip.on small { color: #c3c9d0; }
.pc-lede { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.pc-lede b { color: var(--ink); font-weight: 600; }
.pc-note { font-size: 12px; color: var(--faint); }
.pc-sec { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 10px; }
.pc-sec h3 { font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0; white-space: nowrap; }
.pc-sec .rule { flex: 1; border-top: 1px solid var(--line); }
.pc-grid { display: grid; gap: 12px; }
.pc-grid.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); max-width: 1240px; }
.pc-grid.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); max-width: 980px; }
.pc-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 8px; min-width: 0; }
.pc-card svg { display: block; }
.pc-ch { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.pc-ct { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.pc-cs { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pc-png { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; text-decoration: none; white-space: nowrap; }
.pc-png:hover { color: var(--ink); border-color: var(--ink); }
.pc-qh { font-size: 13px; font-weight: 600; margin: 8px 0 8px; }
.pc-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.pc-pick select { font: inherit; font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); max-width: min(100%, 460px); }
.pc-lbl { color: var(--muted); }
.pc-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.pc-seg button { font: inherit; font-size: 12.5px; border: none; background: var(--panel); color: var(--muted); padding: 5px 11px; cursor: pointer; }
.pc-seg button + button { border-left: 1px solid var(--line); }
.pc-seg button.on { background: var(--ink); color: #fff; }
.pc-seg a { font-size: 12.5px; color: var(--muted); padding: 5px 11px; text-decoration: none; background: var(--panel); }
.pc-seg a + a { border-left: 1px solid var(--line); }
.pc-seg a.on { background: var(--ink); color: #fff; }
.pc-grid.g3w { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); max-width: 1500px; }
.pc-pick-out.busy { opacity: 0.5; }
.pb-links { display: flex; gap: 8px; }
.pc-pick-out .pc-card { max-width: 620px; }

/* --- Results (live election returns) ------------------------------------- */
.res-bar { display:flex; align-items:center; gap:14px; flex-wrap:wrap; margin-bottom:16px; }
.res-bar .seg { flex-shrink:0; }
.res-bar .spacer { flex:1; }
.res-controls { display:flex; align-items:center; gap:10px; flex-wrap:wrap; font-size:13px; }
.res-controls input[type="number"] { width:64px; padding:5px 8px; }
.res-filters { display:flex; align-items:center; gap:14px; flex-wrap:wrap; margin-bottom:14px; font-size:13px; color:var(--muted); }
.res-filters label { display:inline-flex; align-items:center; gap:5px; color:var(--ink); cursor:pointer; }
.res-filters input[type="text"] { width:220px; }
.res-title { font-size:19px; font-weight:700; letter-spacing:-0.02em; color:var(--head); margin:0; }
.res-title .sub { color:var(--muted); font-weight:400; margin-left:8px; font-size:14px; }
.res-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap:14px; }
.res-card { padding:14px 16px; }
.res-card .title-row { display:flex; justify-content:space-between; align-items:baseline; gap:8px; margin-bottom:8px; }
.res-card h3 { font-size:14px; margin:0; font-weight:650; }
.res-card h3 a { color:inherit; text-decoration:none; }
.res-card h3 a:hover { color:var(--accent); }
.res-card.has-called { border-color:var(--called); }
.res-card.alert { border-color:var(--warn); }
.res-card.updated { background:#fff7da; cursor:pointer; }
.cand.advance .name { font-weight:700; }
.cand .name .inc { color:var(--warn); font-weight:700; font-size:11px; margin-left:2px; }
.cand .votes { color:var(--muted); font-variant-numeric:tabular-nums; font-family:var(--mono); font-size:12.5px; }
.cand .pct { font-weight:650; font-variant-numeric:tabular-nums; min-width:48px; text-align:right; }
.h2h-yes { color:var(--called); font-weight:700; }
.h2h-no { color:var(--warn); font-weight:700; }
.res-box { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius-lg); padding:14px 16px; margin-bottom:14px; box-shadow:var(--shadow-sm); }
.res-box .chart-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; flex-wrap:wrap; }
.res-box .chart-head h3 { margin:0; font-size:14px; font-weight:650; }
.res-box .chart-wrap { position:relative; height:300px; }
.res-standings .cand { padding:5px 0; }
.res-margin { font-size:13px; color:var(--muted); margin-top:6px; }
.res-margin b { color:var(--ink); font-variant-numeric:tabular-nums; }
.res-line { display:flex; justify-content:space-between; align-items:baseline; gap:8px; font-size:13px; padding:8px 0 0; margin-top:8px; border-top:1px solid var(--line-2); }
.res-line .lead { font-weight:600; }
.res-line .rep { color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }
.res-line .called-badge { margin-left:6px; }
.commentary-box { width:100%; min-width:200px; resize:vertical; font:inherit; font-size:13px; border:1px solid var(--line); border-radius:var(--radius); padding:6px 8px; }
.commentary-ro { font-size:13px; color:var(--ink); white-space:pre-wrap; }
.res-status { display:inline-flex; align-items:center; gap:6px; padding:3px 9px; border-radius:999px; font-weight:600; font-size:12px; }
.res-status.on { background:#e3f4ea; color:var(--called); }
.res-status.off { background:#eef0f3; color:var(--muted); }
.tag-proj { background:transparent; color:var(--accent); border:1px dashed var(--accent); }
@media (max-width:600px) { .res-box { padding:12px; } }

/* --- County committee cash (/cc, Mini only) ------------------------------ */
.cc-head { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin:18px 0 16px; }
.cc-downloads { display:flex; gap:10px; }
.cc-card { padding:18px 22px; margin-bottom:16px; }
.cc-h { font-size:13px; font-weight:600; text-transform:uppercase; letter-spacing:.4px; color:var(--muted); margin:0 0 12px; }
.cc-h2 { font-size:12px; font-weight:600; color:var(--muted); margin:0 0 6px; }
.cc-form { margin-bottom:18px; }
.cc-amt { width:120px; }
.cc-table td input, .cc-table td select { font:inherit; font-size:13px; padding:4px 8px; }
.cc-table td { padding:7px 12px; }
.cc-add-cell { white-space:nowrap; }
.cc-add-cell button + button { margin-left:6px; }
.cc-table th { padding:8px 12px; position:static; }
.cc-table tr.cc-need td { background:#ffcccc; }
.cc-table tr.cc-asked td, .cc-table tr.cc-outbound td { background:#ffffcc; }
.cc-table tr.cc-received td { background:#dbedd5; }
.cc-table tbody tr:hover td { filter:brightness(.97); }
.cc-sug { font-size:12px; color:var(--ink); margin-right:8px; }
.cc-suggest-box { margin-bottom:16px; padding:10px 12px; border:1px solid var(--flag); border-radius:var(--radius); background:var(--flag-bg); }
.cc-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,460px),1fr)); gap:16px; }
.cc-county { border:1px solid var(--line); border-radius:var(--radius); padding:12px 14px; background:var(--panel); }
.cc-county-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; }
.cc-begin { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); }
.cc-deps { width:100%; border-collapse:collapse; }
.cc-deps td { padding:3px 4px; font-size:13px; border-bottom:1px solid var(--line-2); }
.cc-deps td.num { text-align:right; }
.cc-deps input { font:inherit; font-size:13px; padding:4px 8px; width:100%; }
.cc-deps input[type=date] { width:140px; }
.cc-deps .cc-amt { width:120px; }
.cc-deps tr.cc-new-dep td { border-bottom:none; padding-top:8px; }
.cc-totals { display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:10px; padding-top:8px; border-top:1px solid var(--line); font-size:12px; }
.cc-totals > div { display:flex; gap:6px; }
.cc-totals .lbl { color:var(--muted); }

/* Scenarios: three partisan groups, each a universe pick and a Dem share. */
.sc-controls { display:flex; flex-wrap:wrap; gap:14px; margin-bottom:18px; }
.sc-group { display:flex; align-items:end; gap:12px; padding:12px 16px; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); }
.sc-group-name { font-size:13px; padding-bottom:8px; min-width:92px; }
.sc-group label { display:flex; flex-direction:column; gap:5px; font-size:12px; font-weight:500; color:var(--muted); }
.sc-group input[type="number"] { width:84px; }

/* Counts page */
.cn-cols { flex-wrap:wrap; overflow:visible; margin-bottom:14px; }
.cn-cols .dist-tab { flex:0 0 auto; }
#ct-table th { position:sticky; }
.cn-group td { font-weight:600; color:var(--muted); background:var(--panel); }

/* ----- California Political Tools: accounts ---------------------------------- */
.controls .who { color: var(--ink); font-size: 13px; text-decoration: none; }
.controls a.who:hover { text-decoration: underline; }
form.inline { display: inline; margin: 0; }
.page-title { font-size: 18px; margin: 4px 0 14px; }
.account-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; max-width: 380px; display: flex; flex-direction: column; gap: 12px; margin: 24px auto; box-shadow: var(--shadow-sm); }
.account-form h2, .account-form h3 { margin: 0 0 4px; font-size: 16px; }
.account-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.account-form input, .account-form select { width: 100%; font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); }
.account-form button { align-self: flex-start; }
.account-form.row { max-width: none; margin: 18px 0 0; flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.account-form.row h3 { flex: 1 1 100%; }
.account-form.row label { min-width: 200px; }
.form-error { color: var(--rep); font-weight: 600; margin: 0; }
.temp-box { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
.temp-pw { font-family: var(--mono); font-size: 20px; letter-spacing: 0.06em; margin-top: 6px; user-select: all; }
table.accounts td.actions { text-align: right; white-space: nowrap; }
table.accounts td.actions form + form { margin-left: 6px; }
table.accounts tr.inactive td { color: var(--muted); }
table.accounts select { font: inherit; padding: 3px 6px; }
label.check { margin-right: 10px; white-space: nowrap; }
a.back { color: var(--ink); font-size: 13px; text-decoration: none; }
a.back:hover { text-decoration: underline; }
h4.sub-h { font-size: 12.5px; font-weight: 600; margin: 10px 0 4px; }

/* ----- brand ---------------------------------------------------------------- */
header.bar h1 a.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--brand-ink); text-decoration: none; font-weight: 800; letter-spacing: 0.01em; text-transform: uppercase; font-size: 14px; }
header.bar h1 a.brand .mark { height: 26px; width: auto; display: block; }
.login-logo { display: block; width: min(320px, 70vw); margin: 40px auto 0; }
.login-logo + .account-form { margin-top: 8px; }
.home-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-top: 8px; }
.tile { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow-sm); }
a.tile:hover, .tile h3 a:hover { border-color: var(--accent); color: var(--accent); }
.tile h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--head); }
.tile h3 a { color: inherit; text-decoration: none; }
.tile-big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.tile-line { margin-top: 4px; font-size: 14px; }
.tile-rows { display: flex; flex-direction: column; }
.tile-row { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--line-2); color: var(--ink); text-decoration: none; }
.tile-row:hover { color: var(--accent); }
.tile-go { display: flex; gap: 6px; margin-top: 12px; }
.tile-go input { flex: 1; min-width: 0; font: inherit; padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--radius); }
.signin-box { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.signin-box pre { margin: 0; font: inherit; white-space: pre-wrap; flex: 1; }
.signin-box .temp-pw { margin-top: 0; }
.account-form .checks { display: flex; align-items: center; min-height: 34px; }
.account-form .checks label.check { flex-direction: row; align-items: center; gap: 6px; }
