:root {
  --fundo: #f4f5f7;
  --painel: #ffffff;
  --texto: #14171f;
  --suave: #5f6673;
  --linha: #e3e6eb;
  --vazio: #d9dde3;
  --acento: #e11d48;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0e1117;
    --painel: #171b23;
    --texto: #eef0f4;
    --suave: #9aa3b2;
    --linha: #272d38;
    --vazio: #2b313c;
    --sombra: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }

.topo {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 16px 24px; background: var(--painel); border-bottom: 1px solid var(--linha);
  position: sticky; top: 0; z-index: 10;
}
.marca { display: flex; align-items: center; gap: 14px; }
h1 { font-size: 1.15rem; margin: 0; font-weight: 700; }
h2 { font-size: 1rem; margin: 0; font-weight: 700; }
.ao-vivo {
  display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 800; letter-spacing: .06em;
  color: #fff; background: var(--acento); padding: 4px 9px; border-radius: 999px;
}
.ao-vivo.offline { background: var(--suave); }
.ponto { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulsar 1.4s infinite; }
.ao-vivo.offline .ponto { animation: none; }
@keyframes pulsar { 50% { opacity: .25; } }
.status { display: flex; gap: 24px; }
.status div { display: flex; flex-direction: column; }
.rotulo { font-size: .72rem; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 8px; display: flex; flex-direction: column; gap: 16px; }
.painel { background: var(--painel); border: 1px solid var(--linha); border-radius: 14px; padding: 20px; box-shadow: var(--sombra); }
.cabecalho-painel { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.dica { font-size: .8rem; color: var(--suave); }

.apuracao-linha { display: flex; justify-content: space-between; font-size: .9rem; color: var(--suave); }
.apuracao-linha strong { color: var(--texto); font-size: 1rem; }
.barra-progresso { height: 6px; background: var(--vazio); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.barra-progresso div { height: 100%; width: 0; background: var(--texto); transition: width .8s ease; }
.selo[hidden], .tooltip[hidden] { display: none; }
.selo { display: inline-block; margin-top: 8px; font-size: .8rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #16a34a; color: #fff; }

.duelo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0 14px; }
.cand { display: flex; align-items: center; gap: 16px; }
.cand.direita { flex-direction: row-reverse; text-align: right; }
.foto {
  width: 92px; height: 92px; border-radius: 50%; object-fit: cover; flex: none;
  border: 4px solid var(--cor); background: var(--vazio);
}
.cand .nome { font-size: 1.25rem; font-weight: 800; display: flex; gap: 8px; align-items: center; }
.cand.direita .nome { justify-content: flex-end; }
.cand .meta { font-size: .82rem; color: var(--suave); }
.cand .pct { font-size: 2.6rem; font-weight: 800; line-height: 1.05; color: var(--cor); }
.cand .votos { font-size: .9rem; color: var(--suave); }
.eleito { font-size: .7rem; background: #16a34a; color: #fff; padding: 2px 8px; border-radius: 999px; letter-spacing: .04em; }
.barra-duelo { position: relative; display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: var(--vazio); }
.barra-duelo .seg { height: 100%; transition: width .8s ease; }
.barra-duelo .meio { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; background: var(--texto); opacity: .6; z-index: 1; }

.grade { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.mapa svg { width: 100%; height: auto; display: block; }
.mapa path { stroke: var(--painel); stroke-width: 1; cursor: pointer; transition: fill .6s ease, opacity .2s; }
.mapa path:hover, .mapa path.ativo { stroke: var(--texto); stroke-width: 2; }
.mapa text { font-size: 10px; font-weight: 700; fill: #fff; pointer-events: none; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.35); stroke-width: 2px; }
.legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--suave); margin-top: 8px; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.detalhe h3 { margin: 0 0 4px; font-size: 1.1rem; }
.detalhe .sub { color: var(--suave); font-size: .85rem; margin-bottom: 16px; }
.linha-cand { margin-bottom: 14px; }
.linha-cand .topo-linha { display: flex; justify-content: space-between; font-weight: 600; }
.linha-cand .barra { height: 10px; background: var(--vazio); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.linha-cand .barra div { height: 100%; transition: width .8s ease; }
.linha-cand small { color: var(--suave); }
.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.numeros div { background: var(--fundo); border-radius: 10px; padding: 10px 12px; }
.numeros span { display: block; font-size: .72rem; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; }
.numeros strong { font-size: 1.05rem; }

.governadores { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.gov { border: 1px solid var(--linha); border-radius: 12px; padding: 14px; }
.gov header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.gov header strong { font-size: 1rem; }
.gov header span { font-size: .78rem; color: var(--suave); }
.gov .c { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.gov .c img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 3px solid var(--cor); background: var(--vazio); }
.gov .c .info { flex: 1; min-width: 0; }
.gov .c .info div { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gov .c .info small { color: var(--suave); }
.gov .c .p { font-weight: 800; font-size: 1.1rem; color: var(--cor); }

.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--linha); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: .75rem; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; user-select: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--fundo); }
.lider { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 20; background: var(--painel); color: var(--texto);
  border: 1px solid var(--linha); border-radius: 10px; padding: 10px 12px; font-size: .85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 190px;
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip .t { display: flex; justify-content: space-between; gap: 12px; }

footer { text-align: center; color: var(--suave); font-size: .8rem; padding: 20px 16px 32px; }

html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
.ao-vivo { white-space: nowrap; flex: none; }
.mapa text.pequeno { font-size: 8px; }

/* Tablet */
@media (max-width: 900px) {
  .grade { grid-template-columns: 1fr; }
  .mapa { max-width: 620px; margin: 0 auto; }
  .foto { width: 72px; height: 72px; }
  .cand .pct { font-size: 2.1rem; }
  .cand .nome { font-size: 1.1rem; }
}

/* Celular */
@media (max-width: 600px) {
  .topo { padding: 10px 14px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .marca { gap: 10px; width: 100%; }
  h1 { font-size: .95rem; line-height: 1.25; }
  .status { width: 100%; justify-content: space-between; gap: 12px; }
  .status div { flex-direction: row; align-items: baseline; gap: 6px; }
  .status strong { font-size: .9rem; }
  .rotulo { font-size: .66rem; }

  main { padding: 12px 10px 4px; gap: 12px; }
  .painel { padding: 14px; border-radius: 12px; }
  .cabecalho-painel { margin-bottom: 10px; }

  .duelo { grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 16px 0 12px; }
  .cand, .cand.direita { flex-direction: row; text-align: left; gap: 12px; }
  .cand.direita .nome { justify-content: flex-start; }
  .cand > div { min-width: 0; }
  .foto { width: 60px; height: 60px; border-width: 3px; }
  .cand .nome { font-size: 1rem; flex-wrap: wrap; }
  .cand .meta { font-size: .74rem; }
  .cand .pct { font-size: 1.9rem; }
  .cand .votos { font-size: .8rem; }
  .barra-duelo { height: 14px; }

  /* siglas maiores no mapa; as dos estados pequenos ficam só no toque */
  .mapa text { font-size: 17px; }
  .mapa text.pequeno { display: none; }
  .legenda { gap: 8px 14px; font-size: .75rem; }

  .detalhe h3 { font-size: 1rem; }
  .numeros { gap: 8px; }
  .numeros strong { font-size: .95rem; }

  .governadores { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .gov { padding: 12px; min-width: 0; }
  .gov header { gap: 8px; }
  .gov .c .p { flex: none; }

  table { font-size: .8rem; }
  th, td { padding: 8px 5px; }
  th { font-size: .66rem; white-space: normal; vertical-align: bottom; }
  th:first-child, td:first-child { position: sticky; left: 0; background: var(--painel); }
  .tabela-wrap { margin: 0 -6px; }

  .tooltip { display: none; }
  footer { padding: 16px 14px calc(24px + env(safe-area-inset-bottom)); line-height: 1.6; }
}
