:root {
  --lula: #d62828;
  --flavio: #1d4ed8;
  --cinza: #d4d4d8;
  --cinza-escuro: #52525b;
  --texto: #18181b;
  --fundo: #ffffff;
  --linha: #e4e4e7;
  --suave: #f4f4f5;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--fundo);
  padding-bottom: 72px; /* espaço do rodapé fixo */
}

main, .topo { max-width: 720px; margin: 0 auto; padding: 0 16px; }

h1 { font-size: 1.1rem; margin: 14px 0 10px; }
h2 { font-size: 1rem; margin: 24px 0 8px; }

.eleito {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
}
.eleito.e-lula { background: var(--lula); }
.eleito.e-flavio { background: var(--flavio); }

/* ---- contagem ---- */
.contagem { text-align: center; padding: 16px 0 8px; }
.contagem p { margin: 0; }
.relogio { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- placar ---- */
.cands { display: flex; justify-content: space-between; gap: 12px; }
.cand { display: flex; flex-direction: column; min-width: 0; }
.cand.flavio { text-align: right; }
.cand .nome { font-weight: 600; }
.cand .nome small { font-weight: 400; color: var(--cinza-escuro); }
.cand .pct { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cand.lula .pct { color: var(--lula); }
.cand.flavio .pct { color: var(--flavio); }
.cand .votos { font-size: .85rem; color: var(--cinza-escuro); font-variant-numeric: tabular-nums; }

.barra {
  position: relative;
  display: flex;
  justify-content: space-between;
  height: 14px;
  margin: 10px 0 6px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--cinza);
}
.barra i { display: block; height: 100%; width: 0; transition: width .6s; }
.b-lula { background: var(--lula); }
.b-flavio { background: var(--flavio); }
.barra b { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; }

.apurado { margin: 0; font-size: .9rem; text-align: center; }

/* ---- mapa ---- */
.mapa-wrap { position: relative; margin: 12px 0 0; }
#mapa { display: block; width: 100%; height: auto; touch-action: manipulation; }

.uf {
  fill: var(--cinza);
  stroke: #fff;
  stroke-width: 1;
  stroke-linejoin: round;
  cursor: pointer;
}
.uf.ativo { stroke: var(--texto); stroke-width: 2; }

.c-lula { stop-color: var(--lula); }
.c-flavio { stop-color: var(--flavio); }

.rotulos { pointer-events: none; }
.rotulos text {
  font-size: 15px;
  font-weight: 800;
  fill: var(--cinza-escuro);
  stroke: #fff;
  stroke-width: 3px;
  paint-order: stroke;
  text-anchor: middle;
  dominant-baseline: middle;
}
.rotulos line { stroke: var(--cinza-escuro); stroke-width: 1; }
.r-lula text { fill: var(--lula); }
.r-flavio text { fill: var(--flavio); }

.dica {
  position: absolute;
  z-index: 2;
  min-width: 160px;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--texto);
  color: #fff;
  font-size: .85rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.dica.abaixo { transform: translate(-50%, 16px); }
.dica strong { display: block; margin-bottom: 2px; }
.dica p { margin: 0; font-variant-numeric: tabular-nums; }
.dica .d-lula::before, .dica .d-flavio::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px;
}
.dica .d-lula::before { background: var(--lula); }
.dica .d-flavio::before { background: var(--flavio); }

/* ---- legenda ---- */
.legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: .8rem;
  color: var(--cinza-escuro);
}
.legenda i { display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.legenda .c-lula { background: var(--lula); }
.legenda .c-flavio { background: var(--flavio); }
.legenda .c-cinza { background: var(--cinza); }

/* ---- lista ---- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 4px; border-bottom: 1px solid var(--linha); text-align: right; }
th:first-child, tbody th { text-align: left; font-weight: 500; }
tbody th small { color: var(--cinza-escuro); }
thead th { padding: 0; }
thead button {
  width: 100%;
  padding: 8px 4px;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  text-align: inherit;
  color: inherit;
  cursor: pointer;
}
thead button[aria-pressed="true"] { text-decoration: underline; }
thead button[aria-pressed="true"]::after { content: " ↓"; }
thead th:first-child button[aria-pressed="true"]::after { content: " ↑"; }
td.lidera { font-weight: 700; }
td.lidera.lula { color: var(--lula); }
td.lidera.flavio { color: var(--flavio); }
.nota { font-size: .8rem; color: var(--cinza-escuro); }

.avisos { margin: 24px 0; font-size: .8rem; color: var(--cinza-escuro); }

/* ---- rodapé fixo ---- */
.rodape {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 12px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--linha);
  background: var(--suave);
  font-size: .8rem;
  text-align: center;
}
.rodape a { color: inherit; }
.alerta { color: #b45309; font-weight: 700; }

@media (min-width: 640px) {
  h1 { font-size: 1.4rem; }
  .cand .pct { font-size: 2.6rem; }
}
