/* Censo Electoral v4 — estilos */
:root {
  --brand: #1240b8;
  --brand-600: #0d34a0;
  --brand-ink: #0a2366;
  --brand-50: #eef3ff;
  --accent: #1f7a64;
  --accent-50: #e8f5f1;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --line: #e5e8ef;
  --ok: #157f4c;   --ok-50: #e7f6ee;
  --warn: #9a5b00; --warn-50: #fff4e0;
  --bad: #b42318;  --bad-50: #fdecea;
  --info: #175cd3; --info-50: #eaf2ff;
  --radius: 16px;
  --sidebar-w: 264px;
  --appbar-h: 64px;
  --bottom-h: 68px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);

  --bs-primary: var(--brand);
  --bs-primary-rgb: 18, 64, 184;
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 18, 64, 184;
  --bs-link-hover-color: var(--brand-600);
}

html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--bs-body-font-family); -webkit-tap-highlight-color: transparent; }
.min-w-0 { min-width: 0; }
a { text-decoration: none; }

/* ---------- Botones / formularios ---------- */
.btn { border-radius: 12px; font-weight: 600; }
.btn-lg { padding: .8rem 1.25rem; font-size: 1rem; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-ink); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-600); }
.btn-success { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #186452; --bs-btn-hover-border-color: #186452; --bs-btn-active-bg: #145343; --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-icon { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--ink-2); border: 1px solid var(--line); background: #fff; padding: 0; }
.btn-icon:hover { background: var(--brand-50); color: var(--brand); border-color: #d3defb; }
.form-control, .form-select { border-radius: 12px; border-color: #d8dde7; padding: .65rem .85rem; font-size: 1rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .22rem rgba(18, 64, 184, .14); }
.form-label { font-weight: 600; font-size: .86rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control.is-oficial, .form-control[readonly].is-oficial { background: var(--accent-50); border-color: #bfe3d7; color: #0f4c3d; font-weight: 600; }
.input-group-text { border-radius: 12px; background: #fff; border-color: #d8dde7; color: var(--ink-3); }
.form-floating > .form-control { padding-left: 1rem; }
.btn-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ink-3); width: 40px; height: 40px; z-index: 5; }
.btn-eye-label { top: auto; bottom: 2px; transform: none; }
.alert { border-radius: 12px; border: 0; }

/* ---------- Banner demo ---------- */
.demo-banner { position: sticky; top: 0; z-index: 1100; background: repeating-linear-gradient(45deg, #ffcf33, #ffcf33 12px, #ffd84f 12px, #ffd84f 24px); color: #4a3300; text-align: center; font-weight: 700; font-size: .8rem; padding: .35rem .75rem; }

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--brand-ink); color: #fff; display: flex; flex-direction: column; padding: 1.25rem 1rem; z-index: 1030; }
.demo-banner ~ .sidebar { top: 27px; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem 1.5rem; }
.sidebar-brand img { background: #fff; border-radius: 12px; padding: 4px; }
.brand-title { font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: rgba(255, 255, 255, .6); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: .8rem; color: rgba(255, 255, 255, .72); padding: .7rem .85rem; border-radius: 12px; font-weight: 500; font-size: .95rem; position: relative; }
.side-link i { width: 20px; text-align: center; opacity: .9; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active { background: #fff; color: var(--brand-ink); font-weight: 700; }
.side-link .badge-queue { margin-left: auto; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .12); padding-top: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.sidebar-foot .side-link { color: rgba(255, 255, 255, .72); }
.btn-install { border: 1px dashed rgba(255, 255, 255, .4); background: transparent; color: #fff; border-radius: 12px; padding: .6rem; font-weight: 600; font-size: .9rem; }

/* ---------- Shell ---------- */
.shell { margin-left: var(--sidebar-w); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.appbar { position: sticky; top: 0; z-index: 1020; height: var(--appbar-h); background: rgba(243, 245, 249, .86); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); display: flex; align-items: center; justify-content: space-between; padding: 0 1.75rem; border-bottom: 1px solid transparent; }
.appbar-left { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.appbar-logo { border-radius: 9px; background: #fff; padding: 3px; box-shadow: var(--shadow); }
.appbar-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-right { display: flex; align-items: center; gap: .75rem; }
.avatar-btn { display: flex; align-items: center; gap: .6rem; background: transparent; border: 0; padding: .25rem; border-radius: 999px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand-50); color: var(--brand); font-weight: 800; flex: none; }
.avatar-sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }
.net-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; font-weight: 600; color: var(--ok); background: var(--ok-50); padding: .3rem .65rem; border-radius: 999px; }
.net-pill i { font-size: .45rem; }
.net-pill.off { color: var(--warn); background: var(--warn-50); }
.content { flex: 1; padding: 1.5rem 1.75rem 2rem; width: 100%; max-width: 1440px; }
.app-footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.75rem 1.5rem; font-size: .8rem; color: var(--ink-3); }

.sync-bar { display: flex; align-items: center; gap: .5rem; background: var(--warn-50); color: var(--warn); border-radius: 12px; padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 600; font-size: .9rem; }
.badge-queue { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #f59e0b; color: #1f1300; font-size: .7rem; font-weight: 800; display: inline-grid; place-items: center; }

/* ---------- Bottom nav (móvil) ---------- */
.bottom-nav { display: none; }

/* ---------- Tarjetas ---------- */
.card-x { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; border: 1px solid #eef0f5; }
.card-x-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-x-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.empty { color: var(--ink-3); text-align: center; padding: 1.5rem 0; margin: 0; }
.back-link { display: inline-block; color: var(--ink-3); font-weight: 600; font-size: .9rem; margin-bottom: 1rem; }

.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.15rem; border: 1px solid #eef0f5; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: .75rem; }
.kpi-primary { background: var(--brand-50); color: var(--brand); }
.kpi-success { background: var(--ok-50); color: var(--ok); }
.kpi-warning { background: var(--warn-50); color: var(--warn); }
.kpi-danger  { background: var(--bad-50); color: var(--bad); }
.kpi-label { font-size: .8rem; color: var(--ink-3); font-weight: 600; }
.kpi-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .78rem; color: var(--ink-3); }

.hero-card { background: linear-gradient(135deg, var(--brand-ink), var(--brand) 70%, #2a63e0); color: #fff; border-radius: 20px; padding: 1.5rem; box-shadow: 0 12px 30px rgba(10, 35, 102, .25); }
.hero-kicker { opacity: .8; font-weight: 600; }
.hero-number { font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-number span { font-size: 1.2rem; opacity: .7; font-weight: 600; }
.hero-sub { opacity: .8; font-size: .9rem; }
.hero-progress { height: 10px; background: rgba(255, 255, 255, .2); border-radius: 999px; overflow: hidden; }
.hero-progress > div { height: 100%; background: #7ee2b8; border-radius: 999px; }

.chart-box { position: relative; height: 280px; }

.bar-list, .leader-list, .person-list, .user-list, .log-list { list-style: none; margin: 0; padding: 0; }
.bar-list li { padding: .55rem 0; }
.bar-list-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.bar-list-sub { font-size: .75rem; color: var(--ink-3); margin-top: .2rem; }
.bar-track { height: 8px; background: #edf0f6; border-radius: 999px; overflow: hidden; margin-top: .35rem; }
.bar-track > div { height: 100%; background: var(--brand); border-radius: 999px; min-width: 4px; }
.leader-list li { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem 0; border-top: 1px solid var(--line); }
.leader-list li:first-child { border-top: 0; }
.person-list li { border-top: 1px solid var(--line); }
.person-list li:first-child { border-top: 0; }
.person-list a, .person-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .25rem; color: inherit; }
.person-list a:hover { background: #f8f9fc; }
.log-list li { padding: .45rem 0; border-top: 1px solid var(--line); font-size: .9rem; }

.user-list li { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-top: 1px solid var(--line); }
.user-list li.is-off { opacity: .55; }
.role-chip { font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: #eef0f5; color: var(--ink-2); }
.role-super_admin { background: #1f1147; color: #fff; }
.role-admin { background: var(--brand-50); color: var(--brand); }
.role-lider { background: var(--accent-50); color: var(--accent); }
.role-off { background: var(--bad-50); color: var(--bad); }

/* ---------- Estados ---------- */
.badge-estado { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 700; padding: .28rem .6rem; border-radius: 999px; white-space: nowrap; }
.badge-estado-success { background: var(--ok-50); color: var(--ok); }
.badge-estado-warning { background: var(--warn-50); color: var(--warn); }
.badge-estado-danger  { background: var(--bad-50); color: var(--bad); }

/* ---------- Registro ---------- */
.step { border: 1px solid #eef0f5; }
fieldset.step { min-width: 0; }
fieldset.step:disabled { opacity: .55; }
fieldset.step:disabled .step-n { background: #c9cfdb; }
.step-head { display: flex; gap: .85rem; align-items: flex-start; margin-bottom: 1.1rem; }
.step-head h2 { font-size: 1.05rem; font-weight: 800; margin: 0; }
.step-head p { margin: .15rem 0 0; color: var(--ink-3); font-size: .88rem; }
.step-n { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; }
.cedula-row { display: flex; gap: .75rem; align-items: stretch; }
.cedula-row .btn { white-space: nowrap; }
.cedula-input { font-size: 1.35rem !important; font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.sub-title { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-ink); margin: 1.5rem 0 .85rem; padding-top: 1.25rem; border-top: 1px dashed var(--line); display: flex; align-items: center; flex-wrap: wrap; }

.result-box { display: flex; gap: .85rem; align-items: flex-start; margin-top: 1rem; padding: 1rem; border-radius: 14px; animation: pop .25s ease-out; }
.result-box p { margin: .25rem 0 0; font-size: .92rem; }
.result-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; }
.result-title { font-weight: 800; }
.result-success { background: var(--ok-50); color: #0e4f31; }      .result-success .result-icon { background: var(--ok); color: #fff; }
.result-warning { background: var(--warn-50); color: #5c3800; }    .result-warning .result-icon { background: #d97706; color: #fff; }
.result-danger  { background: var(--bad-50); color: #7a1a12; }     .result-danger .result-icon { background: var(--bad); color: #fff; }
.result-info    { background: var(--info-50); color: #133d8a; }    .result-info .result-icon { background: var(--info); color: #fff; }
.result-grid { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; margin: .5rem 0 0; font-size: .92rem; }
.result-grid dt { font-weight: 600; opacity: .75; }
.result-grid dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.consent { display: flex; gap: .75rem; align-items: flex-start; background: #f7f8fb; border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; font-size: .88rem; color: var(--ink-2); }
.consent .form-check-input { width: 1.3rem; height: 1.3rem; margin: 0; flex: none; }
.consent label { cursor: pointer; }
.consent-error { border-color: var(--bad); background: var(--bad-50); }

/* ---------- Listado / DataTables ---------- */
.filters .form-label { margin-bottom: .2rem; }
.dt-top, .dt-bottom { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: .25rem .25rem .75rem; }
.dt-bottom { padding-top: .75rem; }
div.dataTables_wrapper div.dataTables_filter input { margin-left: 0; width: 220px; }
div.dataTables_wrapper div.dataTables_filter label { margin: 0; }
.dt-buttons.btn-group { gap: .4rem; }
.dt-buttons .btn { border-radius: 10px !important; }
table.dataTable { font-size: .9rem; }
table.dataTable thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); border-bottom-width: 1px !important; }
.page-link { border-radius: 10px !important; margin: 0 2px; border: 0; color: var(--ink-2); }
.active > .page-link { background: var(--brand); }

/* ---------- Progreso masivo ---------- */
.progress-x { height: 12px; background: #edf0f6; border-radius: 999px; overflow: hidden; }
.progress-x > div { height: 100%; width: 0; background: var(--brand); transition: width .3s; }

/* ---------- Toasts ---------- */
#toasts { z-index: 1200; display: flex; flex-direction: column; gap: .5rem; padding-top: calc(env(safe-area-inset-top) + .75rem) !important; }
.app-toast { display: flex; gap: .75rem; align-items: center; min-width: 260px; max-width: 360px; padding: .75rem .9rem; border-radius: 12px; color: #fff; background: #1f2937; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); font-size: .9rem; font-weight: 500; animation: pop .2s ease-out; transition: opacity .35s, transform .35s; }
.app-toast button { margin-left: auto; background: transparent; border: 0; color: inherit; font-size: 1.2rem; line-height: 1; opacity: .7; }
.app-toast.out { opacity: 0; transform: translateY(-6px); }
.app-toast-success { background: #0f6b40; }
.app-toast-warning { background: #8a4b00; }
.app-toast-danger { background: #a11d14; }

/* ---------- Login ---------- */
/* Foto de fondo: capa fija (evita el fallo de background-attachment:fixed en iPhone) */
.auth-body { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--brand-ink); position: relative; isolation: isolate; }
.auth-body::before { content: ''; position: fixed; inset: 0; z-index: -2; background: #0a2366 url('../img/login-bg-sm.jpg') center 35% / cover no-repeat; background-image: image-set(url('../img/login-bg-sm.webp') type('image/webp'), url('../img/login-bg-sm.jpg') type('image/jpeg')); }
.auth-body::after { content: ''; position: fixed; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 35, 102, .35) 0%, rgba(10, 35, 102, .55) 55%, rgba(6, 22, 66, .85) 100%); }
@media (min-width: 900px) {
  .auth-body::before { background-image: url('../img/login-bg.jpg'); background-image: image-set(url('../img/login-bg.webp') type('image/webp'), url('../img/login-bg.jpg') type('image/jpeg')); }
}
.auth-card { width: 100%; max-width: 960px; display: grid; grid-template-columns: 1.1fr 1fr; background: transparent; border-radius: 24px; overflow: hidden; box-shadow: 0 30px 80px rgba(3, 12, 40, .45); }
.auth-hero { background: linear-gradient(165deg, rgba(10, 35, 102, .30) 0%, rgba(10, 35, 102, .72) 60%, rgba(10, 35, 102, .92) 100%); backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px); color: #fff; padding: 3rem 2.5rem; display: flex; align-items: flex-end; position: relative; overflow: hidden; text-shadow: 0 1px 12px rgba(0, 0, 0, .35); }
.auth-form { background: #fff; }
.auth-hero h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 1rem 0; }
.auth-hero p { opacity: .82; }
.auth-chip { display: inline-block; font-size: .78rem; font-weight: 700; background: rgba(255, 255, 255, .14); padding: .35rem .75rem; border-radius: 999px; }
.auth-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .6rem; }
.auth-points i { width: 22px; color: #7ee2b8; }
.auth-form { padding: 2.75rem 2.5rem; display: flex; flex-direction: column; justify-content: center; background: #fff; }
.auth-logo { max-width: 220px; width: 70%; height: auto; margin-bottom: 1.75rem; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { display: none; }
  .shell { margin-left: 0; }
  .appbar { padding: 0 1rem; padding-top: env(safe-area-inset-top); height: calc(var(--appbar-h) + env(safe-area-inset-top)); background: rgba(255, 255, 255, .9); border-bottom-color: var(--line); }
  .appbar-title { font-size: 1.1rem; }
  .content { padding: 1rem 1rem calc(var(--bottom-h) + 1.5rem + env(safe-area-inset-bottom)); }
  .app-footer { display: none; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-3); font-size: .68rem; font-weight: 600; padding: .4rem 0; min-height: 48px; justify-content: center; }
  .bottom-nav a i { font-size: 1.15rem; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a.fab { position: relative; width: 58px; height: 58px; min-height: 0; margin: -26px auto 0; border-radius: 18px; background: var(--brand); color: #fff; box-shadow: 0 10px 22px rgba(18, 64, 184, .38); }
  .bottom-nav a.fab i { font-size: 1.4rem; }
  .bottom-nav a.fab .badge-queue { position: absolute; top: -6px; right: -6px; }
  .kpi-value { font-size: 1.45rem; }
  .card-x { padding: 1rem; }
}
@media (max-width: 767.98px) {
  .auth-card { grid-template-columns: 1fr; max-width: 440px; }
  .auth-hero { display: none; }
  .auth-form { padding: 2rem 1.5rem; }
  .auth-body { align-content: end; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .auth-body::before { bottom: auto; height: 58vh; height: 58dvh; background-size: cover; background-position: 38% 62%; }
  .auth-body::after { background: linear-gradient(180deg, rgba(10, 35, 102, .10) 0%, rgba(10, 35, 102, .35) 35%, #0a2366 58%, #0a2366 100%); }
  .auth-form { padding-top: 1.6rem; }
  .auth-logo { margin-bottom: 1.1rem; }
  .net-pill span { display: none; }
  .net-pill { padding: .45rem; }
  .cedula-row { flex-direction: column; }
  .cedula-row .btn { width: 100%; }
  .hero-number { font-size: 2.1rem; }
  .chart-box { height: 220px; }
  .dt-top { flex-direction: column; align-items: stretch; }
  div.dataTables_wrapper div.dataTables_filter input { width: 100%; }
  div.dataTables_wrapper div.dataTables_filter label { width: 100%; }
  .dt-buttons.btn-group { flex-wrap: wrap; }
  .dt-bottom { justify-content: center; }
  #toasts { left: 0; right: 0; align-items: center; }
  .app-toast { max-width: calc(100vw - 2rem); }
}
@media (display-mode: standalone) { .appbar { user-select: none; } }
@media print {
  .sidebar, .appbar, .bottom-nav, .app-footer, .filters, .dt-top, .dt-bottom, .btn, .sync-bar { display: none !important; }
  .shell { margin: 0; }
  .card-x, .kpi { box-shadow: none; border: 1px solid #ddd; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
