:root {
  --bg-app: #f8f9fa;
  --bg-surface: #ffffff;
  --border-color: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent-red: #ef4444;
  --accent-red-bg: #fef2f2;
  --accent-green: #10b981;
  --radius: 8px;
  --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* PALETA PREDICCIÓN */
  --c-nulo: #64748b;
  --c-mariana: #f59e0b;
  --c-leyda: #f97316;
  --c-fricson: #3b82f6;
  --c-madeline: #a855f7;
  --c-miguel: #ef4444;
  --c-tema-default: #1e293b;
  --c-tema-otros: #94a3b8;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* OVERLAY DE CARGA Y BIENVENIDA */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(248, 249, 250, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), visibility 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.8s ease, transform 0.8s ease, visibility 0.8s ease;
  text-align: center;
}

.loader-step.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(17, 24, 39, 0.1);
  border-top-color: var(--text-main);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-main);
  text-transform: uppercase;
}

.welcome-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.welcome-subtitle {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.welcome-version {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: rgba(107, 114, 128, 0.6);
  margin-top: 8px;
  text-transform: uppercase;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* BARRA SUPERIOR */
.top-bar {
  height: 50px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
}

.brand { display: flex; align-items: center; }

.logo {
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-main);
  font-size: 15px;
}

.top-nav-centered {
  position: relative;
  justify-self: center;
  display: flex;
  align-items: center;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
  gap: 4px;
}

.nav-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: var(--bg-surface);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.nav-btn {
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  padding: 6px 16px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.nav-btn:hover { color: var(--text-main); }
.nav-btn.active { color: var(--text-main); font-weight: 700; }

.top-bar-right { display: flex; justify-content: flex-end; }

.view-panel {
  display: none;
  flex: 1;
  height: calc(100vh - 50px);
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

.view-blank { background: var(--bg-app); }

.top-section-expanded {
  display: flex;
  height: 62%;
  border-bottom: 1px solid var(--border-color);
}

.map-container {
  flex: 1;
  position: relative;
  background: #e5e7eb;
}

#map { width: 100%; height: 100%; }

.sidebar-inline {
  width: 320px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.bottom-dashboard-full {
  height: 38%;
  background: var(--bg-app);
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr 1fr;
  gap: 12px;
  padding: 10px 16px;
  overflow-y: auto;
}

.dash-card {
  background: var(--bg-surface);
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.bars-list { display: flex; flex-direction: column; gap: 4px; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  line-height: 1.2;
}

.bar-row.top-leader .bar-label {
  font-weight: 800;
  color: var(--accent-red);
}

.bar-label {
  width: 120px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  background: var(--text-main);
  width: 0%;
  transition: width 0.6s ease-out;
}

.glow-fast-green {
  background: var(--accent-green);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
  animation: pulse-glow-green 1.2s infinite ease-in-out;
}

.glow-slow-green {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
  animation: pulse-glow-green 3s infinite ease-in-out;
}

.glow-fast-red {
  background: var(--accent-red);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
  animation: pulse-glow-red 1.2s infinite ease-in-out;
}

.glow-slow-red {
  background: var(--accent-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
  animation: pulse-glow-red 3s infinite ease-in-out;
}

@keyframes pulse-glow-green {
  0% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 14px rgba(16, 185, 129, 0.9); }
  100% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.3); }
}

@keyframes pulse-glow-red {
  0% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 14px rgba(239, 68, 68, 0.9); }
  100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.3); }
}

.bar-fill-infinite {
  height: 100%;
  background: linear-gradient(90deg, #111827 0%, #4b5563 50%, #111827 100%);
  background-size: 200% 100%;
  animation: pulse-fill 3.5s infinite linear;
}

@keyframes pulse-fill {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.bar-value-container {
  width: 105px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-weight: 700;
  font-size: 11px;
}

.arrow-up { color: var(--accent-green); }
.arrow-down { color: var(--accent-red); }

.vertical-list { display: flex; flex-direction: column; gap: 4px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  padding: 4px 8px;
  background: #f9fafb;
  border-radius: 4px;
  border-left: 3px solid var(--text-main);
  transition: all 0.3s ease;
}

.list-item::before { content: "▲"; color: var(--accent-green); font-size: 9px; }

.list-item.push-highlight {
  background: #ffffff;
  border-left-color: var(--accent-red);
  box-shadow: 0 3px 8px rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
  animation: push-pulse 2s infinite ease-in-out;
}

@keyframes push-pulse {
  0% { box-shadow: 0 2px 6px rgba(239, 68, 68, 0.12); }
  50% { box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25); }
  100% { box-shadow: 0 2px 6px rgba(239, 68, 68, 0.12); }
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.activity-subtitle { font-size: 10px; color: var(--text-muted); line-height: 1.3; margin-bottom: 6px; }

.live-clock {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-main);
  font-family: monospace;
}

.status-indicator { margin: 8px 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.badge.en-vivo { background: var(--accent-red-bg); color: var(--accent-red); }
.badge.en-vivo::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent-red);
  border-radius: 50%;
  animation: pulse-badge 1.5s infinite;
}

.badge.cerrado { background: #f3f4f6; color: var(--text-muted); }

.counter-display { margin-top: 8px; }
.counter-number { display: block; font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.counter-label { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.8px; margin-top: 4px; display: block; }

.separator { border: 0; border-top: 1px solid var(--border-color); }

.periods-list { display: flex; flex-direction: column; gap: 6px; }

.period-item {
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.period-item:hover { border-color: #9ca3af; }
.period-item.active { border-color: var(--text-main); background: #fafafa; }

.period-name { font-size: 11px; font-weight: 700; }
.period-status { font-size: 10px; font-weight: 600; color: var(--text-muted); }

.map-pulse-heavy { transform-origin: center; animation: svg-push-heavy 1.8s infinite cubic-bezier(0.215, 0.61, 0.355, 1); }
.map-pulse-light { transform-origin: center; animation: svg-push-light 2.6s infinite cubic-bezier(0.215, 0.61, 0.355, 1); }

@keyframes svg-push-heavy {
  0% { fill-opacity: 0.60; stroke-width: 1px; stroke: #ef4444; stroke-opacity: 0.8; }
  50% { fill-opacity: 0.25; stroke-width: 12px; stroke: #ef4444; stroke-opacity: 0.2; }
  100% { fill-opacity: 0.60; stroke-width: 1px; stroke: #ef4444; stroke-opacity: 0.8; }
}

@keyframes svg-push-light {
  0% { fill-opacity: 0.35; stroke-width: 1px; stroke: #ef4444; stroke-opacity: 0.5; }
  50% { fill-opacity: 0.15; stroke-width: 6px; stroke: #ef4444; stroke-opacity: 0.1; }
  100% { fill-opacity: 0.35; stroke-width: 1px; stroke: #ef4444; stroke-opacity: 0.5; }
}

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

/* ESTILOS AMPLIADOS DE LA PÁGINA PREDICCIÓN */
.view-prediccion-content {
  background: var(--bg-app);
  padding: 30px 40px;
  overflow-y: auto;
}

.prediction-grid-layout {
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.prediction-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 28px 36px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.prediction-main-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  margin-bottom: 28px;
}

/* BARRAS VERTICALES ANCHAS Y NOMBRES EN 2 LÍNEAS */
.vertical-chart-container {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  height: 220px;
  padding-bottom: 30px;
  border-bottom: 1px solid #f3f4f6;
}

.v-col-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  flex: 1;
}

.v-pct-label {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-main);
}

.v-bar-track {
  width: 55px;
  height: 160px;
  background: #f3f4f6;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.v-bar-fill {
  width: 100%;
  border-radius: 8px 8px 0 0;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.v-name-label {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
  line-height: 1.25;
  height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ORGANIGRAMA Y MESA RECTANGULAR DE CONCEJO */
.council-board-container {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.council-row-center {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.seat-box {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.seat-alcalde {
  background: var(--accent-red);
  font-size: 13px;
  font-weight: 800;
  padding: 10px 24px;
}

.seat-urbano { background: #3b82f6; }
.seat-rural { background: #10b981; }

.council-table-grid {
  display: grid;
  grid-template-columns: 140px 1fr 140px;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.side-seat-cell {
  display: flex;
  justify-content: center;
}

.center-table-cell {
  display: flex;
  justify-content: center;
}

.main-rectangular-table {
  width: 100%;
  height: 52px;
  background: #e2e8f0;
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  letter-spacing: 1px;
  text-transform: uppercase;
}

@media (max-width: 1024px) {
  body { height: auto; overflow: auto; }
  .top-bar { grid-template-columns: 1fr; height: auto; padding: 12px; gap: 12px; }
  .view-panel { height: auto; }
  .top-section-expanded { flex-direction: column; height: auto; }
  .sidebar-inline { width: 100%; border-left: none; border-top: 1px solid var(--border-color); }
  .map-container { height: 350px; }
  .bottom-dashboard-full { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; }
  .v-bar-track { width: 38px; }
  .council-table-grid { grid-template-columns: 1fr; }
}