:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --surface-glass: rgba(252, 252, 251, 0.92);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 28px rgba(0, 0, 0, .10);
  --hover: rgba(11, 11, 11, 0.05);
  --sel: rgba(42, 120, 214, 0.10);
  --panel-w: 420px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-glass: rgba(26, 26, 25, 0.92);
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .45);
    --hover: rgba(255, 255, 255, 0.06);
    --sel: rgba(57, 135, 229, 0.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-glass: rgba(26, 26, 25, 0.92);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --line: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .45);
  --hover: rgba(255, 255, 255, 0.06);
  --sel: rgba(57, 135, 229, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
/* --esp = espaço reservado à direita para o painel (some quando o painel é escondido); --gap = margem das bordas */
body { --aberto: 1; --gap: 12px; --esp: calc((var(--panel-w) + var(--gap)) * var(--aberto) + var(--gap)); }
body.sem-painel { --aberto: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.search input:focus-visible { outline: 0; }
body { overflow: hidden; font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.maplibregl-ctrl-attrib { font-size: 10px; background: var(--surface-glass) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }

/* barra de progresso */
#progress { position: absolute; top: 0; left: 0; height: 3px; width: 0; background: var(--ink); z-index: 30; opacity: 0; transition: width .4s var(--ease), opacity .3s; }
#progress.on { opacity: 1; }

/* topo */
#topbar { position: absolute; top: var(--gap); left: var(--gap); right: calc(var(--esp) + 50px); display: flex; gap: 10px; align-items: stretch; z-index: 10; pointer-events: none; }
#topbar > * { pointer-events: auto; }
#topbar:focus-within { z-index: 30; }   /* resultados da busca por cima da barra de modos e dos botões */
.brand { background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; white-space: nowrap; }
.brand-kicker { font-size: 11px; color: var(--ink-2); letter-spacing: .02em; }
.brand-title { font-weight: 650; font-size: 15px; }
.search { position: relative; flex: 1; max-width: 420px; min-width: 0; display: flex; align-items: center; background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 0 12px; }
.search .ico { color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 12px 8px; font-size: 14px; }
.search:focus-within { border-color: var(--axis); }
#busca-res { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; animation: pop .18s var(--ease); }
#busca-res li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
#busca-res li .k { font-size: 11px; color: var(--muted); white-space: nowrap; }
#busca-res li .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#busca-res li .t small { color: var(--ink-2); }
#busca-res li[aria-selected="true"], #busca-res li:hover { background: var(--hover); }

/* modos */
#modes { position: absolute; top: calc(var(--gap) + 60px); left: var(--gap); z-index: 10; display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; padding: 3px; background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow); max-width: calc(100vw - var(--esp) - 62px); }
#modes::-webkit-scrollbar { display: none; }
#modes button { flex: none; white-space: nowrap; border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-size: 13px; transition: background .2s, color .2s; }
#modes button:hover { background: var(--hover); color: var(--ink); }
#modes button.on { background: var(--ink); color: var(--surface); }
.mode-cand { display: inline-flex; align-items: center; gap: 0; }
.mode-cand select { border: 0; background: transparent; font-size: 13px; color: var(--ink-2); padding: 6px 2px; cursor: pointer; max-width: 150px; }
.mode-cand select option { background: var(--surface); color: var(--ink); }

/* legenda */
#cantos { position: absolute; left: var(--gap); bottom: 26px; z-index: 10; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: calc(100vw - var(--esp) - 70px); pointer-events: none; }
#cantos > * { pointer-events: auto; max-width: 100%; }
/* zoom e créditos do mapa ficam à esquerda do painel */
.maplibregl-ctrl-bottom-right { right: calc(var(--esp) - 10px); transition: right .35s var(--ease); }
#legend { background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 12px; color: var(--ink-2); max-width: 340px; }
#legend { cursor: pointer; }
#legend .lg-t { font-weight: 600; color: var(--ink); margin-bottom: 6px; font-size: 12px; display: flex; justify-content: space-between; gap: 10px; }
#legend .lg-tg::after { content: "–"; color: var(--muted); font-weight: 400; }
#legend.min .lg-tg::after { content: "+"; }
#legend.min > :not(.lg-t) { display: none !important; }
#legend.min .lg-t { margin: 0; }
.lg-curto { display: none; }
#legend .lg-row { display: grid; grid-template-columns: 98px 1fr; align-items: center; gap: 8px; margin: 3px 0; }
#legend .lg-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#legend .sw { display: flex; gap: 2px; }
#legend .sw i { display: block; height: 12px; flex: 1; min-width: 18px; border-radius: 3px; }
#legend .ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
#legend .ticks.offset { padding-left: 106px; }
#legend .lg-note { margin-top: 6px; font-size: 11px; color: var(--muted); }
#legend .lg-nodata { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; color: var(--muted); }
#legend .lg-nodata i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }

/* ferramentas */
#tools { position: absolute; right: var(--esp); top: var(--gap); z-index: 10; display: flex; flex-direction: column; gap: 6px; transition: right .35s var(--ease); }
#tools button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-glass); backdrop-filter: blur(8px); box-shadow: var(--shadow); cursor: pointer; font-weight: 700; font-size: 12px; transition: transform .15s var(--ease), background .2s; }
#tools button:hover { transform: translateY(-1px); }
#tools button:active { transform: scale(.94); }
#tools button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* painel */
#panel { position: absolute; top: var(--gap); right: var(--gap); bottom: var(--gap); width: var(--panel-w); z-index: 20; transition: transform .35s var(--ease), opacity .35s; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
#panel-handle { display: none; }
body.sem-painel #panel { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
#bt-painel[aria-pressed="true"] svg path { opacity: .35; }
#panel-inner { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.pv { animation: slidein .45s var(--ease); }
@keyframes slidein { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); padding: 14px 16px 2px; }
/* só a linha do título fica presa no topo; ganha sombra quando o conteúdo rola */
.ph { padding: 6px 18px 4px; position: sticky; top: 0; background: var(--surface); z-index: 2; transition: box-shadow .2s; }
.rolado .ph { box-shadow: 0 1px 0 var(--line), 0 8px 14px -10px rgba(0, 0, 0, .25); }
.ph-sub { color: var(--ink-2); font-size: 12.5px; padding: 0 18px 12px; border-bottom: 1px solid var(--line); }
.ph-sub.com-volta { padding-left: 60px; }
.ph-sub .warn { color: var(--ink); background: var(--surface-2); border-radius: 5px; padding: 1px 6px; margin-left: 4px; font-size: 11px; }
.ph-t { min-width: 0; flex: 1; }
.crumbs button { border: 0; background: none; padding: 2px 4px; border-radius: 5px; cursor: pointer; color: var(--ink-2); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs button:hover { background: var(--hover); color: var(--ink); }
.crumbs .sep { color: var(--axis); }
.crumbs .cur { color: var(--ink); font-weight: 600; padding: 2px 4px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-row { display: flex; gap: 10px; align-items: flex-start; }
.back { flex: none; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: grid; place-items: center; margin-top: 2px; transition: transform .15s var(--ease), background .2s; }
.back:hover { background: var(--hover); transform: translateX(-2px); }
.ph-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.ph h1 { margin: 2px 0 2px; font-size: 21px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }

.sec { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sec-t { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.sec-t span { text-transform: none; letter-spacing: 0; font-weight: 400; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; min-width: 0; }
.tile .l { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v { font-size: 17px; font-weight: 650; margin-top: 1px; white-space: nowrap; }
.tile .s { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* resultado (barras) */
.res { display: flex; flex-direction: column; gap: 9px; }
.cr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; animation: fadeup .4s var(--ease) both; }
.cr .nm { font-weight: 600; font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr .nm small { font-weight: 400; color: var(--muted); margin-left: 4px; font-size: 11.5px; }
.cr .pc { font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.cr .bar { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; position: relative; }
.cr .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; transition: width .9s var(--ease); }
.cr .vt { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: -1px; }
.cr.minor .nm { font-weight: 500; color: var(--ink-2); }
.cr.minor .pc { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.cr.minor .bar { height: 5px; }
.more { margin-top: 4px; border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 4px 0; font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; }
.bn-line { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* lista */
.ltools { display: flex; gap: 6px; margin-bottom: 8px; }
.ltools input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); outline: 0; font-size: 13px; }
.ltools input:focus { border-color: var(--axis); }
.ltools select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 9px; margin-bottom: 10px; }
.tabs button { flex: 1; border: 0; background: none; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 8px 8px; margin: 0 -8px; border-radius: 9px; cursor: pointer; transition: background .15s; align-items: center; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--sel); }
.row .rn { font-size: 13px; font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .rn small { font-weight: 400; color: var(--muted); }
.row .rv { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row .rv b { font-weight: 650; color: var(--ink); }
.row .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.stack { grid-column: 1 / -1; display: flex; height: 6px; gap: 2px; border-radius: 3px; overflow: hidden; }
.stack i { display: block; height: 100%; border-radius: 3px; transform-origin: left; animation: grow .7s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.row .meta { grid-column: 1 / -1; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.load-more { width: 100%; margin-top: 6px; padding: 8px; border-radius: 8px; border: 1px dashed var(--axis); background: none; cursor: pointer; color: var(--ink-2); font-size: 12.5px; }

/* abas com a quantidade embaixo */
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.25; min-width: 0; }
.tabs button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabs button small { font-size: 10.5px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* tabela "aqui × referências" */
.cmp-n { table-layout: fixed; font-size: 12px; }
.cmp-n th { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-n th:first-child, .cmp-n td:first-child { width: 34%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-n td { white-space: nowrap; }
.cmp-n .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* posição entre os do mesmo nível */
.pos { display: flex; flex-direction: column; gap: 2px; }
.pos-r { display: grid; grid-template-columns: minmax(0, 1fr) auto 86px; gap: 2px 10px; align-items: baseline; padding: 5px 8px; margin: 0 -8px; border-radius: 8px; font-size: 12.5px; }
.pos-r:hover { background: var(--hover); }
.pos-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.pos-r b { font-variant-numeric: tabular-nums; font-weight: 650; }
.pos-k { font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-bar { grid-column: 1 / -1; position: relative; height: 10px; margin-top: 3px; }
.pos-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 4px; border-radius: 2px; background: var(--surface-2); }
.pos-med { position: absolute; left: 50%; top: 1px; width: 1px; height: 8px; background: var(--axis); }
.pos-pt { position: absolute; top: 0; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }

/* seções, urnas e boletins */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 12px; }
.chips-t { color: var(--muted); margin-right: 2px; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 3px 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip b { font-weight: 650; }
.chip small { color: var(--muted); }
.hist svg { width: 100%; height: 96px; display: block; overflow: visible; }
.hist .eixo { stroke: var(--axis); stroke-width: 1; }
.hist text { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.hist .hb-alvo { fill: transparent; }
.hist g:hover rect:not(.hb-alvo) { filter: brightness(1.15); }
.hist g:hover .hb-alvo { fill: var(--hover); }

/* ficha da seção */
.secnav span small { display: block; font-size: 10.5px; }
.secnav span b { color: var(--ink); font-weight: 650; }
.secnav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.nav-sec { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .15s, transform .15s var(--ease); }
.nav-sec:first-child { justify-self: start; }
.nav-sec:last-child { justify-self: end; }
.nav-sec small { font-weight: 400; color: var(--muted); }
.nav-sec:hover:not(:disabled) { background: var(--hover); }
.nav-sec[data-nav="ant"]:hover:not(:disabled) { transform: translateX(-2px); }
.nav-sec[data-nav="prox"]:hover:not(:disabled) { transform: translateX(2px); }
.nav-sec:disabled { opacity: .4; cursor: default; }
.ficha { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 0; margin: 0; font-size: 12.5px; }
.ficha dt { color: var(--muted); padding: 6px 10px 6px 0; border-top: 1px solid var(--line); }
.ficha dd { margin: 0; padding: 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ficha dt:first-of-type, .ficha dd:first-of-type { border-top: 0; }
.ficha a { color: var(--ink-2); }

/* dica flutuante do painel */
#ptip { position: fixed; z-index: 45; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 6px 9px; font-size: 11.5px; max-width: 300px; opacity: 0; transition: opacity .1s; font-variant-numeric: tabular-nums; }
#ptip.on { opacity: 1; }

.foot { padding: 14px 18px 22px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.foot a { color: var(--ink-2); }

/* tooltip */
#tooltip { position: absolute; z-index: 40; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 9px 11px; font-size: 12px; min-width: 190px; max-width: 280px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
#tooltip.on { opacity: 1; transform: none; }
#tooltip .tt-n { font-weight: 650; font-size: 13px; margin-bottom: 1px; }
#tooltip .tt-s { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
#tooltip .tt-r { display: grid; grid-template-columns: 10px 1fr auto; gap: 6px; align-items: center; margin: 2px 0; font-variant-numeric: tabular-nums; }
#tooltip .tt-r i { width: 8px; height: 8px; border-radius: 50%; }
#tooltip .tt-r b { font-weight: 650; }
#tooltip .tt-f { color: var(--muted); font-size: 11px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 5px; }

/* animações no mapa */
.ripple { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid var(--ink); pointer-events: none; z-index: 15; animation: ripple .7s var(--ease) forwards; }
@keyframes ripple { from { transform: scale(.4); opacity: .9; } to { transform: scale(5); opacity: 0; } }
.pulse { width: 22px; height: 22px; position: relative; pointer-events: none; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2.5px solid var(--ink); }
.pulse::after { animation: pulse 1.8s ease-out infinite; }
.pulse::before { background: transparent; box-shadow: 0 0 0 2px var(--surface); }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.2); opacity: 0; } }

#boot { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: var(--bg); z-index: 50; color: var(--ink-2); transition: opacity .6s; }
#boot.off { opacity: 0; pointer-events: none; }
.boot-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); animation: pulse 1.2s ease-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* turnos (1º · 2º ao vivo · comparar) */
#turnos { display: flex; gap: 2px; padding: 3px; background: var(--surface-glass); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); align-items: center; }
#turnos button { border: 0; background: transparent; padding: 7px 11px; border-radius: 9px; cursor: pointer; color: var(--ink-2); font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; transition: background .2s, color .2s; }
#turnos button:hover { background: var(--hover); color: var(--ink); }
#turnos button.on { background: var(--ink); color: var(--surface); }
.aovivo { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.aovivo.on { background: #d03b3b; box-shadow: 0 0 0 0 rgba(208, 59, 59, .6); animation: vivo 1.6s ease-out infinite; }
@keyframes vivo { 0% { box-shadow: 0 0 0 0 rgba(208, 59, 59, .55); } 100% { box-shadow: 0 0 0 7px rgba(208, 59, 59, 0); } }

/* bloco ao vivo no painel */
.live { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.live-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.live-top b { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink); }
.badge.vivo .aovivo { background: #d03b3b; }
.prog { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 4px; transition: width 1s var(--ease); }
.proj { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.proj b { color: var(--ink); }
.evo { margin-top: 10px; }
.evo svg { width: 100%; height: 110px; display: block; overflow: visible; }
.evo .eixo { stroke: var(--line); stroke-width: 1; }
.evo text { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.evo .lin { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 54px 1fr; gap: 8px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; font-size: 12.5px; cursor: pointer; animation: fadeup .4s var(--ease) both; }
.feed li:hover { background: var(--hover); }
.feed li time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; padding-top: 1px; }
.feed li.virada, .feed li.fim { font-weight: 600; }
.aguarda { font-size: 13px; color: var(--ink-2); padding: 4px 0; }

/* comparação 1º × 2º turno */
.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cmp th { text-align: right; font-weight: 600; color: var(--muted); font-size: 11px; padding: 0 0 6px; }
.cmp th:first-child { text-align: left; }
.cmp td { padding: 5px 0; border-top: 1px solid var(--line); text-align: right; }
.cmp td:first-child { text-align: left; font-weight: 550; }
.cmp .up { color: var(--ink); font-weight: 650; }
.cmp-nota { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* acompanhar (estrela) */
.star { border: 1px solid var(--border); background: var(--surface); color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1; flex: none; transition: transform .15s var(--ease), color .2s; }
.star:hover { transform: scale(1.08); color: var(--ink); }
.star.on { color: #c98500; border-color: #c98500; }
.row .star { width: 24px; height: 24px; font-size: 12px; border-radius: 6px; margin-left: 6px; }
.ph-row .star { margin-top: 2px; margin-left: auto; }

/* avisos */
#toasts { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; cursor: pointer; background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; max-width: min(520px, calc(100vw - 32px)); animation: pop .3s var(--ease); }
.toast small { display: block; opacity: .75; font-size: 11px; margin-bottom: 2px; }
[data-turno="cmp"]:not([data-sem2]) #modes { opacity: .45; pointer-events: none; }
#legend .lg-aviso { color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 6px; }
.aviso-cmp b { color: var(--ink); }

/* modo "% apurado" só no 2º turno */
[data-turno="1"] .so-vivo, [data-sem2] .so-vivo { display: none; }

/* termômetro e ponto de equilíbrio */
.termos { display: flex; flex-direction: column; gap: 10px; }
.termo-t { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; font-weight: 600; }
.termo-t b { font-size: 16px; font-variant-numeric: tabular-nums; }
.termo-trilho { position: relative; height: 16px; border-radius: 8px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.termo-trilho .faixa { position: absolute; top: 0; bottom: 0; opacity: .2; }
.termo-trilho .fill { position: absolute; left: 0; top: 4px; bottom: 4px; width: 0; border-radius: 4px; transition: width 1s var(--ease); }
.termo-trilho .meio { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
.termo-trilho .pj { position: absolute; top: 1px; bottom: 1px; width: 3px; margin-left: -1.5px; background: var(--ink); opacity: .5; border-radius: 2px; }
.termo-s { font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.equil { margin-top: 10px; font-size: 12.5px; line-height: 1.5; background: var(--surface-2); border-radius: 10px; padding: 9px 11px; }

/* momento a momento */
.evo { position: relative; }
.evo .banda { opacity: .14; }
.evo .cursor { stroke: var(--ink); stroke-width: 1; opacity: 0; }
.evo .cur-f, .evo .cur-l { opacity: 0; stroke: var(--surface); stroke-width: 2; }
.evo-tip { position: absolute; top: 22px; left: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 6px 9px; font-size: 11.5px; line-height: 1.45; opacity: 0; transition: opacity .1s; white-space: nowrap; z-index: 3; font-variant-numeric: tabular-nums; }
.evo-tip.on { opacity: 1; }

/* o que falta apurar */
.falta-nota { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; line-height: 1.45; }
.falta-row { display: grid; grid-template-columns: 1fr 120px; gap: 3px 10px; align-items: center; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; font-size: 12.5px; }
.falta-row:hover { background: var(--hover); }
.falta-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.falta-row small { color: var(--muted); font-weight: 400; }
.falta-row .net-v { text-align: right; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.falta-row .fp { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mini-prog { flex: 1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; max-width: 140px; }
.mini-prog i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.net { position: relative; height: 10px; }
.net i { position: absolute; top: 1px; bottom: 1px; border-radius: 3px; }
.net .eixo { left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); border-radius: 0; }

/* para quem foram os votos */
.tr-leg { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--ink-2); margin: 2px 0 6px; }
.tr-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.transf-row { margin: 7px 0; }
.tr-n { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.tr-n small { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tr-bar { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.tr-bar i { display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-style: normal; color: #fff; font-weight: 650; min-width: 0; overflow: hidden; font-variant-numeric: tabular-nums; }
.contrib { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto; gap: 5px 8px; font-size: 12px; align-items: center; }
.contrib > span:first-child, .contrib > span:nth-child(3n+1) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-trilho { display: block; height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.cb { display: block; height: 100%; border-radius: 4px; }
.cv { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
#app:has(#panel[data-folha="max"]) #cantos { display: none; }

/* cartão de comparação lado a lado (modo Comparar) */
#cmpcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); font-size: 12px; max-width: 640px; animation: pop .25s var(--ease); }
#cmpcard[hidden] { display: none; }
#cmpcard.vazio { padding: 10px 12px; max-width: 340px; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; }
#cmpcard.vazio b { color: var(--ink); }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 12px 8px; }
.cc-top b { font-size: 13px; }
.cc-top small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.cc-acoes { display: flex; gap: 4px; flex: none; }
.cc-acoes button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 7px; padding: 3px 9px; cursor: pointer; font-size: 12px; min-width: 28px; }
.cc-acoes button:hover { background: var(--hover); }
#cmpcard.min .cc-corpo { display: none; }
.cc-corpo { max-height: 42vh; overflow: auto; padding: 0 6px 8px; overscroll-behavior: contain; scrollbar-width: thin; }
#cmpcard table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
#cmpcard th { position: sticky; top: 0; background: var(--surface); z-index: 1; padding: 0; text-align: right; }
#cmpcard th:first-child { text-align: left; }
#cmpcard th button { border: 0; background: none; cursor: pointer; font-size: 10.5px; font-weight: 600; color: var(--muted); padding: 4px 6px 6px; white-space: nowrap; }
#cmpcard th button:hover { color: var(--ink); }
#cmpcard td { padding: 5px 6px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; vertical-align: middle; }
#cmpcard td b { font-weight: 650; }
#cmpcard td small { display: block; font-size: 10.5px; color: var(--muted); }
#cmpcard td.nd { color: var(--muted); }
#cmpcard tbody tr { transition: background .15s; }
#cmpcard tbody tr:hover { background: var(--hover); }
#cmpcard tr.novo { animation: fadeup .4s var(--ease); }
#cmpcard tr.novo td { animation: realce 1.8s ease; }
@keyframes realce { from { background: var(--sel); } to { background: transparent; } }
#cmpcard tr.cc-soma td { border-top: 2px solid var(--axis); font-weight: 600; }
.cc-n { text-align: left !important; max-width: 150px; }
.cc-n button, .cc-n > span { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; font-size: 12.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; text-align: left; }
.cc-n button:hover { text-decoration: underline; text-underline-offset: 2px; }
.cc-d { width: 96px; min-width: 80px; }
.cc-d .stack { height: 8px; }
#cmpcard .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.cc-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; border-radius: 5px; }
.cc-x:hover { color: var(--ink); background: var(--hover); }
.cc-nota { font-size: 10.5px; color: var(--muted); padding: 6px 6px 0; white-space: normal; }
/* faixa da disputa: anel = 1º turno, ponto = 2º turno, traço = 50% */
.hl { position: relative; display: block; height: 14px; }
.hl::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 2px; border-radius: 1px; background: var(--surface-2); }
.hl-meio { position: absolute; left: 50%; top: 1px; width: 1px; height: 12px; background: var(--axis); }
.hl-seg { position: absolute; top: 6px; height: 2px; background: var(--ink-2); }
.hl-a, .hl-b { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; }
.hl-a { border: 2px solid; background: var(--surface); }
.hl-b { box-shadow: 0 0 0 2px var(--surface); }
/* botão "+ Comparar" no cabeçalho do painel */
.cmp-add { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 0 10px; height: 30px; margin-top: 2px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; transition: background .15s; }
.cmp-add:hover { background: var(--hover); }
.cmp-add.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ================================================================== tamanhos de tela
   computador ≥ 1280 px: painel 420 (440 em telas grandes) · 901–1279: painel 360, sem a marca
   COMPACTA (pouca altura, ex.: celular deitado): painel estreito ao lado, tudo mais junto
   FOLHA (celular e tablet em pé): painel embaixo que se arrasta, topo numa linha só (a busca vira uma lupa)
   As mesmas condições estão em app.js (FOLHA, COMPACTA). */
@media (min-width: 1600px) { :root { --panel-w: 440px; } }
@media (max-width: 1279px) {
  :root { --panel-w: 360px; }
  .brand { display: none; }
  #modes button { padding: 6px 9px; }
}

@media (max-height: 520px) and (min-width: 561px) {
  :root { --panel-w: clamp(270px, 40vw, 340px); }
  body { --gap: 8px; }
  .brand { display: none; }
  #topbar { gap: 6px; right: calc(var(--esp) + 44px); }
  #turnos { padding: 2px; }
  #turnos button { padding: 6px 9px; font-size: 12.5px; }
  .search input { padding: 8px 6px; font-size: 13px; }
  #modes { top: calc(var(--gap) + 44px); max-width: calc(100vw - var(--esp) - 52px); }
  #modes button { padding: 5px 8px; font-size: 12px; }
  .mode-cand select { font-size: 12px; max-width: 110px; }
  #tools { gap: 4px; }
  #tools button { width: 34px; height: 34px; border-radius: 9px; }
  #cantos { bottom: var(--gap); max-width: calc(100vw - var(--esp) - 56px); }
  #legend { padding: 7px 10px; }
  #cmpcard .cc-corpo { max-height: 46vh; }
  .crumbs { padding: 10px 12px 0; }
  .ph { padding: 4px 14px 4px; }
  .ph-sub { padding: 0 14px 8px; }
  .ph-sub.com-volta { padding-left: 56px; }
  .ph h1 { font-size: 17px; }
  .sec, .live { padding: 10px 14px; }
  .tiles { gap: 6px; }
  .tile { padding: 7px 8px; }
  .tile .v { font-size: 15px; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }
}

@media (max-width: 900px) and (min-height: 521px), (max-width: 560px) {
  :root { --panel-w: 0px; }
  body { --gap: 12px; --esp: 12px; --topo: max(10px, env(safe-area-inset-top)); }
  .brand { display: none; }
  #topbar { top: var(--topo); left: 12px; right: 12px; flex-direction: row; gap: 8px; }
  #turnos { flex: 1; min-width: 0; padding: 3px; }
  #turnos button { flex: 1; justify-content: center; padding: 8px 4px; font-size: 13px; min-width: 0; }
  /* busca recolhida numa lupa; ao tocar, o campo abre por cima dos turnos */
  .search { flex: none; width: 44px; max-width: none; padding: 0; justify-content: center; cursor: pointer; }
  .search input { position: absolute; width: 1px; opacity: 0; pointer-events: none; padding: 0; }
  .search:focus-within { position: absolute; inset: 0; width: auto; padding: 0 12px; justify-content: flex-start; z-index: 3; cursor: auto; }
  .search:focus-within input { position: static; width: auto; opacity: 1; pointer-events: auto; padding: 11px 8px; font-size: 16px; }
  #modes { top: calc(var(--topo) + 50px); left: 12px; right: 12px; max-width: none; }
  #modes button { padding: 7px 11px; }
  /* botões 3D, tema e início embaixo à direita, perto do polegar; os créditos do mapa ficam acima deles */
  #tools { right: 12px; top: auto; bottom: calc(var(--sheet-h, 45dvh) + 10px); gap: 6px; }
  #tools button { width: 40px; height: 40px; }
  #tools #bt-painel { display: none; }
  .maplibregl-ctrl-bottom-right { right: 0; }
  #cantos { left: 12px; right: 12px; bottom: calc(var(--sheet-h, 45dvh) + 10px); max-width: none; z-index: 11; }
  #legend { max-width: calc(100vw - 24px); padding: 8px 10px; }
  #legend.min .lg-longo { display: none; }
  #legend.min .lg-curto { display: inline; }
  #legend.min { padding: 7px 12px; }
  #legend .lg-row { grid-template-columns: 78px 1fr; }
  #legend .ticks.offset { padding-left: 86px; }
  /* o cartão de comparação vai para o topo do painel de baixo (o mapa fica livre para tocar nos estados) */
  #panel > #cmpcard { flex: none; max-width: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; animation: none; font-size: 11.5px; }
  #panel > #cmpcard.vazio { padding: 2px 16px 10px; }
  #panel > #cmpcard .cc-corpo { max-height: 24dvh; }
  .cc-top { padding: 8px 10px 6px; }
  .cc-n, .cc-n button, .cc-n > span { max-width: 104px; }
  /* painel embaixo: arrasta pela alça e encaixa em três alturas (só o título, meia tela, quase cheia) */
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h, 45dvh); border-radius: 18px 18px 0 0; border-bottom: 0; transition: height .32s var(--ease); }
  #panel.arrastando { transition: none; }
  #panel-handle { display: block; flex: none; height: 26px; border: 0; background: none; cursor: grab; position: relative; touch-action: none; }
  #panel-handle:active { cursor: grabbing; }
  #panel-handle::after { content: ""; position: absolute; left: 50%; top: 9px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--axis); }
  #panel-inner { padding-bottom: env(safe-area-inset-bottom); }
  /* cabeçalho enxuto: caminho numa linha que rola de lado, descrição em até 2 linhas */
  .crumbs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 12px 2px; font-size: 12.5px; }
  .crumbs::-webkit-scrollbar { display: none; }
  .crumbs button, .crumbs .cur { flex: none; max-width: 190px; }
  .ph { padding: 4px 16px 4px; }
  .ph h1 { font-size: 19px; margin: 0; }
  .ph-kind { font-size: 10.5px; }
  .back { width: 34px; height: 34px; }
  .ph-sub { padding: 0 16px 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .ph-sub.com-volta { padding-left: 60px; }
  .pv { animation: subir .3s var(--ease); }
  /* campos com 16 px: o iPhone não dá zoom na página ao tocar neles */
  .ltools input { font-size: 16px; }
  #panel, #topbar, #modes, #tools, #cantos { touch-action: manipulation; }
  .row .meta { font-size: 11.5px; }
  .sec, .live { padding: 12px 16px; }
  .tiles { gap: 6px; }
  .tile { padding: 8px 9px; }
  .tile .l { font-size: 10.5px; }
  .tile .v { font-size: 16px; }
  .maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-h, 45dvh) + 136px); }
  #cantos { right: 62px; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }
  #toasts { bottom: calc(var(--sheet-h, 45dvh) + 12px); }
}

/* dedo: alvos de toque maiores */
@media (pointer: coarse) {
  .row .star { width: 32px; height: 32px; font-size: 14px; }
  .crumbs button { padding: 5px 6px; }
  .tabs button { padding: 8px 6px; }
  .nav-sec { padding: 9px 12px; }
  .cc-x { font-size: 20px; padding: 2px 6px; }
  .more, .load-more { padding: 10px 0; }
}
@keyframes subir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
