/* ═══════════════════════════════════════════════════════════════════════════
   Segunda Vuelta (SEP2026) — estilos del cara a cara Fujimori vs Sánchez.
   Reutiliza tokens del tema (claro/oscuro) y clases ya existentes
   (.panel, .participacion-card, .pc-*, .history-card, .table-card, .reg-table,
   .map-container, .map-legend). Aquí solo lo nuevo: switch de vuelta + head-to-head.
═══════════════════════════════════════════════════════════════════════════ */

/* ── Switch de vuelta (topbar) ─────────────────────────────── */
.round-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 3px;
  box-shadow: var(--shadow-sm);
}
.round-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 16px;
  border-radius: 9px;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: all .18s ease;
  line-height: 1.15;
}
.round-btn-main {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.round-btn-tag {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.round-btn:hover .round-btn-main { color: var(--ink-1); }
.round-btn.active {
  background: var(--ink-1);
  box-shadow: var(--shadow-sm);
}
.round-btn.active .round-btn-main { color: var(--surface); }
.round-btn.active .round-btn-tag { color: rgba(255,255,255,.65); }
.round-btn .live-dot { width: 8px; height: 8px; }
/* en el botón activo de SV, el punto vivo se ve siempre */
.round-btn[data-round="sv"].active .live-dot { background: #ff5252; }

/* ── Vistas (sv / pv) ──────────────────────────────────────── */
.round-view { display: none; animation: fadeIn .3s ease; }
.round-view.active { display: block; }

/* Sub-pestañas de Primera Vuelta: centradas y con aire respecto al banner
   (que trae margin-top negativo pensado para ir pegado al topbar). */
.pv-tabs-bar { display: flex; justify-content: center; margin: 0 0 20px; }
#view-pv .final-banner { margin-top: 0; }

/* ── Barra de estado en vivo ───────────────────────────────── */
.sv-statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 16px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  font-size: 12.5px;
}
.sv-live { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink-1); }
.sv-actas { color: var(--ink-2); font-weight: 600; }
.sv-ts { color: var(--ink-3); margin-left: auto; font-size: 11.5px; }

/* Punto rojo "EN VIVO" con pulse (radar). El .live-dot base solo está
   estilizado en .hero-meta de round-1, así que lo definimos aquí para SV. */
.sv-live .live-dot,
.round-btn[data-round="sv"].active .live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: sv-live-pulse 1.6s ease-out infinite;
}
@keyframes sv-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(217,16,35,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(217,16,35,0); }
  100% { box-shadow: 0 0 0 0 rgba(217,16,35,0); }
}

/* ── Cara a cara (head-to-head) ────────────────────────────── */
.sv-h2h {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 28px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.sv-h2h::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(150px 150px at 6% 60%, color-mix(in srgb, var(--sv-left, var(--c-fuji)) 7%, transparent), transparent 70%),
    radial-gradient(150px 150px at 94% 60%, color-mix(in srgb, var(--sv-right, var(--c-sanch)) 7%, transparent), transparent 70%);
  pointer-events: none;
}
/* eyebrow editorial: primer hijo a ancho completo del grid del hero */
.sv-h2h-head { grid-column: 1 / -1; text-align: center; margin-bottom: 4px; }
.sv-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
}
.sv-cand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}
.sv-cand.side-a { align-items: flex-end; text-align: right; }
.sv-cand.side-b { align-items: flex-start; text-align: left; }
.sv-cand-photo-wrap {
  position: relative;
  width: 96px; height: 96px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px currentColor, var(--shadow-md);
  background: var(--surface-2);
}
.sv-cand.side-a .sv-cand-photo-wrap { color: var(--c-fuji); }
.sv-cand.side-b .sv-cand-photo-wrap { color: var(--c-sanch); }
.sv-cand-initial {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 42px;
  color: currentColor;
  user-select: none;
}
.sv-cand-photo {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  background: transparent;
}
.sv-cand-name { font-family: 'Fraunces', serif; font-weight: 700; font-size: 19px; letter-spacing: -0.01em; margin-top: 8px; }
.sv-cand-party { font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.sv-cand-pct {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 46px;
  line-height: 1;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.sv-cand.side-a .sv-cand-pct { color: var(--c-fuji); }
.sv-cand.side-b .sv-cand-pct { color: var(--c-sanch); }
.sv-cand-votes { font-size: 13px; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.sv-cand.leading .sv-cand-photo-wrap {
  box-shadow: 0 0 0 3px currentColor,
              0 0 0 8px color-mix(in srgb, currentColor 20%, transparent),
              var(--shadow-md);
}

.sv-vs { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; z-index: 1; }
.sv-vs-rule { width: 1px; height: 40px; background: var(--border-strong); opacity: .7; }
.sv-proj-callout {
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 150px;
}
.sv-proj-callout-label {
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.sv-proj-callout-name {
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 18px;
  line-height: 1.1; margin-top: 3px;
}
.sv-proj-callout-pct {
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
  font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums;
}
.sv-proj-callout.fuji {
  border-color: color-mix(in srgb, var(--c-fuji) 45%, var(--border));
  background: color-mix(in srgb, var(--c-fuji) 8%, var(--surface));
}
.sv-proj-callout.fuji .sv-proj-callout-name,
.sv-proj-callout.fuji .sv-proj-callout-pct { color: var(--c-fuji); }
.sv-proj-callout.sanch {
  border-color: color-mix(in srgb, var(--c-sanch) 45%, var(--border));
  background: color-mix(in srgb, var(--c-sanch) 8%, var(--surface));
}
.sv-proj-callout.sanch .sv-proj-callout-name,
.sv-proj-callout.sanch .sv-proj-callout-pct { color: var(--c-sanch); }
.sv-proj-callout.tossup { border-color: var(--accent); background: var(--accent-soft); }
.sv-proj-callout.tossup .sv-proj-callout-label { color: var(--accent); }
.sv-proj-callout.tossup .sv-proj-callout-name,
.sv-proj-callout.tossup .sv-proj-callout-pct { color: var(--ink-1); }
.sv-leader {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--ink-2);
  max-width: 180px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.sv-leader strong { color: var(--ink-1); font-weight: 800; }
.sv-leader-num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.sv-leader-unit { font-size: 12px; color: var(--ink-3); font-weight: 600; }

/* ── Barra 50/50 ───────────────────────────────────────────── */
.sv-bar-wrap { margin: 16px 0 22px; }
.sv-bar {
  position: relative;
  display: flex;
  height: 34px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--surface-2);
}
.sv-bar-fill { height: 100%; transition: width .6s cubic-bezier(.4,0,.2,1); }
.sv-bar-fill.side-a { background: var(--c-fuji); }
.sv-bar-fill.side-b { background: var(--c-sanch); }
.sv-bar-mid {
  position: absolute;
  left: 50%; top: -4px; bottom: -4px;
  width: 2px;
  background: var(--ink-1);
  transform: translateX(-50%);
  opacity: .55;
}
.sv-bar-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sv-bar-labels #svBarLabelA { color: var(--c-fuji); }
.sv-bar-labels #svBarLabelB { color: var(--c-sanch); }
.sv-bar-mid-label { color: var(--ink-3); font-size: 10.5px; font-weight: 600; }

/* ── Conteo de actas ONPE (todo de ONPE) ───────────────────── */
/* Cards independientes (como la 1ra vuelta): card grande del % + 4 métricas */
.sv-conteo {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}
.sv-conteo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.sv-conteo-main {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.sv-conteo-cell {
  display: flex; flex-direction: column; justify-content: center;
  text-align: center;
}
/* Título tipo 1ra vuelta: rojo, versalita, con rayitas a los lados, centrado */
.sv-conteo-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.sv-conteo-label::before, .sv-conteo-label::after {
  content: ''; width: 24px; height: 1px; background: var(--accent); opacity: 0.4;
}
/* Mismo estilo que el hero-number de la 1ra vuelta: degradado naranja→rojo
   con clip de texto + JetBrains Mono. */
.sv-conteo-pct {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 44px; line-height: 1;
  letter-spacing: -0.03em; margin: 6px 0 4px;
  background: linear-gradient(90deg, #D91023 0%, #E8943A 35%, #B55C1C 65%, #D91023 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  font-variant-numeric: tabular-nums;
}
.sv-conteo-sign { font-size: 26px; font-weight: 500; margin-left: 2px; }
.sv-conteo-sub { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.sv-conteo-track { width: 100%; max-width: 280px; height: 7px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin-top: 14px; }
.sv-conteo-fill { height: 100%; background: var(--teal); border-radius: 5px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.sv-conteo-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.sv-conteo-cell .cell-label { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.sv-conteo-cell .cell-value {
  font-size: 22px; font-weight: 700; font-family: 'JetBrains Mono', monospace;
  margin-top: 3px; font-variant-numeric: tabular-nums;
}
.sv-conteo-cell .cell-value.accent { color: var(--accent); }
.sv-conteo-cell .cell-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ── Desglose de votos emitidos (reusa .prob-card / .votos-*) ── */
.sv-votos-breakdown { margin-bottom: 18px; }

/* ── Proyección al 100%: banda de ganador + fila ganadora ───── */
.sv-proj-panel { margin-bottom: 18px; }
.sv-chart-wrap { position: relative; height: 300px; margin: 6px 0 18px; }
@media (max-width: 560px) { .sv-chart-wrap { height: 240px; } }
.sv-proj-winner {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 10px; margin: 0 0 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px;
}
.sv-proj-winner-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--ink-3); }
.sv-proj-winner-text { font-weight: 600; color: var(--ink-2); }
.sv-proj-winner-text strong { color: var(--ink-1); font-weight: 800; }
.sv-proj-winner-margin {
  margin-left: auto; font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.sv-proj-winner.fuji {
  background: color-mix(in srgb, var(--c-fuji) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--c-fuji) 40%, var(--border));
}
.sv-proj-winner.fuji .sv-proj-winner-dot { background: var(--c-fuji); }
.sv-proj-winner.fuji .sv-proj-winner-text strong { color: var(--c-fuji); }
.sv-proj-winner.sanch {
  background: color-mix(in srgb, var(--c-sanch) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--c-sanch) 40%, var(--border));
}
.sv-proj-winner.sanch .sv-proj-winner-dot { background: var(--c-sanch); }
.sv-proj-winner.sanch .sv-proj-winner-text strong { color: var(--c-sanch); }
.sv-proj-winner.tossup { background: var(--accent-soft); border-color: var(--accent); }
.sv-proj-winner.tossup .sv-proj-winner-dot { background: var(--accent); }
.sv-proj-winner.tossup .sv-proj-winner-text strong { color: var(--accent); }
.proj-row.sv-proj-win { background: var(--surface-2); box-shadow: inset 3px 0 0 0 var(--accent); }
.proj-row.sv-proj-win.fuji  { box-shadow: inset 3px 0 0 0 var(--c-fuji); }
.proj-row.sv-proj-win.sanch { box-shadow: inset 3px 0 0 0 var(--c-sanch); }

/* ── Fila mapa + columna lateral ───────────────────────────── */
.sv-map-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
  align-items: stretch;          /* la columna lateral se estira al alto del mapa */
}
.sv-side-col { display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.sv-particip-card { margin-bottom: 0; flex-shrink: 0; }
/* El historial crece para llenar la columna (sin hueco) y scrollea UNA sola vez
   en su .history-list interno (no doble scroll). */
.sv-history-card {
  margin-bottom: 0;
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
/* Tope para que la lista scrollee (un solo scroll), como en la 1ra vuelta.
   flex:1 la deja crecer hasta el alto de la card; el tope fuerza el scroll. */
.sv-history-card .history-list { flex: 1; min-height: 0; max-height: 420px; }

/* ── Tabla por departamento — pills de ganador ─────────────── */
.sv-winner-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.sv-winner-pill.fuji { background: color-mix(in srgb, var(--c-fuji) 16%, transparent); color: var(--c-fuji); }
.sv-winner-pill.sanch { background: color-mix(in srgb, var(--c-sanch) 16%, transparent); color: var(--c-sanch); }
.sv-winner-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.reg-table .num.fuji-col { color: var(--c-fuji); font-weight: 600; }
.reg-table .num.sanch-col { color: var(--c-sanch); font-weight: 600; }
.sv-prog { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.sv-prog-track { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.sv-prog-fill { height: 100%; background: var(--teal); border-radius: 4px; }
.sv-prog-val { font-size: 11.5px; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.sv-reg-row { cursor: pointer; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 920px) {
  .sv-map-row { grid-template-columns: 1fr; }
  .sv-conteo { grid-template-columns: 1fr; gap: 16px; }
  .sv-history-card { flex: none; }
  .sv-history-card .history-list { max-height: 360px; }
}
@media (max-width: 900px) {
  .sv-proj-callout { min-width: 130px; padding: 9px 11px; }
}
@media (max-width: 720px) {
  .round-switch { order: 3; width: 100%; }
  .round-btn { flex: 1; align-items: center; }
  .sv-eyebrow { font-size: 10px; }
  .sv-conteo-cells { grid-template-columns: 1fr 1fr; }

  /* Hero balotaje: 2 caras lado a lado (fila 2) + callout/líder a ancho
     completo debajo (fila 3). Evita que el grid de 3 columnas se desborde. */
  .sv-h2h {
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    padding: 20px 12px 18px;
    align-items: start;
  }
  .sv-h2h-head { grid-column: 1 / -1; }
  .sv-cand.side-a { grid-column: 1; grid-row: 2; align-items: center; text-align: center; }
  .sv-cand.side-b { grid-column: 2; grid-row: 2; align-items: center; text-align: center; }
  .sv-vs {
    grid-column: 1 / -1; grid-row: 3;
    flex-direction: column; gap: 8px; margin-top: 12px;
  }
  .sv-vs-rule { display: none; }
  .sv-proj-callout { width: 100%; min-width: 0; max-width: 320px; }
  .sv-proj-winner-margin { margin-left: 0; }
  .sv-cand-pct { font-size: 34px; }
  .sv-cand-photo-wrap { width: 74px; height: 74px; }
  .sv-cand-initial { font-size: 32px; }
  .sv-cand-name { font-size: 15.5px; }
  .sv-cand-party { font-size: 10.5px; }

  /* En móvil: las 4 métricas del conteo bajan DEBAJO del cara a cara (queda
     arriba solo el % grande). `display:contents` desagrupa .sv-conteo para
     poder reordenar sus hijos con order dentro del flex de #view-sv. */
  #view-sv.active { display: flex; flex-direction: column; }
  .sv-conteo { display: contents; }
  .sv-statusbar { order: 0; }
  .sv-conteo-main { order: 1; margin-bottom: 16px; }
  .sv-h2h { order: 2; }
  .sv-bar-wrap { order: 3; }
  .sv-conteo-cells { order: 4; margin-bottom: 16px; }
  .sv-votos-breakdown { order: 5; }
  .sv-proj-panel { order: 6; }
  .sv-map-row { order: 7; }
  .sv-regions-card { order: 8; }
}
@media (max-width: 480px) {
  .sv-conteo-cells { grid-template-columns: 1fr; gap: 8px; }
  .sv-conteo-pct { font-size: 40px; }
  .sv-proj-callout-name { font-size: 17px; }
  .sv-ts { width: 100%; margin-left: 0; }
  .sv-cand-pct { font-size: 30px; }
  .sv-cand-photo-wrap { width: 64px; height: 64px; }
  .sv-cand-initial { font-size: 28px; }
  .sv-cand-name { font-size: 14.5px; }
}
