/* ============================================================
   TerraData — Hoja de estilos principal
   Paleta: #2C3E50 · #5D6D7E · #1ABC9C · #F4F6F8
   ============================================================ */

/* ── Variables ──────────────────────────────────────────── */
:root {
  --color-primary:       #2C3E50;
  --color-secondary:     #5D6D7E;
  --color-accent:        #1ABC9C;
  --color-accent-dark:   #17A589;
  --color-bg:            #F4F6F8;
  --color-surface:       #FFFFFF;
  --color-text:          #2C3E50;
  --color-text-muted:    #7F8C8D;
  --color-border:        #E8ECEF;
  --navbar-height:       60px;
  --sidebar-width:       250px;
  --sidebar-collapsed:   64px;
  --radius:              8px;
  --shadow-sm:           0 1px 3px rgba(44,62,80,.08);
  --shadow-md:           0 4px 16px rgba(44,62,80,.12);
  --transition:          .18s ease;
}

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

html, body { height: 100%; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: .9rem;
  line-height: 1.6;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-dark); }

/* ════════════════════════════════════════════════════════════
   NAVBAR (barra superior fija)
   ════════════════════════════════════════════════════════════ */
.td-navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-height);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem 0 1rem;
  z-index: 1100;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.td-navbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.2px;
  text-decoration: none;
}

.td-navbar-brand:hover { color: #fff; }

.td-navbar-brand-icon {
  width: 28px;
  height: 28px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.td-navbar-brand small {
  display: block;
  font-size: .65rem;
  font-weight: 400;
  color: rgba(255,255,255,.5);
  letter-spacing: .2px;
  line-height: 1;
}

.td-navbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.td-nav-user {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: rgba(255,255,255,.88);
  font-size: .82rem;
}

.td-nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.td-nav-user-name { font-weight: 600; }

.td-nav-badge {
  display: inline-block;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.7);
  border-radius: 20px;
  padding: .15rem .55rem;
  font-size: .68rem;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,.15);
}

.td-nav-logout {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.8);
  padding: .35rem .75rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.td-nav-logout:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* Botón hamburguesa (móvil) */
.td-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: .25rem;
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
.td-sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #263545;          /* azul-pizarra oscuro, continuación del navbar */
  border-right: none;
  overflow: hidden;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width .25s cubic-bezier(.4,0,.2,1), transform var(--transition);
  box-shadow: 2px 0 12px rgba(0,0,0,.18);
}

/* Scrollbar sidebar */
.td-sidebar::-webkit-scrollbar { width: 4px; }
.td-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

/* ── Encabezado con botón colapsar ─────────────────────── */
.td-sidebar-hd {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: .4rem .55rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.td-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.45);
  padding: .28rem .35rem;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.td-collapse-btn:hover {
  background: rgba(255,255,255,.09);
  color: rgba(255,255,255,.95);
}
.td-collapse-btn svg { width: 17px; height: 17px; }

/* ── Menú scrollable ─────────────────────────────────── */
.td-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .35rem 0 .5rem;
}

/* ── Dashboard (link superior) ───────────────────────── */
.td-nav-top {
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.07);
  margin-bottom: .5rem;
  padding: .72rem 1.1rem;
}

/* ── Etiquetas de sección ───────────────────────────── */
.td-section-label {
  padding: 1.1rem 1.1rem .28rem;
  font-size: .64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.38);
  white-space: nowrap;
  overflow: hidden;
}

.td-section-label span { display: block; }

/* ── Ítem de menú ───────────────────────────────────── */
.td-nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .58rem 1.1rem;
  color: rgba(255,255,255,.72);
  font-size: .82rem;
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.td-nav-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  border-left-color: rgba(26,188,156,.55);
}

.td-nav-link.active {
  background: rgba(26,188,156,.18);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--color-accent);
}

.td-nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: rgba(255,255,255,.42);
  transition: color var(--transition);
}

.td-nav-link:hover svg { color: rgba(255,255,255,.85); }
.td-nav-link.active svg { color: var(--color-accent); }
.td-nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* ── Parte inferior del sidebar ─────────────────────── */
.td-sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: .6rem .85rem;
  flex-shrink: 0;
  background: rgba(0,0,0,.2);
  overflow: hidden;
}

.td-sidebar-user-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  overflow: hidden;
}

.td-sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.td-sidebar-user-name {
  font-size: .79rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-sidebar-user-role {
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  white-space: nowrap;
}

.td-sidebar-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.45);
  padding: .28rem;
  border-radius: 5px;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.td-sidebar-logout-btn:hover { background: rgba(231,76,60,.25); color: #ff8b8b; }
.td-sidebar-logout-btn svg { width: 16px; height: 16px; }

/* ════════════════════════════════════════════════════════════
   SIDEBAR COLAPSADO (body.td-collapsed — solo desktop)
   ════════════════════════════════════════════════════════════ */
body.td-collapsed .td-sidebar {
  width: var(--sidebar-collapsed);
  overflow: visible; /* permite que los tooltips sobresalgan */
}

body.td-collapsed .td-menu { overflow: visible; }
body.td-collapsed .td-main { margin-left: var(--sidebar-collapsed); }

body.td-collapsed .td-nav-label,
body.td-collapsed .td-section-label span,
body.td-collapsed .td-sidebar-user-info,
body.td-collapsed .td-sidebar-logout-btn { display: none; }

body.td-collapsed .td-section-label {
  padding: 0;
  margin: .35rem .5rem;
  height: 1px;
  background: rgba(255,255,255,.1);
}

body.td-collapsed .td-nav-link,
body.td-collapsed .td-nav-top {
  justify-content: center;
  padding: .65rem 0;
  border-left: none;
  position: relative;
}

body.td-collapsed .td-collapse-btn svg { transform: rotate(180deg); }
body.td-collapsed .td-sidebar-hd { justify-content: center; }
body.td-collapsed .td-sidebar-bottom { padding: .6rem .5rem; }

/* Tooltip en modo colapsado */
body.td-collapsed .td-nav-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-primary);
  color: #fff;
  padding: .28rem .65rem;
  border-radius: 5px;
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  box-shadow: var(--shadow-md);
}

body.td-collapsed .td-nav-link:hover::after { opacity: 1; }

/* ════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
   ════════════════════════════════════════════════════════════ */
.td-main {
  margin-left: var(--sidebar-width);
  padding-top: var(--navbar-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}

.td-content {
  flex: 1;
  padding: 1.75rem;
  width: 100%;
  min-width: 0;
}

/* ════════════════════════════════════════════════════════════
   COMPONENTES
   ════════════════════════════════════════════════════════════ */

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

.td-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.td-card-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.td-card-title-icon {
  width: 16px;
  height: 16px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.td-card-body { padding: 1.25rem; }

.td-card-link {
  font-size: .78rem;
  color: var(--color-accent);
  font-weight: 500;
  white-space: nowrap;
}
.td-card-link:hover { color: var(--color-accent-dark); }

/* ── KPI / Stat cards ──────────────────────────────────── */
.td-stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

.td-stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.td-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.td-stat-icon svg {
  width: 22px;
  height: 22px;
}

.td-stat-icon.teal   { background: rgba(26,188,156,.12); color: var(--color-accent); }
.td-stat-icon.blue   { background: rgba(44,62,80,.08);   color: var(--color-primary); }
.td-stat-icon.orange { background: rgba(230,126,34,.1);  color: #E67E22; }
.td-stat-icon.red    { background: rgba(231,76,60,.1);   color: #E74C3C; }

.td-stat-body { flex: 1; min-width: 0; }

.td-stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--color-text-muted);
  margin-bottom: .25rem;
}

.td-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
  margin-bottom: .2rem;
}

.td-stat-value.accent { color: var(--color-accent); }

.td-stat-sub {
  font-size: .76rem;
  color: var(--color-text-muted);
}

/* ── Barras de candidato ───────────────────────────────── */
.td-cand-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .8rem;
}

.td-cand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.td-cand-name {
  font-size: .82rem;
  font-weight: 500;
  color: var(--color-text);
  min-width: 170px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.td-cand-bar-wrap {
  flex: 1;
  height: 7px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
}

.td-cand-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .7s cubic-bezier(.4,0,.2,1);
}

.td-cand-pct {
  font-size: .78rem;
  font-weight: 700;
  color: var(--color-text);
  min-width: 44px;
  text-align: right;
  flex-shrink: 0;
}

.td-cand-votes {
  font-size: .75rem;
  color: var(--color-text-muted);
  min-width: 64px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Badges ────────────────────────────────────────────── */
.td-badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1px;
  white-space: nowrap;
}

.td-badge-pendiente   { background: #FEF9E7; color: #B7950B; }
.td-badge-revisado    { background: #EAF2FF; color: #2471A3; }
.td-badge-aprobado    { background: #E8F8F5; color: #1A8A70; }
.td-badge-rechazado   { background: #FDEDEC; color: #C0392B; }
.td-badge-reportado   { background: #FDEDEC; color: #C0392B; }
.td-badge-en_revision { background: #EAF2FF; color: #2471A3; }
.td-badge-resuelto    { background: #E8F8F5; color: #1A8A70; }
.td-badge-info        { background: #EAF2FF; color: #2471A3; }

/* ── Tablas ────────────────────────────────────────────── */
.td-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .845rem;
}

.td-table th {
  padding: .6rem .9rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  background: #FAFBFC;
  white-space: nowrap;
}

.td-table td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.td-table tbody tr:last-child td { border-bottom: none; }
.td-table tbody tr:hover { background: #F8FAFB; }

/* ── Botones ───────────────────────────────────────────── */
.btn-td-primary {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  font-size: .845rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn-td-primary:hover {
  background: var(--color-accent-dark);
  color: #fff;
  box-shadow: 0 3px 10px rgba(26,188,156,.3);
}

.btn-td-secondary {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: .5rem 1.1rem;
  border-radius: 7px;
  font-size: .845rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-td-secondary:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-td-danger {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #FDEDEC;
  color: #C0392B;
  border: 1px solid rgba(192,57,43,.2);
  padding: .45rem .9rem;
  border-radius: 7px;
  font-size: .845rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-td-danger:hover { background: rgba(231,76,60,.15); }

.btn-td-sm { padding: .3rem .65rem; font-size: .78rem; }

/* ── Forms ─────────────────────────────────────────────── */
.td-form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: .3rem;
}

.td-form-control {
  width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  font-size: .855rem;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.td-form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(26,188,156,.1);
}

.td-form-group { margin-bottom: 1rem; }

/* ── Alertas ───────────────────────────────────────────── */
.td-alert {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .7rem 1rem;
  border-radius: 7px;
  font-size: .855rem;
  margin-bottom: 1rem;
}

.td-alert-error   { background: #FDEDEC; color: #C0392B; border: 1px solid rgba(192,57,43,.2); }
.td-alert-success { background: #E8F8F5; color: #1A8A70; border: 1px solid rgba(26,188,156,.2); }
.td-alert-info    { background: #EAF2FF; color: #2471A3; border: 1px solid rgba(36,113,163,.18); }
.td-alert-warning { background: #FEF9E7; color: #9A7D0A; border: 1px solid rgba(183,149,11,.2); }

/* ── Login page ────────────────────────────────────────── */
.td-login-bg {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 25%, rgba(52,120,180,.45) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 75%, rgba(20,80,140,.40) 0%, transparent 48%),
    radial-gradient(ellipse at 50% 50%, rgba(30,70,110,.30) 0%, transparent 70%),
    linear-gradient(135deg, #08131d 0%, #1c3f60 35%, #0f2a42 65%, #06111a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.td-login-card {
  background: rgba(255,255,255,.97);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.20);
  padding: 2.5rem 2.25rem 2rem;
  width: 100%;
  max-width: 400px;
}

.td-login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.td-login-logomark {
  width: 56px;
  height: 56px;
  background: var(--color-primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  margin-bottom: .75rem;
}

.td-login-logomark svg { width: 28px; height: 28px; }

.td-login-logo h1 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -.4px;
  margin-bottom: .25rem;
}

.td-login-logo p {
  font-size: .78rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ── Mapa ──────────────────────────────────────────────── */
#td-map {
  width: 100%;
  height: 480px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

/* ── Gráficas ──────────────────────────────────────────── */
.td-chart-wrap {
  position: relative;
  width: 100%;
}

/* ── Footer ────────────────────────────────────────────── */
.td-footer {
  text-align: center;
  padding: 1rem 1.75rem;
  font-size: .75rem;
  color: #BDC3C7;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-top: auto;
}

/* ── Winner badge ──────────────────────────────────────── */
.td-winner-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: rgba(26,188,156,.1);
  color: var(--color-accent);
  border: 1px solid rgba(26,188,156,.2);
  border-radius: 20px;
  padding: .12rem .5rem;
  font-size: .68rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ── Utilities ─────────────────────────────────────────── */
.td-divider { border: none; border-top: 1px solid var(--color-border); margin: 1.25rem 0; }
.td-text-muted  { color: var(--color-text-muted) !important; }
.td-text-accent { color: var(--color-accent) !important; }
.td-fw-bold     { font-weight: 700 !important; }
.td-fs-sm       { font-size: .8rem !important; }

/* Grid helpers */
.td-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.td-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.td-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

@media (max-width: 900px) {
  .td-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .td-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 540px) {
  .td-grid-4, .td-grid-3, .td-grid-2 { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .td-nav-toggle { display: flex; }

  .td-nav-user-name,
  .td-nav-badge { display: none; }

  /* En móvil el sidebar siempre se oculta con transform, no con width */
  .td-sidebar {
    width: var(--sidebar-width) !important; /* anular colapso en móvil */
    transform: translateX(-100%);
    z-index: 1050;
  }

  .td-sidebar.td-open { transform: translateX(0); }

  /* Botón colapsar oculto en móvil (no aplica en vista pequeña) */
  .td-collapse-btn { display: none; }

  /* En móvil el colapso de desktop no afecta el margen */
  body.td-collapsed .td-main,
  .td-main { margin-left: 0 !important; }

  /* Sidebar bottom: siempre mostrar en móvil */
  body.td-collapsed .td-nav-label { display: block; }
  body.td-collapsed .td-section-label span { display: block; }
  body.td-collapsed .td-sidebar-user-info { display: block; }
  body.td-collapsed .td-sidebar-logout-btn { display: flex; }

  body.td-collapsed .td-section-label {
    padding: .7rem 1.1rem .22rem;
    margin: 0;
    height: auto;
    background: none;
  }

  body.td-collapsed .td-nav-link,
  body.td-collapsed .td-nav-top {
    justify-content: flex-start;
    padding: .58rem 1.1rem;
    border-left: 3px solid transparent;
    position: static;
  }

  body.td-collapsed .td-nav-link::after { display: none; }
  body.td-collapsed .td-sidebar-hd { justify-content: flex-end; }
  body.td-collapsed .td-sidebar-bottom { padding: .6rem .85rem; }

  .td-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1040;
  }

  .td-overlay.td-open { display: block; }

  .td-content { padding: 1rem .85rem; }

  /* Tablas responsivas */
  .td-table th, .td-table td { padding: .5rem .65rem; font-size: .8rem; }
}

@media (max-width: 576px) {
  .td-content { padding: .85rem .65rem; }
  .td-stat-value { font-size: 1.4rem; }
  .td-cand-name { min-width: 120px; max-width: 140px; }
}

/* ── Bootstrap modal: z-index sobre navbar (1100) ─────── */
.modal-backdrop { z-index: 1110 !important; }
.modal          { z-index: 1120 !important; }

/* ── Scrollbar global ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-secondary); }

/* ════════════════════════════════════════════════════════════
   ALIASES DE FORMULARIO (usados en módulos de campaña/reportes)
   ════════════════════════════════════════════════════════════ */
.td-label  { display:block; font-size:.78rem; font-weight:600; color:var(--color-text); margin-bottom:.3rem; }
.td-input  {
  width:100%; padding:.5rem .8rem;
  border:1px solid var(--color-border); border-radius:7px;
  font-size:.855rem; color:var(--color-text);
  background:var(--color-surface); outline:none;
  transition:border-color var(--transition), box-shadow var(--transition);
  font-family:inherit;
}
.td-input:focus {
  border-color:var(--color-accent);
  box-shadow:0 0 0 3px rgba(26,188,156,.1);
}
.td-input::placeholder { color:var(--color-text-muted); }

/* ════════════════════════════════════════════════════════════
   FAB — Botón flotante de acción
   ════════════════════════════════════════════════════════════ */
.td-fab {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(26,188,156,.4);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  z-index: 900;
}
.td-fab:hover {
  background: var(--color-accent-dark);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 20px rgba(26,188,156,.5);
}
.td-fab svg { pointer-events: none; }

/* ════════════════════════════════════════════════════════════
   PANEL LATERAL SLIDE-IN (usado en casillas.php)
   ════════════════════════════════════════════════════════════ */
.td-slide-panel {
  position: fixed;
  top: var(--navbar-height);
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 92vw;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 24px rgba(44,62,80,.12);
  transform: translateX(100%);
  transition: transform .3s ease;
  z-index: 1050;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.td-slide-panel.open { transform: translateX(0); }
.td-slide-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}
.td-slide-panel-body { padding: 1.25rem; flex: 1; }
.td-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 1049;
}
.td-panel-overlay.open { display: block; }

/* ════════════════════════════════════════════════════════════
   ANIMACIONES
   ════════════════════════════════════════════════════════════ */
@keyframes tdFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tdFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tdSlideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.td-content { animation: tdFadeIn .22s ease; }

/* Trigger para paneles de gráficas (estadísticas) */
.td-chart-panel {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .35s ease, transform .35s ease;
}
.td-chart-panel.td-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ════════════════════════════════════════════════════════════
   @MEDIA PRINT — global
   ════════════════════════════════════════════════════════════ */
@media print {
  .td-sidebar,
  .td-navbar,
  .td-footer,
  .td-fab,
  .no-print       { display: none !important; }

  .td-main        { margin-left: 0 !important; padding-top: 0 !important; }
  .td-content     { padding: .5rem !important; animation: none !important; }

  body            { background: #fff !important; font-size: 10pt; }

  .td-card        {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  canvas          { max-width: 100% !important; }

  .btn-td-primary,
  .btn-td-secondary,
  .btn-td-danger  { display: none !important; }

  a               { text-decoration: none; color: #000; }

  .td-table th,
  .td-table td    { font-size: 9pt; }
}
