:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --lula-red: #dc2626;
  --lula-bg: #fef2f2;
  --lula-border: #fecaca;
  --bols-blue: #2563eb;
  --bols-bg: #eff6ff;
  --bols-border: #bfdbfe;
  --gain-green: #16a34a;
  --gain-bg: #f0fdf4;
  --gain-border: #bbf7d0;
  --gold-100: #d97706;
  --gold-bg: #fef3c7;
  --gold-border: #fde68a;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: #f1f5f9;
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 60px;
}

/* Header */
.top-header {
  background: linear-gradient(135deg, #090d16 0%, #1e293b 50%, #0f172a 100%);
  color: #ffffff;
  padding: 20px 24px;
  border-bottom: 3px solid #3b82f6;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.header-container {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-section h1 {
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}

.brand-section p {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-top: 4px;
}

.poll-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.btn-ping {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.btn-ping:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
}

.btn-ping:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.select-interval {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* Key Metrics Cards */
.metrics-grid {
  max-width: 1500px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.metric-card.highlight-lula {
  border-top: 4px solid var(--lula-red);
}

.metric-card.highlight-bols {
  border-top: 4px solid var(--bols-blue);
}

.metric-card.highlight-gain {
  border-top: 4px solid var(--gain-green);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.metric-card.highlight-info {
  border-top: 4px solid #6366f1;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-val {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 8px 0 4px 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.metric-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.val-gain-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
}

.gain-positive {
  background: var(--gain-bg);
  color: var(--gain-green);
  border: 1px solid var(--gain-border);
}

.gain-negative {
  background: var(--lula-bg);
  color: var(--lula-red);
  border: 1px solid var(--lula-border);
}

/* Main Container */
.main-wrapper {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Nav Tabs */
.tabs-bar {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #cbd5e1;
  margin-bottom: 20px;
  padding-bottom: 2px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  position: relative;
}

.tab-btn:hover {
  color: var(--text-main);
  background: #e2e8f0;
}

.tab-btn.active {
  color: #1e40af;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-bottom: 2px solid #ffffff;
  margin-bottom: -4px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.03);
}

/* Filter and Actions Bar */
.filter-bar {
  background: #ffffff;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: #e2e8f0;
}

.filter-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.search-box {
  position: relative;
  min-width: 280px;
  flex: 1;
  max-width: 420px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.85rem;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-export-png {
  background: #0f172a;
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

a.btn-export-png { color: #ffffff; text-decoration: none; }

.btn-export-png:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

/* Data Table */
.table-container {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table thead th {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 2px solid #334155;
}

.data-table thead th.group-header {
  text-align: center;
  background: #1e293b;
  border-left: 1px solid #334155;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr.row-br {
  background: #f1f5f9;
  font-weight: 700;
}

.data-table tbody tr.row-reg {
  background: #f8fafc;
  font-weight: 600;
}

.badge-100 {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
}

.badge-progress {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.cand-cell {
  display: flex;
  flex-direction: column;
}

.cand-pct {
  font-weight: 700;
}

.cand-votes {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.gain-cell-green {
  color: var(--gain-green);
  font-weight: 700;
}

.gain-cell-red {
  color: var(--lula-red);
  font-weight: 700;
}

/* Chart Tab Layout */
.chart-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-title h3 {
  font-size: 1.25rem;
  font-weight: 800;
}

.chart-title p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.chart-container-box {
  position: relative;
  height: 480px;
  width: 100%;
}

.chart-legend-box {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  width: 24px;
  height: 4px;
  border-radius: 2px;
}

/* Map Tab Layout */
.map-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.map-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.map-container-box {
  height: 600px;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  border: 1px solid var(--border-color);
}

.modal-header {
  padding: 18px 24px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 16px 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
}

.btn-close-modal {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 10000;
  display: none;
  animation: slideUp 0.3s forwards;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Drill-down (UF -> municípios) */
.drill-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  font-weight: 700;
}

.data-table tbody tr.clickable {
  cursor: pointer;
}

.gain-base {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

.map-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
}

.map-legend {
  background: #ffffff;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  font-size: 0.75rem;
  line-height: 1.5;
  max-width: 240px;
}

.map-legend i {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border-radius: 3px;
}

/* 2018/2022 ocultos por padrão */
.hide-hist .col-hist {
  display: none;
}

.cmp-cell {
  background: #ecfdf5;
  min-width: 150px;
}

.cmp-main {
  font-size: 1rem;
  font-weight: 800;
}

/* Notificações e histórico */
.notify-stack {
  position: fixed;
  top: 84px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.notify-item {
  background: #ffffff;
  border-left: 5px solid #2563eb;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
  padding: 10px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  animation: notify-in 0.25s ease-out;
}

.notify-item.g1 {
  border-left-color: #d97706;
}

.notify-item strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

@keyframes notify-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.hist-badge {
  background: #dc2626;
  color: #ffffff;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.72rem;
  margin-left: 4px;
}

.hist-src {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.hist-src.tse { background: #dbeafe; color: #1e40af; }
.hist-src.g1 { background: #fef3c7; color: #92400e; }

/* Aba variação */
.var-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.var-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 16px 18px;
}

.var-card h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.var-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.var-card th,
.var-card td {
  padding: 6px 4px;
  text-align: right;
  border-bottom: 1px solid #f1f5f9;
}

.var-card th:first-child,
.var-card td:first-child {
  text-align: left;
}

.var-card .big {
  font-size: 1.05rem;
  font-weight: 800;
}

.var-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* =============================================================
   Revisão de UI (painel principal, tabela, barras de ferramentas)
   ============================================================= */
.top-header {
  padding: 14px 24px;
}

.brand-section h1 {
  font-size: 1.3rem;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* As selects fora do cabeçalho ficam claras */
.main-wrapper .select-interval {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  padding: 7px 10px;
}

/* Painel principal */
.hero {
  max-width: 1500px;
  margin: 18px auto 8px;
  padding: 0 20px;
}

.hero-scope {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

/* Placar de votos válidos */
.placar {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 18px 12px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}
.placar-wait { color: var(--text-muted); font-size: 0.9rem; }
.placar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.placar-cand { display: flex; flex-direction: column; }
.placar-cand.bols { align-items: flex-end; text-align: right; }
.placar-cand.lula .cand-name, .placar-cand.lula .placar-pct { color: var(--lula-red); }
.placar-cand.bols .cand-name, .placar-cand.bols .placar-pct { color: var(--bols-blue); }
.placar-pct { font-size: 2.6rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.placar-votos { font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.placar-mid { text-align: center; font-size: 0.88rem; }
.placar-apur { font-weight: 800; font-size: 1.05rem; color: #7c3aed; }
.placar-bar { position: relative; display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #e2e8f0; margin-top: 10px; }
.placar-bar .l { background: var(--lula-red); }
.placar-bar .b { background: var(--bols-blue); }
.placar-bar .placar-50 { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: #0f172a; }
.placar-bar.sm { height: 6px; margin-top: 4px; width: 130px; }
.placar-foot { font-size: 0.78rem; color: var(--text-muted); margin-top: 8px; }
@media (max-width: 640px) {
  .placar-top { flex-wrap: wrap; }
  .placar-mid { order: 3; width: 100%; }
  .placar-pct { font-size: 1.9rem; }
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.hero-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-top: 5px solid #64748b;
  border-radius: 12px;
  padding: 14px 18px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.hero-card.lula { border-top-color: var(--lula-red); }
.hero-card.bols { border-top-color: var(--bols-blue); }
.hero-card.status { border-top-color: #7c3aed; }

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.cand-name {
  font-weight: 800;
  font-size: 1.05rem;
}

.hero-card.lula .cand-name, .hero-card.lula .cand-num { color: var(--lula-red); }
.hero-card.bols .cand-name, .hero-card.bols .cand-num { color: var(--bols-blue); }

.cand-num {
  font-weight: 800;
  font-size: 1.1rem;
}

.hero-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 8px;
}

.hero-big {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero-sub {
  font-size: 0.88rem;
  color: #334155;
}

.hero-cmp {
  margin-top: 10px;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f1f5f9;
  font-size: 0.85rem;
}

.hero-cmp.pos { background: #f0fdf4; border: 1px solid #bbf7d0; }
.hero-cmp.neg { background: #fef2f2; border: 1px solid #fecaca; }

.hero-cmp-big {
  font-weight: 800;
  font-size: 1.1rem;
}

.hero-cmp.pos .hero-cmp-big { color: #15803d; }
.hero-cmp.neg .hero-cmp-big { color: #b91c1c; }

.hero-cmp-ref {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.hero-foot {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.progress {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.progress > div {
  height: 100%;
  background: #7c3aed;
}

.progress.sm {
  height: 4px;
  margin: 4px 0 0;
  width: 70px;
}

.progress.sm > div { background: #d97706; }

.kv {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}

.kv td { padding: 2px 0; }
.kv td:first-child { color: var(--text-muted); }
.kv td:last-child { text-align: right; font-weight: 600; }

.howto {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #334155;
}

.howto summary {
  cursor: pointer;
  font-weight: 700;
  color: #1e40af;
}

.howto ul {
  margin: 8px 0 0 20px;
  display: grid;
  gap: 4px;
}

/* Abas */
.tabs-bar .tab-btn {
  white-space: nowrap;
}

/* Barras de ferramentas */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.toolbar-2 {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 12px;
}

.toolbar-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

.toolbar-grow { flex: 1; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 10px;
}

.seg .filter-btn {
  border: none;
  background: transparent;
}

.seg .filter-btn.active {
  background: #0f172a;
  color: #ffffff;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.toolbar .search-box {
  flex: 1;
  min-width: 240px;
}

/* Tabela */
.data-table th.group-header.grp-lula { background: #b91c1c; }
.data-table th.group-header.grp-bols { background: #1d4ed8; }
.data-table thead th.th-hl { background: #166534; }
.data-table thead th.th-hist { background: #475569; }
.data-table td.td-hl { background: #f0fdf4; }
.data-table td.td-hist { background: #f8fafc; }

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.8rem;
  color: #334155;
}

.cell-stack .big {
  font-size: 1rem;
  font-weight: 800;
}

.muted {
  color: #94a3b8;
  font-size: 0.8rem;
}

.loc { white-space: nowrap; }

.chev {
  color: #2563eb;
  font-weight: 800;
}

.empty {
  text-align: center;
  padding: 40px !important;
  color: #64748b;
}

.table-foot {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.map-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.map-selects .map-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Notificações embaixo, sem cobrir o painel */
.notify-stack {
  top: auto;
  bottom: 16px;
}

.badge-g1 {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.hero-card.abst { border-top-color: #0f766e; }
.hero-card.abst .cand-name { color: #0f766e; }
.data-table th.group-header.grp-abst { background: #0f766e; }
.hero-grid { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }

/* Ordenação por clique no cabeçalho */
.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table thead th.sortable:hover {
  filter: brightness(1.25);
}

.data-table thead th.sorted {
  box-shadow: inset 0 -3px 0 #facc15;
}

.sort-hint {
  opacity: 0.45;
  font-size: 0.75em;
}

.abst-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.abst-col {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
}

.abst-col .hero-big { font-size: 1.5rem; }
.abst-col .hero-sub { font-size: 0.8rem; }

.abst-col-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #0f766e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.proj-warn {
  background: #faf5ff;
  border: 1px dashed #a855f7;
  color: #581c87;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
}

.status-tse { margin-top: 8px; font-size: 0.8rem; }
.status-tse summary { cursor: pointer; font-weight: 700; color: #6d28d9; }
.data-table th.group-header.grp-bn { background: #475569; }

#tab-grafico .chart-container-box { height: 580px; }

/* Botões de zoom da curva */
.zoom-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; }
.zoom-bar .zoom-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.zoom-bar button {
  border: 1px solid var(--border-color); background: #f8fafc; border-radius: 8px;
  padding: 6px 10px; font-size: 0.85rem; font-weight: 600; cursor: pointer; min-height: 34px;
}
.zoom-bar button:hover { background: #eef2ff; }
.zoom-bar button[data-zoom="in"], .zoom-bar button[data-zoom="out"] { min-width: 40px; font-size: 1.05rem; }
@media (max-width: 700px) {
  #tab-grafico .chart-container-box { height: 72vh; min-height: 440px; }
  .zoom-bar .zoom-label { width: 100%; }
  .zoom-bar button { flex: 1 1 auto; }
}

/* Abas: rolam na horizontal no celular em vez de alargar a página */
.tabs-bar { overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  .tab-btn { padding: 10px 12px; font-size: 0.9rem; }
}
.zoom-bar button.on { background: #ede9fe; border-color: #a78bfa; color: #5b21b6; }
.hero-escopo { font-size: 0.78rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 3px 7px; margin-top: 4px; }
.placar-falta { margin-top: 8px; font-size: 0.85rem; background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 8px; padding: 6px 10px; color: #3b0764; }
.txt-lula { color: var(--lula-red); }
.txt-bols { color: var(--bols-blue); }
.hist-list { font-size: 0.75rem; color: #475569; white-space: normal; overflow-wrap: anywhere; }
.btn-chip { border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8; border-radius: 999px; padding: 5px 12px; font-size: 0.82rem; font-weight: 700; cursor: pointer; }
.btn-chip:hover { background: #dbeafe; }
.transf-list { margin: 4px 0 0; padding-left: 18px; font-size: 0.88rem; line-height: 1.5; }
.transf-list li { margin-bottom: 4px; }

/* Locais de votação */
.loc-search {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
}

.loc-search .search-input {
  padding-left: 12px;
}

.loc-sug {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  max-height: 320px;
  overflow-y: auto;
}

.loc-sug button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.loc-sug button:hover,
.loc-sug button.on {
  background: #eff6ff;
}

.loc-pop {
  font-size: 0.78rem;
  max-width: 300px;
}

.loc-pop table {
  border-collapse: collapse;
  margin-top: 4px;
}

.loc-pop td {
  padding: 1px 6px 1px 0;
}

.loc-secoes {
  max-height: 140px;
  overflow-y: auto;
  margin-top: 6px;
  border-top: 1px solid #e2e8f0;
}

#loc-body tr {
  cursor: pointer;
}

@media (max-width: 700px) {
  #loc-map {
    height: 420px;
  }
}

/* Urnas com zero voto: blocos exportáveis em PNG */
.uz-block { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 16px; margin-top: 16px; }
.uz-block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.uz-block-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.uz-block .uz-sub { font-size: 0.82rem; color: var(--text-muted, #64748b); margin: -4px 0 10px; }
.uz-block .data-table td, .uz-block .data-table th { white-space: nowrap; }
.uz-block .data-table td.uz-local { white-space: normal; min-width: 220px; font-size: 0.8rem; }
.uz-block ul.uz-exp { margin: 0; padding-left: 20px; line-height: 1.55; font-size: 0.9rem; }
.uz-block .uz-src { font-size: 0.72rem; color: var(--text-muted, #64748b); margin-top: 8px; }
.uz-tag { display: inline-block; font-size: 0.7rem; padding: 1px 6px; border-radius: 6px; background: #f1f5f9; color: #475569; margin-left: 4px; }
.uz-tag.ind { background: #fef3c7; color: #92400e; }
/* Tabelas largas saem inteiras; mapa e cartões mantêm a largura da tela */
.uz-exporting:not(#uz-mapa):not(#uz-explicacao) { width: max-content; max-width: none; }
.uz-exporting .btn-export-png { visibility: hidden; }
.uz-exporting .table-container { overflow: visible !important; max-height: none !important; }
.uz-pop-acoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.uz-pop-acoes button, .uz-pin { background: #0f172a; color: #fff; border: none; border-radius: 6px; padding: 4px 8px; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.uz-pin { background: #e2e8f0; color: #0f172a; padding: 2px 6px; }
.uz-exporting .uz-pin { display: none; }
.uz-exporting .leaflet-control-layers { visibility: hidden; }
.uz-block:not(#uz-resumo) .data-table th { cursor: pointer; user-select: none; }
.uz-block .data-table th[data-sort]:not([data-sort=""])::after { content: " " attr(data-sort); }
.uz-exporting .data-table th::after { content: none !important; }
.uz-aprox-ic span { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  border: 2px dashed #94a3b8; background: rgba(255, 255, 255, 0.85); color: #0f172a; font: 800 13px/1 Inter, sans-serif; }
.uz-aprox-leg { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px dashed #64748b; font-size: 10px; font-weight: 800; color: #0f172a; vertical-align: -2px; }
.uz-aprox-nota { margin: 6px 0; padding: 6px 8px; background: #fef3c7; color: #78350f; border-radius: 6px; font-size: 0.78rem; line-height: 1.35; }
.uz-loc-link { color: #1d4ed8; text-decoration: none; }
.uz-loc-link:hover { text-decoration: underline; }
#uz-municipios td.uz-local { min-width: 0; white-space: nowrap; font-size: 0.78rem; line-height: 1.45; }
#uz-municipios .uz-loc-link { display: block; }
.uz-exporting .uz-loc-link { color: inherit; }
@keyframes uz-pisca { 0%, 60% { background: #fde68a; } 100% { background: transparent; } }
tr.uz-destaque td { animation: uz-pisca 3s ease-out; }
.uz-pop-gps { margin-top: 6px; font-size: 0.72rem; color: #64748b; }
/* Tabelas longas das urnas com zero voto: rolagem própria com o cabeçalho fixo (sai inteira no PNG) */
#uz-municipios .table-container, #uz-secoes .table-container { max-height: 75vh; overflow: auto; }
#uz-municipios thead th, #uz-secoes thead th { position: sticky; top: 0; z-index: 2; }
/* Primeira coluna (município) fixa ao rolar para o lado */
#uz-municipios td:first-child, #uz-secoes td:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg-card); box-shadow: 1px 0 0 var(--border-color); }
#uz-municipios thead th:first-child, #uz-secoes thead th:first-child { left: 0; z-index: 3; }
.uz-exporting td:first-child { box-shadow: none; }
@media (max-width: 700px) {
  #uz-municipios .table-container, #uz-secoes .table-container { max-height: 70vh; }
  .uz-block { padding: 12px; }
  .uz-block-head { flex-wrap: wrap; gap: 8px; }
  .uz-block-head h3 { flex-basis: 100%; font-size: 0.95rem; }
  .uz-block .data-table td, .uz-block .data-table th { padding: 8px 10px; font-size: 0.8rem; }
  #uz-municipios td:first-child, #uz-secoes td:first-child { white-space: normal; min-width: 120px; max-width: 150px; }
  #uz-map .leaflet-control-layers { font-size: 0.72rem; }
}

/* "O que pode explicar" em cartões */
.uz-fatos { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.uz-fato { border: 1px solid var(--border-color); border-radius: 10px; padding: 12px 14px; background: #f8fafc; }
.uz-fato-tit { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.uz-fato-big { font-size: 1.6rem; font-weight: 800; line-height: 1.2; margin: 2px 0; color: var(--text-main); }
.uz-fato-sub { font-size: 0.84rem; color: #334155; line-height: 1.45; }
.uz-fato-nota { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; line-height: 1.4; }
.uz-fato .uz-aprox-nota a, .uz-fato-sub a { color: #1d4ed8; }
.uz-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.uz-chips span { background: #e2e8f0; border-radius: 999px; padding: 2px 8px; font-size: 0.72rem; }
.uz-barra { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin-top: 8px; gap: 1px; }
.uz-leg { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.75rem; margin-top: 6px; }
.uz-leg i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.uz-hbars { margin-top: 8px; display: grid; gap: 6px; }
.uz-hbar { display: grid; grid-template-columns: 54px 1fr; gap: 2px 8px; align-items: center; font-size: 0.78rem; }
.uz-hbar-rot { color: var(--text-muted); }
.uz-hbar-trilho { background: #e2e8f0; height: 8px; border-radius: 4px; overflow: hidden; }
.uz-hbar-trilho span { display: block; height: 100%; }
.uz-hbar-val { grid-column: 2; }
.uz-hbar-val small { color: var(--text-muted); }
@media (min-width: 1100px) { .uz-fato:nth-child(4), .uz-fato:nth-child(5) { grid-column: span 2; } }
.uz-pop-hist { width: 100%; border-collapse: collapse; margin: 8px 0 2px; font-size: 0.8rem; }
.uz-pop-hist th { font-size: 0.68rem; text-align: right; padding: 0 4px 2px; font-weight: 700; }
.uz-pop-hist td { padding: 3px 4px; text-align: right; border-top: 1px solid #e2e8f0; font-variant-numeric: tabular-nums; }
.uz-pop-hist td:first-child { text-align: left; color: #64748b; white-space: nowrap; }
.uz-pop-hist td:last-child { width: 70px; }
.uz-pop-hist tr.uz-pop-atual td { font-weight: 800; background: #fef9c3; }
.uz-pop-barra { display: block; height: 6px; background: #2563eb; border-radius: 3px; overflow: hidden; }
.uz-pop-barra span { display: block; height: 100%; background: #dc2626; }
.uz-pop-leg { font-size: 0.66rem; color: #64748b; line-height: 1.3; margin-bottom: 6px; }
.uz-leg-col { flex-direction: column; gap: 3px; }
@media (max-width: 700px) {
  /* Popup aberto no celular: esconde zoom e camadas, que ficariam por cima do título */
  #uz-map:has(.leaflet-popup) .leaflet-control-zoom, #uz-map:has(.leaflet-popup) .leaflet-control-layers { visibility: hidden; }
}
.uz-visao-bar { margin-top: 16px; flex-wrap: wrap; gap: 8px; align-items: center; }
.uz-mapa-ref { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; color: var(--text-main); font-weight: 600; }
.uz-mapa-ref .seg .filter-btn { padding: 4px 12px; }
.uz-exporting .uz-mapa-ref .filter-btn:not(.active) { display: none; }
.uz-mapa-leg { margin-top: 8px; align-items: center; }
