:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7973;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --neutral-fill: #e4e2dc;
  --warn: #fab219;
  --crit: #d03b3b;
  --good: #0ca30c;
  /* cores dos candidatos/partidos — ordem fixa por votação no recorte */
  --c0: #2a78d6; --c1: #eb6834; --c2: #1baf7a; --c3: #eda100; --c4: #e87ba4; --c5: #008300;
  --cx: #b9b7b0;
  --seq-comp: #4a3aa7;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #3987e5; --accent-ink: #86b6ef; --neutral-fill: #2f2f2c;
    --c0: #3987e5; --c1: #d95926; --c2: #199e70; --c3: #c98500; --c4: #d55181; --c5: #008300;
    --cx: #5c5b56; --seq-comp: #9085e9;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #3987e5; --accent-ink: #86b6ef; --neutral-fill: #2f2f2c;
  --c0: #3987e5; --c1: #d95926; --c2: #199e70; --c3: #c98500; --c4: #d55181; --c5: #008300;
  --cx: #5c5b56; --seq-comp: #9085e9;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "IBM Plex Sans", system-ui, sans-serif; }
.num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14.5px; font-weight: 600; }
a { color: var(--accent-ink); }
.muted { color: var(--text-2); font-size: 13.5px; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.top-in { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--text); flex: none; }
.brand b { font-size: 16px; }
.logo { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.nav { display: flex; gap: 2px; }
.nav a { text-decoration: none; color: var(--text-2); padding: 6px 10px; border-radius: 8px; font-size: 14.5px; white-space: nowrap; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.nav a:hover { color: var(--text); }
.top .search { margin-left: auto; }
.theme { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; display: grid; place-items: center; flex: none; }
@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; height: auto; padding: 8px 0; gap: 8px; }
  .brand b { display: none; }
  .top .search { order: 3; flex-basis: 100%; max-width: none; }
}

.search { position: relative; flex: 0 1 280px; }
.search input { width: 100%; padding: 7px 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 9px; font: inherit; font-size: 14px; }
.search ul { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 320px; overflow: auto; }
.search li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.search li[aria-selected="true"], .search li:hover { background: var(--surface-2); }
.search li span { color: var(--muted); font-size: 12px; }

.banner { margin-top: 14px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); font-size: 13.5px; }

/* ---------- controles ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; margin: 16px 0 12px; }
.ctl { display: grid; gap: 4px; }
.ctl > span { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 6px 11px; border-radius: 7px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); font-weight: 500; }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
select, .btn { font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.btn { cursor: pointer; background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); }
input.txt { font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

/* ---------- cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; min-width: 0; }
.card-h { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.kpi .l { color: var(--text-2); font-size: 12.5px; }
.kpi .v { font-size: 20px; font-weight: 600; line-height: 1.25; }
.kpi .d { color: var(--muted); font-size: 12px; }

/* ---------- barras de resultado ---------- */
.bars { display: grid; gap: 2px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 4px 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-row .who b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .who .p { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.bar-row .pc { text-align: right; font-weight: 600; }
.bar-row .track { grid-column: 1 / -1; position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; }
.bar-row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.bar-row .ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .5; }
.bar-row .sub { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -2px; }
.chip { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); white-space: nowrap; }
.badge.el { background: color-mix(in srgb, var(--good) 14%, var(--surface)); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.badge.t2 { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

/* ---------- mapa ---------- */
.mapcard { position: relative; }
.mapbox { width: 100%; }
.map { width: 100%; display: block; }
.map path { stroke: var(--surface); stroke-width: .6; vector-effect: non-scaling-stroke; cursor: pointer; }
.map path:hover { stroke: var(--text); stroke-width: 1.5; }
.map path.sel { stroke: var(--text); stroke-width: 2.4; }
.legend { display: flex; align-items: center; gap: 6px 12px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend .it { display: inline-flex; align-items: center; gap: 5px; }
.legend .ramp { display: flex; align-items: center; gap: 6px; }
.legend .rb { width: 130px; height: 10px; border-radius: 3px; }
.maphint { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.maphint span { background: var(--surface); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); }
.crumbs { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.crumbs button { border: 0; background: none; color: var(--accent-ink); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.tip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.14); max-width: 260px; }
.tip b { display: block; margin-bottom: 2px; }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .row .num { margin-left: auto; padding-left: 10px; }

/* ---------- alertas ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--warn); }
.pill.forte::before { background: var(--crit); }
.pill.ok::before { background: var(--good); border-radius: 50%; }
.pill.plain::before { display: none; }
.flags { display: grid; gap: 8px; }
.flag { border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.flag.forte { border-left-color: var(--crit); }
.flag .t { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; font-size: 14px; }
.flag p { margin: 4px 0 0; font-size: 13.5px; color: var(--text-2); }
.flag .ben { font-size: 12.5px; color: var(--muted); }
.flag.hl { outline: 2px solid var(--accent); }
.okbox { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; color: var(--text-2); }
.okbox.good::before { content: "✓ "; color: var(--good); font-weight: 700; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; color: var(--text-2); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.row { cursor: pointer; }
table.list tr.row:hover td { background: var(--surface-2); }
table.list .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tablewrap { overflow-x: auto; }
.more { text-align: center; padding: 10px 0 2px; }

/* ---------- seções ---------- */
.secgrid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 900px) { .secgrid { grid-template-columns: 1fr; } }
.sc { width: 100%; height: 320px; display: block; }
.sc .axis text { fill: var(--text-2); font: 11px "IBM Plex Mono", monospace; }
.sc .axis line, .sc .axis .domain { stroke: var(--line); }
.sc .axl { fill: var(--muted); font-size: 11.5px; }
.sc circle { cursor: pointer; }
.seclist { display: grid; gap: 8px; max-height: 440px; overflow: auto; align-content: start; }

/* ---------- município ---------- */
.mhead { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; margin: 18px 0 4px; }
.mhead .uf { color: var(--muted); font-weight: 500; font-size: 18px; }
.cargos { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .cargos { grid-template-columns: 1fr; } }
.cargos .card { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; color: var(--text-2); font: inherit; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* ---------- metodologia ---------- */
.prose { max-width: 820px; }
.prose p, .prose li { color: var(--text-2); }
.prose h2 { margin: 26px 0 8px; }
.ind { padding: 12px 0; border-top: 1px solid var(--line); }
.ind p { margin: 4px 0; font-size: 14px; }

.foot { color: var(--muted); font-size: 12.5px; padding: 12px 0 32px; }
