/* ============================================================
   Calculadora de Retotalização Eleitoral — Design System 2.0
   ============================================================ */

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens — Sistema RetotalizaJE ────────────────────── */
:root {
  /* ── Core palette ────────────────────────────────────────────── */
  --navy:          #0F1C2E;
  --navy-mid:      #1A2F4A;
  --navy-light:    #2A4A6B;
  --navy-border:   rgba(255,255,255,0.10);
  --gold:          #F59E0B;
  --gold-light:    #FCD34D;
  --teal:          #10B981;
  --teal-light:    #34D399;
  --slate:         #F1F5F9;
  --slate-mid:     #E2E8F0;
  --slate-dark:    #CBD5E1;
  --text-main:     #0F172A;
  --text-muted:    #475569;
  --text-hint:     #94A3B8;
  --f1-color:      #3B82F6;
  --f2-color:      #10B981;
  --f3-color:      #F59E0B;
  --white:         #ffffff;

  /* ── Extended accent tokens ──────────────────────────────────── */
  --accent-blue:   #3B82F6;
  --accent-green:  #10B981;
  --accent-amber:  #F59E0B;
  --accent-red:    #EF4444;
  --surface-light: #F1F5F9;

  /* ── Legacy aliases (JS-generated classes reference these) ───── */
  --cor-primaria:       var(--navy);
  --cor-primaria-clara: var(--navy-mid);
  --cor-acento:         var(--gold);
  --cor-fundo:          var(--slate);
  --cor-fundo-card:     var(--white);
  --cor-borda:          var(--slate-mid);
  --cor-texto:          var(--text-main);
  --cor-texto-fraco:    var(--text-muted);
  --cor-eleito:         #065F46;
  --cor-eleito-fundo:   #ECFDF5;
  --cor-barrado:        #991B1B;
  --cor-barrado-fundo:  #FEF2F2;
  --cor-alerta:         #92400E;
  --cor-alerta-fundo:   #FFFBEB;
  --cor-fase3:          #1E3A5F;
  --cor-fase3-fundo:    #EFF6FF;
  --raio:               8px;
  --sombra:             0 4px 16px rgba(0,0,0,.12);
}

/* ── Base ────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--slate);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   ZONA 1 — TOPBAR
   ═══════════════════════════════════════════════════════════════ */
.topbar {
  background: var(--navy);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--navy-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-icon {
  width: 28px; height: 28px;
  background: var(--gold);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-icon svg { width: 16px; height: 16px; fill: var(--navy); }

.topbar-title {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: normal;
  color: var(--white);
  line-height: 1.2;
  cursor: default;
  margin: 0;
  padding: 0;
}
.topbar-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
  margin-top: 2px;
}
.topbar-adi-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--gold-light);
  background: rgba(201,152,58,0.12);
  border: 1px solid rgba(201,152,58,0.25);
  padding: 3px 8px;
  border-radius: 4px;
}
.topbar-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
}
.topbar-docs-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}
.topbar-docs-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); }

/* ═══════════════════════════════════════════════════════════════
   ZONA 2 — APP BODY (sidebar + main)
   ═══════════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--navy);
  border-right: 1px solid var(--navy-border);
  padding: 0 0 16px;
  overflow-y: auto;
  height: calc(100vh - 52px - 40px);
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--navy-border);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.sidebar-label-optional {
  font-size: 9px;
  opacity: 0.7;
  font-weight: 400;
}
.sidebar-field { margin-bottom: 8px; }
.sidebar-field:last-child { margin-bottom: 0; }

/* ── Sidebar: field components ───────────────────────────────── */
.field-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 4px;
  display: block;
}
.field-input, .field-select {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 7px 10px;
  color: rgba(255,255,255,0.8);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field-input::placeholder { color: rgba(255,255,255,0.2); }
.field-input:focus, .field-select:focus {
  border-color: rgba(201,152,58,0.5);
  background: rgba(255,255,255,0.08);
}
.field-select option { background: var(--navy-mid); color: rgba(255,255,255,0.85); }

.field-input-num {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--gold-light);
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s;
}
.field-input-num:focus { border-color: rgba(201,152,58,0.5); }
.field-input-num::placeholder { color: rgba(201,152,58,0.25); font-size: 14px; }

/* ── Sidebar: toggle ─────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: background 0.15s;
}
.toggle-row:hover { background: rgba(255,255,255,0.06); }
.toggle-native { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-box {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.2);
  margin-top: 3px;
  flex-shrink: 0;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--gold);
}
.toggle-native:checked ~ .toggle-box,
.toggle-row:has(input:checked) .toggle-box {
  background: rgba(201,152,58,0.2);
  border-color: rgba(201,152,58,0.5);
}
.toggle-native:checked ~ .toggle-box::after {
  content: '✓';
}
.toggle-text-title {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  display: block;
  font-weight: 500;
  margin-bottom: 2px;
  line-height: 1.3;
}
.toggle-text-desc {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  line-height: 1.4;
}

/* ── Sidebar: party cards (JS-generated) ─────────────────────── */
.partido-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 10px 10px 8px;
  margin-bottom: 8px;
}
.partido-card-header {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: flex-start;
  margin-bottom: 0;
}
/* Force inputs to work inside narrow sidebar (override inline width styles) */
.partido-sigla    { width: 86px !important; }
.partido-nome     { width: auto !important; flex: 1 !important; min-width: 70px !important; }
.partido-nominais { width: 100% !important; }
.partido-legenda  { width: 100% !important; }
.partido-card-header .input-valida { flex: 1 1 100px; }
.partido-card-header .input-valida:first-child { flex: 0 0 auto; }

/* Style all inputs inside party cards */
.partido-card input {
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 5px;
  color: rgba(255,255,255,0.8);
  padding: 5px 8px;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.partido-card input:focus { border-color: rgba(201,152,58,0.45) !important; }
.partido-card input::placeholder { color: rgba(255,255,255,0.18); font-size: 10px; }
.partido-card .partido-sigla {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--white);
  letter-spacing: 0.04em;
}
.partido-card .partido-nominais,
.partido-card .partido-legenda {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.candidatos-wrapper { margin-top: 8px; }
.candidatos-lista { padding-left: 0; }
.candidato-row {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.candidato-row input {
  background: rgba(255,255,255,0.05) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 4px;
  color: rgba(255,255,255,0.7);
  padding: 4px 7px;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  outline: none;
  flex: 1;
}
.candidato-row input.votos { width: 90px !important; flex: 0 0 90px; font-family: 'JetBrains Mono', monospace; }
.candidato-row input[style*="width:80px"] { width: 70px !important; flex: 0 0 70px; }

/* ── Sidebar: cassation rows ─────────────────────────────────── */
.cassacao-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 8px 8px 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
}
.cassacao-row input, .cassacao-row select {
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 5px;
  color: rgba(255,255,255,0.8);
  padding: 5px 8px;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.cassacao-row input:focus, .cassacao-row select:focus {
  border-color: rgba(201,152,58,0.45) !important;
}
.cass-partido  { width: 80px !important; flex: 0 0 80px; font-family: 'JetBrains Mono', monospace; }
.cass-candidato { width: auto !important; flex: 1 1 100px; min-width: 80px; }
.cass-votos    { width: 100% !important; font-family: 'JetBrains Mono', monospace; }
.cass-modalidade { width: 100% !important; flex: 1 1 110px; }
.cassacao-row .input-valida { flex: 1 1 100px; }
.cassacao-row select option { background: var(--navy-mid); }

/* ── Sidebar: presets ────────────────────────────────────────── */
.sidebar-preset-nota {
  margin-top: 8px;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 5px;
}

/* ── Sidebar: buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--raio);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  padding: 7px 12px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
}
.btn-calcular {
  width: 100%;
  background: var(--gold);
  border: none;
  border-radius: 8px;
  padding: 12px;
  color: var(--navy);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.1s;
  display: block;
}
.btn-calcular:hover  { background: var(--gold-light); }
.btn-calcular:active { transform: scale(0.98); }
.btn-calcular:disabled { opacity: 0.45; cursor: not-allowed; background: var(--gold); transform: none; }

.btn-sidebar-add {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 6px;
  color: rgba(255,255,255,0.45);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 7px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 6px;
  display: block;
}
.btn-sidebar-add:hover { background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.7); }
.btn-sidebar-clear {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.35);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 7px;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.15s;
  display: block;
}
.btn-sidebar-clear:hover { background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.6); }

/* Buttons inside partido/cassacao cards */
.sidebar .btn-perigo {
  background: rgba(180,40,30,0.2);
  color: rgba(230,110,100,0.9);
  border: 1px solid rgba(180,40,30,0.3);
  font-family: 'JetBrains Mono', monospace;
}
.sidebar .btn-perigo:hover { background: rgba(180,40,30,0.35); }
.sidebar .btn-secundario {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.1);
  font-family: 'JetBrains Mono', monospace;
}
.sidebar .btn-secundario:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }
.btn-sm  { padding: 4px 9px; font-size: 11px; }
.btn-xs  { padding: 3px 6px; font-size: 10px; border-radius: 4px; }

/* Sidebar actions area */
.sidebar-actions { display: flex; flex-direction: column; gap: 6px; }

/* ── Sidebar: validation (dark context) ──────────────────────── */
.sidebar input.invalido {
  border-color: rgba(210,60,50,0.7) !important;
  box-shadow: 0 0 0 2px rgba(210,60,50,0.12);
}
.sidebar input.valido {
  border-color: rgba(42,157,143,0.6) !important;
  box-shadow: 0 0 0 2px rgba(42,157,143,0.1);
}
.sidebar .campo-erro {
  color: rgba(240,120,110,0.9);
  font-size: 10px;
  margin-top: 3px;
  font-family: 'Inter', sans-serif;
  line-height: 1.35;
}
.input-valida { display: flex; flex-direction: column; }

/* Error messages in main context */
.campo-erro {
  display: block;
  color: #c0392b;
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.35;
}
input.invalido { border-color: #c0392b !important; box-shadow: 0 0 0 2px rgba(192,57,43,.12); }
input.valido   { border-color: #27ae60 !important; box-shadow: 0 0 0 2px rgba(39,174,96,.10); }

/* ── Sidebar: errors/warnings box ────────────────────────────── */
#erros-formulario {
  padding: 0 16px;
}
#erros-formulario .alerta {
  font-size: 11px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 5px;
}

/* ═══════════════════════════════════════════════════════════════
   ZONA 3 — MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  height: calc(100vh - 52px - 40px);
  min-width: 0;
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 0;
  opacity: 0.45;
  min-height: 320px;
}
.empty-state svg { width: 56px; height: 56px; opacity: 0.6; }
.empty-title {
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  color: var(--text-muted);
  text-align: center;
}
.empty-sub {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-hint);
  text-align: center;
  max-width: 300px;
  line-height: 1.55;
}

/* Show/hide empty state using :has() — no JS needed */
.main-content:has(#painel-parametros .param-item) .empty-state { display: none; }
.main-content:not(:has(#painel-parametros .param-item)) .result-sections { display: none; }

/* ── QE Banner (#painel-parametros restyled) ─────────────────── */
.result-sections { display: flex; flex-direction: column; gap: 16px; }

#painel-parametros.params-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--slate-mid);
  overflow: hidden;
  margin-bottom: 0;
}
#painel-parametros .param-item {
  flex: 1 1 140px;
  padding: 16px 20px;
  border-right: 1px solid var(--slate-mid);
  border-radius: 0;
  background: none;
  border-top: none;
  border-bottom: none;
  border-left: none;
  box-shadow: none;
}
#painel-parametros .param-item:last-child { border-right: none; }
#painel-parametros .param-item .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
#painel-parametros .param-item .valor {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: -0.02em;
  margin-top: 4px;
}
#painel-parametros .param-item .detalhe {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-hint);
  margin-top: 3px;
}

/* ── Phase nav ───────────────────────────────────────────────── */
.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.phase-nav {
  display: flex;
  gap: 3px;
  background: var(--white);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--slate-mid);
}
.phase-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
}
.phase-tab:hover { background: var(--slate); }
.phase-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.phase-dot-f1 { background: var(--f1-color); }
.phase-dot-f2 { background: var(--f2-color); }
.phase-dot-f3 { background: var(--f3-color); }
.phase-dot-audit { background: var(--text-hint); }
.phase-tab-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.phase-tab.active[data-phase="f1"]    { background: rgba(58,123,213,0.1); }
.phase-tab.active[data-phase="f2"]    { background: rgba(42,157,143,0.1); }
.phase-tab.active[data-phase="f3"]    { background: rgba(201,152,58,0.1); }
.phase-tab.active[data-phase="audit"] { background: rgba(15,25,35,0.06); }
.phase-tab.active[data-phase="f1"]    .phase-tab-label { color: var(--f1-color); font-weight: 500; }
.phase-tab.active[data-phase="f2"]    .phase-tab-label { color: var(--f2-color); font-weight: 500; }
.phase-tab.active[data-phase="f3"]    .phase-tab-label { color: var(--f3-color); font-weight: 500; }
.phase-tab.active[data-phase="audit"] .phase-tab-label { color: var(--text-main); font-weight: 500; }

.phase-count-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.count-f1    { background: rgba(58,123,213,0.15); color: var(--f1-color); }
.count-f2    { background: rgba(42,157,143,0.15); color: var(--f2-color); }
.count-f3    { background: rgba(201,152,58,0.15); color: var(--f3-color); }
.count-audit { background: rgba(0,0,0,0.06); color: var(--text-muted); }

/* ── Export action buttons ───────────────────────────────────── */
.export-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-action {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--slate-dark);
  background: var(--white);
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.1s;
  white-space: nowrap;
}
.btn-action:hover { background: var(--slate); }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-action-primary {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(15,25,35,0.25);
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.btn-action-primary:hover { background: var(--navy-mid); }
.btn-action-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Result panel ────────────────────────────────────────────── */
.result-panel {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--slate-mid);
  overflow: hidden;
}
.result-panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--slate-mid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.result-panel-title {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--navy);
}
.result-panel-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-hint);
}

/* ── Result table ────────────────────────────────────────────── */
.tabela-scroll { overflow-x: auto; }
.result-panel .tabela-scroll table,
table { width: 100%; border-collapse: collapse; }

.result-panel table thead tr,
thead tr { background: var(--slate); border-bottom: 2px solid var(--slate-mid); }

.result-panel table th,
th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-hint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 14px;
  font-weight: 500;
  text-align: left;
  background: var(--slate);
  white-space: nowrap;
}
th.center, td.center { text-align: center; }
th.right, td.right   { text-align: right; }

.result-panel table tbody tr,
tbody tr {
  border-bottom: 1px solid var(--slate-mid);
  transition: background 0.1s;
}
.result-panel table tbody tr:last-child,
tbody tr:last-child { border-bottom: none; }
.result-panel table tbody tr:hover,
tbody tr:hover { background: #f7f9fb; }

.result-panel table td,
td {
  font-family: 'Inter', sans-serif;
  padding: 11px 14px;
  vertical-align: middle;
  font-size: 13px;
}
/* Numbers use monospace */
td.right, td.center {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Phase cells (F1/F2/F3 columns — always cols 5,6,7 in result table) */
td.td-fase {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  cursor: help;
  text-decoration: underline dotted var(--slate-dark);
  text-underline-offset: 3px;
}
td.td-fase:hover { text-decoration-color: var(--text-muted); }

.result-panel .tabela-scroll table tbody td:nth-child(5).td-fase {
  background: rgba(58,123,213,0.07); color: #1a5aa0;
}
.result-panel .tabela-scroll table tbody td:nth-child(6).td-fase {
  background: rgba(42,157,143,0.07); color: #0f6e56;
}
.result-panel .tabela-scroll table tbody td:nth-child(7).td-fase {
  background: rgba(201,152,58,0.07); color: #8a5a10;
}

/* Row status coloring */
tr.eleito td  { background: rgba(26,107,58,0.04); }
tr.eleito td:first-child  { border-left: 3px solid var(--cor-eleito); }
tr.barrado td { background: rgba(139,26,26,0.04); }
tr.barrado td:first-child { border-left: 3px solid var(--cor-barrado); }
tr.fase3 td   { background: rgba(26,61,107,0.04); }
tr.fase3 td:first-child   { border-left: 3px solid var(--f1-color); }
tr.qualificado td:first-child { border-left: 3px solid var(--gold); }

.row-vencedor td { background: rgba(26,107,58,0.07) !important; font-weight: 600; }
.row-excluido td { color: var(--text-hint); font-style: italic; }

/* Audit sub-table headers */
.rodada-body table th {
  background: var(--slate);
  color: var(--text-muted);
  font-size: 10px;
}

/* ── Badges (JS-generated) ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.badge-eleito     { background: rgba(26,107,58,0.1);  color: var(--cor-eleito); border: 1px solid rgba(26,107,58,0.2); }
.badge-barrado    { background: rgba(139,26,26,0.1);  color: var(--cor-barrado); border: 1px solid rgba(139,26,26,0.2); }
.badge-qualificado{ background: rgba(201,152,58,0.1); color: #7a4f00; border: 1px solid rgba(201,152,58,0.25); }
.badge-fase3      { background: rgba(26,61,107,0.1);  color: var(--cor-fase3); border: 1px solid rgba(26,61,107,0.2); }

/* Badge zone (F2 eligibility in table) */
.badge-zona {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 3px;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  letter-spacing: 0.02em;
}
.zona-apta     { background: rgba(42,157,143,0.1);  color: #0f6e56; border: 1px solid rgba(42,157,143,0.2); }
.zona-sensivel { background: rgba(201,152,58,0.1);  color: #8a5a10; border: 1px solid rgba(201,152,58,0.2); }
.zona-excluida { background: var(--slate); color: var(--text-hint); border: 1px solid var(--slate-dark); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alerta {
  background: var(--cor-alerta-fundo);
  border: 1px solid #e8c840;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}
.alerta.critico { background: var(--cor-barrado-fundo); border-color: #e88080; border-left-color: var(--cor-barrado); color: var(--cor-barrado); }
.alerta.info    { background: var(--cor-fase3-fundo);   border-color: #80aadd; border-left-color: #3a7bd5; color: var(--cor-fase3); }
.alerta-titulo  { font-weight: 700; margin-bottom: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* Fase banner (F3 activated) */
.fase-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; font-size: 13px; font-family: 'Inter', sans-serif; }
.fase-banner.fase3 { background: var(--cor-fase3-fundo); color: var(--cor-fase3); border: 1px solid #a8c8f0; }
.fase-banner.normal { background: var(--cor-eleito-fundo); color: var(--cor-eleito); border: 1px solid #a8d9b4; }

/* Comparativo variation cells */
.var-cell { font-family: 'JetBrains Mono', monospace; font-weight: 700; text-align: center; font-size: 12px; }
.var-pos   { color: #0f6e56; }
.var-neg   { color: #8b1a1a; }
.var-zero  { color: var(--text-hint); }

/* ═══════════════════════════════════════════════════════════════
   AUDIT PANEL
   ═══════════════════════════════════════════════════════════════ */
.audit-panel {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--slate-mid);
  padding: 18px 20px;
}
.audit-panel-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-hint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* Audit cards (JS-generated .rodada-card) */
.auditoria-container { display: flex; flex-direction: column; gap: 8px; }
.rodada-card { border: 1px solid var(--slate-mid); border-radius: 8px; overflow: hidden; transition: box-shadow 0.15s; }
.rodada-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

.rodada-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--slate);
  border-bottom: 1px solid var(--slate-mid);
  user-select: none;
  transition: background 0.1s;
}
.rodada-header:hover { background: var(--slate-mid); }
.rodada-header span { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

.fase-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(42,157,143,0.12);
  color: #0f6e56;
  white-space: nowrap;
}
.fase-badge.fase3 { background: rgba(201,152,58,0.12); color: #8a5a10; }

.rodada-header .vencedor  { font-weight: 700; color: var(--navy); font-family: 'JetBrains Mono', monospace; }
.rodada-header .media     { color: var(--text-muted); font-size: 11px; font-family: 'JetBrains Mono', monospace; }
.rodada-header .candidato { font-size: 11px; color: var(--cor-eleito); font-family: 'Inter', sans-serif; font-style: italic; }

.rodada-body { padding: 12px; display: none; }
.rodada-body.aberto { display: block; }
.rodada-fundamentacao { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--text-muted); margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--slate-mid); line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════════
   COMPARE PANEL
   ═══════════════════════════════════════════════════════════════ */
.compare-panel {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--slate-mid);
  overflow: hidden;
}
.compare-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--slate-mid);
  background: rgba(200,40,20,0.03);
  display: flex;
  align-items: center;
  gap: 10px;
}
.compare-header-icon {
  width: 22px; height: 22px; border-radius: 4px;
  background: rgba(200,40,20,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #8a2010; flex-shrink: 0;
}
.compare-header-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--navy);
}
.compare-header-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-hint);
  margin-left: auto;
}
.compare-panel .comparativo-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}
.compare-panel .card {
  background: var(--slate);
  border: 1px solid var(--slate-mid);
  border-radius: 8px;
  overflow: hidden;
}
.compare-panel .alerta { margin: 0 16px 16px; }

/* ═══════════════════════════════════════════════════════════════
   DOCS SECTION
   ═══════════════════════════════════════════════════════════════ */
.docs-section { display: none; }
.docs-container { max-width: 820px; padding: 24px; }
.docs-container h2 {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: var(--navy);
  margin: 24px 0 8px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 5px;
}
.docs-container h2:first-child { margin-top: 0; }
.docs-container h3 { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--navy-mid); margin: 16px 0 6px; }
.docs-container p  { font-family: 'Inter', sans-serif; margin-bottom: 10px; line-height: 1.65; font-size: 13px; }
.docs-container ul { padding-left: 20px; margin-bottom: 10px; }
.docs-container li { font-family: 'Inter', sans-serif; font-size: 13px; margin-bottom: 5px; }
.docs-container .formula {
  background: var(--slate);
  border: 1px solid var(--slate-mid);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  margin: 10px 0;
  color: var(--navy);
}
.glossario-item { display: flex; gap: 12px; margin-bottom: 10px; font-family: 'Inter', sans-serif; font-size: 13px; }
.glossario-item .termo { font-family: 'JetBrains Mono', monospace; font-weight: 700; min-width: 80px; color: var(--navy); font-size: 12px; }

/* ═══════════════════════════════════════════════════════════════
   ZONA 5 — FOOTER
   ═══════════════════════════════════════════════════════════════ */
.footer {
  background: var(--navy);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--navy-border);
  height: 40px;
  flex-shrink: 0;
}
.footer-legal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.04em;
}
.footer-disclaimer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.15);
}

/* ═══════════════════════════════════════════════════════════════
   MODO APRESENTAÇÃO
   ═══════════════════════════════════════════════════════════════ */
#apres-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #fff;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#apres-sair {
  display: none;
  position: fixed;
  top: 14px;
  right: 20px;
  z-index: 9010;
  background: var(--navy);
  color: rgba(255,255,255,0.7);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--navy-border);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
body.modo-apresentacao #apres-overlay { display: block; }
body.modo-apresentacao #apres-sair    { display: inline-flex; align-items: center; }

#apres-conteudo { max-width: 1300px; margin: 0 auto; padding: 48px 40px 80px; }
#apres-titulo {
  font-family: 'Inter', sans-serif;
  font-size: 28pt;
  font-weight: normal;
  text-align: center;
  color: var(--navy);
  margin-bottom: 8px;
  line-height: 1.2;
}
#apres-subtitulo {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-hint);
  margin-bottom: 40px;
  letter-spacing: 0.03em;
}
#apres-tabela .tabela-scroll { overflow-x: auto; }
#apres-tabela table { font-size: 16pt; width: 100%; }
#apres-tabela th    { font-size: 12pt; padding: 12px 16px; }
#apres-tabela td    { padding: 12px 16px; }
body.modo-apresentacao #apres-tabela .badge-zona { font-size: 11pt; padding: 3px 9px; margin-top: 4px; }
body.modo-apresentacao #apres-tabela .badge      { font-size: 11pt; padding: 3px 10px; }

/* ═══════════════════════════════════════════════════════════════
   MÓDULO DE IMPORTAÇÃO TSE
   ═══════════════════════════════════════════════════════════════ */

/* Cabeçalho: toggle + link TSE lado a lado */
.import-header {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

/* Botão de toggle do painel */
.import-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  background: rgba(42,157,143,0.1);
  border: 1px solid rgba(42,157,143,0.25);
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
}
.import-toggle-btn:hover {
  background: rgba(42,157,143,0.18);
  border-color: rgba(42,157,143,0.4);
  color: rgba(255,255,255,0.9);
}
.import-toggle-btn[aria-expanded="true"] {
  background: rgba(42,157,143,0.18);
  border-color: rgba(42,157,143,0.45);
  color: var(--teal-light);
}
.import-toggle-icon {
  font-size: 12px;
  line-height: 1;
}

/* Link "Portal TSE" */
.import-link-tse {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(255,255,255,0.3);
  text-decoration: none;
  padding: 4px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.07);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.import-link-tse:hover { color: rgba(255,255,255,0.6); border-color: rgba(255,255,255,0.15); }

/* Corpo colapsável */
#import-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Passo de importação */
.import-step { display: flex; flex-direction: column; gap: 3px; }
.import-step-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}
.import-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(42,157,143,0.2);
  border: 1px solid rgba(42,157,143,0.35);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--teal-light);
  flex-shrink: 0;
}
.import-step-req  { color: var(--gold-light); font-size: 10px; }
.import-step-opt  { color: rgba(255,255,255,0.3); font-size: 10px; }
.import-step-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(255,255,255,0.2);
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}

/* Input de arquivo */
.import-file-input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 5px;
  padding: 5px 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.import-file-input:hover,
.import-file-input:focus {
  border-color: rgba(42,157,143,0.4);
  background: rgba(255,255,255,0.07);
  outline: none;
}
/* Safari/iOS: estilo do label do file input */
.import-file-input::file-selector-button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: rgba(42,157,143,0.15);
  border: 1px solid rgba(42,157,143,0.3);
  border-radius: 4px;
  color: var(--teal-light);
  padding: 3px 8px;
  cursor: pointer;
  margin-right: 8px;
}

/* Filtros */
.import-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.import-filter-field { display: flex; flex-direction: column; gap: 3px; }
.import-filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.import-filter-select {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  padding: 5px 8px;
  color: rgba(255,255,255,0.7);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  outline: none;
  transition: border-color 0.15s;
}
.import-filter-select:focus { border-color: rgba(42,157,143,0.45); }
.import-filter-select option { background: var(--navy-mid); }

/* Botão processar */
.import-btn-processar {
  width: 100%;
  background: rgba(42,157,143,0.18);
  border: 1px solid rgba(42,157,143,0.35);
  border-radius: 7px;
  color: var(--teal-light);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
}
.import-btn-processar:hover  { background: rgba(42,157,143,0.28); border-color: rgba(42,157,143,0.5); }
.import-btn-processar:active { transform: scale(0.98); }
.import-btn-processar:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Status / progresso */
.import-status {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  line-height: 1.5;
  padding: 0;
  border-radius: 5px;
}
.import-status:empty { display: none; }
.import-status.progresso {
  color: rgba(255,255,255,0.5);
  font-style: italic;
}
.import-status.ok {
  color: var(--teal-light);
  background: rgba(42,157,143,0.08);
  border: 1px solid rgba(42,157,143,0.2);
  padding: 6px 10px;
  border-radius: 5px;
}
.import-status.aviso {
  color: var(--gold-light);
  background: rgba(201,152,58,0.08);
  border: 1px solid rgba(201,152,58,0.2);
  padding: 6px 10px;
  border-radius: 5px;
}
.import-status.erro {
  color: rgba(240,120,110,0.95);
  background: rgba(180,40,30,0.1);
  border: 1px solid rgba(180,40,30,0.25);
  padding: 6px 10px;
  border-radius: 5px;
}

/* Spinner animado */
.import-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(42,157,143,0.3);
  border-top-color: var(--teal-light);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* Badge de confirmação */
.import-badge {
  margin-top: 8px;
  background: rgba(42,157,143,0.1);
  border: 1px solid rgba(42,157,143,0.25);
  border-radius: 6px;
  padding: 8px 10px;
}
.import-badge-linha1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--teal-light);
  margin-bottom: 2px;
}
.import-badge-linha2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  line-height: 1.4;
}
.import-badge-linha3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
  word-break: break-all;
}

/* ── Tab stubs (always hidden, kept for JS compat) ───────────── */
.tab-content { display: none !important; }

/* ── Animations ──────────────────────────────────────────────── */
.fade-in { animation: fadeIn 0.2s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Legacy: preset bar (sidebar context replaces this) ──────── */
.preset-bar { display: none; }

/* ── Responsivo ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  #app { height: auto; }
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; height: auto; position: static; overflow-y: visible; }
  .main-content { height: auto; overflow-y: visible; }
  .phase-nav { flex-wrap: wrap; }
  .topbar-adi-badge { display: none; }
  .footer-disclaimer { display: none; }
  .compare-panel .comparativo-container { grid-template-columns: 1fr; }
  #painel-parametros.params-grid { flex-direction: column; }
  #painel-parametros .param-item { border-right: none; border-bottom: 1px solid var(--slate-mid); }
}

/* ═══════════════════════════════════════════════════════════════
   SISTEMA RETOTALIZAJE — Overrides v4
   Palette update, Inter/JetBrains Mono, refined shadows, WCAG AA
   ═══════════════════════════════════════════════════════════════ */

/* ── Topbar refinements ──────────────────────────────────────── */
.topbar-title {
  font-size: 15px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
}
.topbar-sub {
  font-size: 10px !important;
  letter-spacing: 0.06em !important;
}
.topbar-adi-badge {
  font-size: 10px !important;
  background: rgba(245,158,11,0.14) !important;
  border-color: rgba(245,158,11,0.3) !important;
  color: #FCD34D !important;
}

/* ── Sidebar refinements ─────────────────────────────────────── */
.sidebar-label {
  font-weight: 600 !important;
  letter-spacing: 0.09em !important;
}
.field-label {
  font-weight: 500 !important;
}
.field-input, .field-select {
  font-family: 'Inter', sans-serif !important;
}
.field-input:focus, .field-select:focus {
  border-color: rgba(59,130,246,0.55) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15) !important;
}
.field-input-num {
  font-family: 'JetBrains Mono', monospace !important;
  color: #FCD34D !important;
}
.field-input-num:focus {
  border-color: rgba(59,130,246,0.55) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15) !important;
}

/* ── Calcular button — accent blue (WCAG AA: white on #2563EB ≈ 5.9:1) ── */
.btn-calcular {
  background: #2563EB !important;
  color: #ffffff !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  font-size: 14px !important;
  letter-spacing: 0.02em !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35) !important;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s !important;
}
.btn-calcular:hover {
  background: #1D4ED8 !important;
  box-shadow: 0 6px 18px rgba(37,99,235,0.45) !important;
}
.btn-calcular:active { transform: scale(0.98) !important; }
.btn-calcular:disabled {
  background: rgba(37,99,235,0.4) !important;
  box-shadow: none !important;
  color: rgba(255,255,255,0.6) !important;
  transform: none !important;
}

/* ── Sidebar action buttons ──────────────────────────────────── */
.btn-sidebar-add {
  font-family: 'Inter', sans-serif !important;
  border-radius: 8px !important;
  font-weight: 500 !important;
}
.btn-sidebar-clear {
  font-family: 'Inter', sans-serif !important;
  border-radius: 8px !important;
}

/* ── Party and cassation cards ───────────────────────────────── */
.partido-card {
  border-radius: 10px !important;
}
.partido-card input {
  font-family: 'Inter', sans-serif !important;
  border-radius: 6px !important;
}
.partido-card input:focus { box-shadow: 0 0 0 2px rgba(59,130,246,0.2) !important; }

.cassacao-row {
  border-radius: 8px !important;
}
.cassacao-row input, .cassacao-row select {
  font-family: 'Inter', sans-serif !important;
  border-radius: 6px !important;
}
.cassacao-row input:focus, .cassacao-row select:focus {
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2) !important;
}

/* ── Main panels — elevated shadows ─────────────────────────── */
.result-panel {
  border-radius: 14px !important;
  box-shadow: 0 2px 12px rgba(15,23,42,0.07) !important;
}
.audit-panel {
  border-radius: 14px !important;
  box-shadow: 0 2px 12px rgba(15,23,42,0.07) !important;
}
.compare-panel {
  border-radius: 14px !important;
  box-shadow: 0 2px 12px rgba(15,23,42,0.07) !important;
}
#painel-parametros.params-grid {
  border-radius: 14px !important;
  box-shadow: 0 2px 12px rgba(15,23,42,0.07) !important;
}

/* ── Phase nav refinements ───────────────────────────────────── */
.phase-nav {
  border-radius: 12px !important;
  box-shadow: 0 1px 4px rgba(15,23,42,0.06) !important;
}
.phase-tab {
  border-radius: 9px !important;
  font-family: 'Inter', sans-serif !important;
}
.phase-tab-label {
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 11px !important;
}
.phase-tab.active[data-phase="f1"] { background: rgba(59,130,246,0.12) !important; }
.phase-tab.active[data-phase="f2"] { background: rgba(16,185,129,0.12) !important; }
.phase-tab.active[data-phase="f3"] { background: rgba(245,158,11,0.12) !important; }
.phase-tab.active[data-phase="f1"] .phase-tab-label { color: #3B82F6 !important; }
.phase-tab.active[data-phase="f2"] .phase-tab-label { color: #059669 !important; }
.phase-tab.active[data-phase="f3"] .phase-tab-label { color: #D97706 !important; }

/* Phase count badges */
.count-f1 { background: rgba(59,130,246,0.15) !important; color: #2563EB !important; }
.count-f2 { background: rgba(16,185,129,0.15) !important; color: #059669 !important; }
.count-f3 { background: rgba(245,158,11,0.15) !important; color: #D97706 !important; }

/* ── Export action buttons ───────────────────────────────────── */
.btn-action {
  font-family: 'JetBrains Mono', monospace !important;
  border-radius: 7px !important;
  transition: background 0.12s, border-color 0.12s !important;
}
.btn-action:focus-visible {
  outline: 2px solid #3B82F6 !important;
  outline-offset: 2px !important;
}
.btn-action-primary {
  font-family: 'JetBrains Mono', monospace !important;
  border-radius: 7px !important;
}
.btn-action-primary:focus-visible {
  outline: 2px solid #60A5FA !important;
  outline-offset: 2px !important;
}

/* Salvar Estudo button: green accent */
#btn-salvar-estudo:not(:disabled) {
  background: rgba(16,185,129,0.08) !important;
  color: #059669 !important;
  border-color: rgba(16,185,129,0.35) !important;
}
#btn-salvar-estudo:not(:disabled):hover {
  background: rgba(16,185,129,0.16) !important;
  border-color: rgba(16,185,129,0.55) !important;
}

/* ── Result table refinements ────────────────────────────────── */
.result-panel table th,
th {
  font-family: 'JetBrains Mono', monospace !important;
  letter-spacing: 0.07em !important;
}
.result-panel table td,
td {
  font-family: 'Inter', sans-serif !important;
}
td.right, td.center {
  font-family: 'JetBrains Mono', monospace !important;
}
td.td-fase {
  font-family: 'JetBrains Mono', monospace !important;
}

/* F1/F2/F3 phase column tints — updated colours */
.result-panel .tabela-scroll table tbody td:nth-child(5).td-fase {
  background: rgba(59,130,246,0.08) !important; color: #1D4ED8 !important;
}
.result-panel .tabela-scroll table tbody td:nth-child(6).td-fase {
  background: rgba(16,185,129,0.08) !important; color: #065F46 !important;
}
.result-panel .tabela-scroll table tbody td:nth-child(7).td-fase {
  background: rgba(245,158,11,0.08) !important; color: #92400E !important;
}

/* ── Audit panel ─────────────────────────────────────────────── */
.rodada-card { border-radius: 10px !important; }
.fase-badge {
  background: rgba(16,185,129,0.12) !important;
  color: #065F46 !important;
}
.fase-badge.fase3 {
  background: rgba(245,158,11,0.12) !important;
  color: #92400E !important;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge-eleito  { background: rgba(6,95,70,0.10)  !important; color: #065F46 !important; border-color: rgba(6,95,70,0.2) !important; }
.badge-barrado { background: rgba(153,27,27,0.10) !important; color: #991B1B !important; border-color: rgba(153,27,27,0.2) !important; }
.badge-fase3   { background: rgba(30,58,95,0.10)  !important; color: #1E3A5F !important; border-color: rgba(30,58,95,0.2) !important; }

/* Zone badges */
.zona-apta     { background: rgba(16,185,129,0.10) !important; color: #065F46 !important; border-color: rgba(16,185,129,0.2) !important; }
.zona-sensivel { background: rgba(245,158,11,0.10) !important; color: #92400E !important; border-color: rgba(245,158,11,0.2) !important; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alerta {
  border-left-color: var(--gold) !important;
  border-radius: 10px !important;
  font-family: 'Inter', sans-serif !important;
}
.alerta.critico { border-left-color: var(--accent-red) !important; }
.alerta.info    { border-left-color: var(--accent-blue) !important; }
.alerta-titulo  { font-family: 'JetBrains Mono', monospace !important; }

/* ── Import section ──────────────────────────────────────────── */
.import-toggle-btn {
  font-family: 'Inter', sans-serif !important;
  background: rgba(16,185,129,0.10) !important;
  border-color: rgba(16,185,129,0.28) !important;
  border-radius: 8px !important;
}
.import-toggle-btn:hover {
  background: rgba(16,185,129,0.18) !important;
  border-color: rgba(16,185,129,0.45) !important;
}
.import-toggle-btn[aria-expanded="true"] {
  background: rgba(16,185,129,0.18) !important;
  color: #34D399 !important;
}
.import-btn-processar {
  font-family: 'Inter', sans-serif !important;
  border-radius: 9px !important;
}

/* ── Docs section ────────────────────────────────────────────── */
.docs-container h2 {
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  font-size: 15px !important;
  border-bottom-color: var(--gold) !important;
}
.docs-container h3 {
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
}
.docs-container .formula {
  font-family: 'JetBrains Mono', monospace !important;
  border-radius: 8px !important;
}
.glossario-item .termo {
  font-family: 'JetBrains Mono', monospace !important;
}

/* ── Presentation mode ───────────────────────────────────────── */
#apres-titulo    { font-family: 'Inter', sans-serif !important; font-weight: 700 !important; }
#apres-subtitulo { font-family: 'JetBrains Mono', monospace !important; }

/* ── Global focus-visible ring ───────────────────────────────── */
:focus-visible {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}
button:focus:not(:focus-visible) { outline: none; }

/* ── Import body: ensure hidden by default (JS toggles inline) ── */
#import-body[style*="display: none"],
#import-body:not([style]) {
  display: none;
}

/* ── result-panel-title font ─────────────────────────────────── */
.result-panel-title {
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
}
.compare-header-title {
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
}

/* ── CSS header comment update ───────────────────────────────── */
/* Sistema RetotalizaJE — Design System v4 */
/* ===== AUTH / PAYWALL ===== */

.auth-container,
.compra-container {
  max-width: 400px;
  margin: 80px auto;
  padding: 40px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
}

.auth-container h1 {
  font-size: 1.4rem;
  color: var(--navy);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
  transition: all .15s;
}

.tab-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.auth-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 4px;
}

.btn-primary:hover { background: var(--navy-mid); }

.auth-separator {
  text-align: center;
  color: #9ca3af;
  margin: 16px 0;
  font-size: 0.85rem;
}

.btn-google {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #374151;
}

.btn-google:hover { background: #f9fafb; }

.auth-erro {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 6px;
  min-height: 16px;
}

.compra-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: #6b7280;
}

.pacotes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.pacote-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.pacote-card h3 {
  font-size: 0.95rem;
  color: var(--navy);
  margin: 0 0 8px;
}

.pacote-creditos {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.pacote-preco {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 4px 0 12px;
}

.btn-comprar {
  display: block;
  background: var(--navy);
  color: #fff;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
}

.btn-comprar:hover { background: var(--navy-mid); }

.compra-nota {
  font-size: 0.8rem;
  color: #9ca3af;
  text-align: center;
  line-height: 1.5;
}

.btn-logout {
  background: transparent;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-logout:hover { background: #f9fafb; }

@media (max-width: 480px) {
  .pacotes-grid { grid-template-columns: 1fr; }
  .auth
 /* ===== TUTORIAL TSE ===== */
.tse-tutorial {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px;
}
.tse-tutorial-header {
  text-align: center;
  margin-bottom: 24px;
}
.tse-tutorial-badge {
  display: inline-block;
  background: rgba(245,159,11,.12);
  border: 1px solid rgba(245,159,11,.3);
  color: var(--gold);
  font-size: 10px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
}
.tse-tutorial-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.3;
}
.tse-tutorial-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.tse-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.tse-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--slate);
  border: 1px solid var(--slate-mid);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color .2s;
}
.tse-step:hover {
  border-color: var(--gold);
}
.tse-step-num {
  width: 26px;
  height: 26px;
  background: rgba(245,159,11,.15);
  border: 1px solid rgba(245,159,11,.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
  margin-top: 1px;
}
.tse-step-body {
  flex: 1;
}
.tse-step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}
.tse-step-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
}
.tse-step-desc strong {
  color: var(--text-main);
  font-weight: 600;
}
.tse-files-note {
  background: rgba(59,130,246,.07);
  border: 1px solid rgba(59,130,246,.2);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 10px;
}
.tse-files-note strong {
  color: var(--accent-blue);
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tse-tip {
  background: rgba(16,185,129,.06);
  border: 1px solid rgba(16,185,129,.2);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.tse-tip strong {
  color: var(--teal);
}