:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --border: #e5e7eb;
  --text: #131313;
  --text-2: #424242;
  --muted: #686868;
  --accent: #18a953;          /* verde "eleito" */
  --accent-ink: #0f7a3b;      /* verde para texto sobre fundo claro */
  --accent-soft: #f3ffe6;     /* fundo do candidato selecionado */
  --accent-hl: #ceff98;
  --bar-off: #b1b1b1;         /* barra de quem não foi eleito */
  --bad: #cd2e2b;
  --topo: #131313;            /* faixa do topo */
  --topo-ink: #ffffff;
  /* sequencial verde (mapa: % do candidato na RA) */
  --seq-1: #e3f6e9; --seq-2: #bfe9cc; --seq-3: #8fd8a9; --seq-4: #57c180;
  --seq-5: #18a953; --seq-6: #11803f; --seq-7: #0a5a2c;
  /* categórico (vencedor por RA) */
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-outros: #c9c9c9;
  --sem-dado: #ececec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0e; --surface: #1a1a1a; --surface-2: #232323; --border: #2e2e2e;
    --text: #f5f5f5; --text-2: #d0d0d0; --muted: #9a9a9a;
    --accent: #22c063; --accent-ink: #5ad68c; --accent-soft: #15261b; --accent-hl: #2c4a1c;
    --bar-off: #5a5a5a; --bad: #e66767; --topo: #000000; --topo-ink: #ffffff;
    --seq-1: #0d3a20; --seq-2: #11552c; --seq-3: #137339; --seq-4: #18a953;
    --seq-5: #46c477; --seq-6: #86dca6; --seq-7: #c4f0d3;
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-outros: #4d4d4d;
    --sem-dado: #262626;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0e; --surface: #1a1a1a; --surface-2: #232323; --border: #2e2e2e;
  --text: #f5f5f5; --text-2: #d0d0d0; --muted: #9a9a9a;
  --accent: #22c063; --accent-ink: #5ad68c; --accent-soft: #15261b; --accent-hl: #2c4a1c;
  --bar-off: #5a5a5a; --bad: #e66767; --topo: #000000; --topo-ink: #ffffff;
  --seq-1: #0d3a20; --seq-2: #11552c; --seq-3: #137339; --seq-4: #18a953;
  --seq-5: #46c477; --seq-6: #86dca6; --seq-7: #c4f0d3;
  --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-outros: #4d4d4d;
  --sem-dado: #262626;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- topo */
.topo { background: var(--topo); color: var(--topo-ink); position: sticky; top: 0; z-index: 1000; }
.topo-in, .filtros-in, main { max-width: 1320px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.topo-in { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 8px; }
.marca { display: flex; gap: 12px; align-items: center; }
.selo { background: var(--accent); color: #fff; font-weight: 800; border-radius: 8px; padding: 6px 9px; font-size: 15px; }
.marca strong { display: block; font-size: 17px; font-weight: 700; }
.sub { color: #b9b9b9; font-size: 12px; }
.btn-icone { background: transparent; border: 1px solid #3a3a3a; color: var(--topo-ink); border-radius: 99px; width: 34px; height: 34px; cursor: pointer; }
.abas { display: flex; gap: 2px; max-width: 1320px; margin: 0 auto; padding: 0 12px; overflow-x: auto; }
.abas button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px 9px; cursor: pointer;
  color: #bdbdbd; font-weight: 600; white-space: nowrap;
}
.abas button:hover { color: #fff; }
.abas button.ativa { color: #fff; border-bottom-color: var(--accent); }

/* ---------- filtros (cargo + busca) */
.filtros { background: var(--surface); border-bottom: 1px solid var(--border); }
.filtros-in { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.pilulas { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.pilulas button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 7px 16px; cursor: pointer;
  font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.pilulas button:hover { border-color: var(--text-2); }
.pilulas button[aria-checked="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.busca { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 14px; min-width: 340px; color: var(--muted); }
.busca input { border: 0; background: transparent; padding: 9px 0; width: 100%; outline: none; color: var(--text); }
.busca:focus-within { border-color: var(--accent); }

main { padding-top: 20px; padding-bottom: 48px; }
.aba { display: none; }
.aba.ativa { display: block; }

.btn, .btn-sec { border-radius: 99px; padding: 8px 16px; cursor: pointer; white-space: nowrap; font-weight: 600; }
.btn { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn:hover { filter: brightness(.95); }
.btn-sec { background: var(--surface); border: 1px solid var(--border); }
.btn-sec:hover { border-color: var(--text-2); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- apuração */
.apur-cab { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.apur-sub { margin-top: 6px; display: flex; gap: 10px; align-items: center; color: var(--text-2); flex-wrap: wrap; }
.progresso { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.progresso .trilho { width: 120px; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progresso .trilho span { display: block; height: 100%; background: var(--accent); }
.resumo { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.resumo div { padding: 8px 16px; border-left: 1px solid var(--border); white-space: nowrap; }
.resumo div:first-child { border-left: 0; }
.resumo span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.resumo b { font-size: 16px; }
.resumo small { color: var(--muted); margin-left: 4px; }

.apur-grid { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 20px; align-items: start; }
.lista-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.lista-topo { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.lista { max-height: calc(100vh - 250px); min-height: 560px; overflow-y: auto; }
.cand {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
}
.cand:hover { background: var(--surface-2); }
.cand.sel { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.cand .foto { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--surface-2); grid-row: span 2; border: 2px solid var(--border); }
.cand.eleito .foto { border-color: var(--accent); }
.cand .nome { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand .partido { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.cand .num { text-align: right; }
.cand .num b { font-size: 18px; font-weight: 800; display: block; line-height: 1.1; }
.cand .num span { font-size: 12px; color: var(--muted); }
.cand .barra { grid-column: 2 / 4; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cand .barra span { display: block; height: 100%; background: var(--bar-off); border-radius: 99px; }
.cand.eleito .barra span { background: var(--accent); }
.cand .pos { position: absolute; left: 5px; top: 5px; font-size: 10px; color: var(--muted); }
.selo-st { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.selo-st.eleito { background: var(--accent); color: #fff; }
.selo-st.turno2 { background: var(--accent-hl); color: #131313; }
.selo-st.suplente { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.selo-st.anulado { background: transparent; color: var(--bad); border: 1px solid var(--bad); }

.mapa-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 104px; }
.mapa-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.mapa-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mapa-titulo { font-size: 17px; font-weight: 700; display: flex; gap: 10px; align-items: center; text-transform: none; }
.mapa-titulo img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }
.mapa-titulo .dica { margin-left: 0; }
.mapa-acoes { display: flex; gap: 12px; align-items: center; }
.mapa-dica { color: var(--muted); margin: 4px 0 12px; font-size: 13px; }
.mapa-box { position: relative; border-radius: 10px; overflow: hidden; }
#mapa { height: 520px; background: var(--surface-2); }
.leaflet-container { font: inherit; background: var(--surface-2); }
.legenda {
  position: absolute; left: 12px; bottom: 12px; z-index: 500; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 12px; max-width: 340px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.legenda .escala { display: flex; gap: 2px; margin: 6px 0 2px; }
.legenda .escala span { flex: 1; height: 10px; border-radius: 2px; min-width: 26px; }
.legenda .rotulos { display: flex; justify-content: space-between; color: var(--muted); }
.legenda .item { display: flex; gap: 6px; align-items: center; margin: 3px 0; }
.legenda .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.ra-tabela summary { font-weight: 700; cursor: pointer; }
.ra-tabela .tabela-rolagem { margin-top: 10px; max-height: 360px; }
.chk { display: flex; gap: 6px; align-items: center; color: var(--text-2); cursor: pointer; font-size: 13px; }
.chk input { accent-color: var(--accent); }

/* ---------- comuns */
.painel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.painel-titulo { font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.dica { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.vazio { padding: 48px; text-align: center; color: var(--text-2); background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.tabela-rolagem { max-height: 600px; overflow: auto; }
.tabela-rolagem.curta { max-height: 290px; }
.tabela-rolagem.alta { max-height: none; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; background: var(--surface); z-index: 1; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
td.n, th.n { text-align: right; }
tr.clicavel { cursor: pointer; }
tr.clicavel:hover td { background: var(--surface-2); }
tr.detalhe td { background: var(--surface-2); }
.mini { color: var(--muted); font-size: 11px; white-space: nowrap; }

.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 54px; gap: 8px; align-items: center; padding: 3px 0; font-size: 13px; }
.hbar .trilho { height: 14px; position: relative; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { position: absolute; left: calc(var(--w) + 6px); top: -1px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.hbar .pct { text-align: right; color: var(--text-2); }
.hbar .nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cand-card { display: flex; gap: 20px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 16px; flex-wrap: wrap; }
.cand-card img { width: 104px; height: 138px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.cand-card h2 { margin: 0 0 2px; font-size: 24px; font-weight: 800; }
.cand-card .meta { color: var(--text-2); }
.cand-card .nums { display: flex; gap: 28px; margin-top: 12px; flex-wrap: wrap; }
.cand-card .nums div b { display: block; font-size: 24px; font-weight: 800; }
.cand-card .nums div span { color: var(--muted); font-size: 12px; }
.cand-card .acoes { margin-left: auto; display: flex; flex-direction: column; gap: 8px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); }
.badge.eleito, .badge.entra { background: var(--accent); color: #fff; border-color: var(--accent); }
.badge.nao { color: var(--text-2); }
.badge.sai { color: var(--bad); border-color: var(--bad); }

.pessoa { display: flex; gap: 8px; align-items: center; min-width: 0; }
.pessoa img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.pessoa .t { min-width: 0; }
.pessoa .t b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pessoa .t span { color: var(--muted); font-size: 12px; }
.pessoa.grande img { width: 56px; height: 56px; }
a.link { color: inherit; text-decoration: none; cursor: pointer; }
a.link:hover b { text-decoration: underline; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; }
.tile > span { color: var(--muted); font-size: 11px; display: block; text-transform: uppercase; letter-spacing: .04em; }
.tile b { font-size: 24px; font-weight: 800; }
.tile small { color: var(--text-2); display: block; font-size: 12px; }

.qe-bar { position: relative; height: 8px; background: var(--surface-2); border-radius: 99px; min-width: 120px; }
.qe-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; }
.qe-bar .marca80 { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0; }
.chip-pessoa { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 5px 14px 5px 5px; }

.ajuste { display: grid; grid-template-columns: minmax(0, 1fr) 160px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.ajuste input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.ajuste .rm { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; height: 36px; cursor: pointer; }
.sim-botoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.espaco { flex: 1; }
.resposta { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); }
.delta-pos { color: var(--accent-ink); font-weight: 700; }
.delta-neg { color: var(--bad); font-weight: 700; }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.rel p { color: var(--text-2); min-height: 60px; }
.destaque-rel { border-color: var(--accent); background: var(--accent-soft); }

.tooltip {
  position: fixed; z-index: 2000; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.15); max-width: 280px;
}
.tooltip b { display: block; font-size: 13px; }
.carregando { position: fixed; right: 16px; bottom: 16px; background: var(--text); color: var(--bg); padding: 6px 14px; border-radius: 99px; z-index: 3000; }

@media (max-width: 1050px) {
  .apur-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .mapa-col { position: static; order: -1; }
  .lista { max-height: 640px; min-height: 0; }
  #mapa { height: 420px; }
  .busca { min-width: 0; width: 100%; }
  .resumo { width: 100%; overflow-x: auto; }
}
@media (max-width: 600px) {
  .topo-in, .filtros-in, main { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 22px; }
  .resumo div { padding: 8px 10px; }
}
@media print {
  .topo, .filtros, .mapa-acoes, .sim-botoes, .acoes, .leaflet-control-container, .lista-topo { display: none !important; }
  body { background: #fff; }
  .mapa-col { position: static; }
  .tabela-rolagem, .lista { max-height: none !important; overflow: visible; }
  .painel, .cand-card, .tile, .cand { break-inside: avoid; }
}

/* ---------- tabelas ordenáveis */
table.ordenavel th:not([data-sem-ordem]) { cursor: pointer; user-select: none; white-space: nowrap; }
table.ordenavel th:not([data-sem-ordem]):hover { color: var(--text); }
table.ordenavel th::after { content: ''; display: inline-block; width: 1em; margin-left: 2px; color: var(--accent-ink); }
table.ordenavel th[aria-sort="descending"]::after { content: '▼'; font-size: 9px; }
table.ordenavel th[aria-sort="ascending"]::after { content: '▲'; font-size: 9px; }
table.ordenavel th[aria-sort="descending"], table.ordenavel th[aria-sort="ascending"] { color: var(--text); }

/* barra dentro da célula */
.celbar { position: relative; height: 18px; display: flex; align-items: center; }
.celbar span { height: 12px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; max-width: 78%; }
.celbar em { font-style: normal; font-size: 12px; color: var(--text-2); margin-left: 6px; white-space: nowrap; }

/* ---------- meta por RA */
.meta { margin-top: 14px; }
.meta-cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.meta-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.meta-card.falta { border-left: 5px solid var(--bad); }
.meta-card.sobra { border-left: 5px solid var(--accent); }
.meta-card .rot { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
.meta-card .big { font-size: 30px; font-weight: 800; margin: 10px 0 4px; letter-spacing: -.02em; }
.meta-card .big small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.meta-card p { margin: 6px 0 0; color: var(--text-2); }
.meta-barra { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 99px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.seg button[aria-checked="true"] { background: var(--text); color: var(--surface); }
.duo { position: relative; height: 12px; background: var(--surface-2); border-radius: 99px; min-width: 110px; }
.duo .atual { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar-off); border-radius: 99px; }
.duo .alvo { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: var(--accent); border-radius: 2px; }
@media (max-width: 1050px) { .meta-cards { grid-template-columns: minmax(0, 1fr); } }

/* explicação da última cadeira */
.explica { border-left: 5px solid var(--accent); }
.explica-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.explica p { margin: 0 0 8px; color: var(--text-2); }
.explica ol { margin: 0 0 8px; padding-left: 20px; color: var(--text-2); }
.explica li { margin-bottom: 4px; }
@media (max-width: 800px) { .explica-grid { grid-template-columns: minmax(0, 1fr); } }

/* análise do candidato (simulador) */
.analise-topo { border-left: 5px solid var(--accent); }
.analise-topo input { width: 100%; max-width: 560px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 10px 16px; font-size: 15px; }
.analise-topo input:focus { outline: 2px solid var(--accent); }
.explica-lista { margin: 0; padding-left: 20px; color: var(--text-2); }
.explica-lista li { margin-bottom: 6px; line-height: 1.5; }
.texto-ra { color: var(--text-2); margin: 0 0 12px; line-height: 1.55; }
.meta-card .big.delta-neg, .meta-card .big.delta-pos { font-size: 30px; }

/* legenda do mapa recolhível */
.legenda { padding-right: 30px; }
.leg-toggle { position: absolute; top: 4px; right: 4px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.leg-toggle:hover { background: var(--surface-2); color: var(--text); }
.legenda.recolhida { padding: 6px 10px; }
.legenda.recolhida .leg-corpo { display: none; }
.legenda.recolhida .leg-toggle { position: static; font-size: 12px; font-weight: 600; color: var(--text-2); }
/* quadro ao passar o mouse */
.tt-ra { font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.tt-venc { display: flex; gap: 10px; align-items: center; }
.tt-venc img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }
.tt-venc b { display: block; font-size: 14px; }
.tt-rot { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink); font-weight: 700; }
.tt-seg { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--muted); }

/* guia "como ler esta página" */
.guia { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: 14px; padding: 4px 16px; margin-bottom: 16px; }
.guia summary { cursor: pointer; font-weight: 700; padding: 8px 0; color: var(--accent-ink); list-style: none; }
.guia summary::-webkit-details-marker { display: none; }
.guia summary::before { content: '?'; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; margin-right: 8px; }
.guia summary::after { content: ' ▾'; font-weight: 400; }
.guia:not([open]) summary::after { content: ' ▸'; }
.guia-corpo { color: var(--text-2); padding-bottom: 10px; line-height: 1.55; }
.guia-corpo ul, .guia-corpo ol { margin: 4px 0 8px; padding-left: 20px; }
.guia-corpo li { margin-bottom: 4px; }
.guia-corpo p { margin: 6px 0; }

/* sugestões de candidatos */
.sug-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin: 0 0 16px; }
details.sug-box > summary { cursor: pointer; font-weight: 600; color: var(--text-2); }
details.sug-box[open] > summary { margin-bottom: 8px; }
.sug-grupo { margin-top: 10px; }
.sug-titulo { font-weight: 700; margin-bottom: 8px; }
.sug-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.sug-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 10px; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.sug-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.sug-card.sel { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.sug-card img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; grid-row: span 2; background: var(--surface-2); }
.sug-txt { min-width: 0; }
.sug-txt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-txt span { color: var(--muted); font-size: 12px; }
.sug-tag { justify-self: start; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.sug-tag.falta { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.sug-tag.sobra { background: var(--accent-soft); color: var(--accent-ink); }

/* e se tivesse concorrido por outra legenda */
#outras-leg { margin-top: 16px; }
tr.linha-atual td { background: var(--surface-2); }
details.mais-legendas > summary { cursor: pointer; font-weight: 600; color: var(--text-2); margin: 10px 0 6px; }

/* barra de exportação */
.barra-export { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; margin: -4px 0 14px; }
.barra-export:empty { display: none; }
.exp-rot { color: var(--muted); font-size: 13px; margin-right: 2px; }
.btn-exp { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 13px; }
.btn-exp:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.btn-exp:disabled { opacity: .5; cursor: not-allowed; }

/* modo PDF (página gerada pelo servidor) */
#pdf-cab { border-bottom: 3px solid var(--accent); padding: 0 0 10px; margin-bottom: 16px; }
.pdf-marca { font-size: 22px; font-weight: 800; }
.pdf-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
body.modo-pdf { background: #fff; }
body.modo-pdf .topo, body.modo-pdf .filtros, body.modo-pdf .guia, body.modo-pdf .barra-export, body.modo-pdf .sug-box,
body.modo-pdf #sim-sugestoes, body.modo-pdf .analise-topo, body.modo-pdf .meta-barra .btn-sec, body.modo-pdf .acoes,
body.modo-pdf .mapa-acoes, body.modo-pdf .leg-toggle, body.modo-pdf .leaflet-control-container, body.modo-pdf .lista-box,
body.modo-pdf .mapa-dica, body.modo-pdf #sim-livre, body.modo-pdf .carregando, body.modo-pdf #leg-sim-ne,
body.modo-pdf details.mais-legendas > summary { display: none !important; }
body.modo-pdf main { padding-top: 12px; max-width: none; }
body.modo-pdf .apur-grid { grid-template-columns: minmax(0, 1fr); }
body.modo-pdf .mapa-col { position: static; }
body.modo-pdf .tabela-rolagem, body.modo-pdf .lista { max-height: none !important; overflow: visible !important; }
body.modo-pdf .meta-card, body.modo-pdf .tile, body.modo-pdf .cand-card, body.modo-pdf tr, body.modo-pdf .explica { break-inside: avoid; }
body.modo-pdf .painel { break-inside: auto; }          /* tabelas longas podem continuar na página seguinte */
body.modo-pdf .grid-2 { grid-template-columns: minmax(0, 1fr); }
body.modo-pdf thead { display: table-header-group; }   /* repete o cabeçalho da tabela em cada página */
body.modo-pdf .so-tela { display: none !important; }
body.modo-pdf .mapa-card { break-inside: avoid; }

/* =================================================================== versão mobile */
@media (max-width: 700px) {
  body { font-size: 14px; }
  .topo { position: static; }                         /* topo não fica grudado: libera a tela */
  .topo-in { padding-top: 10px; padding-bottom: 4px; }
  .marca strong { font-size: 15px; }
  .sub { display: none; }
  .abas { padding: 0 8px; }
  .abas button { padding: 9px 10px 8px; font-size: 14px; }
  .filtros { position: sticky; top: 0; z-index: 900; }  /* cargo e busca continuam à mão */
  .filtros-in { padding-top: 8px; padding-bottom: 8px; gap: 8px; }
  .pilulas button { padding: 6px 12px; font-size: 13px; }
  .busca { min-width: 0; width: 100%; }
  main { padding-top: 14px; }
  h1 { font-size: 21px; }
  .apur-cab { margin-bottom: 10px; }
  .resumo { width: 100%; overflow-x: auto; }
  .resumo div { padding: 6px 10px; }
  .resumo b { font-size: 14px; }
  .painel, .mapa-card, .meta-card { padding: 12px; border-radius: 12px; }
  #mapa { height: 360px; }
  .mapa-cab { align-items: flex-start; }
  .mapa-acoes { width: 100%; justify-content: space-between; }
  .legenda { max-width: calc(100% - 24px); font-size: 11px; }
  .lista { max-height: 520px; }
  .cand { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 10px 12px; }
  .cand .foto { width: 44px; height: 44px; }
  .cand .nome { font-size: 14px; }
  .cand .num b { font-size: 16px; }
  /* ficha do candidato */
  .cand-card { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .cand-card img { width: 84px; height: 112px; }
  .cand-card h2 { font-size: 19px; }
  .cand-card .nums { gap: 14px; }
  .cand-card .nums div b { font-size: 18px; }
  .cand-card .acoes { grid-column: 1 / -1; margin-left: 0; flex-direction: row; flex-wrap: wrap; }
  .cand-card .acoes button { flex: 1 1 140px; }
  .hbar { grid-template-columns: 110px minmax(0, 1fr) 48px; }
  /* análise e cartões */
  .meta-cards { grid-template-columns: minmax(0, 1fr); }
  .meta-card .big { font-size: 26px; }
  .meta-barra { gap: 8px; }
  .seg { display: grid; grid-template-columns: 1fr; width: 100%; border-radius: 12px; }
  .seg button { border-radius: 0; padding: 9px; }
  .meta-barra .btn-sec { flex: 1 1 auto; }
  .sug-cards { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile b { font-size: 19px; }
  .explica-grid { grid-template-columns: minmax(0, 1fr); }
  .barra-export { justify-content: flex-start; }
  .exp-rot { width: 100%; }
  .analise-topo input { font-size: 16px; }             /* 16px evita o zoom automático do iPhone */
  .busca input { font-size: 16px; }
  /* tabelas: só as colunas essenciais no celular (o Excel/CSV traz todas) */
  th, td { padding: 7px 5px; }
  #meta-tabela th:nth-child(2), #meta-tabela td:nth-child(2),
  #meta-tabela th:nth-child(5), #meta-tabela td:nth-child(5),
  #meta-tabela th:nth-child(7), #meta-tabela td:nth-child(7),
  #meta-tabela th:nth-child(9), #meta-tabela td:nth-child(9) { display: none; }
  #outras-leg th:nth-child(3), #outras-leg td:nth-child(3),
  #outras-leg th:nth-child(5), #outras-leg td:nth-child(5),
  #outras-leg th:nth-child(6), #outras-leg td:nth-child(6) { display: none; }
  #cand-ras th:nth-child(4), #cand-ras td:nth-child(4) { display: none; }
  #leg-tabela table { min-width: 900px; }               /* tabela de legendas: rola para o lado */
  #leg-tabela { overflow-x: auto; }
  .tooltip { max-width: 240px; }
}
