/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:          #f5f5f0;
  --surface:     #ffffff;
  --surface-2:   #f0efe9;
  --border:      #e2e0d8;
  --border-2:    #d0cdc3;

  /* Text */
  --text-1:      #0f0e0a;
  --text-2:      #4a4840;
  --text-3:      #8a8880;

  /* Brand accent (Peru red) */
  --accent:      #c8102e;
  --accent-soft: #fce8eb;

  /* Status */
  --green:       #16a34a;
  --red:         #dc2626;
  --amber:       #d97706;

  /* Map */
  --map-stroke:  #ffffff;

  /* Misc */
  --radius:      3px;
  --radius-sm:   2px;
  --shadow:      none;
  --shadow-lg:   none;
  --transition:  180ms ease;
}

[data-theme="dark"] {
  --bg:          #0e0d0b;
  --surface:     #1a1916;
  --surface-2:   #232119;
  --border:      #2e2c27;
  --border-2:    #3d3b35;
  --text-1:      #f2f0eb;
  --text-2:      #b0aea6;
  --text-3:      #6e6c66;
  --accent-soft: #3d0a10;
  --map-stroke:  #1a1916;
  --shadow:      0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
}

/* ── Accessibility helpers ──────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Page H1 — visible, integrated into layout ─────────────────────────────── */
.page-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-align: center;
  padding: 6px 16px 0;
  margin: 0;
}

/* ── Section H2 — visible but unobtrusive ───────────────────────────────────── */
.view-h2 {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  padding: 10px 4px 0;
  margin: 0;
}
[data-view="president"] .view-h2 { display: none; } /* presidente ya tiene título propio en JS */

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  max-width: 1180px;
  margin: 0 auto;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-flag {
  width: 28px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-shrink: 0;
}
.logo-flag-r { flex: 1; background: #c8102e; }
.logo-flag-w { flex: 1; background: #ffffff; }

.logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}
.logo-text span { color: var(--accent); }

.header-escrutinio {
  display: flex;
  gap: 20px;
  margin-left: auto;
  align-items: center;
}

.escrutinio-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.escrutinio-label {
  font-size: 0.68rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.escrutinio-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background var(--transition), border-color var(--transition);
  font-size: 1rem;
}
.btn-icon:hover {
  background: var(--border);
  border-color: var(--border-2);
}

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 20px 0 0;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-2); }

.stat-label {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 0.75rem;
  color: var(--text-3);
}
.stat-card.accent .stat-value { color: var(--accent); }

/* ── View sections ─────────────────────────────────────────────────────────── */
.view { animation: fadeIn 220ms ease; }
.view.hidden { display: none !important; }

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

/* ── Chamber grid (hemicycle + legend) ─────────────────────────────────────── */
.chamber-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.chamber-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chamber-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.chamber-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
}

.chamber-total {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
}

.chamber-body {
  padding: 20px;
}

/* ── Hemicycle SVG ──────────────────────────────────────────────────────────── */
.hemi-wrap {
  width: 100%;
  aspect-ratio: 2 / 1;
  overflow: visible;
}

.hemi-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--border);
}

.hemi-svg .seat {
  cursor: pointer;
  transition: opacity 200ms ease, r 200ms ease;
}
.hemi-svg .seat:hover { opacity: 1 !important; }

.hemi-label {
  font-size: 24px;
  font-weight: 800;
  fill: var(--text-1);
  font-family: inherit;
}

/* ── Hemicycle tooltip ──────────────────────────────────────────────────────── */
.hemi-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.97);
  transition: opacity 130ms ease, transform 130ms ease;
  max-width: 220px;
  min-width: 160px;
}
.hemi-tt-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.hemi-tt-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  padding: 10px 12px;
}
.hemi-tt-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-2);
}
.hemi-tt-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hemi-tt-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.hemi-tt-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
}
.hemi-tt-party {
  font-size: 0.70rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hemi-tt-dept {
  font-size: 0.65rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Legend ────────────────────────────────────────────────────────────────── */
.legend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.legend-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.legend-body {
  padding: 8px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.legend-item {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.8rem;
}
.legend-item:hover { background: var(--surface-2); }

.legend-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 3px;
  flex-shrink: 0;
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
[data-theme="dark"] .legend-logo { background: #f5f4f0; }

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 5px;
}
.legend-name { color: var(--text-2); truncate: ellipsis; }
.legend-seats {
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.legend-pct {
  color: var(--text-3);
  font-size: 0.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
}

/* ── Both chambers view — flat ─────────────────────────────────────────────── */
.both-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.both-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}

.both-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.both-panel-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.both-panel-total {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-1);
}

.both-panel-body {
  padding: 10px 12px;
}

.both-legend {
  padding: 0 6px 6px;
}

/* ── Map view ──────────────────────────────────────────────────────────────── */
.map-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
}

.map-svg-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.map-svg {
  width: 100%;
  height: auto;
}

.dept-path {
  cursor: pointer;
  transition: fill-opacity 180ms ease, stroke-width 180ms ease;
}
.dept-path:hover {
  fill-opacity: 1 !important;
  stroke-width: 1.2 !important;
}

.map-tooltip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-1);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ── Threshold view ────────────────────────────────────────────────────────── */
.thr-header {
  display: grid;
  grid-template-columns: 10px 1fr 60px 50px 60px 50px 80px;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.thr-row {
  display: grid;
  grid-template-columns: 10px 1fr 60px 50px 60px 50px 80px;
  gap: 8px;
  padding: 9px 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  transition: background var(--transition);
}
.thr-row:last-child { border-bottom: none; }
.thr-row:hover { background: var(--surface-2); }

.thr-eliminated { opacity: 0.45; }

.thr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.thr-name { color: var(--text-1); font-weight: 500; }
.thr-pct  { color: var(--text-3); font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; }
.thr-seats { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.thr-s { color: #6366f1; }
.thr-d { color: #f97316; }

.thr-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-align: center;
  letter-spacing: 0.03em;
}
.badge-in  { background: #dcfce7; color: #15803d; }
.badge-out { background: var(--surface-2); color: var(--text-3); }

[data-theme="dark"] .badge-in  { background: #14532d; color: #4ade80; }
[data-theme="dark"] .badge-out { background: var(--border); color: var(--text-3); }

/* ── Upload & status bar ───────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 24px;
  flex-wrap: wrap;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: var(--accent);
  border-radius: 2px;
  padding: 2px 5px;
}
.status-dot::after {
  content: 'EN VIVO';
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
  line-height: 1;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-text {
  font-size: 0.77rem;
  color: var(--text-3);
  flex: 1;
  font-variant-numeric: tabular-nums;
}

.upload-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.77rem;
  color: var(--text-2);
  cursor: pointer;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background var(--transition), border-color var(--transition);
}
.upload-label:hover { background: var(--surface-2); border-color: var(--border-2); }
.upload-label input { display: none; }

/* ── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-author {
  font-size: 0.8rem;
  color: var(--text-3);
}
.footer-author strong { color: var(--text-2); }
.footer-author a { color: var(--accent); text-decoration: none; }
.footer-author a:hover { text-decoration: underline; }

.footer-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.footer-link {
  font-size: 0.78rem;
  color: var(--text-3);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-link:hover { color: var(--text-1); }

/* ── Card utility ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body { padding: 20px; }

/* ── Responsive — tablet (≤ 900px) ────────────────────────────────────────── */
@media (max-width: 900px) {
  .chamber-grid { grid-template-columns: 1fr; }
  .both-grid    { grid-template-columns: 1fr; }
  .map-grid     { grid-template-columns: 1fr; }
  .stats-bar    { grid-template-columns: repeat(2, 1fr); }
}

/* ── Responsive — mobile (≤ 640px) ────────────────────────────────────────── */
@media (max-width: 640px) {

  /* ─ Header ─────────────────────────────────────────────── */
  .header-inner {
    padding: 10px 14px;
    gap: 8px;
  }

  /* ─ Container padding ───────────────────────────────────── */
  .container { padding: 0 14px; }

  /* ─ Stats bar ───────────────────────────────────────────── */
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-top: 14px;
  }
  .stat-value { font-size: 1.5rem; }
  .stat-card  { padding: 12px 14px; }

  /* ─ Status bar ──────────────────────────────────────────── */
  .status-bar { padding: 8px 0 16px; gap: 8px; }
  .upload-label { font-size: 0.72rem; padding: 5px 10px; }

  /* ─ Threshold table ─────────────────────────────────────── */
  .thr-header, .thr-row {
    grid-template-columns: 8px 1fr 46px 36px 70px;
    gap: 6px;
    padding: 8px 10px;
    font-size: 0.76rem;
  }
  .thr-s, .thr-pct:nth-child(3) { display: none; }
  .thr-badge { font-size: 0.63rem; padding: 2px 6px; }
  .thr-name  { font-size: 0.76rem; }

  /* ─ Both panel header ───────────────────────────────────── */
  .both-panel-total { font-size: 1.1rem; }
  .both-panel-body  { padding: 10px; }
  .both-legend      { max-height: none; }
  .chamber-body     { padding: 12px; }
  .legend-body      { max-height: 300px; }

  /* ─ Map ─────────────────────────────────────────────────── */
  .map-card { padding: 12px; }

  /* ─ Footer ──────────────────────────────────────────────── */
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .footer-author { font-size: 0.75rem; }
}

/* ── Responsive — small phones (≤ 400px) ──────────────────────────────────── */
@media (max-width: 400px) {
  html { font-size: 14px; }
  .stats-bar { gap: 6px; }
  .stat-value { font-size: 1.35rem; }
}

/* ── Scrollbar styling ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Accessibility ─────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Countdown Hero ────────────────────────────────────────────────────────── */
#countdown-hero {
  margin: 24px 0;
  border-radius: 0;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  background: var(--surface);
  overflow: hidden;
  animation: hero-in 0.4s ease;
}
@keyframes hero-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
#countdown-hero .pres-countdown-wrap {
  padding: 52px 24px 44px !important;
}
#countdown-hero .cd-title {
  font-size: 0.85rem;
}
#countdown-hero .cd-num {
  width: 96px; height: 96px; font-size: 3rem;
}

/* Subtle note in tab panel when hero is active */
.pres-waiting-hero-note {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 20px;
  font-size: 0.82rem; color: var(--text-3);
}

/* ── Countdown ─────────────────────────────────────────────────────────────── */
.pres-countdown-wrap {
  padding: 48px 24px 40px !important;
  gap: 0 !important;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cd-title {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-3); margin-bottom: 6px;
}
.cd-subtitle {
  font-size: 1rem; color: var(--text-2); margin-bottom: 28px; font-weight: 400;
}

/* Digits row */
.cd-digits {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 28px;
}
.cd-unit {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.cd-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 2.8rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: color 80ms ease;
}
.cd-label {
  font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-3); font-weight: 600;
}
.cd-sep {
  font-size: 2.4rem; font-weight: 700; color: var(--border-2);
  line-height: 1; margin-bottom: 20px; /* align with number, not label */
}

/* Tick flash on seconds */
@keyframes cd-tick {
  0%   { transform: scaleY(1);   opacity: 1; }
  30%  { transform: scaleY(.85); opacity: .6; }
  100% { transform: scaleY(1);   opacity: 1; }
}
.cd-tick { animation: cd-tick 300ms ease; }

/* Footer note */
.cd-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 0.8rem; color: var(--text-3);
  margin-bottom: 28px;
}
.cd-footer strong { color: var(--text-2); }

/* Day-progress bar (8 AM → 5 PM) */
.cd-progress-wrap {
  width: 100%; max-width: 360px;
  height: 4px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
.cd-progress-bar {
  height: 100%; background: var(--accent);
  border-radius: 4px; transition: width 1s linear;
  min-width: 0;
}

/* Spinner for "waiting for first data" */
@keyframes spin { to { transform: rotate(360deg); } }
.cd-spin { animation: spin 1.2s linear infinite; display: inline-flex !important; }

/* Mobile */
@media (max-width: 480px) {
  .cd-num { width: 68px; height: 68px; font-size: 2.1rem; border-radius: 10px; }
  .cd-sep { font-size: 1.8rem; margin-bottom: 16px; }
  .cd-digits { gap: 5px; }
  .cd-subtitle { font-size: 0.88rem; margin-bottom: 20px; }
}
@media (max-width: 360px) {
  .cd-num { width: 58px; height: 58px; font-size: 1.7rem; }
  .cd-sep { font-size: 1.5rem; }
}

/* ── Presidential results — flat list ──────────────────────────────────────── */
.pres-container { padding: 4px 0 8px; }

.pres-waiting {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 20px; text-align: center;
  background: var(--surface); border-radius: 0;
  border: 1px solid var(--border);
}
.pres-waiting-icon { margin-bottom: 12px; color: var(--text-3); opacity: .5; }
.pres-waiting-text { font-size: 1rem; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.pres-waiting-sub  { font-size: 0.82rem; color: var(--text-3); margin: 0; max-width: 340px; }

/* Header row: title + virtual pill */
.pi-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.pi-title {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3);
  flex: 1;
}

/* Flat list */
.pi-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.pi-row {
  display: grid;
  grid-template-columns: 22px 32px 32px 1fr minmax(60px, 200px) 52px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
}
.pi-row:last-child { border-bottom: none; }
.pi-row:hover      { background: var(--surface-2); }

/* Top 2: left accent stripe */
.pi-row--top {
  background: color-mix(in srgb, var(--pc) 4%, var(--surface));
  border-left: 3px solid var(--pc);
  padding-left: 9px;
}
.pi-row--top:hover { background: color-mix(in srgb, var(--pc) 8%, var(--surface)); }

.pi-rank {
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-3); text-align: center;
  font-variant-numeric: tabular-nums;
}
.pi-row--top .pi-rank { color: var(--pc); }

/* Party logo — 28×28 */
.pi-logo {
  width: 28px; height: 28px;
  border-radius: 5px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 800; color: #fff;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.06);
}
.pi-logo--img { background: #fff; padding: 2px; }
.pi-logo--img img { width: 100%; height: 100%; object-fit: contain; display: block; }
[data-theme="dark"] .pi-logo--img { background: #f5f4f0; }

/* Candidate face — 28×28 */
.pi-face-wrap { display: flex; align-items: center; }
.pi-face {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover; object-position: top center;
  display: block; flex-shrink: 0;
  border: 1.5px solid var(--border);
}
.pi-face--fb {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 700; color: #fff;
  border: none;
}

/* Text block */
.pi-text {
  display: flex; flex-direction: column;
  min-width: 0; gap: 1px;
}
.pi-name {
  font-size: 0.82rem; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.pi-row--top .pi-name { font-weight: 700; }
.pi-pty {
  font-size: 0.68rem; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}

/* Bar */
.pi-bar-wrap {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.pi-bar {
  height: 100%; border-radius: 3px; min-width: 2px;
  transition: width .5s ease;
}

/* Percentage */
.pi-pct {
  font-size: 0.82rem; font-weight: 700;
  color: var(--text-1); text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pi-row--top .pi-pct { color: var(--pc); font-size: 0.88rem; }

/* Mobile */
@media (max-width: 600px) {
  .pi-row {
    grid-template-columns: 18px 28px 28px 1fr 44px;
    gap: 7px; padding: 7px 10px;
  }
  .pi-bar-wrap { display: none; }
  .pi-name { font-size: 0.78rem; }
  .pi-pty  { font-size: 0.62rem; }
  .pi-pct  { font-size: 0.78rem; }
}
@media (max-width: 400px) {
  .pi-row  { grid-template-columns: 16px 26px 26px 1fr 42px; gap: 5px; }
  .pi-logo, .pi-face { width: 26px; height: 26px; }
}

/* ── Lucide icon alignment ─────────────────────────────────────────────────── */
[data-lucide], i[data-lucide] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
}
/* Upload label icon */
.upload-label i { margin-right: 4px; }

/* Theme toggle: center the icon */
.btn-icon i { display: flex; }

/* Threshold badge icon */
.thr-badge i { margin-right: 3px; vertical-align: -2px; }

/* Escrutinio icon */
.pres-escrutinio i { margin-right: 6px; opacity: .7; }

/* Waiting state icon */
.pres-waiting-icon i {
  color: var(--text-3);
  display: block;
  margin: 0 auto;
}

/* Rank badge icon */
.pres-rank i { margin-right: 3px; vertical-align: -1px; }

/* ── Candidates gallery ────────────────────────────────────────────────────── */
.cand-gallery {
  margin: 18px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Desktop: galería compacta */
@media (min-width: 900px) {
  .cand-gallery {
    margin: 14px 0 0;
  }
  .cand-gallery-scroll {
    padding: 8px 10px 10px;
  }
}

.cand-gallery-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.cand-gallery-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.cand-gallery-title i { color: var(--accent); }

.cand-gallery-scroll {
  display: flex;
  gap: 2px;
  padding: 10px 10px 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  align-items: stretch;
}
.cand-gallery-scroll::-webkit-scrollbar { height: 4px; }
.cand-gallery-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

/* ── Individual candidate card — logo-primary design ───────────────────────── */
.cand-item {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 84px;
  scroll-snap-align: start;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform 130ms ease, box-shadow 130ms ease;
  cursor: default;
}
.cand-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  z-index: 1;
}

/* Logo block — colored (text acronym) or white (real image) */
.cand-logo-area {
  width: 100%;
  height: 76px;
  background-color: var(--cc, #94A3B8);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px 18px;
  flex-shrink: 0;
  border-bottom: 3px solid var(--cc, #94A3B8);
}
.cand-logo-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,.12) 0%, transparent 45%, rgba(0,0,0,.22) 100%);
  pointer-events: none;
}

/* Variant with actual logo image — white background */
.cand-logo-area--img {
  background-color: #fff;
  padding: 6px 6px 18px;
}
.cand-logo-area--img::before { display: none; }
[data-theme="dark"] .cand-logo-area--img { background-color: #f8f8f6; }

.cand-logo-img {
  max-width: 100%;
  max-height: 44px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
}

/* Party acronym — large bold text acting as logo */
.cand-acr {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 6px rgba(0,0,0,.3);
}

/* Short party name below acronym */
.cand-logo-label {
  font-size: 7px;
  font-weight: 700;
  color: rgba(255,255,255,.82);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  line-height: 1.3;
  position: relative;
  z-index: 1;
  padding: 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Bottom section — small candidate photo + name */
.cand-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 6px 8px;
  margin-top: -16px;
  position: relative;
  z-index: 2;
  gap: 5px;
}

/* Small circular photo overlapping logo area */
.cand-photo-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  background-color: var(--cc, #94A3B8);
  flex-shrink: 0;
}
.cand-photo-sm {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

/* Fallback initials inside photo ring */
.cand-photo-fb {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
}

/* Candidate name */
.cand-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-1);
  text-align: center;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}

/* ── Congress waiting state ────────────────────────────────────────────────── */
.view-wait {
  padding: 24px 16px 32px;
  animation: fadeIn 220ms ease;
}

.view-wait-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
}

.view-wait-inner i {
  color: var(--text-3);
  opacity: .4;
  animation: pulse 3s infinite;
}

.view-wait-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-2);
  margin: 0;
}

.view-wait-sub {
  font-size: 0.85rem;
  color: var(--text-3);
  max-width: 400px;
  line-height: 1.6;
  margin: 0;
}

/* ── WhatsApp share button ─────────────────────────────────────────────────── */
.btn-share-wa {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  background: #25D366;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), transform 80ms ease;
  flex-shrink: 0;
}
.btn-share-wa:hover  { background: #1ebe5c; }
.btn-share-wa:active { transform: scale(.97); }
.btn-share-wa i      { flex-shrink: 0; }

/* ── Segunda Vuelta — hero card ────────────────────────────────────────────── */
.sv-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  margin: 0 0 20px;
  overflow: hidden;
  animation: sv-appear 380ms ease;
}

@keyframes sv-appear {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Accent stripe top */
.sv-banner::before {
  content: '';
  display: block;
  height: 4px;
  background: var(--accent);
}

/* ── Header row ── */
.sv-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 9px;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-3);
  background: var(--surface);
}
.sv-header i { color: var(--accent); flex-shrink: 0; }
.sv-header strong {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sv-date { color: var(--text-3); margin-left: 2px; }

/* ── Body ── */
.sv-body { padding: 10px 12px; }

/* ── Horizontal 3-card grid ── */
.sv-candidates-grid {
  display: grid;
  grid-template-columns: 1fr 0px 1fr 0px 1fr;
  gap: 0 2px;
  align-items: stretch;
}

/* ── Full-bleed photo card ── */
.sv-card {
  position: relative;
  height: 340px;
  border-radius: 0;
  overflow: hidden;
}

/* Photo fills card */
.sv-card-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
  display: block;
}
.sv-card-photo-fb {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem; font-weight: 800; color: #fff;
  background: var(--sv-color, #94A3B8);
}

/* Dark gradient overlay — transparent top, deep black bottom */
.sv-card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.08) 0%,
    rgba(0,0,0,.0)  18%,
    rgba(0,0,0,.55) 55%,
    rgba(0,0,0,.96) 100%
  );
}

/* Content layer above photo */
.sv-card-content {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 8px 9px;
}

/* Top row: rank (left) + trend badge (right) */
.sv-card-top {
  display: flex; justify-content: space-between; align-items: flex-start;
}

/* Rank badge — top-left */
.sv-rank {
  background: var(--sv-color, #94A3B8);
  color: #fff;
  font-size: 0.85rem; font-weight: 900; line-height: 1;
  padding: 4px 10px; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  letter-spacing: 0.03em;
}

/* Trend badge — top-right */
.sv-trend {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 7px; border-radius: 6px;
  font-weight: 800; line-height: 1.15;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
  animation: sv-trend-pop 0.35s ease;
}
.sv-trend-up   { background: rgba(21,128,61,.92);  color: #fff; }
.sv-trend-down { background: rgba(185,28,28,.92);  color: #fff; }
.sv-trend { transition: transform 150ms ease; }
.sv-trend:hover { transform: scale(1.15); }
.sv-trend-arrow { font-size: 0.9rem; }
.sv-trend-label { font-size: 0.6rem; letter-spacing: 0.02em; }
@keyframes sv-trend-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Bottom info block */
.sv-card-bottom {
  display: flex; flex-direction: column; gap: 4px;
}

.sv-name {
  font-size: 1.05rem; font-weight: 900; color: #fff;
  line-height: 1.15; text-shadow: 0 2px 8px rgba(0,0,0,.9);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; letter-spacing: -0.01em;
}

/* Party row */
.sv-party-row {
  display: flex; align-items: center; gap: 5px;
}
.sv-party-logo {
  width: 22px; height: 22px;
  object-fit: contain; border-radius: 3px; flex-shrink: 0;
  background: rgba(255,255,255,.95);
  padding: 1px;
}
.sv-party {
  font-size: 0.68rem; font-weight: 500; color: rgba(255,255,255,.88);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* Stats row: pct + votes */
.sv-card-stats {
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
  margin-top: 2px;
}
.sv-votes {
  font-size: 0.62rem; color: rgba(255,255,255,.72); white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* Pct — big */
.sv-pct {
  font-size: 2.1rem; font-weight: 900; color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: -0.03em;
  line-height: 1; text-shadow: 0 2px 10px rgba(0,0,0,.7);
  display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap;
}

/* Delta badge */
.sv-delta {
  font-size: 0.67rem; font-weight: 700; letter-spacing: 0;
  padding: 2px 5px; border-radius: 4px; line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.sv-delta-up   { background: rgba(21,128,61,.9);  color: #fff; }
.sv-delta-down { background: rgba(185,28,28,.9); color: #fff; }

/* Progress bar at bottom edge */
.sv-bar-track {
  width: 100%; height: 3px;
  background: rgba(255,255,255,.18); border-radius: 2px; overflow: hidden;
  margin-top: 6px;
}
.sv-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }

/* ── Separator — zero-width column, content floats over card boundary ── */
.sv-sep {
  position: relative;
  width: 0;
  overflow: visible;
  z-index: 20;
  align-self: stretch;
}
.sv-sep-divider { display: none; }

/* Floating badge centered on the seam between two cards */
.sv-sep-inner {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.sv-gap-pts {
  display: flex; align-items: baseline; gap: 3px;
  font-size: 1rem; font-weight: 900; color: #fff;
  white-space: nowrap; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,.72);
  padding: 4px 8px; border-radius: 3px;
  backdrop-filter: blur(4px);
}
.sv-gap-unit {
  font-size: 0.6rem; font-weight: 600; color: rgba(255,255,255,.65);
}
.sv-gap-votes {
  font-size: 0.6rem; color: rgba(255,255,255,.8);
  white-space: nowrap; text-align: center; line-height: 1;
  background: rgba(0,0,0,.65);
  padding: 3px 7px; border-radius: 3px;
  backdrop-filter: blur(4px);
}
.sv-gap-trend {
  font-size: 0.62rem; font-weight: 700;
  padding: 3px 7px; border-radius: 3px; line-height: 1.4;
  text-align: center; white-space: nowrap;
  backdrop-filter: blur(4px);
}
.sv-gap-trend-delta {
  display: block; font-weight: 500; font-size: 0.56rem;
  opacity: .85; margin-top: 1px;
}
.sv-gap-trend-close { background: rgba(21,128,61,.88); color: #fff; }
.sv-gap-trend-open  { background: rgba(185,28,28,.88); color: #fff; }

/* Mobile: badges más compactos */
@media (max-width: 600px) {
  .sv-gap-pts   { font-size: 0.82rem; padding: 3px 6px; }
  .sv-gap-votes { display: none; }
  .sv-gap-trend-delta { display: none; }
}
@media (max-width: 400px) {
  .sv-gap-pts { font-size: 0.7rem; padding: 2px 5px; }
}

/* ── Footer row ── */
.sv-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-3);
  background: var(--surface);
}
.sv-footer i { opacity: .7; flex-shrink: 0; }
.sv-footer a { color: var(--accent); text-decoration: none; }
.sv-footer a:hover { text-decoration: underline; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .sv-header { padding: 10px 14px 8px; }
  .sv-body   { padding: 8px 10px; }
  .sv-card   { height: 260px; }
  .sv-pct    { font-size: 1.6rem; }
  .sv-name   { font-size: 0.85rem; }
  .sv-footer { padding: 8px 14px; }
  .sv-date   { display: none; }
  .sv-sep    { min-width: 44px; gap: 4px; }
  .sv-gap-pts { font-size: 0.95rem; }
  .sv-gap-votes { display: none; }
  .sv-gap-trend-delta { display: none; }
}
@media (max-width: 400px) {
  .sv-card   { height: 220px; }
  .sv-sep    { min-width: 32px; }
  .sv-gap-votes, .sv-votes { display: none; }
  .sv-pct    { font-size: 1.35rem; }
}

/* ── Seats bars ────────────────────────────────────────────────────────────── */
.seats-bars-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.seats-bar-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.seats-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.seats-bar-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
}

.seats-bar-detail {
  font-size: 0.75rem;
  color: var(--text-3);
}
.seats-bar-detail strong { color: var(--text-1); }
.seats-bar-parties { color: var(--accent); font-weight: 600; }

.seats-bar-track {
  display: flex;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  gap: 1px;
}

.seats-seg {
  height: 100%;
  min-width: 1px;
  transition: filter 150ms ease;
  cursor: default;
}
.seats-seg:hover          { filter: brightness(1.15); }
.seats-seg-empty          { background: var(--surface-2) !important; }

.seats-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
}

.seats-bar-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-2);
}
.seats-bar-leg-item strong { color: var(--text-1); }

.seats-bar-leg-dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.seats-bar-leg-logo {
  width: 16px; height: 16px;
  object-fit: contain;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
[data-theme="dark"] .seats-bar-leg-logo { background: #f5f4f0; }

.seats-bar-leg-more {
  font-size: 0.72rem;
  color: var(--text-3);
  align-self: center;
}

.seats-bar-note {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-3);
  margin: -4px 0 6px;
  padding: 5px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.seats-bar-note svg { flex-shrink: 0; opacity: 0.7; }

/* ── Trend chart ───────────────────────────────────────────────────────────── */
.trend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}

.trend-header-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
}

.trend-header-sub {
  font-size: 0.72rem;
  color: var(--text-3);
}

.trend-content { padding: 16px; }

.trend-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 12px;
  color: var(--text-3);
}
.trend-empty i         { opacity: .5; }
.trend-empty-title     { font-size: 1rem; font-weight: 600; color: var(--text-2); }
.trend-empty-sub       { font-size: 0.85rem; line-height: 1.6; max-width: 380px; }

.trend-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-3);
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}
.trend-meta i { margin-right: 3px; }
.trend-meta strong { color: var(--text-1); }

.trend-chart-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.trend-svg {
  width: 100%;
  min-width: 480px;
  height: auto;
  display: block;
  overflow: visible;
}

/* SVG text classes — used inside inline SVG */
.trend-axis-label {
  font-size: 11px;
  fill: var(--text-3);
  font-family: inherit;
}
.trend-axis-title {
  font-size: 11px;
  fill: var(--text-3);
  font-family: inherit;
  font-weight: 600;
}
.trend-thr-label {
  font-size: 10px;
  fill: var(--accent);
  font-family: inherit;
  font-weight: 700;
}
.trend-line-label {
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
}

.trend-note {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 10px;
  line-height: 1.5;
}


/* ══════════════════════════════════════════════════════════════════════════════
   DESKTOP UX IMPROVEMENTS (≥ 900px)
   ══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {

  /* ── Stat cards: borde izquierdo acento para jerarquía visual ── */
  .stat-card {
    border-left: 3px solid var(--border-2);
    padding-left: 16px;
  }
  .stat-card.accent {
    border-left-color: var(--accent);
  }

  /* ── Stats bar: 4 columnas con altura uniforme ── */
  .stats-bar {
    align-items: stretch;
  }
  .stat-value {
    font-size: 2rem;
  }

  /* ── Podio presidencial: más grande en desktop ── */
  .pres-podium {
    gap: 20px;
    margin-bottom: 28px;
  }
  .pres-card {
    padding: 26px 20px 20px;
  }
  .pres-rank-1 .pres-avatar { width: 116px; height: 116px; }
  .pres-avatar              { width: 96px; height: 96px; }
  .pres-rank-1 .pres-pct   { font-size: 1.6rem; }
  .pres-pct                 { font-size: 1.25rem; }
  .pres-rank-1 .pres-name  { font-size: 1.05rem; }

  /* ── Escrutinio pill: más visible ── */
  .pres-escrutinio {
    padding: 10px 18px;
    border-radius: var(--radius);
    margin-bottom: 24px;
  }
  .pres-esc-val { font-size: 1.15rem; }

  /* ── Segunda Vuelta banner: más espacio en desktop ── */
  .sv-card   { height: 420px; }
  .sv-pct    { font-size: 2.6rem; }
  .sv-name   { font-size: 1.15rem; }
  .sv-sep    { min-width: 70px; }
  .sv-gap-pts { font-size: 1.2rem; }

  /* ── Status bar: alinear a la derecha, más compacta ── */
  .status-bar {
    padding: 8px 0 20px;
    justify-content: flex-start;
    gap: 14px;
  }
  .status-text {
    font-size: 0.82rem;
    color: var(--text-2);
  }

  /* ── View wait state: centrada y espaciosa ── */
  .view-wait-inner {
    padding: 60px 40px;
  }

  /* ── Tabla de resultados completa en desktop ── */
  .pres-row {
    padding: 12px 16px;
  }
  .pres-row-name { font-size: 0.86rem; }
  .pres-row-pct  { font-size: 0.88rem; }

  /* ── Header: separar escrutinio más prominente ── */
  .escrutinio-value {
    font-size: 1.05rem;
  }

}

/* ═══════════════════════════════════════════════════════════════════════════
   NUEVO LAYOUT — sin tabs, secciones lineales
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Header simplificado ────────────────────────────────────────────────── */
.header-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding: 0 8px;
}

.header-actas {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.actas-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 600;
}
.actas-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ── Share button: solo ícono en mobile ─────────────────────────────────── */
@media (max-width: 640px) {
  .share-label { display: none; }
  .btn-share-wa { padding: 6px 10px; }
  .header-meta { display: none; }
  .header-actas { padding: 4px 8px; }
  .actas-label { display: none; }
}

/* ── Secciones de resultados ────────────────────────────────────────────── */
.result-section {
  margin-bottom: 16px;
}

/* ── Divisor de sección Congreso ─────────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 14px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-2);
}
.section-divider i { color: var(--text-3); opacity: .7; }
.section-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
}

/* ── Status bar sin botón WhatsApp (ahora en header) ───────────────────── */
.status-bar {
  padding: 8px 0 12px;
}

/* ── Pill "Virtuales · X% actas" ─────────────────────────────────────────── */
.virtual-pill,
.pi-virtual-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0;
}
[data-theme="dark"] .virtual-pill,
[data-theme="dark"] .pi-virtual-pill {
  background: #451a03;
  color: #fcd34d;
  border-color: #78350f;
}
.virtual-pill i, .pi-virtual-pill i { opacity: .8; }

/* pi-header ya definido arriba */

/* ── Barra de actas presidencial ─────────────────────────────────────────── */
.pres-actas-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0 14px;
}

.pres-actas-track {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.pres-actas-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.8s ease;
  min-width: 2px;
}

.pres-actas-pct {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  mix-blend-mode: difference;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.pres-actas-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-3);
}
.pres-actas-label i { opacity: .7; flex-shrink: 0; }
.pres-actas-link { color: var(--accent); text-decoration: none; }
.pres-actas-link:hover { text-decoration: underline; }

/* ── Fila "más candidatos" ────────────────────────────────────────────────── */
.pi-more {
  padding: 8px 12px;
  font-size: 0.72rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  text-align: center;
  font-style: italic;
}

/* ── Más Votados del Congreso ──────────────────────────────────────────────── */
.mv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mv-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}

.mv-block-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}
.mv-block-header i { color: var(--accent); flex-shrink: 0; }

.mv-block-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  flex: 1;
}

.mv-block-count {
  font-size: 0.7rem;
  color: var(--text-3);
  flex-shrink: 0;
}

.mv-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 540px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.mv-list::-webkit-scrollbar { width: 4px; }
.mv-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

.mv-row {
  display: grid;
  grid-template-columns: 26px 22px 1fr 56px 68px;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.mv-row:last-child { border-bottom: none; }
.mv-row:hover { background: var(--surface-2); }

/* Oro / Plata / Bronce para los 3 primeros */
.mv-row:nth-child(1) .mv-rank { color: #f59e0b; font-weight: 800; }
.mv-row:nth-child(2) .mv-rank { color: #94a3b8; font-weight: 700; }
.mv-row:nth-child(3) .mv-rank { color: #b45309; font-weight: 700; }

.mv-rank {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.mv-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 3px;
  flex-shrink: 0;
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
[data-theme="dark"] .mv-logo { background: #f5f4f0; }

.mv-logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 6px;
  border: none;
  flex-shrink: 0;
}

.mv-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.mv-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.mv-meta {
  font-size: 0.64rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.mv-bar-col { min-width: 0; }

.mv-bar-track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.mv-bar-fill {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.4s ease;
}

.mv-votes {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-1);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 900px) {
  .mv-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .mv-row {
    grid-template-columns: 22px 20px 1fr 56px;
    gap: 6px;
    padding: 6px 10px;
  }
  .mv-bar-col { display: none; }
  .mv-name  { font-size: 0.74rem; }
  .mv-votes { font-size: 0.7rem; }
}

/* ── WhatsApp flotante ──────────────────────────────────────────────────────── */
.wa-float {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.wa-float:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.wa-float:active { transform: scale(0.96); }

.wa-float-icon {
  width: 32px;
  height: 32px;
  display: block;
  flex-shrink: 0;
}

/* Tooltip al hacer hover */
.wa-float::after {
  content: 'Consultas y apoyo';
  position: absolute;
  right: 64px;
  top: 50%;
  transform: translateY(-50%);
  background: #1a1916;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.wa-float:hover::after { opacity: 1; }

.wa-float-label { display: none; }

@media (max-width: 640px) {
  .wa-float { bottom: 20px; right: 20px; width: 52px; height: 52px; }
  .wa-float::after { display: none; }
}

/* ── Section nav anchors ────────────────────────────────────────────────────── */
.section-nav {
  display: flex;
  gap: 6px;
  padding: 0 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }

.section-nav-link {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  text-decoration: none;
  color: var(--text-2);
  background: var(--surface);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.section-nav-link:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-1);
}
.section-nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Seats bar legend expand toggle ────────────────────────────────────────── */
.leg-overflow { display: none; }
.seats-bar-legend[data-expanded="true"] .leg-overflow { display: inline-flex; }

.seats-bar-leg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  align-self: center;
  flex-shrink: 0;
}
.seats-bar-leg-toggle:hover { background: var(--accent-soft); }
.seats-bar-leg-toggle[aria-expanded="true"] i { transform: rotate(180deg); }
.seats-bar-leg-toggle i { transition: transform 200ms ease; }

/* ── Hemicycle mobile bottom sheet ─────────────────────────────────────────── */
.hemi-sheet {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.hemi-sheet.hemi-sheet-visible {
  opacity: 1;
  pointer-events: auto;
}
.hemi-sheet-inner {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 0 20px 40px;
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(.32, .72, 0, 1);
}
.hemi-sheet.hemi-sheet-visible .hemi-sheet-inner {
  transform: translateY(0);
}
.hemi-sheet-handle {
  width: 40px; height: 4px;
  background: var(--border-2);
  border-radius: 4px;
  margin: 12px auto 20px;
}
.hemi-sheet-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
}
.hemi-sheet-logo {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
[data-theme="dark"] .hemi-sheet-logo { background: #f5f4f0; }
.hemi-sheet-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hemi-sheet-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.hemi-sheet-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.25;
}
.hemi-sheet-party {
  font-size: 0.82rem;
  color: var(--text-2);
}
.hemi-sheet-dept {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════════════
   ANIMACIONES INTERACTIVAS
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Barras de progreso se llenan desde la izquierda ── */
@keyframes bar-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.sv-bar-fill {
  transform-origin: left center;
  animation: bar-grow 0.7s cubic-bezier(.4,0,.2,1) forwards;
}
.mv-bar-fill {
  transform-origin: left center;
  animation: bar-grow 0.55s cubic-bezier(.4,0,.2,1) forwards;
}
.pi-bar {
  transform-origin: left center;
  animation: bar-grow 0.55s cubic-bezier(.4,0,.2,1) forwards;
}

/* ── 2. Escaños del hemiciclo: pop-in escalonado (primera carga) ── */
@keyframes seat-pop {
  from { opacity: 0; transform: scale(0.2); }
  65%  { transform: scale(1.2); }
  to   { opacity: var(--seat-op, 0.92); transform: scale(1); }
}
@keyframes seat-fade {
  from { opacity: 0; }
  to   { opacity: var(--seat-op, 0.92); }
}
.seat {
  transform-box: fill-box;
  transform-origin: center;
}

/* ── 3. Porcentaje presidencial: pulso al actualizarse ── */
@keyframes pct-update {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
.sv-pct-changed {
  animation: pct-update 500ms cubic-bezier(.34,1.56,.64,1);
  display: inline-block;
}

/* ── 4. Filas de más votados: entrada escalonada ── */
@keyframes mv-row-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
.mv-row {
  animation: mv-row-in 280ms ease both;
}

/* ── 5. Scroll reveal para secciones ── */
.result-section.reveal-ready {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 550ms ease, transform 550ms ease;
}
.result-section.reveal-ready.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Hover scale micro-interactions ── */

/* Cards presidenciales */
.sv-card {
  transition: transform 200ms ease, box-shadow 200ms ease;
  will-change: transform;
}
.sv-card:hover {
  transform: scale(1.03);
  z-index: 2;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}

/* Escaños del hemiciclo */
.seat {
  transition: transform 150ms ease, opacity 200ms ease;
}
.hemi-svg .seat:hover {
  opacity: 1 !important;
  transform: scale(1.6);
}

/* Filas de más votados */
.mv-row {
  transition: background var(--transition), transform 150ms ease;
  transform-origin: left center;
}
.mv-row:hover {
  transform: scale(1.015) translateX(3px);
}

/* Leyenda del hemiciclo */
.legend-item {
  transition: background var(--transition), transform 160ms ease;
  transform-origin: left center;
}
.legend-item:hover {
  transform: scale(1.03) translateX(2px);
}

/* Nav de secciones */
.section-nav-link {
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), transform 150ms ease;
}
.section-nav-link:hover { transform: scale(1.06); }

/* No animar si el usuario prefiere movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .sv-bar-fill, .mv-bar-fill, .pi-bar,
  .sv-pct-changed, .mv-row,
  .result-section.reveal-ready {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .sv-card:hover, .mv-row:hover, .legend-item:hover,
  .section-nav-link:hover, .sv-trend:hover,
  .hemi-svg .seat:hover {
    transform: none !important;
  }
}

