/* Painel Apuração 2026 — tema verde e amarelo */

:root {
  --green-900: #03190C;
  --green-800: #04200F;
  --green-700: #00612A;
  --green-600: #00843D;
  --green-500: #009C3B;
  --yellow: #FFDF00;
  --yellow-600: #F2C500;
  --blue: #002776;

  /* Tema escuro (padrão "telão") */
  --bg: #04200F;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #0a4a24 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 0%, #3d3a05 0%, transparent 55%);
  --surface: #0B2A1C;
  --surface-2: #0F3524;
  --border: rgba(255, 255, 255, .08);
  --ink: #F3F8F2;
  --ink-2: #B9CDBF;
  --muted: #86A391;
  --grid: rgba(255, 255, 255, .07);
  --neutral: #4A5E52;
  --cand-a: #E8403A;
  --cand-b: #3D7BE0;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --accent-ink: #FFDF00;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #EEF5EC;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #d6f0d9 0%, transparent 60%),
               radial-gradient(900px 500px at 110% 0%, #fff6bf 0%, transparent 55%);
    --surface: #FFFFFF;
    --surface-2: #F4F9F2;
    --border: rgba(0, 60, 25, .12);
    --ink: #0B2A1C;
    --ink-2: #33513F;
    --muted: #5F7A69;
    --grid: rgba(0, 60, 25, .09);
    --neutral: #C5CFC8;
    --cand-a: #C8221C;
    --cand-b: #1F56B8;
    --shadow: 0 8px 24px rgba(0, 60, 25, .10);
    --accent-ink: #00612A;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #EEF5EC;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #d6f0d9 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 0%, #fff6bf 0%, transparent 55%);
  --surface: #FFFFFF;
  --surface-2: #F4F9F2;
  --border: rgba(0, 60, 25, .12);
  --ink: #0B2A1C;
  --ink-2: #33513F;
  --muted: #5F7A69;
  --grid: rgba(0, 60, 25, .09);
  --neutral: #C5CFC8;
  --cand-a: #C8221C;
  --cand-b: #1F56B8;
  --shadow: 0 8px 24px rgba(0, 60, 25, .10);
  --accent-ink: #00612A;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-feature-settings: "tnum" 1;
  line-height: 1.4;
  min-height: 100vh;
}
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Topo ---------- */
.sim-banner {
  background: #FFDF00; color: #3a2a00; text-align: center; font-weight: 800; font-size: 13px; padding: 7px 12px;
  border-bottom: 3px solid #1b1b1b;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(90deg, var(--green-700), var(--green-500));
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.stripe { height: 5px; background: linear-gradient(90deg, var(--yellow), var(--yellow-600), var(--yellow)); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > div { min-width: 0; }
.brand-flag { width: 44px; height: 31px; flex: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.brand-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--yellow); }
.brand-title { margin: 0; font-size: clamp(17px, 2.4vw, 24px); font-weight: 900; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, .25); font-size: 12px; font-weight: 800; letter-spacing: .08em; white-space: nowrap;
}
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #aaa; }
.live[data-state="live"] .live-dot { background: #FF3B30; box-shadow: 0 0 0 0 rgba(255, 59, 48, .7); animation: pulse 1.6s infinite; }
.live[data-state="connecting"] .live-dot { background: var(--yellow); animation: blink 1s infinite; }
.live[data-state="error"] .live-dot { background: #FF9500; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,48,.7); } 70% { box-shadow: 0 0 0 10px rgba(255,59,48,0); } 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); } }
@keyframes blink { 50% { opacity: .3; } }
.viewers {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, .25); color: #fff; font-size: 13px; white-space: nowrap;
}
.viewers strong { color: var(--yellow); font-weight: 800; }
.viewers.bump strong { animation: bump .5s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); } }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: rgba(0, 0, 0, .22); color: #fff; cursor: pointer;
}
.icon-btn:hover { background: rgba(0, 0, 0, .35); }

main.wrap { padding-top: 18px; padding-bottom: 12px; display: grid; gap: 16px; }

/* ---------- Cartões ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 17px; font-weight: 800; }
.card-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }

/* ---------- Progresso ---------- */
.progress-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.progress-value { font-size: clamp(34px, 6vw, 52px); font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.progress-value small { font-size: .5em; margin-left: 2px; color: var(--ink-2); }
.progress-meta { display: grid; gap: 4px; font-size: 14px; text-align: right; }
.progress-meta strong { font-weight: 700; }
.progress-bar { position: relative; margin-top: 14px; height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--green-500), var(--yellow));
  transition: width .8s cubic-bezier(.2, .8, .2, 1);
  position: relative; overflow: hidden;
}
.progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  transform: translateX(-100%); animation: shine 2.2s infinite;
}
@keyframes shine { to { transform: translateX(100%); } }
.notice { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.notice.warn { color: #FFB020; }

/* ---------- Duelo ---------- */
.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; }
.versus { display: grid; place-items: center; }
.versus span {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--yellow); color: var(--green-800); font-weight: 900; font-size: 18px;
  box-shadow: 0 0 0 5px rgba(255, 223, 0, .18);
}
.cand {
  --c: var(--cand-a);
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 20px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
  transition: border-color .4s, box-shadow .4s, transform .4s;
}
.cand[data-slot="b"] { --c: var(--cand-b); }
.cand::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--c);
}
.cand.leading { border-color: var(--yellow); box-shadow: 0 0 0 2px var(--yellow), var(--shadow); }
.cand.elected { border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow), 0 0 40px rgba(255, 223, 0, .35), var(--shadow); }
.cand-photo {
  position: relative; width: clamp(96px, 13vw, 150px); aspect-ratio: 1; border-radius: 50%;
  padding: 5px; background: conic-gradient(var(--c) calc(var(--p, 0) * 1%), var(--surface-2) 0);
  transition: background .8s;
}
.cand-photo img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: top center;
  display: block; background: var(--surface-2); border: 4px solid var(--surface);
}
.cand-num {
  position: absolute; right: -4px; bottom: 2px; min-width: 40px; padding: 3px 8px; border-radius: 10px;
  background: var(--c); color: #fff; font-weight: 900; font-size: 16px; text-align: center;
  border: 3px solid var(--surface);
}
.cand-body { min-width: 0; }
.cand-tags { display: flex; gap: 6px; flex-wrap: wrap; min-height: 22px; margin-bottom: 4px; }
.tag { font-size: 11px; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; }
.tag-lead { background: var(--yellow); color: var(--green-800); }
.tag-elected { background: var(--green-500); color: #fff; box-shadow: 0 0 0 2px var(--yellow); }
.tag-party { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.cand-name { margin: 0; font-size: clamp(18px, 2.4vw, 28px); font-weight: 900; line-height: 1.1; letter-spacing: -.01em; }
.cand-vice { margin: 4px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand-pct { margin-top: 10px; font-size: clamp(40px, 6.6vw, 72px); font-weight: 900; line-height: .95; letter-spacing: -.03em; }
.cand-pct small { font-size: .42em; color: var(--ink-2); margin-left: 2px; letter-spacing: 0; }
.cand-votes { margin-top: 6px; font-size: 15px; color: var(--ink-2); font-weight: 600; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background-color: rgba(255, 223, 0, .28); } 100% { background-color: transparent; } }

/* ---------- Barra dividida ---------- */
.split-labels { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 800; margin-bottom: 8px; gap: 8px; }
.split-labels span:last-child { text-align: right; }
.split-center { color: var(--muted); font-weight: 700; font-size: 12px; }
.split { position: relative; display: flex; gap: 2px; height: 26px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.split-a, .split-b { height: 100%; transition: flex-basis .8s cubic-bezier(.2, .8, .2, 1); flex: 0 0 50%; }
.split-a { background: var(--cand-a); }
.split-b { background: var(--cand-b); }
.split-mid { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; background: var(--yellow); transform: translateX(-1px); }
.diff { margin-top: 10px; text-align: center; font-size: 15px; color: var(--ink-2); }
.diff strong { color: var(--ink); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px;
  display: grid; gap: 2px; box-shadow: var(--shadow); min-width: 0;
}
.kpi-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi-value { font-size: clamp(18px, 2.2vw, 24px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

/* ---------- Gráfico ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 4px; border-radius: 2px; background: currentColor; }
.swatch-dash { height: 0; border-top: 2px dashed var(--yellow); background: none; }
.chart { position: relative; height: 320px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; touch-action: pan-y; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .ref50 { stroke: var(--yellow); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .8; }
.chart .series { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .endpoint { stroke: var(--surface); stroke-width: 2; }
.chart .end-label { font-size: 12px; font-weight: 800; fill: var(--ink); }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-size: 14px; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.tooltip .tt-title { font-weight: 800; margin-bottom: 6px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip .tt-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tooltip .tt-muted { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------- Mapa de blocos ---------- */
.map-wrap { position: relative; }
.tilemap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; max-width: 460px; margin: 0 auto; }
.tile {
  aspect-ratio: 1; border-radius: 10px; display: grid; place-content: center; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
  color: #fff; transition: background-color .8s, transform .15s; padding: 0; font: inherit;
}
.tile:hover, .tile:focus-visible, .tile.active { transform: scale(1.08); outline: 2px solid var(--yellow); outline-offset: 1px; z-index: 2; }
.tile-uf { font-weight: 900; font-size: clamp(11px, 2.6vw, 15px); letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.tile-pct { font-size: clamp(8px, 1.9vw, 11px); font-weight: 700; opacity: .95; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.tile.empty-tile { color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, transparent 6px 12px); }
.tile.empty-tile .tile-uf, .tile.empty-tile .tile-pct { text-shadow: none; }
.tile.zz { border-style: dashed; }
.map-legend { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-top: 16px; font-size: 13px; font-weight: 700; }
.map-scale { height: 10px; border-radius: 999px; }
.map-legend-sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 2px 4px 0; }

/* ---------- Tabela ---------- */
.search {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-size: 14px; min-width: 200px;
}
.search:focus { outline: 2px solid var(--yellow); outline-offset: 1px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table th {
  text-align: right; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 8px; border-bottom: 2px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap;
}
.table th:first-child, .table td:first-child { text-align: left; }
.table th[aria-sort="ascending"]::after { content: " ▲"; color: var(--accent-ink); }
.table th[aria-sort="descending"]::after { content: " ▼"; color: var(--accent-ink); }
.table td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.uf-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.uf-badge { display: inline-grid; place-items: center; width: 30px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 900; color: #fff; }
.mini-bar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--surface-2); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-500), var(--yellow)); }
.lead-cell { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }

/* ---------- Rodapé ---------- */
.footer { padding-top: 8px; padding-bottom: 32px; font-size: 13px; color: var(--ink-2); }
.footer a { color: var(--accent-ink); }

/* ---------- Eleito ---------- */
.elected-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at center, rgba(0, 156, 59, .92), rgba(3, 25, 12, .96));
  animation: fadein .5s ease-out;
}
@keyframes fadein { from { opacity: 0; } }
.elected-card { text-align: center; color: #fff; max-width: 520px; }
.elected-card img {
  width: min(220px, 50vw); aspect-ratio: 1; border-radius: 50%; object-fit: cover; object-position: top;
  border: 8px solid var(--yellow); box-shadow: 0 0 0 10px rgba(255,223,0,.25), 0 20px 60px rgba(0,0,0,.5);
  animation: pop .7s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.elected-kicker { margin-top: 22px; color: var(--yellow); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 14px; }
.elected-name { font-size: clamp(30px, 7vw, 56px); font-weight: 900; line-height: 1.05; margin-top: 6px; }
.elected-pct { font-size: 20px; margin-top: 8px; font-weight: 600; }
.elected-close {
  margin-top: 22px; border: 0; border-radius: 12px; padding: 12px 22px; font: inherit; font-weight: 800;
  background: var(--yellow); color: var(--green-800); cursor: pointer;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .duel { grid-template-columns: 1fr 1fr; gap: 10px; }
  .versus { display: none; }
  .cand { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 16px 10px 14px; gap: 10px; }
  .cand-tags { justify-content: center; }
  .cand-vice { white-space: normal; }
  .cand-votes { font-size: 13px; }
  .progress-meta { text-align: left; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; border-radius: 16px; }
  .table-scroll { margin: 0 -14px; padding: 0 14px; }
  .chart { height: 260px; }
  .search { min-width: 0; width: 100%; }
  .brand-kicker { font-size: 10px; }
  .live { padding: 5px 9px; font-size: 11px; }
}
@media (max-width: 520px) {
  .brand-flag { width: 34px; height: 24px; }
  .brand-title { font-size: 16px; }
  .live-label, .viewers-label { display: none; }
  .live { padding: 8px; }
  .viewers { padding: 6px 9px; }
  .topbar-right { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
