@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4W61C4E.ttf) format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4TC1C4E.ttf) format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4QK1C4E.ttf) format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4e6yC4E.ttf) format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4deyC4E.ttf) format('truetype');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4bCyC4E.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/plusjakartasans/v12/LDIbaomQNQcsA88c7O9yZ4KMCoOg4IA6-91aHEjcWuA_907NSg.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/plusjakartasans/v12/LDIbaomQNQcsA88c7O9yZ4KMCoOg4IA6-91aHEjcWuA_qU7NSg.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/plusjakartasans/v12/LDIbaomQNQcsA88c7O9yZ4KMCoOg4IA6-91aHEjcWuA_m07NSg.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/plusjakartasans/v12/LDIbaomQNQcsA88c7O9yZ4KMCoOg4IA6-91aHEjcWuA_d0nNSg.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/plusjakartasans/v12/LDIbaomQNQcsA88c7O9yZ4KMCoOg4IA6-91aHEjcWuA_TknNSg.ttf) format('truetype');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/plusjakartasans/v12/LDIbaomQNQcsA88c7O9yZ4KMCoOg4IA6-91aHEjcWuA_KUnNSg.ttf) format('truetype');
}

:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  
  --bg-app: #f4f6fa;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-sidebar: #ffffff;
  
  --border-glass: rgba(255, 255, 255, 0.4);
  --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
  --shadow-hover: 0 12px 40px 0 rgba(31, 38, 135, 0.1);
  --border-card: rgba(226, 232, 240, 0.8);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;

  /* Candidate colors mapping (CSS vars for easy usage in JS/HTML) */
  --c-cepeda: linear-gradient(180deg, #ff5e62, #ff2525);
  --c-de-la-espriella: linear-gradient(180deg, #1e3a8a, #0b132b);
  --c-paloma: linear-gradient(180deg, #3b82f6, #1d4ed8);
  --c-fajardo: linear-gradient(180deg, #10b981, #047857);
  --c-claudia: linear-gradient(180deg, #22c55e, #15803d);
  --c-botero: linear-gradient(180deg, #06b6d4, #0891b2);
  --c-lizcano: linear-gradient(180deg, #f97316, #c2410c);
  --c-uribe: linear-gradient(180deg, #6366f1, #4338ca);
  --c-caicedo: linear-gradient(180deg, #ec4899, #db2777);
  --c-barreras: linear-gradient(180deg, #8b5cf6, #6d28d9);
  --c-macollins: linear-gradient(180deg, #f43f5e, #be123c);
  --c-matamoros: linear-gradient(180deg, #64748b, #334155);
  --c-murillo: linear-gradient(180deg, #eab308, #ca8a04);
  --c-blanco: linear-gradient(180deg, #cbd5e1, #94a3b8);
  --c-nulo: linear-gradient(180deg, #475569, #1e293b);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.5);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* App Header */
.app-header {
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-card);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-title-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  font-size: 2rem;
}

.header-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #1e3a8a;
}

.header-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Main Layout Grid */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 0;
  position: relative;
  overflow: hidden;
}

/* Left Content Area */
.main-content {
  flex: 1;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0; /* Prevents flex items from overflowing */
}

/* Top Dashboard Row */
.dashboard-top-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 768px) {
  .dashboard-top-row {
    grid-template-columns: 1fr;
  }
}

/* Turnout Config Card */
.turnout-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 0.65rem 1rem;
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 450px;
}

.turnout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.turnout-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.turnout-census-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 1px;
}

.turnout-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  line-height: 1.15;
}

.turnout-value .pct-val {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.turnout-value .votes-val {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.slider-container {
  position: relative;
  display: flex;
  align-items: center;
}

.range-slider-modern {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  background: #cbd5e1; /* Higher contrast slate track matching candidate sliders */
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.range-slider-modern::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2.5px solid #ffffff; /* Thick white border to match candidate slider thumbs */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); /* Subtle shadow matching candidate thumbs */
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
}

.range-slider-modern::-webkit-slider-thumb:hover {
  transform: scale(1.2); /* Grow on hover, matching candidates */
  background: var(--accent-primary-hover);
}

.range-slider-modern::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
}

.range-slider-modern::-moz-range-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-primary-hover);
}

.turnout-limits {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Quick Info Summary Card */
.summary-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 0.65rem 1.25rem;
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.summary-metric {
  display: flex;
  flex-direction: column;
}

.summary-metric-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-metric-value {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
}

/* Visualization Panel (Chart Area) */
.chart-container-wrapper {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Let it shrink to fit viewport height */
}

.chart-axis-lines {
  position: absolute;
  top: 3.5rem;
  bottom: 106px; /* Aligns with candidate info box height */
  left: 3.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.axis-line {
  width: 100%;
  border-top: 1px dashed rgba(203, 213, 225, 0.5);
  position: relative;
}

.axis-label {
  position: absolute;
  left: -2.75rem;
  top: -7px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 2.25rem;
  text-align: right;
}

/* The actual scrollable chart view */
.chart-scroll-area {
  flex: 1;
  display: flex;
  overflow-x: auto;
  padding-left: 3.5rem; /* Margins to clear the Y-axis labels */
  padding-top: 3.5rem; /* Clearance for the values above the 100% mark */
  padding-bottom: 1.25rem; /* Additional bottom padding to clear the scrollbar and avoid overlapping candidate names */
  gap: 0.75rem;
  align-items: flex-end;
  min-height: 0; /* Let flexbox control the height to avoid clipping */
}

/* Thicker, high-contrast scrollbar specifically for the chart on desktop */
.chart-scroll-area::-webkit-scrollbar {
  height: 10px;
}
.chart-scroll-area::-webkit-scrollbar-track {
  background: rgba(226, 232, 240, 0.4);
  border-radius: 10px;
}
.chart-scroll-area::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.chart-scroll-area::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

/* Candidate Visual Column */
.candidate-column {
  flex: 0 0 110px; /* Fixed width for standard comparison */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  position: relative;
  transition: transform 0.2s;
  cursor: pointer;
}

.candidate-column:hover {
  transform: translateY(-2px);
}

/* Vertical Bar Container */
.bar-track {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
  height: calc(100% - 100px); /* Height of the candidate badge/label combined */
}

/* Filled portion of the Bar */
.bar-fill {
  width: 55px;
  margin: 0 auto;
  border-radius: 9999px 9999px 0 0;
  background: var(--c-cepeda); /* Default */
  height: 0%; /* Dynamic */
  transition: height 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s;
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.candidate-column:hover .bar-fill {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Bar values overlay */
.bar-value-tooltip {
  position: absolute;
  top: -55px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bar-value-tooltip::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: var(--text-primary) transparent;
  display: block;
  width: 0;
}

.candidate-column:hover .bar-value-tooltip,
.candidate-column.active-slide .bar-value-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
}

/* Container for labels always floating above the bar */
.bar-label-above {
  position: absolute;
  bottom: calc(100% + 6px); /* Always 6px above the top of the bar fill */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 90px;
  pointer-events: none;
}

/* Percentage text above column */
.column-percentage {
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-primary); /* Always dark slate */
  margin-bottom: 2px;
}

.column-votes {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary); /* Always dark/slate secondary */
  white-space: nowrap;
}

/* Candidate Identification Area at the bottom of Column */
.candidate-card-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 90px;
  text-align: center;
}

/* Stylized Avatar Badge */
.candidate-avatar-badge {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1rem;
  color: #ffffff;
  margin-bottom: 0.5rem;
  transition: transform 0.2s, border-color 0.2s;
  background-clip: padding-box;
}

.candidate-column:hover .candidate-avatar-badge {
  transform: scale(1.1);
}

.candidate-avatar-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 90px;
}

.simulation-sidebar {
  width: 380px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
}

.sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
}

.sidebar-actions {
  display: flex;
  gap: 0.5rem;
}

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

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

/* Status Bar for Distribution Tracking */
.distribution-tracker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tracker-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-assigned {
  color: var(--accent-primary);
}

.metric-remaining {
  color: var(--text-secondary);
}

.metric-remaining.warning {
  color: var(--accent-warning);
}

.metric-remaining.empty {
  color: var(--accent-success);
}

.tracker-bar-bg {
  height: 8px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.tracker-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary) 0%, #3b82f6 100%);
  width: 0%; /* Dynamic */
  transition: width 0.3s ease, background 0.3s;
}

.tracker-bar-fill.complete {
  background: linear-gradient(90deg, var(--accent-success) 0%, #059669 100%);
}

.tracker-bar-fill.over {
  background: linear-gradient(90deg, var(--accent-danger) 0%, #dc2626 100%);
}

/* Sidebar Sliders List */
.sidebar-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Individual Candidate Slider Card */
.candidate-control-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-card);
  background: #ffffff;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  flex-shrink: 0; /* Prevent cards from squeezing/shrinking in the scrollable flex container */
  min-height: 98px; /* Ensure stable card height so sliders are always fully visible */
}

.candidate-control-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--c-accent); /* Injected dynamically */
}

.candidate-control-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transform: translateX(2px);
}

.control-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.control-card-names {
  display: flex;
  flex-direction: column;
}

.control-card-fam-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.control-card-full-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.control-card-values {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.percentage-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* Modern Number Input */
.percentage-number-input {
  width: 65px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  outline: none;
  transition: all 0.2s;
}

.percentage-number-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Chrome/Safari spinner removal */
.percentage-number-input::-webkit-outer-spin-button,
.percentage-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-suffix {
  margin-left: 2px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.control-slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.slider-row-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.slider-bound-label {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 32px;
  user-select: none;
}

.slider-bound-label.max-val-label {
  text-align: right;
  min-width: 42px;
}

/* Custom styled slider per candidate card */
.candidate-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  background: #cbd5e1; /* Darker slate track for high visibility and contrast */
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.candidate-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c-accent-solid, var(--accent-primary)); /* Solid color of the candidate */
  border: 2.5px solid #ffffff; /* Thick white border to pop out */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
}

.candidate-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.candidate-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-accent-solid, var(--accent-primary));
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.15s;
}

.candidate-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* Blank/Null custom controls styling overrides */
.candidate-control-card.blank-or-null {
  background: #f8fafc;
}

/* Footer Credits */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  border-top: 1px solid var(--border-card);
  background: #ffffff;
}

.app-footer a {
  color: var(--accent-primary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.mobile-floating-controller {
  display: none;
}

#app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* Sector Legend Card styling */
.sector-legend-card {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
}

.sector-legend-title {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 4px;
}

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

.sector-legend-item {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.sector-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
}

.sector-dot.govt {
  background: #ff2525; /* Red representing govt */
}
.sector-dot.opp {
  background: #1d4ed8; /* Blue representing opp */
}
.sector-dot.ind {
  background: #10b981; /* Green representing ind */
}
.sector-dot.blank {
  background: #94a3b8; /* Slate representing blanco */
}
.sector-dot.null {
  background: #1e293b; /* Charcoal representing null */
}

.sector-name {
  color: var(--text-secondary);
  flex: 1;
}

.sector-value {
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--text-primary);
  margin-left: 0.5rem;
}

/* SPA Navigation Tabs styling */
.app-tabs {
  display: flex;
  gap: 0.25rem;
  background: rgba(226, 232, 240, 0.8);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  user-select: none;
}

.tab-button {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-button.active {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.tab-button:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.4);
}

/* Read-only controls styling for reference tabs */
.candidate-control-card.readonly {
  opacity: 0.82;
  background: #f8fafc;
  pointer-events: none; /* Disables all hover translation, clicking and focus */
  border-style: dashed;
}

.candidate-control-card.readonly .percentage-number-input {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-secondary);
  cursor: not-allowed;
}

.candidate-control-card.readonly .candidate-slider {
  background: #cbd5e1;
  opacity: 0.5;
  cursor: not-allowed;
}

/* Disabled button overrides */
button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* Turnout Card Readonly Styles */
.turnout-card.readonly {
  opacity: 0.82;
  pointer-events: none;
  border-style: dashed;
}

.turnout-card.readonly .range-slider-modern {
  opacity: 0.5;
  cursor: not-allowed;
}

.turnout-card.readonly .range-slider-modern::-webkit-slider-thumb {
  background: #94a3b8 !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
}

.turnout-card.readonly .range-slider-modern::-moz-range-thumb {
  background: #94a3b8 !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
}

/* Invamer Info Card styling */
.invamer-info-card {
  position: absolute;
  top: 1.5rem;
  left: 4.5rem;
  background: #ffffff; /* Fondo sólido para garantizar la renderización correcta en html2canvas */
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 515px; /* Otro 25% de incremento (desde 412px) */
}

.invamer-info-text {
  font-size: 0.72rem; /* Reducido un punto para ajustarse a 2 líneas */
  color: var(--text-secondary);
  line-height: 1.35;
  margin: 0;
}

.invamer-info-source {
  font-size: 0.72rem; /* Reducido un punto */
  color: var(--text-primary);
  border-top: 1px solid #e2e8f0;
  padding-top: 4px;
  margin-top: 1px;
}

.source-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s;
}

.source-link:hover {
  color: var(--accent-primary-hover);
  text-decoration: underline;
}

/* Hidden branding header for image exports */
.export-header {
  display: none; /* Hidden on screen by default */
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 0.25rem;
}

.export-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-logo {
  font-size: 1.5rem;
}

.export-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e3a8a;
}

.export-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.export-web {
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 700;
  margin-top: 1px;
}

/* Responsive adjustments to prevent overlap on mobile and tablets */
@media (max-width: 1024px) {
  body {
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  .app-layout {
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }
  
  .app-header {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .main-content {
    flex: none;
    height: auto;
    padding: 1rem 0.5rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Desktop sidebar is hidden on mobile and tablets */
  .simulation-sidebar {
    display: none !important;
  }
  
  #app-container {
    height: auto !important;
    overflow: visible !important;
    padding-bottom: 145px !important; /* Space to scroll contents above the floating editor panel */
  }

  .chart-container-wrapper {
    display: flex !important; /* Restore horizontal chart container visibility on mobile/tablet */
    height: auto !important;
    min-height: auto;
    flex-direction: column;
    padding: 1rem 0.5rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  
  .chart-scroll-area {
    order: 1;
    flex-direction: column;
    overflow-y: visible;
    overflow-x: hidden;
    height: auto;
    padding: 0.5rem 0.5rem !important;
    gap: 0px !important;
    align-items: stretch;
  }
  
  .sector-legend-card {
    order: 2;
    position: static !important;
    margin: 1.5rem 0.5rem 1rem 0.5rem !important;
    width: auto !important;
    max-width: 100% !important;
    box-sizing: border-box;
    box-shadow: var(--shadow-glass) !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-glass) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
  }
  
  .invamer-info-card {
    order: 3;
    position: static !important;
    margin: 0.5rem 0.5rem 1rem 0.5rem !important;
    width: auto !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .invamer-info-text {
    white-space: normal !important;
    word-break: break-word !important;
  }

  .summary-widget {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)) !important;
    gap: 0.5rem !important;
    padding: 0.65rem 0.75rem !important;
    width: 100% !important;
  }
  
  .summary-metric {
    align-items: center;
    text-align: center;
  }
  
  .summary-metric-title {
    font-size: 0.68rem !important;
  }
  
  .summary-metric-value {
    font-size: 1.1rem !important;
  }
  
  /* Horizontal chart layout for mobile */
  .candidate-column {
    flex: none;
    display: grid !important;
    grid-template-columns: auto 1fr !important;
    grid-template-rows: auto auto !important;
    align-items: center !important;
    height: auto !important;
    padding: 0.55rem 0 !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    column-gap: 0.65rem !important; /* Spacing between avatar and name/bar */
    row-gap: 0.25rem !important; /* Spacing between name and bar */
  }
  
  .candidate-column:hover {
    transform: translateX(2px);
  }
  
  .candidate-card-info {
    display: contents !important; /* Direct children become grid items of .candidate-column */
  }
  
  .candidate-avatar-badge {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important; /* Span both name and bar rows */
    width: 36px !important;
    height: 36px !important;
    font-size: 0.85rem !important;
    margin-bottom: 0 !important;
    border: 2.5px solid #ffffff !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
    flex-shrink: 0;
    align-self: center !important;
    justify-self: center !important;
  }
  
  .candidate-avatar-label {
    grid-column: 2 !important;
    grid-row: 1 !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    max-width: none !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    align-self: end !important; /* Position it close to the bar */
    justify-self: start !important; /* Force grid item to align to the left */
    text-align: left !important; /* Force text to align to the left */
    line-height: 1.2 !important;
  }
  
  .bar-track {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
    flex-direction: row !important;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 0 !important;
    height: 20px !important;
    position: relative;
    align-self: start !important; /* Position it close to the name */
  }
  
  .bar-fill {
    width: calc(var(--bar-percentage, 0%) * 0.75) !important; /* Scale to leave 25% width for labels */
    height: 14px !important;
    margin: 0;
    border-radius: 0 9999px 9999px 0;
  }
  
  .bar-label-above {
    position: absolute;
    left: calc(100% + 8px) !important;
    bottom: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: flex;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0 !important;
    text-align: left;
    width: auto !important;
    white-space: nowrap;
    line-height: 1.1;
  }
  
  .column-percentage {
    font-size: 0.75rem;
    margin-bottom: 0;
    font-weight: 800;
  }
  
  .column-votes {
    font-size: 0.58rem !important;
    font-weight: 600;
  }
  
  .summary-widget {
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    justify-content: space-between;
  }
  
  .chart-axis-lines {
    display: none !important;
  }
  
  #btn-export {
    margin: 1.5rem auto;
    width: calc(100% - 3rem);
    justify-content: center;
    display: flex;
  }

  /* Mobile Floating Controller Panel */
  .mobile-floating-controller {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-card);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.08);
    padding: 0.75rem 1.25rem;
    z-index: 999;
    flex-direction: column;
    gap: 0.5rem;
  }

  .floating-header {
    display: flex;
    justify-content: center;
  }

  .floating-title {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }

  .floating-selector-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .mobile-select-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
  }

  .mobile-select-dropdown {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    background-color: #ffffff;
    outline: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
  }

  .mobile-select-dropdown:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  }

  .floating-slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-top: 2px;
  }

  .floating-slider-row .candidate-slider {
    height: 14px !important;
    border-radius: 9999px !important;
  }

  .floating-slider-row .candidate-slider::-webkit-slider-thumb {
    width: 20px !important;
    height: 20px !important;
    background: var(--c-accent-solid, var(--accent-primary)) !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
  }

  .floating-slider-row .candidate-slider::-moz-range-thumb {
    width: 16px !important;
    height: 16px !important;
    background: var(--c-accent-solid, var(--accent-primary)) !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
  }

  .floating-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
  }

  .floating-input-wrapper .percentage-number-input {
    width: 70px;
  }

  .floating-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1px;
  }

  .floating-remaining-lbl {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
  }

  .btn-small {
    padding: 4px 10px !important;
    font-size: 0.75rem !important;
  }
}

/* Cookie Consent Banner */
.cookie-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 1rem 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 700px;
  width: calc(100% - 3rem);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.cookie-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.cookie-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cookie-icon {
  font-size: 1.5rem;
}

.cookie-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
}

.cookie-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .cookie-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    bottom: 1rem;
    width: calc(100% - 2rem);
  }
  .cookie-actions {
    justify-content: flex-end;
  }
}

#app-container.invamer-active {
  padding-bottom: 24px !important;
}
#app-container.invamer-active .mobile-floating-controller {
  display: none !important;
}
