/* ============================================
   SISTEMA DE DISEÑO — Elecciones 2026 · v1.0
   Layers: Design tokens → Layout → Typography → Components → Responsive utils
   ============================================ */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  /* Brand Corporate */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-500: #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;
  --brand-900: #1e3a8a;
  --brand-accent: #6366f1;

  /* Semantic */
  --success:   #16a34a;
  --success-soft: #dcfce7;
  --success-text: #14532d;
  --warning:   #f59e0b;
  --warning-soft: #fef3c7;
  --warning-text: #78350f;
  --danger:    #dc2626;
  --danger-soft: #fee2e2;
  --danger-text: #7f1d1d;
  --info:      #0ea5e9;
  --info-soft: #e0f2fe;
  --info-text: #0c4a6e;

  /* Neutral palette */
  --neutral-50:  #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;
  --neutral-950: #020617;

  /* Bg + surface */
  --app-bg:   linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #ecfeff 100%);
  --surface:  #ffffff;
  --surface-muted: var(--neutral-50);
  --border:   var(--neutral-200);
  --text:     var(--neutral-900);
  --text-muted: var(--neutral-500);

  /* Typography scale (ratio 1.25 — Major Third) */
  --fs-xs:   0.75rem;   /* 12px */
  --fs-sm:   0.875rem;  /* 14px */
  --fs-base: 1rem;      /* 16px */
  --fs-lg:   1.25rem;   /* 20px */
  --fs-xl:   1.5625rem; /* 25px */
  --fs-2xl:  2rem;      /* 32px */
  --fs-3xl:  2.5rem;    /* 40px */
  --lh-base: 1.55;
  --lh-tight: 1.2;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Spacing scale (4px base) */
  --s-1:  0.25rem;  /* 4  */
  --s-2:  0.5rem;   /* 8  */
  --s-3:  0.75rem;  /* 12 */
  --s-4:  1rem;     /* 16 */
  --s-5:  1.25rem;  /* 20 */
  --s-6:  1.5rem;   /* 24 */
  --s-8:  2rem;     /* 32 */
  --s-10: 2.5rem;   /* 40 */
  --s-12: 3rem;     /* 48 */
  --s-16: 4rem;     /* 64 */

  /* Effects */
  --shadow-xs:  0 1px 2px  rgba(15,23,42,.06);
  --shadow-sm:  0 2px 6px  rgba(15,23,42,.08);
  --shadow-md:  0 6px 18px rgba(15,23,42,.10);
  --shadow-lg:  0 14px 40px rgba(15,23,42,.14);
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-w: 288px;
  --sidebar-w-collapsed: 80px;
  --topbar-h: 72px;
  --content-maxw: 1280px;
}

/* ---------- 2. RESET & LAYOUT ---------- */
*,*::before,*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--app-bg);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
img, svg { display: block; max-width: 100%; }
svg { vertical-align: middle; }
.icon { display: inline-block; vertical-align: text-bottom; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 12px; height: 12px; stroke-width: 2; }
.icon-md { width: 16px; height: 16px; stroke-width: 2; }
.icon-lg { width: 20px; height: 20px; stroke-width: 2; }
.icon-xl { width: 24px; height: 24px; stroke-width: 2; }
button { font-family: inherit; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
:focus { outline: 0; }
:focus-visible {
  outline: 3px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 9999;
  background: var(--brand-700); color: white; padding: var(--s-3) var(--s-4);
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* Layout shell — sidebar + main */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}
.skip-to-content { display: block; padding: var(--s-4); }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--neutral-900) 0%, var(--neutral-800) 100%);
  color: var(--neutral-100);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,.06);
  z-index: 40;
}
.sidebar-brand {
  padding: var(--s-6) var(--s-5) var(--s-4);
  display: flex; align-items: center; gap: var(--s-3);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-500), #8b5cf6);
  color: white; display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(37,99,235,.45);
}
.brand-logo svg { width: 24px; height: 24px; stroke-width: 2; }
.brand-title { font-size: var(--fs-base); font-weight: 800; line-height: 1.15; color: white; }
.brand-sub   { font-size: var(--fs-xs); color: var(--neutral-400); margin-top: 2px; font-weight: 500; letter-spacing: .2px; }

.sidebar-nav { padding: var(--s-4) var(--s-3); overflow-y: auto; flex: 1; }
.nav-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--neutral-500);
  padding: var(--s-3) var(--s-3) var(--s-2);
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: block; }
.nav-link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-3);
  border-radius: var(--radius-sm);
  color: var(--neutral-300);
  font-weight: 500;
  font-size: var(--fs-sm);
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
  cursor: pointer;
  user-select: none;
}
.nav-link:hover { background: rgba(255,255,255,.05); color: white; }
.nav-link.active {
  background: linear-gradient(90deg, rgba(37,99,235,.22), rgba(99,102,241,.08));
  color: white;
  box-shadow: inset 3px 0 0 var(--brand-300);
}
.nav-link svg { width: 20px; height: 20px; stroke-width: 1.8; flex-shrink: 0; color: currentColor; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
  letter-spacing: .2px;
}
.sidebar-footer {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: var(--s-3);
}
.avatar {
  width: 38px; height: 38px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-500), var(--success));
  color: white; display: grid; place-items: center;
  font-weight: 700; font-size: var(--fs-sm);
  border: 2px solid rgba(255,255,255,.1);
}
.sidebar-user-meta { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: var(--fs-sm); font-weight: 600; color: white; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.sidebar-user-role { font-size: var(--fs-xs); color: var(--neutral-400); }
.role-chip {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
  letter-spacing: .3px; text-transform: uppercase;
}
.role-chip.super   { background: var(--danger-soft); color: var(--danger-text); }
.role-chip.admin   { background: var(--warning-soft); color: var(--warning-text); }

/* Main shell */
.app-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--s-8);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-6);
}
.topbar-title {
  display: flex; align-items: center; gap: var(--s-4);
}
.page-breadcrumb {
  display: flex; align-items: center; gap: var(--s-2);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500;
}
.page-breadcrumb .sep { color: var(--neutral-300); }
.page-breadcrumb .current { color: var(--text); font-weight: 600; }
.page-title {
  font-size: var(--fs-xl); font-weight: 800; line-height: var(--lh-tight);
  margin: 0;
  color: var(--neutral-900);
  letter-spacing: -.01em;
}
.topbar-actions { display: flex; align-items: center; gap: var(--s-3); }

.content-wrap {
  padding: var(--s-8);
  width: 100%;
  max-width: var(--content-maxw);
  margin: 0 auto;
  flex: 1;
}
.app-foot {
  text-align: center; color: var(--text-muted);
  font-size: var(--fs-xs);
  padding: var(--s-6) var(--s-6) var(--s-8);
  border-top: 1px solid var(--border);
  margin-top: var(--s-12);
  background: rgba(255,255,255,.5);
  backdrop-filter: blur(4px);
}
.app-foot b { color: var(--neutral-700); }

/* Mobile menu button (topbar hamburger) */
.menu-toggle {
  display: none;
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  align-items: center; justify-content: center;
  padding: 0;
}
.menu-toggle svg { width: 22px; height: 22px; stroke-width: 2; }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  z-index: 35;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* ---------- 3. TYPOGRAPHY ---------- */
h1 { font-size: var(--fs-3xl); font-weight: 800; line-height: var(--lh-tight); letter-spacing: -.02em; margin: 0 0 var(--s-4); }
h2 { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 var(--s-4); }
h3 { font-size: var(--fs-xl); font-weight: 700; line-height: 1.3; margin: 0 0 var(--s-3); }
h4 { font-size: var(--fs-lg); font-weight: 600; line-height: 1.35; margin: 0 0 var(--s-3); }
p  { margin: 0 0 var(--s-4); }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: var(--fs-sm); }
.text-xs    { font-size: var(--fs-xs); }
.font-bold  { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }

/* ---------- 4. COMPONENTS ---------- */

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 10px var(--s-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand-600); color: white;
  font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: 0 4px 12px rgba(37,99,235,.22);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover   { background: var(--brand-700); box-shadow: 0 6px 16px rgba(37,99,235,.28); transform: translateY(-1px); color: white; }
.btn:active  { transform: translateY(0); }
.btn:disabled{ opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg     { width: 18px; height: 18px; stroke-width: 2; }
.btn-sm      { padding: 6px var(--s-3); font-size: var(--fs-xs); border-radius: var(--radius-xs); }
.btn-lg      { padding: 14px var(--s-6); font-size: var(--fs-base); border-radius: var(--radius-md); }
.btn.ghost {
  background: white; color: var(--brand-700);
  border-color: var(--brand-200);
  box-shadow: var(--shadow-xs);
}
.btn.ghost:hover { background: var(--brand-50); color: var(--brand-800); border-color: var(--brand-300); }
.btn.success { background: var(--success); box-shadow: 0 4px 12px rgba(22,163,74,.25); }
.btn.success:hover { background: #15803d; }
.btn.danger  { background: var(--danger); box-shadow: 0 4px 12px rgba(220,38,38,.25); }
.btn.danger:hover  { background: #b91c1c; }
.btn.warn    { background: var(--warning); color: var(--warning-text); box-shadow: 0 4px 12px rgba(245,158,11,.25); }
.btn.warn:hover    { background: #d97706; color: white; }
.btn-plain { background: transparent; color: var(--text-muted); border: 1px solid var(--border); box-shadow: none; }
.btn-plain:hover { background: var(--neutral-50); color: var(--text); }

/* --- Cards & surfaces --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card.section-title { margin-bottom: var(--s-2); }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--s-5);
  gap: var(--s-4); flex-wrap: wrap;
}
.section-head h2, .section-head h3 { margin: 0; }
.section-head .subtitle { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--s-1); }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-5);
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--kpi-accent, linear-gradient(135deg, rgba(37,99,235,.08), rgba(99,102,241,.04)));
  pointer-events: none;
}
.kpi-card .kpi-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  margin-bottom: var(--s-3);
  background: var(--kpi-icon-bg, var(--brand-100));
  color: var(--kpi-icon-color, var(--brand-700));
  position: relative;
}
.kpi-card .kpi-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.kpi-card .kpi-label {
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: var(--s-2);
  position: relative;
}
.kpi-card .kpi-value {
  font-size: var(--fs-2xl); font-weight: 800;
  color: var(--text);
  line-height: var(--lh-tight);
  letter-spacing: -.02em;
  position: relative;
}
.kpi-card .kpi-foot {
  margin-top: var(--s-3);
  display: flex; align-items: center; gap: var(--s-2);
  position: relative;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Ambito mini cards */
.ambito-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s-4); }
.ambito-card {
  background: linear-gradient(135deg, var(--brand-50), #f5f3ff);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-md);
  padding: var(--s-4) var(--s-5);
}
.ambito-card .title { font-size: var(--fs-xs); font-weight: 700; color: var(--neutral-600); text-transform: uppercase; letter-spacing: .4px; margin-bottom: var(--s-1); }
.ambito-card .value { font-size: var(--fs-xl); font-weight: 800; color: var(--neutral-900); letter-spacing: -.01em; }

/* --- Badges / Chips --- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  text-transform: uppercase;
}
.badge.ok     { background: var(--success-soft); color: var(--success-text); }
.badge.review { background: #ecfdf5; color: #065f46; }
.badge.obs    { background: var(--warning-soft); color: var(--warning-text); }
.badge.pend   { background: var(--brand-50); color: var(--brand-700); }
.badge.err    { background: var(--danger-soft); color: var(--danger-text); }
.badge.info   { background: var(--info-soft); color: var(--info-text); }
.badge.neutral{ background: var(--neutral-100); color: var(--neutral-700); }
.badge svg    { width: 14px; height: 14px; stroke-width: 2; flex-shrink: 0; }
.badge-lg     { font-size: var(--fs-sm); padding: 6px 14px; }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-weight: 600; font-size: var(--fs-xs);
  border: 1px solid var(--border);
}
.chip svg { width: 14px; height: 14px; stroke-width: 2; }
.chip.ok    { background: var(--success-soft); color: var(--success-text); border-color: #86efac; }
.chip.warn  { background: var(--warning-soft); color: var(--warning-text); border-color: #fcd34d; }
.chip.err   { background: var(--danger-soft); color: var(--danger-text); border-color: #fca5a5; }
.chip.info  { background: var(--info-soft); color: var(--info-text); border-color: #7dd3fc; }

/* FIX ICONOS GIGANTES REVISION HUMANA: clamp SVG/img dentro de filas voto */
.vote-row-name svg,
.vote-row-name svg *,
.ambito-head svg,
.ambito-head svg *,
.review-meta-info svg,
.review-meta-info svg * {
  width: 14px !important;
  height: 14px !important;
  stroke-width: 2 !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  max-width: none !important;
  vertical-align: middle !important;
}
.vote-row-name img.org-logo {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  object-fit: contain !important;
  border-radius: 5px !important;
  flex-shrink: 0 !important;
  background: #ffffff !important;
  border: 1px solid var(--border) !important;
  padding: 1px !important;
  box-sizing: border-box !important;
  display: inline-block !important;
  vertical-align: middle !important;
}

/* FIX SAVE INDICATOR PILL (disquete fuera del contenedor) */
.rs-save-indicator {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 9px !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}
.rs-save-indicator > svg:first-child,
.rs-save-indicator > svg:first-child * {
  width: 16px !important;
  height: 16px !important;
  max-width: none !important;
  max-height: 16px !important;
  display: inline-block !important;
  box-sizing: content-box !important;
  vertical-align: middle !important;
  stroke-width: 2 !important;
  flex-shrink: 0 !important;
  padding: 7px !important;
  border-radius: 999px !important;
  background: var(--success, #10b981) !important;
  color: #ffffff !important;
}

/* =============== FIX ICONOS GIGANTES: MÓDULO GESTIÓN ORGANIZACIONES =============== */
/* Capa 1 Global: clamp 100% preventivo */
.kpi-card svg, .kpi-card svg *,
.org-drag-handle svg, .org-drag-handle svg *,
.org-preview svg, .org-preview svg *,
.save-order-bar svg, .save-order-bar svg *,
.org-toolbar svg, .org-toolbar svg *,
.btn-xs svg, .btn-xs svg *,
.status-toggle svg, .status-toggle svg *,
.org-manual-move svg, .org-manual-move svg *,
svg.toast-icon, svg.toast-icon * {
  max-width: none !important;
  display: inline-block !important;
  flex-shrink: 0 !important;
  vertical-align: middle !important;
  box-sizing: content-box !important;
}
.kpi-card svg, .kpi-card svg * {
  width: 32px !important; height: 32px !important; stroke-width: 2 !important;
}
.org-drag-handle svg, .org-drag-handle svg * {
  width: 18px !important; height: 18px !important; stroke-width: 2.5 !important;
}
.org-preview svg, .org-preview svg * {
  width: 22px !important; height: 22px !important; stroke-width: 1.8 !important;
}
.save-order-bar svg, .save-order-bar svg * {
  width: 16px !important; height: 16px !important; stroke-width: 2 !important;
}
.org-toolbar svg, .org-toolbar svg * {
  width: 18px !important; height: 18px !important; stroke-width: 2 !important;
}
.btn-xs svg, .btn-xs svg * {
  width: 13px !important; height: 13px !important; stroke-width: 2.2 !important;
}
.status-toggle svg, .status-toggle svg * {
  width: 11px !important; height: 11px !important; stroke-width: 2.5 !important;
}
.org-manual-move svg, .org-manual-move svg * {
  width: 12px !important; height: 12px !important; stroke-width: 2.2 !important;
}

/* --- Tables --- */
.table-wrap { overflow: auto; border-radius: var(--radius-md); border: 1px solid var(--border); background: white; }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data-table th, table.data-table td {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table thead th {
  background: var(--neutral-50);
  color: var(--neutral-600);
  font-weight: 700;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table tbody tr:hover td { background: var(--neutral-50); }
table.data-table .mono { font-variant-numeric: tabular-nums; font-weight: 600; }

/* --- Forms --- */
label.field-label {
  display: block;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--neutral-700);
  margin-bottom: var(--s-2);
}
input[type=text], input[type=password], input[type=number], input[type=search],
input[type=date], select, textarea {
  width: 100%;
  padding: 11px var(--s-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-300);
  font-size: var(--fs-sm);
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: all .15s ease;
  line-height: 1.4;
}
input::placeholder, textarea::placeholder { color: var(--neutral-400); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500);
  outline: 3px solid rgba(37,99,235,.15);
  background: white;
}
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>"); background-repeat: no-repeat; background-position: right var(--s-3) center; padding-right: var(--s-10); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.form-grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s-4); }
.form-help { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--s-1); }
.form-error { font-size: var(--fs-xs); color: var(--danger); margin-top: var(--s-1); font-weight: 600; }

/* Filter bar (sticky header) */
.filter-bar {
  display: flex; gap: var(--s-3); align-items: flex-end; flex-wrap: wrap;
  padding: var(--s-4) var(--s-5);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: var(--s-6);
}
.filter-bar .field { flex: 1 1 180px; min-width: 180px; }
.filter-bar .actions { display: flex; gap: var(--s-2); align-items: flex-end; }

/* Confidence visual (mini bar + circle ring) */
.confidence-row {
  display: flex; align-items: center; gap: var(--s-3);
}
.conf-bar-track {
  flex: 1; height: 8px; background: var(--neutral-100);
  border-radius: var(--radius-full); overflow: hidden; min-width: 120px;
}
.conf-bar-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width .4s ease, background-color .3s ease;
}
.conf-bar-fill.high   { background: linear-gradient(90deg, #10b981, #16a34a); }
.conf-bar-fill.medium { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.conf-bar-fill.low    { background: linear-gradient(90deg, #f97316, #dc2626); }
.conf-pct { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-sm); min-width: 40px; text-align: right; }

.confidence-ring-wrap { display: grid; place-items: center; position: relative; width: 160px; height: 160px; flex-shrink: 0;}
.confidence-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.confidence-ring .track { stroke: var(--neutral-100); fill: none; stroke-width: 12; }
.confidence-ring .ring-fill {
  fill: none; stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 452.389;
  transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1), stroke .5s ease;
}
.ring-inner-num {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.ring-inner-num .big   { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1; }
.ring-inner-num .small { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; margin-top: var(--s-1); text-transform: uppercase; letter-spacing: .5px; }

/* Cards grid actas list */
.acta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-5);
}
.acta-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--s-3);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.acta-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--brand-200);
}
.acta-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--card-accent, var(--brand-500));
  transition: width .2s ease;
}
.acta-card:hover::before { width: 6px; }
.acta-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
}
.acta-meta-id { font-family: "SF Mono", Consolas, monospace; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.acta-mesa-num { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -.01em; color: var(--text); line-height: 1.2; }
.acta-meta-row {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500;
  flex-wrap: wrap;
}
.acta-meta-row .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--neutral-300); display: inline-block; }
.acta-card-cta {
  display: flex; gap: var(--s-2); align-items: center; justify-content: flex-end;
  margin-top: var(--s-1);
  padding-top: var(--s-3); border-top: 1px dashed var(--border);
}

/* Pagination */
.paginator {
  display: flex; align-items: center; justify-content: center;
  gap: var(--s-2); margin-top: var(--s-8); flex-wrap: wrap;
}
.paginator a, .paginator span.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: var(--fs-sm);
  color: var(--neutral-700);
  border: 1px solid var(--border);
  background: white;
  text-decoration: none;
  transition: all .15s ease;
}
.paginator a:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-200); }
.paginator a.btn-nav { padding: 0 var(--s-3); width: auto; gap: var(--s-1); }
.paginator a.btn-nav svg { width: 16px; height: 16px; stroke-width: 2.5; }
.paginator .current { background: var(--brand-600); color: white; border-color: var(--brand-600); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.paginator .ellipsis { border: 0; color: var(--text-muted); background: transparent; width: auto; }
.paginator .info { color: var(--text-muted); font-size: var(--fs-xs); margin-right: auto; font-weight: 500; }

/* Messages */
.msg {
  padding: var(--s-4) var(--s-5);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: var(--s-5);
  display: flex; align-items: flex-start; gap: var(--s-3);
  border-left: 4px solid;
}
.msg svg { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; margin-top: 2px; }
.msg.err  { background: var(--danger-soft); color: var(--danger-text); border-left-color: var(--danger); }
.msg.ok   { background: var(--success-soft); color: var(--success-text); border-left-color: var(--success); }
.msg.info { background: var(--info-soft); color: var(--info-text); border-left-color: var(--info); }
.msg.warn { background: var(--warning-soft); color: var(--warning-text); border-left-color: var(--warning); }

/* Toast notification */
.toast-container {
  position: fixed; bottom: var(--s-6); right: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-2);
  z-index: 9998;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--radius-md);
  background: var(--neutral-900); color: white;
  box-shadow: var(--shadow-lg);
  font-weight: 500; font-size: var(--fs-sm);
  transform: translateX(120%);
  opacity: 0;
  transition: transform .35s cubic-bezier(.4,0,.2,1), opacity .25s ease;
  min-width: 260px;
  pointer-events: auto;
  border-left: 4px solid var(--brand-500);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warn    { border-left-color: var(--warning); }
.toast svg { width: 18px; height: 18px; stroke-width: 2.2; flex-shrink: 0; }

/* Charts grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: var(--s-5);
  margin-bottom: var(--s-6);
}
.charts-grid > .card canvas { max-height: 360px; }
.charts-grid-2 {
  display: grid; grid-template-columns: repeat(2,1fr); gap: var(--s-5);
  margin-bottom: var(--s-6);
}
.chart-wrap { position: relative; width: 100%; height: 360px; }
.chart-wrap.sm { height: 280px; }

/* Split review layout */
.split-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-6);
  align-items: start;
  min-height: calc(100vh - var(--topbar-h) - 160px);
}
.split-image-pane {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-6));
}
.split-image-wrap {
  background: var(--neutral-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 4/3;
  box-shadow: var(--shadow-sm);
}
.split-image-wrap img#review-img {
  width: 100%; height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform .25s ease;
  background: repeating-conic-gradient(var(--neutral-200) 0% 25%, white 0% 50%) 50% / 18px 18px;
}
.split-image-controls {
  position: absolute; bottom: var(--s-3); right: var(--s-3);
  display: flex; gap: var(--s-2);
  background: rgba(15,23,42,.82);
  backdrop-filter: blur(10px);
  padding: var(--s-2);
  border-radius: var(--radius-md);
  z-index: 2;
}
.split-image-controls button {
  width: 34px; height: 34px; border: 0; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08); color: white; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s ease;
}
.split-image-controls button:hover { background: rgba(255,255,255,.18); }
.split-image-controls button svg { width: 18px; height: 18px; stroke-width: 2; }

.split-form-pane .vote-tabs {
  display: flex; gap: var(--s-2); flex-wrap: wrap;
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
}
.vote-tab {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: white;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--neutral-600);
  cursor: pointer;
  transition: all .15s ease;
}
.vote-tab:hover { background: var(--neutral-50); border-color: var(--neutral-300); }
.vote-tab.active {
  background: var(--brand-600); color: white;
  border-color: var(--brand-600);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.vote-tab-panel { display: none; }
.vote-tab-panel.active { display: block; }

.vote-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all .15s ease;
}
.vote-row:hover { background: var(--neutral-50); border-color: var(--border); }
.vote-row + .vote-row { margin-top: var(--s-1); }
.vote-row.is-corrected { background: var(--success-soft); border-color: #86efac; }
.vote-row.org-name { font-weight: 600; font-size: var(--fs-sm); color: var(--text); display: flex; align-items: center; gap: var(--s-2);}
.vote-row .vote-input-wrap { position: relative; }
.vote-row .vote-input-wrap input { text-align: right; padding-right: var(--s-8); font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-base); color: var(--text); }
.vote-row .ia-tag {
  position: absolute; right: var(--s-3); top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .2px;
  pointer-events: none;
}
.vote-row .ia-tag.orig-conf-low { color: var(--danger); font-weight: 800; }
.vote-row .row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 80px; }
.vote-row .diff-badge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-full); background: var(--danger-soft); color: var(--danger-text); text-transform: uppercase;}
.vote-row .diff-badge.match { background: var(--success-soft); color: var(--success-text); }

/* Hero banner */
.hero-banner {
  background: linear-gradient(135deg, var(--neutral-900) 0%, #1e3a8a 100%);
  color: white;
  border-radius: var(--radius-xl);
  padding: var(--s-8) var(--s-10);
  margin-bottom: var(--s-6);
  display: flex; align-items: center; gap: var(--s-10);
  flex-wrap: wrap;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero-banner::before {
  content: ""; position: absolute; right: -10%; top: -30%; width: 60%; height: 220%;
  background: radial-gradient(circle at center, rgba(99,102,241,.25), transparent 60%);
  pointer-events: none;
}
.hero-content { flex: 1 1 360px; position: relative; z-index: 2; }
.hero-eyebrow { font-size: var(--fs-xs); font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: var(--brand-300); margin-bottom: var(--s-3); display: block; }
.hero-title { font-size: var(--fs-3xl); font-weight: 800; line-height: 1.05; margin: 0 0 var(--s-3); color: white; letter-spacing: -.02em; }
.hero-sub { font-size: var(--fs-base); line-height: 1.6; color: rgba(255,255,255,.72); margin: 0; max-width: 520px;}
.hero-actions { display: flex; gap: var(--s-3); margin-top: var(--s-6); flex-wrap: wrap; }
.hero-actions .btn.ghost { background: rgba(255,255,255,.12); color: white; border-color: rgba(255,255,255,.2); box-shadow: none; }
.hero-actions .btn.ghost:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.35); }

/* Login card (no sidebar layout) */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--app-bg);
}
.login-hero {
  background: linear-gradient(160deg, var(--neutral-900) 0%, #1e3a8a 50%, #581c87 100%);
  color: white;
  padding: var(--s-16) var(--s-12);
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(99,102,241,.35), transparent 45%),
    radial-gradient(circle at 20% 80%, rgba(14,165,233,.25), transparent 50%);
  pointer-events: none;
}
.login-hero-top { display: flex; align-items: center; gap: var(--s-4); position: relative; z-index: 2; }
.login-hero-top .brand-big {
  width: 60px; height: 60px; border-radius: 18px;
  background: linear-gradient(135deg, var(--brand-500), #8b5cf6);
  color: white; display: grid; place-items: center;
  box-shadow: 0 18px 40px rgba(37,99,235,.5);
}
.login-hero-top .brand-big svg { width: 32px; height: 32px; stroke-width: 2; }
.login-hero-top .brand-text { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -.01em; }
.login-hero-top .brand-text small { display: block; font-size: var(--fs-sm); color: rgba(255,255,255,.6); font-weight: 500; }
.login-hero-main { position: relative; z-index: 2; }
.login-hero-main h1 { font-size: clamp(2.2rem, 4vw, 3.4rem); color: white; line-height: 1.05; margin-bottom: var(--s-4); letter-spacing: -.02em; }
.login-hero-main p  { font-size: var(--fs-lg); color: rgba(255,255,255,.75); line-height: 1.6; max-width: 460px; }
.login-hero-feat { list-style: none; padding: 0; margin: var(--s-8) 0 0; display: flex; flex-direction: column; gap: var(--s-3); position: relative; z-index: 2; }
.login-hero-feat li { display: flex; align-items: center; gap: var(--s-3); color: rgba(255,255,255,.88); font-weight: 500; font-size: var(--fs-base); }
.login-hero-feat li .ic {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.12); display: grid; place-items: center; color: var(--brand-300); flex-shrink: 0;
}
.login-hero-feat li svg { width: 18px; height: 18px; stroke-width: 2.2; }
.login-hero-foot { font-size: var(--fs-xs); color: rgba(255,255,255,.5); position: relative; z-index: 2;}
.login-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-12);
  position: relative;
}
.login-card {
  width: 100%; max-width: 460px;
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--s-10) var(--s-8);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-card h2 { font-size: var(--fs-2xl); margin: 0 0 var(--s-2); letter-spacing: -.01em; }
.login-card p.subtitle { color: var(--text-muted); margin: 0 0 var(--s-8); font-size: var(--fs-sm); }
.field-pwd-wrap { position: relative; }
.field-pwd-wrap .toggle-pwd {
  position: absolute; right: var(--s-3); top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); display: grid; place-items: center; border-radius: var(--radius-sm);
}
.field-pwd-wrap .toggle-pwd:hover { background: var(--neutral-50); color: var(--text); }
.field-pwd-wrap .toggle-pwd svg { width: 18px; height: 18px; stroke-width: 2; }
.login-card .actions { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); margin-top: var(--s-6); flex-wrap: wrap; }
.login-card .actions .btn { flex: 1 1 auto; }
.login-card .foot-note { font-size: var(--fs-xs); color: var(--text-muted); text-align: center; margin-top: var(--s-8); }
.login-card .foot-note b { color: var(--neutral-700); }

/* Tabs component */
.tab-headers {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--s-5);
  overflow-x: auto;
}
.tab-headers button {
  background: transparent; border: 0; cursor: pointer;
  padding: var(--s-3) var(--s-5);
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s ease;
  white-space: nowrap;
}
.tab-headers button:hover { color: var(--text); background: var(--neutral-50); }
.tab-headers button.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-600);
}
.tab-body { display: none; }
.tab-body.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px);} to { opacity: 1; transform: none; } }

/* Timeline actividad */
.timeline { position: relative; padding-left: 36px; margin: var(--s-4) 0; }
.timeline::before { content: ""; position: absolute; left: 12px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: var(--s-5); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -30px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand-500);
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--brand-200);
}
.timeline-item.success::before { background: var(--success); box-shadow: 0 0 0 2px #bbf7d0; }
.timeline-item.warn::before    { background: var(--warning); box-shadow: 0 0 0 2px #fde68a; }
.timeline-item.danger::before  { background: var(--danger); box-shadow: 0 0 0 2px #fecaca; }
.t-time { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; margin-bottom: 2px;}
.t-title { font-size: var(--fs-sm); font-weight: 700; color: var(--text); margin: 0; }
.t-desc  { font-size: var(--fs-sm); color: var(--text-muted); margin: 2px 0 0; }

/* HTMX busy / loading indicator */
.htmx-request .htmx-spin::after {
  content: ""; display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: white;
  border-radius: 50%; margin-left: var(--s-2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 5. RESPONSIVE BREAKPOINTS ---------- */

/* < 1280 large-desktop */
@media (max-width: 1280px) {
  :root { --sidebar-w: 248px; --content-maxw: none; }
  .container-xl { padding-inline: var(--s-6); }
  .layout-main { padding: var(--s-5); }
}

/* < 1024 tablet */
@media (max-width: 1024px) {
  :root { --sidebar-w: 260px; --content-maxw: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ambito-grid { grid-template-columns: repeat(2, 1fr); }
  .acta-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .content-wrap { padding: var(--s-6); }
  .topbar { padding: 0 var(--s-6); }
  .split-shell { grid-template-columns: 1fr; }
  .split-image-pane { position: static; }
  .form-grid-4 { grid-template-columns: repeat(2,1fr); }
  .hero-banner { padding: var(--s-6) var(--s-6); gap: var(--s-6);}
  .confidence-ring-wrap { width: 130px; height: 130px; }
  .ring-inner-num .big { font-size: 1.8rem; }
}

/* < 992 tablet-landscape */
@media (max-width: 992px) {
  .page-head { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  .page-head .actions { width: 100%; justify-content: flex-start; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-4); }
  .ambitos-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .content-wrap { padding: var(--s-5); }
  .topbar { padding: 0 var(--s-5); }
}

/* < 768 mobile-large */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: var(--s-4); }
  .charts-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-4 { grid-template-columns: 1fr; }
  .topbar { padding: 0 var(--s-4); height: 64px; }
  .page-title { font-size: var(--fs-lg); }
  .content-wrap { padding: var(--s-5) var(--s-4); }
  .vote-row { grid-template-columns: 1fr 140px; }
  .vote-row .row-meta { display: none; }
  .login-shell { grid-template-columns: 1fr; min-height: auto; }
  .login-hero { padding: var(--s-8) var(--s-5); min-height: 300px; }
  .login-form-wrap { padding: var(--s-6) var(--s-4); margin-top: -32px; position: relative; z-index: 3; }
  .login-card { padding: var(--s-6) var(--s-5); }
  .hero-title { font-size: var(--fs-2xl); }
}

/* < 640 mobile */
@media (max-width: 640px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex; }
  .kpi-grid { grid-template-columns: 1fr; }
  .ambito-grid { grid-template-columns: 1fr 1fr; }
  .acta-grid { grid-template-columns: 1fr; }
  .sidebar-brand { padding-top: var(--s-5); }
  .hero-banner { padding: var(--s-5) var(--s-5); border-radius: var(--radius-lg); }
  .hero-banner::before { display: none; }
  .toast-container { left: var(--s-3); right: var(--s-3); bottom: var(--s-4); }
  .toast { min-width: auto; }
  .filter-bar .field { flex: 1 1 100%; }
  .paginator .info { width: 100%; margin: 0 0 var(--s-3); text-align: center; order: 2; }
}

/* < 480 small-mobile */
@media (max-width: 480px) {
  :root { --fs-sm: 13px; --fs-base: 14px; --s-1: 4px; --s-2: 6px; --s-3: 8px; --s-4: 10px; --s-5: 14px; --s-6: 18px; }
  .kpi { padding: var(--s-3) var(--s-4); border-radius: var(--radius-md); }
  .card { padding: var(--s-4); }
  .topbar { padding: 0 var(--s-3); height: 56px; }
  .content-wrap { padding: var(--s-4); }
  .hero-title { font-size: 1.5rem; line-height: 1.2; }
  .btn { padding-inline: var(--s-4); }
  .confidence-ring-wrap { width: 110px; height: 110px; }
  .ring-inner-num .big { font-size: 1.5rem; }
  .modal-root .modal-dialog { width: 100vw; max-width: 100vw; height: 100vh; border-radius: 0; }
  .split-shell { grid-template-columns: 1fr; gap: var(--s-3); }
}

/* Print mode (compact) */
@media print {
  .sidebar, .topbar-actions, .menu-toggle, .app-foot, .toast-container, .split-image-controls, .btn, .filter-bar { display: none !important; }
  .app-main { max-width: none; padding: 0; }
  .content-wrap { padding: 0 !important; max-width: none !important; }
  .card, .acta-card, .hero-banner { box-shadow: none !important; border-color: #ccc !important; break-inside: avoid; }
  body { background: white !important; color: black !important; }
  * { box-shadow: none !important; }
}

/* ============== MODALES ============== */
.modal-root { position: fixed; inset: 0; z-index: 120; display: none; }
.modal-root.open { display: block; }
.modal-root.open .modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.65); backdrop-filter: blur(6px);
  animation: fadein .18s ease-out;
}
.modal-root .modal-dialog {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(1200px, calc(100vw - 48px)); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: popin .22s cubic-bezier(.2,0,.2,1);
}
.modal-root .modal-dialog.modal-xl { width: min(1400px, calc(100vw - 48px)); }
@keyframes fadein { from { opacity:0 } to { opacity:1 } }
@keyframes popin { from { opacity:0; transform: translate(-50%,-48%) scale(.96); } to { opacity:1; transform: translate(-50%,-50%) scale(1); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border); background: var(--neutral-50);
  flex: 0 0 auto;
}
.modal-title { font-size: var(--fs-base); display:flex; align-items:center; }
.modal-title b { color: var(--text); font-weight: 700; }
.modal-actions { display: flex; gap: var(--s-2); align-items: center; }
.modal-body { flex: 1 1 auto; overflow: hidden; position: relative; display:flex; flex-direction: column; min-height: 0; }

/* Acta Viewer stage */
.acta-viewer-body { background: var(--neutral-900); }
.acta-viewer-stage {
  flex: 1 1 auto; overflow: auto; position: relative;
  background-image:
    linear-gradient(45deg, #1e293b 25%, transparent 25%), linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%), linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: #0f172a;
  display: flex; align-items: flex-start; justify-content: center; padding: var(--s-8);
  box-shadow: inset 0 0 240px rgba(0,0,0,.35);
}
.acta-viewer-stage img {
  max-width: none; transform-origin: center center;
  transition: transform .12s ease-out;
  border-radius: 4px; box-shadow: 0 18px 60px rgba(0,0,0,.5);
  background: white;
}
.acta-viewer-toolbar-bottom {
  flex: 0 0 auto; padding: var(--s-3) var(--s-6);
  background: rgba(15,23,42,.92); color: #cbd5e1; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
}
@media (max-width: 768px) {
  .modal-root .modal-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); border-radius: var(--radius-md); }
  .modal-header { padding: var(--s-3) var(--s-4); }
  .acta-viewer-stage { padding: var(--s-4); }
  .acta-viewer-toolbar-bottom { padding: var(--s-2) var(--s-4); flex-direction: column; align-items: flex-start; }
}

/* ================== MÓDULO RESULTADOS ONPE ================== */
.onpe-wrapper { width: 100%; }
.onpe-filter-bar {
  background: linear-gradient(90deg, #005eb8 0%, #00448a 100%);
  padding: var(--s-4) var(--s-6);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-5);
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-sm);
  color: #fff;
}
.onpe-filter-bar .field { display:flex; flex-direction:column; gap:4px; min-width: 0; }
.onpe-filter-bar label { font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.onpe-filter-bar select {
  padding: 10px 12px; font-size: 15px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px; background: #fff; color: #0f172a;
  min-height: 44px;
}
.onpe-kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #e8e8e8; border-radius: var(--radius-md);
  margin-bottom: var(--s-5); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.onpe-kpi {
  padding: var(--s-5) var(--s-6); text-align: center;
  border-right: 1px solid #c9c9c9;
  display: flex; flex-direction: column; gap: var(--s-1);
}
.onpe-kpi:last-child { border-right: none; }
.onpe-kpi .onpe-kpi-num { font-size: 22px; font-weight: 700; color: #0f172a; line-height: 1.15; }
.onpe-kpi .onpe-kpi-lbl { font-size: 14px; color: #334155; font-weight: 500; }
.onpe-date {
  background: #eaf4ff; color: #1e3a8a;
  padding: var(--s-3) var(--s-5);
  text-align: center; font-weight: 600; font-size: 15px;
  border-radius: var(--radius-sm); margin-bottom: var(--s-6);
}
.onpe-shell {
  display: grid; grid-template-columns: 240px 1fr;
  gap: var(--s-6);
}
.onpe-sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
}
.onpe-sidebar-group { margin-bottom: var(--s-5); }
.onpe-sidebar-title {
  font-size: 17px; font-weight: 800; color: #0f172a;
  padding: var(--s-2) var(--s-3); margin: 0 0 4px;
}
.onpe-sidebar-item {
  display: block;
  padding: 10px 14px;
  border-radius: 6px;
  color: #334155;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease-out, color .12s;
}
.onpe-sidebar-item:hover { background: #f1f5f9; color: #1e40af; }
.onpe-sidebar-item.active {
  background: #e7f0fe; color: #1e40af;
  border-left: 4px solid #005eb8;
  padding-left: 10px;
  font-weight: 700;
}
.onpe-content { min-width: 0; }
.onpe-content-title {
  font-size: 28px; font-weight: 800; color: #003366; margin: 0 0 var(--s-5);
  letter-spacing: -.3px;
}
.onpe-content-head {
  display:flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4);
  margin-bottom: var(--s-4); flex-wrap: wrap;
}
.onpe-chart-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--s-5); box-shadow: var(--shadow-xs); margin-bottom: var(--s-5);
}
.onpe-chart-wrap { position: relative; height: 480px; width: 100%; }
.onpe-table {
  width: 100%; border-collapse: collapse; background: #fff;
  box-shadow: var(--shadow-xs); border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--border);
}
.onpe-table th {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  color: #002859; font-weight: 700; font-size: 18px; padding: 14px 18px;
  text-align: left; border-bottom: 2px solid #93c5fd;
}
.onpe-table th.text-right, .onpe-table td.text-right { text-align: right; }
.onpe-table td {
  padding: 12px 18px; font-size: 15px; color: #0f172a;
  border-bottom: 1px solid var(--neutral-200);
  vertical-align: middle;
}
.onpe-table tr:nth-child(even) td { background: #f8fafc; }
.onpe-table tr.total-row td { background: #e2e8f0; font-weight: 700; border-top: 2px solid #94a3b8; }
.onpe-table tr.total-emitted td { background: #cbd5e1; font-weight: 800; border-top: 3px solid #64748b; color: #0f172a; }
.onpe-logo {
  width: 40px; height: 40px; border-radius: 8px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
  flex: 0 0 auto;
  border: 2px solid #bfdbfe;
  box-shadow: 0 2px 4px rgba(37,99,235,.25);
  margin-right: 10px; vertical-align: middle;
}
.onpe-org-cell { display:flex; align-items: center; gap: var(--s-3); }
.onpe-org-cell .org-name { font-size: 15px; font-weight: 600; color: #0f172a; }
.onpe-table .votos-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700; font-size: 16px; color: #0f172a; font-variant-numeric: tabular-nums;
}
.onpe-empty {
  background: #fff; border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md); padding: var(--s-8) var(--s-6);
  text-align: center; color: #475569; font-weight: 500;
}
@media (max-width: 1024px) {
  .onpe-shell { grid-template-columns: 1fr; }
  .onpe-kpi-grid { grid-template-columns: 1fr 1fr; }
  .onpe-kpi { border-right: 1px solid #c9c9c9; border-bottom: 1px solid #c9c9c9; }
  .onpe-kpi:nth-child(2n) { border-right: none; }
  .onpe-kpi:nth-child(n+3) { border-bottom: none; }
}
@media (max-width: 768px) {
  .onpe-filter-bar { grid-template-columns: 1fr; padding: var(--s-4); gap: var(--s-4); }
  .onpe-content-title { font-size: 20px; }
  .onpe-chart-wrap { height: 360px; }
  .onpe-table th, .onpe-table td { padding: 8px 10px; font-size: 13px; }
  .onpe-table th { font-size: 14px; }
}
@media (max-width: 640px) {
  .onpe-kpi-grid { grid-template-columns: 1fr; }
  .onpe-kpi { border-right: none !important; border-bottom: 1px solid #c9c9c9; }
  .onpe-kpi:last-child { border-bottom: none; }
}

/* ================================================================
   Bloque 5/6 hardening: Batch button loading state + a11y widgets
   ================================================================ */
.btn[disabled], .btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  filter: saturate(0.6);
  pointer-events: auto;
}
.btn .btn-icon-spin { display: none; width: 1em; height: 1em; }
.btn[aria-busy="true"] .btn-icon-spin {
  display: inline-block;
  animation: btn-spin 0.9s linear infinite;
}
.btn[aria-busy="true"] .btn-icon-rest { display: none; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"] .btn-icon-spin { animation-duration: 2.2s; }
}

/* Auto-batch widget label (keyboard-focusable) */
.auto-batch-widget .ab-label[tabindex="0"] {
  cursor: pointer;
  outline: none;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin: -2px -6px;
}
.auto-batch-widget .ab-label[tabindex="0"]:focus-visible {
  box-shadow: 0 0 0 3px var(--brand-500);
}
.auto-batch-widget.loading .ab-sub {
  opacity: 0.7;
  font-style: italic;
}

/* Topbar actions wrap mobile */
@media (max-width: 768px) {
  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
  }
  .page-head .topbar-actions { margin-top: var(--s-2); }
}
