/* ============== Sistema de tema (light + dark) ==============
 * Paleta: azules profundos para acción principal + cyan/teal y morado como
 * acentos contrastantes. Variables semánticas para que cambiar de tema sea
 * un solo toggle en <html data-theme="dark">.
 */
:root {
  /* Tema claro (default) */
  --bg:           #f3f6fc;
  --bg-elev:      #ffffff;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #dde3ee;
  --border-strong:#c4cce0;
  --text:         #0f172a;
  --text-soft:    #334155;
  --muted:        #64748b;

  --primary:        #2563eb;   /* azul principal */
  --primary-dark:   #1d4ed8;
  --primary-soft:   #dbeafe;   /* fondo suave azul */
  --primary-hover:  #1e40af;

  --accent:         #06b6d4;   /* cyan/teal — contraste */
  --accent-soft:    #cffafe;
  --accent2:        #8b5cf6;   /* violeta — segundo acento */
  --accent2-soft:   #ede9fe;

  --secondary:      #eff3ff;
  --danger:         #dc2626;
  --danger-soft:    #fee2e2;
  --warn:           #d97706;
  --warn-soft:      #fef3c7;
  --success:        #059669;
  --success-soft:   #d1fae5;

  --shadow:    0 4px 18px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 36px rgba(15, 23, 42, 0.12);
  --radius:    10px;

  /* Sticky offset — altura del topbar */
  --topbar-h: 60px;
}

html[data-theme="dark"] {
  --bg:           #0b1220;
  --bg-elev:      #111a2e;
  --surface:      #15203a;
  --surface-2:    #1b294a;
  --border:       #243352;
  --border-strong:#34466b;
  --text:         #e6ecf7;
  --text-soft:    #c4cce0;
  --muted:        #8b97b3;

  --primary:        #60a5fa;
  --primary-dark:   #3b82f6;
  --primary-soft:   #1e3a8a;
  --primary-hover:  #93c5fd;

  --accent:         #22d3ee;
  --accent-soft:    #155e75;
  --accent2:        #a78bfa;
  --accent2-soft:   #4c1d95;

  --secondary:      #1b2950;
  --danger:         #f87171;
  --danger-soft:    #4a1717;
  --warn:           #fbbf24;
  --warn-soft:      #4a2d09;
  --success:        #34d399;
  --success-soft:   #064e3b;

  --shadow:    0 4px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

/* Forzar display:none en elementos con atributo [hidden] (defaults del
 * navegador no funcionan con display:flex/grid). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: background-color .25s ease, color .25s ease;
  -webkit-text-size-adjust: 100%;
}

/* Selección de texto coherente con tema */
::selection { background: var(--primary-soft); color: var(--text); }

/* Scrollbar discreto en modo oscuro */
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Estilos comunes a inputs nativos para que respeten el tema */
input, select, textarea, button {
  font-family: inherit;
  color: var(--text);
}
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input[disabled], select[disabled], textarea[disabled] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

/* ============== Topbar ============== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 18px; }
.brand small { color: var(--muted); }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #6f86ff);
  color: white; font-weight: 700;
  display: grid; place-items: center;
  font-size: 18px;
}
.topnav { color: var(--muted); font-size: 12px; }

/* ============== Tabs ============== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;       /* justo debajo del topbar */
  z-index: 99;
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
.tab:hover:not(.disabled) { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab.disabled { color: #c4c9d4; cursor: not-allowed; }

main { padding: 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============== Panel ============== */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-header h2 { margin: 0 0 4px 0; }
.panel-header .muted { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type=search],
input[type=text],
input[type=date],
select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  background: white;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=search] { min-width: 280px; }
select { min-width: 180px; cursor: pointer; }
input[type=search]:focus,
input[type=text]:focus,
input[type=date]:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 89, 255, 0.12);
}

label.block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0;
}

.stats { display: flex; gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 160px;
}
.stat-label { display: block; color: var(--muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--primary); }

/* ============== Tabla ============== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.table-wrap.small { max-height: 280px; overflow: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  text-align: left;
  background: #fafbfd;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #fafbfd; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table.compact thead th,
.data-table.compact tbody td { padding: 8px 10px; font-size: 13px; }

.row-actions { display: flex; gap: 6px; }

.row-inactiva td { opacity: 0.55; }
.row-inactiva td:last-child { opacity: 1; }   /* mantener acciones legibles */

.chip {
  display: inline-block;
  padding: 3px 9px;
  background: var(--secondary);
  color: var(--primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state p { margin: 4px 0; }

/* ============== Buttons ============== */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  transition: background .12s, transform .04s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--primary); }
.btn-secondary:hover { background: #dfe6ff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef0f5; }
.btn-link { background: transparent; color: var(--primary); padding: 6px 8px; }
.btn-link:hover { text-decoration: underline; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #f9d6d3; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 6px;
}
.icon-btn:hover { background: #eef0f5; color: var(--text); }

/* ============== Modal ============== */
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}
.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  overflow: hidden;
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
}
.modal-dialog.wide { width: min(820px, calc(100vw - 32px)); }
.modal-dialog header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-dialog header h3 { margin: 0; font-size: 16px; }
.modal-dialog form,
.modal-dialog .modal-body { padding: 20px; overflow: auto; }
.modal-dialog footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: #fafbfd;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.form-grid label.full,
.form-grid .full { grid-column: 1 / -1; }
.form-grid textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  color: var(--text);
  resize: vertical;
  min-height: 60px;
}
.form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,89,255,.12);
}
.form-grid input { color: var(--text); }

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--danger-bg);
  border: 1px solid #f5c6c1;
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
}
.form-success {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--success-bg);
  border: 1px solid #c3e6cb;
  color: var(--success);
  border-radius: 8px;
  font-size: 13px;
}

/* ============== Import ============== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin: 14px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.upload-zone.dragover { border-color: var(--primary); background: #f6f8ff; }
.hint { color: var(--muted); margin: 4px 0 8px 18px; font-size: 13px; }
.hint b { color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: #fff3cd; color: #856404; }
.badge-err { background: var(--danger-bg); color: var(--danger); }

/* ============== Toast ============== */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #1f2937;
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  z-index: 100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.reg-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.reg-banner.activa { background: #ecfdf5; border-color: #a7f3d0; }
.reg-banner.error  { background: #fef2f2; border-color: #fca5a5; }

.batch-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.batch-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 500; }
.batch-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
#batchBarFill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), #6f86ff);
  transition: width .4s ease;
}
.batch-meta {
  display: flex; gap: 16px; font-size: 12px; color: var(--muted);
  align-items: center; flex-wrap: wrap;
}
.batch-meta span { font-variant-numeric: tabular-nums; }
#batchPct { font-weight: 600; color: var(--primary); }

.add-asistente {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.autocomplete-wrap { position: relative; flex: 1; max-width: 480px; }
.autocomplete-wrap input[type=search] { width: 100%; }

.suggest-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow: auto;
  z-index: 20;
}
.suggest-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.suggest-item:hover, .suggest-item.active { background: #f4f6fd; }
.suggest-item:last-child { border-bottom: none; }
.suggest-item .suggest-name { font-weight: 500; }
.suggest-item .suggest-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.suggest-item.is-other .suggest-meta { color: #b95000; }

/* ============== Auth (login / registro) ============== */
.auth-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e3a8a, #2b59ff);
  display: grid; place-items: center;
  z-index: 200;
}
.auth-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: min(420px, calc(100vw - 32px));
}
.auth-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-form {
  display: flex; flex-direction: column; gap: 12px;
}
.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.auth-form input { color: var(--text); }
.auth-form button[type=submit] { margin-top: 8px; }

#userInfo {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.user-rol {
  background: var(--secondary);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.user-rol.administrador { background: #fef3c7; color: #92400e; }
.user-rol.gerente       { background: #ecfdf5; color: var(--success); }
.user-rol.comunicador   { background: #ede9fe; color: #6d28d9; }

/* ============== Día D — Calculadora de Curules ============== */
.dia-d { border-left: 4px solid #d97706; }
.dia-d-config {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.dia-d-config label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.dia-d-config input, .dia-d-config select {
  padding: 7px 10px; font-size: 14px; color: var(--text);
}
.dia-d-partidos { margin-bottom: 14px; }
.dia-d-partidos input[type=text],
.dia-d-partidos input[type=number] {
  padding: 5px 8px; font-size: 13px; width: 100%;
}
.dia-d-partidos .btn { margin-right: 8px; margin-top: 8px; }
.dia-d-resultado {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 14px 16px;
}
.dia-d-resultado h4 { margin: 0 0 10px 0; }
.dia-d-resultado .resumen {
  background: white;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}
.dia-d-resultado .resumen b { color: var(--primary); }
.dia-d-resultado table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dia-d-resultado th, .dia-d-resultado td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.dia-d-resultado th { background: white; font-weight: 600; }
.dia-d-resultado tr.gana td { background: #ecfdf5; font-weight: 500; }
.dia-d-resultado tr.umbral-falla td { color: #92400e; font-style: italic; }
.dia-d-resultado .cocientes { font-size: 11px; color: var(--muted); }
.dia-d-resultado .marcado { color: var(--success); font-weight: 700; }

.top-lideres-list { padding-left: 24px; margin: 0; }
.top-lideres-list li { padding: 4px 0; font-size: 13px; }
.top-lideres-list li b { color: var(--primary); }

/* ============== Reportes ============== */
.reportes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.reporte-card { padding: 18px 20px; }
.reporte-card h3 { margin: 0 0 6px 0; }
.reporte-card .muted { margin: 0 0 14px 0; font-size: 13px; }
.reporte-config { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; font-size: 13px; }
.reporte-config label { display: flex; align-items: center; gap: 8px; }
.reporte-config select { padding: 6px 10px; }

.print-only { display: none; }

/* ============== Vista de IMPRESION ============== */
@media print {
  /* Tamaño carta US Letter (8.5 x 11") con margenes */
  @page { size: letter; margin: 1.5cm 1.2cm; }

  body { background: white; color: black; font-size: 11pt; }
  .topbar, .tabs, main, .reg-banner, .batch-progress, .toast, .modal { display: none !important; }
  .print-only { display: block !important; }

  #printArea h1 { font-size: 16pt; margin: 0 0 4px 0; }
  #printArea h2 { font-size: 12pt; margin: 12px 0 6px 0; border-bottom: 1px solid #888; padding-bottom: 2px; }
  #printArea .reporte-header {
    border-bottom: 2px solid #2b59ff;
    padding-bottom: 8px;
    margin-bottom: 14px;
    display: flex; justify-content: space-between; align-items: flex-end;
  }
  #printArea .reporte-header small { font-size: 9pt; color: #555; }

  #printArea table {
    width: 100%; border-collapse: collapse; font-size: 9.5pt;
    page-break-inside: auto;
  }
  #printArea tr { page-break-inside: avoid; page-break-after: auto; }
  #printArea th, #printArea td {
    border: 1px solid #ccc;
    padding: 4px 6px;
    text-align: left;
    vertical-align: top;
  }
  #printArea thead th {
    background: #eef2ff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-weight: 600;
  }
  #printArea .group-title {
    margin-top: 16px;
    background: #f4f6fb !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 6px 8px;
    border-left: 3px solid #2b59ff;
    page-break-after: avoid;
  }
  #printArea .group-title h3 { margin: 0; font-size: 11pt; }
  #printArea .foto-mini {
    width: 28px; height: 28px; object-fit: cover; border-radius: 3px;
    border: 1px solid #ccc;
  }
  #printArea .footer {
    margin-top: 18px;
    font-size: 8pt;
    color: #888;
    border-top: 1px solid #ddd;
    padding-top: 6px;
  }
  #printArea .page-break { page-break-before: always; }
}

/* ============== Dashboard / Inicio ============== */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  transition: transform .12s, box-shadow .12s, border-color .12s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.kpi-card::after {
  content: '\2192';
  position: absolute;
  top: 14px; right: 16px;
  color: var(--muted);
  opacity: 0; transition: opacity .12s, transform .12s;
}
.kpi-card:hover::after { opacity: 1; transform: translateX(4px); }
.kpi-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.kpi-value {
  font-size: 38px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.kpi-card.kpi-primary { background: linear-gradient(135deg, var(--primary), #6f86ff); color: white; }
.kpi-card.kpi-primary .kpi-label,
.kpi-card.kpi-primary .kpi-sub { color: rgba(255,255,255,.85); }
.kpi-card.kpi-primary .kpi-value { color: white; }
.kpi-card.kpi-primary::after { color: white; }
.kpi-card.kpi-alerta { border-left: 4px solid var(--danger); }
.kpi-card.kpi-alerta .kpi-value { color: var(--danger); }

.kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.kpi-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.kpi-mini-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.kpi-mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.kpi-mini-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}
.kpi-mini-prog {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.kpi-mini-prog span {
  display: block;
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width .4s ease;
}

.dash-row {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}
.dash-row-2 { grid-template-columns: 2fr 1fr; }
.dash-row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .dash-row-2, .dash-row-3 { grid-template-columns: 1fr; }
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dash-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.dash-card h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}
.chart-box { position: relative; height: 280px; }
.chart-box.small { height: 240px; max-width: 360px; margin: 0 auto; }

.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.dash-list li:last-child { border-bottom: none; }
.dash-list .item-title { font-weight: 500; color: var(--text); }
.dash-list .item-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dash-list .item-right {
  float: right;
  background: var(--secondary);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.hojas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.hoja-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  display: flex; gap: 12px; align-items: flex-start;
}
.hoja-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.hoja-card .avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  background: var(--secondary);
  display: inline-grid; place-items: center; color: var(--primary); font-weight: 600;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.hoja-card h3 { margin: 0 0 4px 0; font-size: 15px; }
.hoja-card .muted { font-size: 12px; }
.hoja-card .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.hoja-card .meta .chip { font-size: 10px; }

.hoja-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  margin-top: 12px;
}
.hoja-aside {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  height: fit-content;
  position: sticky; top: 12px;
}
.hoja-foto-grande {
  width: 140px; height: 140px;
  margin: 0 auto 12px auto;
  border-radius: 50%;
  background: var(--secondary);
  border: 2px solid var(--border);
  display: grid; place-items: center;
  overflow: hidden;
  color: var(--primary); font-size: 36px; font-weight: 700;
}
.hoja-foto-grande img { width: 100%; height: 100%; object-fit: cover; }
.hoja-aside h3 { margin: 6px 0 4px 0; }
.hoja-meta { text-align: left; margin-top: 12px; font-size: 13px; }
.hoja-meta dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-top: 8px; }
.hoja-meta dd { margin: 0; color: var(--text); }

.hoja-main { min-width: 0; }
.hoja-form fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--surface);
}
.hoja-form legend { padding: 0 8px; font-weight: 600; font-size: 13px; color: var(--primary); }
.hoja-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  resize: vertical;
}
.hoja-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,89,255,.12); }

.intereses-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 56px;
}
.interes-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--secondary);
  color: var(--primary);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.interes-chip button {
  background: transparent; border: none; color: var(--primary);
  cursor: pointer; padding: 0; font-size: 16px; line-height: 1;
}
.interes-chip button:hover { color: var(--danger); }

.lista-intereses { list-style: none; margin: 0; padding: 0; }
.lista-intereses li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.lista-intereses li:last-child { border-bottom: none; }
.lista-intereses li .meta { font-size: 12px; color: var(--muted); }

@media (max-width: 800px) {
  .hoja-layout { grid-template-columns: 1fr; }
  .hoja-aside { position: static; }
}

.direccion-builder {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tipo-via-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tipo-via-row button {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all .12s;
}
.tipo-via-row button:hover { border-color: var(--primary); }
.tipo-via-row button.activo {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.direccion-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.direccion-inputs input[type=text] { padding: 6px 10px; font-size: 14px; }
.direccion-inputs #dirVia,
.direccion-inputs #dirCruz,
.direccion-inputs #dirPlaca { width: 70px; flex: 0 0 70px; }
.direccion-inputs .dir-comp { flex: 1 1 200px; min-width: 180px; }
.direccion-inputs span { color: var(--muted); font-weight: 600; }

.foto-uploader {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.foto-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.foto-preview img { width: 100%; height: 100%; object-fit: cover; }
.foto-actions { display: flex; flex-direction: column; gap: 6px; }
.tabla-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 8px;
}
.tabla-avatar.placeholder {
  background: var(--secondary);
  color: var(--primary);
  display: inline-grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
}

.obs-historica {
  font-size: 12px;
  color: #92400e;
  background: #fffbeb;
  border-left: 3px solid #d97706;
  padding: 4px 8px;
  margin-top: 6px;
  border-radius: 4px;
  white-space: pre-wrap;
}

.alerta-card,
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #d97706;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.alerta-card.resuelta,
.ticket-card.resuelta { border-left-color: var(--success); opacity: 0.75; }
.ticket-card.prio-alta { border-left-color: var(--danger); border-left-width: 5px; }
.ticket-card.prio-baja { border-left-color: #94a3b8; }
.alerta-card header,
.ticket-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.alerta-card h4,
.ticket-card h4 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ticket-num {
  background: var(--secondary);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  font-weight: 700;
}
.ticket-meta { font-size: 12px; margin-top: 2px; }
.ticket-estado-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.prioridad-badge {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10px;
  border-radius: 4px;
  font-weight: 600;
  background: #eef2ff;
  color: var(--primary);
}
.prioridad-badge.prio-alta  { background: #fee2e2; color: var(--danger); }
.prioridad-badge.prio-baja  { background: #f1f5f9; color: #64748b; }

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.ticket-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.ticket-field span { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: 10px; font-weight: 600; }
.ticket-field input, .ticket-field select { padding: 6px 8px; font-size: 13px; }
.ticket-tiempo {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}
.ticket-tiempo small { display: block; font-size: 10px; margin-top: 2px; }
.ticket-tiempo.urgente { background: #fef3c7; border-color: #fde68a; }
.ticket-tiempo.urgente small { color: #92400e; }
.ticket-tiempo.overdue { background: #fee2e2; border-color: #fca5a5; }
.ticket-tiempo.overdue small { color: var(--danger); font-weight: 600; }
.alerta-detalle {
  margin: 10px 0 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fffbeb;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #fde68a;
}
.alerta-card.resuelta .alerta-detalle { background: #f0fdf4; border-color: #bbf7d0; }
.alerta-card footer { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.reasignar-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.reasignar-wrap select { min-width: 180px; padding: 6px 10px; }

.map-container {
  height: calc(100vh - 320px);
  min-height: 480px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.map-popup b { color: var(--primary); }
.map-popup small { color: var(--muted); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  input[type=search] { min-width: 0; flex: 1; }
  .actions { width: 100%; }
}

/* ============== Día D — Importar desde URL + visor tipo navegador ============== */
.dia-d-import {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
}
.dia-d-import-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.dia-d-import input[type=url] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: monospace;
  font-size: 13px;
}

.dia-d-visor {
  margin: 14px 0;
}

.visor-browser {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 320px;
}
.visor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(#f1f5f9, #e2e8f0);
  border-bottom: 1px solid var(--border);
}
.visor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.visor-dot.red    { background: #ef4444; }
.visor-dot.yellow { background: #f59e0b; }
.visor-dot.green  { background: #10b981; }
.visor-url {
  flex: 1;
  margin-left: 10px;
  font-family: monospace;
  font-size: 12px;
  color: #475569;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.visor-body {
  position: relative;
  max-height: 560px;
  overflow: auto;
  background: #f1f5f9;
}
.visor-body img {
  display: block;
  width: 100%;
  height: auto;
}
.visor-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.85);
  color: var(--muted);
  font-size: 14px;
  z-index: 2;
}

.visor-detectados {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  max-height: 600px;
  overflow: auto;
}
.visor-detectados .table-wrap.small { max-height: 360px; overflow: auto; }
.visor-detectados input[type=text],
.visor-detectados input[type=number] {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}
.visor-detectados .det-votos { text-align: right; }

/* ============== Resultados Día D: candidatos electos ============== */
.electos-list {
  list-style: decimal inside;
  margin: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.4;
}
.electos-list li {
  padding: 2px 0;
  border-bottom: 1px dashed rgba(0,0,0,.05);
}
.electos-list li:last-child { border-bottom: none; }
.electo-nombre { font-weight: 600; }
.electo-pref {
  margin-left: 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.electos-col { min-width: 220px; max-width: 360px; vertical-align: top; }
.tabla-resultado .cocientes {
  font-family: monospace;
  font-size: 11px;
  color: var(--muted);
  max-width: 240px;
  word-break: break-all;
}
.aviso-electos {
  margin: 10px 0;
  padding: 8px 12px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 13px;
  color: #78350f;
}
.tabla-resultado tr.gana td { background: #ecfdf5; }
.tabla-resultado tr.umbral-falla td { color: var(--muted); font-style: italic; }
.tabla-resultado .marcado { color: #059669; font-weight: 600; }

/* ============== Widget foto-capture (reusable) ============== */
.foto-capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.foto-capture .fc-preview {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
}
.foto-capture .fc-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.foto-capture .fc-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.foto-capture .fc-actions .btn { font-size: 12px; padding: 6px 10px; }
.foto-capture .fc-hint { font-size: 11px; text-align: center; }

/* Overlay de cámara */
.foto-capture .fc-cam-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.foto-capture .fc-cam-card {
  background: #000;
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}
.foto-capture .fc-cam-card video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 8px;
}
.foto-capture .fc-cam-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.foto-capture .fc-cam-actions .btn { min-width: 130px; }

/* ============== Toggle de vista lista/calendario ============== */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-toggle .vt-btn {
  background: var(--surface);
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  border-right: 1px solid var(--border);
}
.view-toggle .vt-btn:last-child { border-right: none; }
.view-toggle .vt-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ============== Calendario mensual ============== */
.cal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}
.cal-leyenda {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 12px;
  flex-wrap: wrap;
}
.cal-leyenda .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.cal-leyenda .dot-encuentro { background: var(--primary); }
.cal-leyenda .dot-diaD { background: var(--accent2); }
.cal-leyenda .dot-hoy { background: var(--success); }

.cal-dias-semana {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-celda {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 90px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform .1s ease, border-color .15s ease, box-shadow .15s ease;
}
.cal-celda:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.cal-celda.cal-otro-mes {
  background: var(--bg);
  opacity: .55;
}
.cal-celda.cal-hoy {
  border-color: var(--success);
  background: var(--success-soft);
}
.cal-celda.cal-diaD {
  border: 2px solid var(--accent2);
  background: var(--accent2-soft);
}
.cal-celda.cal-seleccionada {
  outline: 2px solid var(--primary);
}
.cal-num {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.cal-eventos {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}
.cal-chip {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-chip.cal-chip-diaD {
  background: var(--accent2-soft);
  color: var(--accent2);
  font-weight: 700;
  text-transform: uppercase;
}
.cal-detalle {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cal-detalle h4 { margin: 0 0 10px 0; }
.cal-evento-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.cal-evento-row:last-child { border-bottom: none; }

@media (max-width: 640px) {
  .cal-celda { min-height: 70px; padding: 4px; }
  .cal-chip { font-size: 10px; padding: 1px 4px; }
}

/* ============== Testigos electorales ============== */
.testigos-elec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
}
.testigos-elec-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.testigos-elec-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.testigos-elec-card .elec-card-head {
  font-size: 15px;
  color: var(--primary);
}

/* Sub-tabs dentro del detalle de elección */
.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 12px 0 14px 0;
  overflow-x: auto;
}
.subtab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  white-space: nowrap;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--primary); border-bottom-color: var(--primary); }
.subpanel { display: none; }
.subpanel.active { display: block; }

/* Código de acceso (testigo) */
.codigo-acceso {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-family: monospace;
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--accent);
}

/* ============== Tareas del encuentro ============== */
#tablaTareas .tarea-desc {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.4;
  max-width: 540px;
}
#tablaTareas tr.tarea-resuelta td {
  color: var(--muted);
  background: #f8fafc;
}
#tablaTareas .ticket-num-link {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
#tablaTareas .ticket-num-link:hover { text-decoration: underline; }

.highlight-flash {
  animation: highlight-flash 2s ease;
  box-shadow: 0 0 0 3px rgba(43,89,255,.35);
}
@keyframes highlight-flash {
  0%   { background: #dbeafe; }
  100% { background: transparent; }
}

/* ============== Modal "Nuevo asistente" ============== */
.cedula-buscar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.cedula-buscar input[type=text] {
  font-family: monospace;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.cedula-buscar button {
  white-space: nowrap;
  height: 38px;
  align-self: flex-end;
}
.busca-resultado {
  margin: 6px 0 14px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}
.busca-resultado.info {
  background: #dbeafe;
  border-left: 3px solid #2563eb;
  color: #1e3a8a;
}
.busca-resultado.new {
  background: #ecfdf5;
  border-left: 3px solid #10b981;
  color: #064e3b;
}
.busca-resultado.warn {
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  color: var(--danger);
}
.busca-resultado .btn-link { padding: 0; font-weight: 600; }

/* Fieldset que envuelve el resto del formulario hasta validar cédula */
.lider-resto {
  border: none;
  padding: 0;
  margin: 0;
}
.lider-resto[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

/* Botón "Candidatos" en la tabla de partidos */
#tablaPartidos [data-candidatos] {
  font-size: 12px;
  padding: 4px 8px;
  white-space: nowrap;
}
#tablaPartidos [data-candidatos] .cand-count {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ============== Toggle de tema en el header ============== */
.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 38px; height: 38px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .2s ease, transform .15s ease, border-color .2s ease;
}
.theme-toggle:hover { background: var(--primary-soft); border-color: var(--primary); transform: rotate(15deg); }
.theme-toggle .theme-icon-light { display: none; }
.theme-toggle .theme-icon-dark  { display: inline; }
html[data-theme="dark"] .theme-toggle .theme-icon-light { display: inline; }
html[data-theme="dark"] .theme-toggle .theme-icon-dark  { display: none; }

/* ============== Ajustes globales para que TODO respete el tema ============== */
.panel-header h2,
.dash-card h3,
.dash-card h4,
section h2,
main h2, main h3, main h4 { color: var(--text); }

.muted, small.muted { color: var(--muted); }

/* Panels / cards genéricas */
.panel, .dash-card, .modal-dialog, .auth-card, .hoja-card, .reporte-card {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Tablas */
.data-table {
  background: var(--surface);
  color: var(--text);
}
.data-table thead th {
  background: var(--surface-2);
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--primary-soft); }
.data-table td { color: var(--text); }

/* Chips/badges adaptan a tema */
.badge { border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 600; }
.badge-ok   { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft);    color: var(--warn); }
.badge-err  { background: var(--danger-soft);  color: var(--danger); }

/* Botones — paleta nueva */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--secondary);
  color: var(--primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger); filter: brightness(0.92); }
.btn-warn {
  background: var(--warn);
  color: #fff;
}
.btn-link {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 6px 10px;
  text-decoration: none;
}
.btn-link:hover { color: var(--primary-hover); text-decoration: underline; }

/* Inputs y selects en modo oscuro: borde más visible */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: var(--muted); }

/* KPI cards mejoradas */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--text);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-lg); }
.kpi-card.kpi-primary { background: linear-gradient(135deg, var(--primary), var(--accent2)); color: #fff; border-color: transparent; }
.kpi-card.kpi-primary .kpi-label, .kpi-card.kpi-primary .kpi-sub { color: rgba(255,255,255,.85); }
.kpi-card.kpi-alerta  { border-left: 4px solid var(--warn); }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-sub   { color: var(--muted); font-size: 12px; }

/* Stats compactos */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { color: var(--text); font-size: 20px; font-weight: 700; }

/* Auth overlay refresh */
.auth-overlay {
  background: rgba(8, 14, 32, .55);
  backdrop-filter: blur(6px);
}
html[data-theme="dark"] .auth-overlay { background: rgba(0, 0, 0, .65); }
.auth-card { box-shadow: var(--shadow-lg); }

/* Modales — fondo oscurecido y card adaptable */
.modal-backdrop {
  background: rgba(8, 14, 32, .55);
  backdrop-filter: blur(4px);
}
html[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, .7); }
.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal-dialog header { border-bottom: 1px solid var(--border); }
.modal-dialog footer { border-top: 1px solid var(--border); background: var(--surface-2); }

/* ============== Responsive: breakpoints adicionales ============== */
@media (max-width: 1024px) {
  .dia-d-visor { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row-2, .dash-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  main { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .brand small { display: none; }
  .panel-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .panel-header .actions { width: 100%; }
  .panel-header .actions input[type=search],
  .panel-header .actions select { width: 100%; }
  .actions { flex-wrap: wrap; gap: 6px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-mini-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { flex-wrap: wrap; }
  .stat { flex: 1 1 calc(50% - 8px); }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal-dialog,
  .modal-dialog.wide {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    overflow-y: auto;
  }
  .table-wrap { overflow-x: auto; }
  .data-table { min-width: 600px; }
  /* Mapa más alto que ancho en mobile */
  .map-container { height: 60vh; min-height: 360px; }
}
@media (max-width: 480px) {
  .tab { padding: 12px 10px; font-size: 13px; }
  .kpi-mini-grid { grid-template-columns: 1fr; }
  .reportes-grid { grid-template-columns: 1fr; }
  .btn { padding: 8px 10px; font-size: 13px; }
  /* Acciones de fila se apilan */
  .row-actions { flex-direction: column; gap: 4px; align-items: stretch; }
  /* Visor del navegador en pantalla pequeña */
  .visor-toolbar { flex-wrap: wrap; }
  .visor-url { width: 100%; }
}
