/* ===========================================================
   Painel Eleitoral — tokens e estilos base
   Paleta oficial da marca — cores exatas tiradas do SVG vetorial real da
   logo que o usuário mandou (img/logo-mark.svg, img/favicon.svg):
   fundo #080F22 (.st2), branco #FEFEFE (.st3), ciano #04E0FB (.st4),
   azul #016EFD (.st0), ciano intermediário #05B3F0 (.st1, usado como
   --accent-3 pra dar variedade sem sair da família de cor da marca).
   Cards/texto secundário (#111827/#1F2937/#D1D5DB/#94A3B8) e positivo/
   negativo (#22C55E/#EF4444) vieram do briefing em texto que acompanhou
   a marca — o SVG só define o mark, não a paleta de UI inteira.
   --tie (âmbar) NÃO está no brand sheet — é adição própria deste sistema
   pro semântico "empate técnico/atenção", que a marca enviada não cobre.
   Ver CLAUDE.md, seção do rebrand.
   =========================================================== */

:root {
  --bg:             #080F22;
  --bg-line:        rgba(255, 255, 255, 0.03);
  --surface:        #111827;
  --surface-raised: #1F2937;
  --ink:            #FEFEFE;
  --ink-soft:       #D1D5DB;
  --ink-faint:      #94A3B8;
  --border:         #1F2937;
  --border-strong:  #334155;

  --accent:         #04E0FB;
  --accent-2:       #016EFD;
  --accent-3:       #05B3F0;
  --accent-bg:      rgba(4, 224, 251, 0.12);
  --positive:       #22C55E;
  --negative:       #EF4444;
  --tie:            #F59E0B;
  --tie-bg:         rgba(245, 158, 11, 0.12);

  --party-fallback: #94A3B8;

  --font-display: "Space Grotesk", "Archivo", system-ui, sans-serif;
  --font-body:    "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

  --radius: 3px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

body {
  background-image:
    linear-gradient(var(--bg-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, select {
  font-family: var(--font-body);
  font-size: 14px;
}

::selection { background: var(--accent); color: #080F22; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* scrollbars discretos, tema escuro */
* { scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- layout shell ---------- */

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
  max-width: 1160px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
}

.brand-mark {
  width: 72px;
  height: auto;
  flex: none;
  padding-right: 18px;
  border-right: 1px solid var(--border-strong);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.brand-word--accent {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-top: 2px;
}

.brand-text small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0;
  margin-top: 6px;
}

.topbar nav a {
  text-decoration: none;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
  margin-left: 18px;
}
.topbar nav a:first-child { margin-left: 0; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

section {
  margin-top: 28px;
}

h2.section-title {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

h2.section-title::before {
  content: "";
  width: 14px;
  height: 2px;
  background: var(--accent);
  display: inline-block;
}

/* ---------- filtros ---------- */

.filterbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(8, 15, 34, 0.92);
  backdrop-filter: blur(2px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  margin: 0 auto;
  max-width: 1160px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filterbar select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--ink);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.filterbar select:hover { border-color: var(--accent); }

.filterbar .spacer { flex: 1; }

.btn-link {
  background: none;
  border: none;
  color: var(--ink-soft);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 4px;
}
.btn-link:hover { color: var(--accent); }

/* ---------- KPIs ---------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: inset 3px 0 0 var(--border-strong);
}

.kpi-card--lead { box-shadow: inset 3px 0 0 var(--kpi-accent, var(--accent)); }
.kpi-card--media { box-shadow: inset 3px 0 0 var(--accent); }

.kpi-card .kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.kpi-card .kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
}

.kpi-card .kpi-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
}

.tag-tie {
  display: inline-block;
  background: var(--tie-bg);
  color: var(--tie);
  border: 1px solid var(--tie);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 6px;
}

/* ---------- hero (corrida) ---------- */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.hero-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.race-row {
  display: grid;
  grid-template-columns: 180px 1fr 72px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.race-name {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.race-name .dot {
  width: 9px; height: 9px;
  flex: none;
}

.race-track {
  position: relative;
  height: 28px;
  background: var(--surface-raised);
  border-radius: 2px;
  overflow: visible;
}

.race-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  transition: width 700ms ease;
}

.race-margin {
  position: absolute;
  top: -4px; bottom: -4px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 1px dashed var(--ink-faint);
  border-right: 1px dashed var(--ink-faint);
}

.race-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  text-align: right;
}

/* ---------- tendência ---------- */

.trend-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  height: 360px;
  box-sizing: border-box;
  position: relative;
}

.trend-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.trend-fallback {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- divergência ---------- */

.divergence-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.divergence-card {
  flex: none;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.divergence-card .inst {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.divergence-card .row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}

.empty-note {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- tabela ---------- */

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.section-toggle {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.section-toggle:hover { border-color: var(--accent); color: var(--ink); }
.section-toggle--collapsed { color: var(--accent); border-color: var(--accent); }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.polls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 720px;
}

table.polls-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding: 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

table.polls-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--ink);
}

table.polls-table tbody tr:hover {
  background: var(--surface-raised);
}

table.polls-table tr.row-tie td:first-child {
  box-shadow: inset 3px 0 0 var(--tie);
}

table.polls-table tr.row-media {
  border-top: 2px solid var(--border-strong);
  background: var(--surface-raised);
}

table.polls-table tr.row-media td {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
}

table.polls-table tr.row-media td:first-child {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.chip-cenario {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 6px;
}

/* ---------- comparar ---------- */

.compare-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.compare-controls select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-width: 220px;
  color: var(--ink);
}
.compare-controls select:hover { border-color: var(--accent); }

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.compare-card h3 {
  font-family: var(--font-display);
  font-size: 14px;
  margin: 0 0 12px;
  color: var(--accent);
}

.compare-field {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}
.compare-field span:first-child { color: var(--ink-soft); }

.compare-diff {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.diff-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.diff-val.pos { color: var(--positive); }
.diff-val.neg { color: var(--negative); }

/* ---------- cards de disputa (home -> detalhe) ---------- */

.race-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.race-link:hover .hero { border-color: var(--accent); }

/* ---------- footer note ---------- */

/* ---------- leitura rápida ---------- */

.insights-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.insight-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.insight-row:last-child { margin-bottom: 0; }

.insight-icon {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.insight-icon--accent   { background: var(--accent-bg); color: var(--accent); }
.insight-icon--orange   { background: rgba(37, 99, 235, 0.14); color: var(--accent-2); }
.insight-icon--positive { background: rgba(34, 197, 94, 0.14); color: var(--positive); }
.insight-icon--warn     { background: var(--tie-bg); color: var(--tie); }

.insight-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}
.insight-text b { color: var(--ink); }

.method-note {
  font-size: 11.5px;
  color: var(--ink-faint);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding-top: 14px;
}

.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px 32px;
}
.site-footer p {
  font-size: 11.5px;
  color: var(--ink-faint);
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin: 0;
}
.site-footer a { color: var(--ink-faint); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

.footer-credit { border-top: none !important; padding-top: 10px !important; }
.footer-credit a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.footer-credit a:hover { color: var(--accent); text-decoration: none; }
.footer-credit svg { flex: none; }

/* ---------- página candidatos ---------- */
/* Migrado do antigo tema claro dedicado (css/light.css, ainda existe mas não é mais
   referenciado) pro tema escuro único da marca — o brand system novo é "dark mode
   nativo", sem variante clara. */

.page-title {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--ink);
}
.page-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 28px; }

.cand-section { margin-bottom: 40px; }

.cand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.cand-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}

.cand-card .swatch { height: 4px; }

.cand-card .body { padding: 20px; }

.cand-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.avatar {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar .initials {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.cand-card .nome { font-family: var(--font-display); font-size: 18px; font-weight: 700; margin: 0; color: var(--ink); }
.cand-card .partido { font-size: 13px; color: var(--ink-soft); margin: 2px 0 0; }
.cand-card .cargo-atual { font-size: 13px; margin: 0 0 8px; color: var(--ink); }

.ig-link {
  display: inline-block;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--accent);
}
.ig-link:hover { border-color: var(--accent); text-decoration: none; }

.mandatos { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink); }
.mandatos li { margin-bottom: 4px; }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: 4px; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .compare-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr; }
  .race-row { grid-template-columns: 90px 1fr 60px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
