:root {
  /* === Latinalytics brand === */
  --brand: #3170FD;          /* azul do logo Latinalytics */
  --brand-dark: #1f5ae6;
  --brand-light: #dbeafe;
  --mint: #10b981;           /* verde menta (disponibilidade) */
  --mint-soft: rgba(16, 185, 129, 0.14);

  /* === Cores dos candidatos === */
  /* 2026 em destaque (forte), 2022 como contexto (claro) */
  --a-2022: #fca5a5;      /* rosa claro suave (contexto histórico) */
  --a-2022-soft: rgba(252, 165, 165, 0.22);
  --b-2022: #93c5fd;      /* azul céu claro (contexto histórico) */
  --b-2022-soft: rgba(147, 197, 253, 0.22);

  --a-2026: #7f1d1d;      /* vermelho vinho profundo (destaque) */
  --a-2026-soft: rgba(127, 29, 29, 0.14);
  --b-2026: #1e3a8a;      /* azul marinho profundo (destaque) */
  --b-2026-soft: rgba(30, 58, 138, 0.14);

  --warning: #6b7280;        /* cinza neutro para o marcador 'hoje' */
  --positive: #10b981;
  --negative: #dc2626;

  /* Tema claro - alinhado com background gradiente Latinalytics */
  --bg: #f4f7fb;
  --bg-elev: #ffffff;
  --bg-elev-2: #f8fafc;
  --border: rgba(15, 23, 42, 0.10);
  --border-soft: rgba(15, 23, 42, 0.06);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --accent: var(--brand);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-pill: 0 4px 20px rgba(37, 99, 235, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] {
  --bg: #0a0a0b;
  --bg-elev: #131315;
  --bg-elev-2: #1c1c1f;
  --border: rgba(255,255,255,0.10);
  --border-soft: rgba(255,255,255,0.06);
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --accent: #60a5fa;
  --brand: #60a5fa;
  --brand-dark: #3b82f6;
  --brand-light: rgba(96, 165, 250, 0.14);
  --mint: #34d399;
  --shadow: 0 1px 2px rgba(0,0,0,0.30), 0 4px 12px rgba(0,0,0,0.40);
  --shadow-pill: 0 4px 20px rgba(0,0,0,0.40), 0 1px 3px rgba(0,0,0,0.30);

  /* Tema escuro - 2026 destaque, 2022 contexto */
  --a-2022: #fecaca;      /* rosa muito claro */
  --b-2022: #bfdbfe;      /* azul muito claro */
  --a-2026: #ef4444;      /* vermelho vivo */
  --b-2026: #3b82f6;      /* azul vivo */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(16, 185, 129, 0.06), transparent 60%),
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(37, 99, 235, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  gap: 16px;
}
[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(52, 211, 153, 0.05), transparent 60%),
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(96, 165, 250, 0.06), transparent 60%),
    var(--bg);
}

/* ============ HEADER PILL (Latinalytics style) ============ */
.header-pill {
  position: sticky;          /* sempre visível ao rolar */
  top: 10px;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 22px;
  box-shadow: var(--shadow-pill);
}
/* faixa acima do header fixo: esconde o conteúdo que passa por baixo */
.header-pill::before {
  content: '';
  position: absolute;
  left: -24px; right: -24px; top: -11px;
  height: 11px;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(16, 185, 129, 0.06), transparent 60%),
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(37, 99, 235, 0.07), transparent 60%);
  background-attachment: fixed;
  z-index: -1;
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
a.brand-block { text-decoration: none; color: inherit; }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}
.brand-name {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.brand-tagline {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border-soft);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Botão Metodologia (no header) */
.btn-methodology {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-methodology:hover {
  background: var(--brand);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
[data-theme="dark"] .btn-methodology {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
}
[data-theme="dark"] .btn-methodology:hover {
  background: var(--brand);
  color: white;
}
.lang-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}
.lang-switch button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 999px;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}
.lang-switch button:hover:not(.active) { color: var(--text); }
.lang-switch button.active {
  background: #0f172a;
  color: white;
}
[data-theme="dark"] .lang-switch button.active {
  background: white;
  color: #0f172a;
}

/* ============ CONTEXTO NO HEADER (ao rolar) ============ */
.header-context {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(6px);
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap;
}
.header-pill.scrolled .header-context { opacity: 1; transform: translate(-50%, -50%); }
.ctx-flag { height: 30px; width: auto; border-radius: 5px; box-shadow: 0 3px 8px -3px rgba(15, 23, 42, 0.45); }
.ctx-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
/* bandeira ao lado do título */
.topbar .title-flag {
  height: 56px;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 6px 16px -6px rgba(15, 23, 42, 0.45);
  flex-shrink: 0;
  align-self: center;
}
/* estado sem arquivo de bandeira: selo com a sigla */
.flag-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 10 / 7;
  background: var(--brand);
  color: #fff;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.topbar .title-flag.flag-fallback { font-size: 22px; }
.ctx-flag.flag-fallback { font-size: 13px; }

/* ============ TAG BADGE (BRASIL - ELEIÇÃO) ============ */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  align-self: flex-start;
  margin-left: 8px;
}
.tag-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px var(--mint-soft);
}

/* ============ TOPBAR (título do dashboard) ============ */
.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  padding: 8px 8px 0;
  gap: 16px;
}
.title-block h1 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.05;
}
.title-block .accent {
  color: var(--brand);
  font-weight: 800;
}
.title-block .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  max-width: 720px;
}
.theme-toggle {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-elev-2); color: var(--brand); }

/* ============ KPIs ============ */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 4px 8px 0;
}
/* Situação x Oposição: cada grupo com a cor da sua série */
.kpi-group {
  border: 1.5px solid color-mix(in srgb, var(--g) 38%, transparent);
  background: color-mix(in srgb, var(--g) 5%, var(--bg-elev));
  border-radius: 20px;
  padding: 10px 10px 10px;
}
.kg-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 2px 8px 9px;
}
.kg-label {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--g);
  letter-spacing: -0.01em;
}
.kg-note {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.kg-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.kpi .k-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.kpi .k-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 600;
  margin-top: 3px;
  line-height: 1.1;
}
.kpi .k-delta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
  font-family: 'JetBrains Mono', monospace;
}
.kpi .k-delta.pos { color: var(--positive); }
.kpi .k-delta.neg { color: var(--negative); }
/* turno já apurado: o card mostra a urna (TSE), não a média das pesquisas */
.kpi .k-urna { width: 13px; height: 13px; vertical-align: -2px; margin-right: 6px; color: var(--text-secondary); }
.kpi-urna { background-image: linear-gradient(135deg, color-mix(in srgb, var(--g) 7%, transparent), transparent 60%); }

/* ============ CONTROLS ============ */
.control-bar {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
/* Turno: o controle principal, em caixa própria e na cor da marca */
.turn-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 18px;
  background: var(--brand);
  border-radius: 16px;
  box-shadow: 0 6px 18px -8px rgba(49, 112, 253, 0.55);
  flex-shrink: 0;
}
.turn-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.segmented.turn-seg {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}
.segmented.turn-seg button {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
}
.segmented.turn-seg button + button { border-left-color: rgba(255, 255, 255, 0.25); }
.segmented.turn-seg button:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.segmented.turn-seg button.active { background: #fff; color: var(--brand-dark); border-color: #fff; }
.control-bar .controls { flex: 1; min-width: 0; }
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 12px 18px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.control-group > label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev);
}
.segmented button {
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}
.segmented button + button { border-left: 1px solid var(--border-soft); }
.segmented button:hover { background: var(--bg-elev-2); color: var(--text); }
.segmented button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Dropdown */
.custom-select {
  position: relative;
  min-width: 220px;
}
.select-btn {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.select-btn:hover { background: var(--bg-elev-2); }
.select-btn.open svg { transform: rotate(180deg); }
.select-btn svg { transition: transform 0.2s ease; color: var(--text-secondary); }

.select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}
.select-menu.open { display: block; }
.select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  transition: background 0.1s ease;
}
.select-item:hover { background: var(--bg-elev-2); }
.select-item.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 0;
  padding: 0;
  pointer-events: none;
}
.select-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.select-item .badge {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}
.select-item .comparable-badge {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 4px;
}

/* Switch */
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.switch input { display: none; }
.switch .slider {
  width: 32px;
  height: 18px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}
.switch .slider::after {
  content: '';
  position: absolute;
  top: 1px; left: 1px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .slider::after {
  transform: translateX(14px);
}
.switch-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============ CHART CARD (legend + chart together) ============ */
.chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

/* ============ LEGEND ============ */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 0 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid transparent;
}
/* 2026 = círculo cheio (destaque); 2022 = triangulinho aberto (contexto) */
.dot-a26 { background: var(--a-2026); }
.dot-b26 { background: var(--b-2026); }
.dot-a22 { background: var(--a-2022); border-color: var(--a-2026); }
.dot-b22 { background: var(--b-2022); border-color: var(--b-2026); }
.dash {
  width: 22px;
  height: 0;
  border-top: 2px dashed var(--warning);
}

/* ============ CHART ============ */
.chart-container {
  flex: 1;
  position: relative;
  padding: 6px 0 0;
  min-height: 480px;
  display: flex;
}
#chart {
  width: 100%;
  height: 100%;
  min-height: 480px;
}
#chart .tick line, #chart .domain { stroke: var(--border); }
#chart .tick text {
  fill: var(--text-secondary);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
}
.axis-title {
  fill: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
}
.grid line { stroke: var(--border-soft); stroke-dasharray: 2 3; }
.grid line.zero { stroke: var(--text-tertiary); stroke-dasharray: none; stroke-width: 1; }
.today-marker {
  stroke: var(--warning);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}
.today-label {
  fill: var(--warning);
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
}
.event-marker {
  stroke-width: 1.25;
  stroke-dasharray: 2 3;
  opacity: 0.85;
}
.event-marker-2022 { stroke: var(--a-2022); }
.event-marker-2026 { stroke: var(--a-2026); }
.event-marker-election {
  stroke: var(--text-secondary);
  stroke-width: 1.5;
  stroke-dasharray: none;
  opacity: 0.7;
}
.event-label {
  font-size: 10px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
}
.event-label-2022 { fill: var(--a-2022); }
.event-label-2026 { fill: var(--a-2026); }
.event-label-election { fill: var(--text-secondary); }

.tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  z-index: 200;
  min-width: 170px;
  transition: opacity 0.12s ease;
}
.tooltip .tt-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}
.tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--text-secondary);
}
.tooltip .tt-row .num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
}
.tooltip .tt-row.pair {
  border-top: 1px solid var(--border-soft);
  margin-top: 4px;
  padding-top: 4px;
}

/* ============ FOOTER PILL (Latinalytics style) ============ */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.footer-brand {
  font-weight: 500;
  white-space: nowrap;
}
.footer-brand strong { color: var(--text); font-weight: 600; }
.footer-meta {
  color: var(--text-tertiary);
  font-size: 11px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.footer-lang {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ============ MODAL DE METODOLOGIA ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev));
  flex-shrink: 0;
}
.modal-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.modal-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.modal-close {
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.modal-close:hover {
  background: var(--bg-elev-2);
  color: var(--text);
  border-color: var(--border);
}
.modal-body {
  padding: 20px 28px 28px;
  overflow-y: auto;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.7;
  scroll-behavior: smooth;
}

/* Tipografia interna do modal */
.modal-body h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 4px;
  margin-bottom: 8px;
  line-height: 1.15;
}
.modal-body h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  letter-spacing: -0.01em;
}
.modal-body h3:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 16px;
}
.modal-body h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 14px;
  margin-bottom: 4px;
}
.modal-body p {
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.modal-body ul, .modal-body ol {
  margin: 4px 0 12px 20px;
  padding-left: 4px;
}
.modal-body ul li, .modal-body ol li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.modal-body strong {
  color: var(--text);
  font-weight: 600;
}
.modal-body em { font-style: italic; }
.modal-body code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--brand);
  font-weight: 500;
}
.modal-body ol {
  counter-reset: item;
  list-style: none;
  padding-left: 0;
}
.modal-body ol > li {
  counter-increment: item;
  padding-left: 32px;
  position: relative;
  margin-bottom: 10px;
}
.modal-body ol > li::before {
  content: counter(item);
  position: absolute;
  left: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  background: var(--brand-light);
  color: var(--brand-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
}
[data-theme="dark"] .modal-body ol > li::before {
  background: rgba(96, 165, 250, 0.18);
  color: #93c5fd;
}

/* Scrollbar do modal (webkit) */
.modal-body::-webkit-scrollbar {
  width: 8px;
}
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1180px) {
  .ctx-label { display: none; }
}
@media (max-width: 640px) {
  .header-context { display: none; }
}
@media (max-width: 900px) {
  body { padding: 12px; gap: 12px; }
  .header-pill { padding: 10px 12px; border-radius: 18px; flex-wrap: wrap; }
  .brand-tagline { display: none; }
  .btn-methodology span { display: none; }
  .btn-methodology { padding: 8px; }
  .modal-panel { max-height: 95vh; border-radius: 16px; }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 16px 20px 24px; font-size: 13px; }
  .modal-body h2 { font-size: 19px; }
  .topbar { flex-direction: column; align-items: flex-start; padding: 4px 4px 0; }
  .title-block h1 { font-size: 24px; }
  .title-block .subtitle { font-size: 12px; }
  .kpi-strip { grid-template-columns: 1fr; }
  .ctx-label { display: none; }
  .control-bar { flex-direction: column; }
  .turn-box { justify-content: space-between; }
  .chart-card { padding: 14px; border-radius: 16px; }
  .footer { border-radius: 20px; flex-direction: column; align-items: flex-start; }
  .footer-meta { white-space: normal; overflow: visible; }
}



/* ============ TOPO COMPACTO ============ */
/* grade: [bandeira | título]  /  [nota do eixo, alinhada à borda esquerda da bandeira] */
.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr);
  gap: 20px;
  align-items: center;
}
.hero-row .topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 18px;
  row-gap: 12px;
  align-items: center;
  padding: 0 0 0 8px;
}
.hero-row .kpi-strip { padding: 0 8px 0 0; }
.topbar .title-flag { grid-column: 1; grid-row: 1; height: 60px; align-self: center; }
.topbar .title-flag.flag-fallback { width: 86px; height: 60px; font-size: 22px; }
.topbar .title-block { grid-column: 2; grid-row: 1; min-width: 0; }
.title-block h1 {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 27px;
  line-height: 1.05;
}
.h1-bottom { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 14px; row-gap: 4px; }
.h1-years { font-size: 38px; line-height: 1; letter-spacing: -0.03em; white-space: nowrap; }
.title-block .subtitle {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--text-secondary);
}
.axis-note {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text-tertiary);
}
/* KPIs mais baixos */
.kpi-group { padding: 8px; border-radius: 16px; }
.kg-head { padding: 0 6px 6px; }
.kg-label { font-size: 14px; }
.kpi { padding: 10px 14px; border-radius: 12px; }
.kpi .k-value { font-size: 22px; }
@media (max-width: 1180px) {
  .hero-row { grid-template-columns: 1fr; }
  .hero-row .topbar { padding: 0 4px; }
  .hero-row .kpi-strip { padding: 0 4px; }
}
@media (max-width: 900px) {
  .hero-row .topbar { column-gap: 12px; row-gap: 8px; }
  .topbar .title-flag { height: 44px; }
  .topbar .title-flag.flag-fallback { width: 63px; height: 44px; font-size: 17px; }
  .title-block h1 { font-size: 21px; }
  .h1-years { font-size: 29px; }
  .title-block .subtitle { font-size: 13px; }
}


/* ============ PARCEIRO NO HEADER ============ */
.header-pill { justify-content: flex-start; }
/* contexto (bandeira + nome) no fluxo, centralizado no espaço entre o parceiro e os botões */
.header-pill .header-context {
  position: static; transform: translateY(6px); margin: 0 auto; padding: 0 16px;
  visibility: hidden; min-width: 0;
}
.header-pill.scrolled .header-context { transform: none; visibility: visible; }
.header-pill .header-right { margin-left: 0; }
.nav-partner { display: inline-flex; align-items: center; gap: 10px; margin-left: 18px; padding-left: 18px;
  border-left: 1px solid var(--border-soft); text-decoration: none; flex-shrink: 0; }
.nav-partner .partner-label { font: 500 10.5px/1.2 'JetBrains Mono', monospace; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--text-tertiary); }
.nav-partner .partner-logo { display: inline-flex; background: #000; border-radius: 8px; padding: 5px 9px;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.55); }
.nav-partner .partner-logo img { display: block; height: 26px; width: auto; }
@media (max-width: 1180px) { .header-pill .brand-tagline { display: none; } }
@media (max-width: 900px) {
  .nav-partner { margin-left: 10px; padding-left: 10px; gap: 6px; }
  .nav-partner .partner-label { display: none; }
  .nav-partner .partner-logo img { height: 18px; }
}


/* ============ COMPARTILHAR ============ */
.btn-share { background: #111a2e; color: #fff; }
.btn-share:hover { background: var(--brand); color: #fff; }
.btn-share:disabled { opacity: .6; cursor: progress; }
[data-theme="dark"] .btn-share { background: #f4f4f5; color: #0f172a; }
.header-right { gap: 8px; }
.share-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #111a2e; color: #fff; font-size: 13px; padding: 12px 18px; border-radius: 12px; z-index: 2000;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.share-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.share-toast a { color: #93c5fd; font-weight: 600; }
@media (max-width: 900px) { .btn-share span { display: none; } .btn-share { padding: 8px; } }

/* ============ VOTOS TOTAIS x VÁLIDOS ============ */
.turn-box { flex-wrap: wrap; }
.segmented.votes-seg button { font-size: 12px; }
.segmented.votes-seg button:disabled { opacity: .45; cursor: not-allowed; }

/* ============ RESULTADO OFICIAL ============ */
.res-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
  margin: 14px 8px 0;
}
.res-strip[hidden] { display: none; }
.res-main, .res-erro {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.res-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.res-tag {
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 15px; color: var(--text);
}
.res-tag::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); background: var(--brand); margin-right: 8px; vertical-align: 1px; }
.res-src { font: 500 11px 'JetBrains Mono', monospace; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; }
.res-rows { display: grid; gap: 6px; }
.res-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) 64px; align-items: center; gap: 10px; font-size: 13.5px; }
.res-name { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.res-name small { font: 600 10.5px 'JetBrains Mono', monospace; color: var(--text-tertiary); }
.res-bar { height: 6px; border-radius: 99px; background: var(--border-soft); overflow: hidden; }
.res-bar i { display: block; height: 100%; border-radius: 99px; }
.res-val { font: 600 15px 'JetBrains Mono', monospace; text-align: right; }
.res-badge { font: 700 9.5px/1 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .06em; padding: 3px 6px; border-radius: 6px; flex-shrink: 0; }
.res-badge.win { background: color-mix(in srgb, var(--positive) 16%, transparent); color: #047857; }
.res-badge.t2 { background: var(--brand-light, rgba(49,112,253,.12)); color: var(--brand); }
[data-theme="dark"] .res-badge.win { color: var(--mint, #34d399); }
.res-status { margin-top: 10px; font-size: 12.5px; color: var(--text-secondary); }
.res-erro { display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.res-erro b { color: var(--text); }
.res-erro b.neg { color: var(--negative); }
.res-k { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); }
.res-erro a { color: var(--brand); font-weight: 600; text-decoration: none; margin-top: auto; }
.res-erro a:hover { text-decoration: underline; }
@media (max-width: 860px) { .res-strip { grid-template-columns: 1fr; } }
.urna-mark { cursor: pointer; }
.urna-lbl { font: 700 11px 'JetBrains Mono', monospace; paint-order: stroke; stroke: var(--bg-elev); stroke-width: 3px; }
.dot-urna { display: inline-block; width: 9px; height: 9px; transform: rotate(45deg); background: var(--text); border-radius: 1px; margin: 0 3px; }
.urna-cap { font: 700 9.5px 'JetBrains Mono', monospace; letter-spacing: .08em; fill: var(--text-tertiary); }

/* ============ MARGENS DE ERRO (só com um ano escolhido) ============ */
.moe-bar { stroke-width: 1.4; stroke-opacity: .26; stroke-linecap: round; }
.moe-band { fill-opacity: .13; stroke: none; }
.toggle-comp { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.switch-label small { font-size: 11px; color: var(--text-tertiary); margin-left: 2px; }
.switch-label small[hidden] { display: none; }
.moe-key { display: inline-block; width: 18px; height: 10px; border-radius: 3px; position: relative;
  background: color-mix(in srgb, var(--text-secondary) 16%, transparent); }
.moe-key::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1.5px; margin-left: -.75px;
  background: color-mix(in srgb, var(--text-secondary) 55%, transparent); border-radius: 1px; }
.moe-note { margin: 2px 4px 10px; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); }
.moe-note b { color: var(--text); font-weight: 600; }
.moe-note b.neg { color: var(--negative); }
