/* ==========================================================================
   VeriVote — design system  (all styles for every page live in this file)
   ==========================================================================
   QUICK CHANGES
     • Main colour (purple) ...... --primary in :root (light) and [data-theme="dark"]
     • Gradient (logo/buttons) ... --gradient
     • Font ...................... --font  (Inter is loaded in includes/layout.php)
     • Corner roundness .......... --radius-sm / --radius / --radius-lg / --radius-xl

   CONTENTS  (search for the name in quotes to jump there)
     1. "Colour tokens"           light + dark theme variables
     2. "Base"                    page defaults, grid & spacing helpers
     3. "Buttons"                 .btn, .btn-primary, .btn-danger, .icon-btn …
     4. "Forms"                   inputs, .field, password strength, file upload, switches
     5. "Cards"                   .card, .stat (number tiles)
     6. "Badges / chips / avatars"
     7. "Alerts"                  coloured message boxes
     8. "Toasts"                  pop-up messages (bottom right)
     9. "Modal"                   confirm dialogs
    10. "Tables"                  admin tables
    11. "Segmented tabs"          All / Pending / Approved … tabs
    12. "Empty state"             "Nothing here yet" boxes
    13. "Progress bars"
    14. "Brand"                   logo + app name
    15. "Auth (split-screen)"     login / register / verify pages
    16. "Voter shell"             voter top bar, dashboard hero, receipt
    17. "Ballot"                  candidate cards, review list, receipt + QR
    18. "Results"                 result rows, winner card, donut chart
    19. "Admin shell"             sidebar, admin top bar, admin widgets
    20. "Responsive"              tablet / phone layouts, print styles
   ========================================================================== */

/* ---------- Colour tokens ---------- */
:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f2f3f8;
    --surface-3: #e9eaf2;
    --border: #e4e6ef;
    --border-strong: #d3d6e3;
    --text: #0e1120;
    --text-2: #3a3f55;
    --muted: #6a7089;
    --primary: #5b5bf0;
    --primary-hover: #4a4ade;
    --primary-soft: rgba(91, 91, 240, .10);
    --primary-ring: rgba(91, 91, 240, .28);
    --on-primary: #ffffff;
    --success: #12a150;
    --success-soft: rgba(18, 161, 80, .12);
    --warning: #c97a06;
    --warning-soft: rgba(217, 140, 6, .14);
    --danger: #e0294f;
    --danger-soft: rgba(224, 41, 79, .11);
    --info: #0b84c6;
    --info-soft: rgba(11, 132, 198, .12);
    --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 48%, #d946ef 100%);
    --shadow-sm: 0 1px 2px rgba(16, 20, 45, .05);
    --shadow: 0 1px 2px rgba(16, 20, 45, .04), 0 6px 20px -6px rgba(16, 20, 45, .10);
    --shadow-lg: 0 24px 60px -18px rgba(16, 20, 45, .28);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 26px;
    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #090a12;
    --surface: #11121c;
    --surface-2: #181a27;
    --surface-3: #212435;
    --border: #232638;
    --border-strong: #31354c;
    --text: #eceef9;
    --text-2: #c3c7dc;
    --muted: #8b91ad;
    --primary: #7b7bff;
    --primary-hover: #9292ff;
    --primary-soft: rgba(123, 123, 255, .14);
    --primary-ring: rgba(123, 123, 255, .35);
    --success: #34d17c;
    --success-soft: rgba(52, 209, 124, .13);
    --warning: #f5b33d;
    --warning-soft: rgba(245, 179, 61, .13);
    --danger: #ff5c7f;
    --danger-soft: rgba(255, 92, 127, .13);
    --info: #45b7f5;
    --info-soft: rgba(69, 183, 245, .13);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
[hidden] { display: none !important; }
:root[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }
::selection { background: var(--primary-ring); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px } .mt-4 { margin-top: 36px }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border-strong);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    font: 600 14px/1 var(--font); letter-spacing: -.005em;
    color: var(--b-fg); background: var(--b-bg);
    border: 1px solid var(--b-bd); border-radius: 10px;
    cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { color: var(--b-fg); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { --b-bg: var(--primary); --b-fg: var(--on-primary); --b-bd: transparent; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 18px -6px var(--primary-ring); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-gradient { --b-fg: #fff; --b-bd: transparent; background: var(--gradient); box-shadow: 0 10px 30px -10px rgba(139, 92, 246, .6); }
.btn-gradient:hover { background: var(--gradient); filter: brightness(1.07); color: #fff; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { --b-bg: var(--danger); --b-fg: #fff; --b-bd: transparent; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); color: #fff; }
.btn-danger-soft { --b-bg: var(--danger-soft); --b-fg: var(--danger); --b-bd: transparent; }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }
.btn-success-soft { --b-bg: var(--success-soft); --b-fg: var(--success); --b-bd: transparent; }
.btn-success-soft:hover { background: var(--success); color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; padding: 0;
    color: var(--text-2); background: transparent;
    border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint, .hint { color: var(--muted); font-size: 12.5px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; width: 17px; height: 17px; }
.input-wrap > .icon ~ input { padding-left: 40px; }
.input-wrap .reveal { position: absolute; right: 6px; width: 32px; height: 32px; display: grid; place-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 8px; }
.input-wrap .reveal:hover { background: var(--surface-2); color: var(--text); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"],
input[type="search"], input[type="datetime-local"], input[type="date"], input:not([type]), select, textarea {
    width: 100%; height: 44px; padding: 0 14px;
    font: 500 14.5px var(--font); color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px;
    transition: border-color .15s, box-shadow .15s, background .15s;
    appearance: none;
}
textarea { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b91ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type="password"] { padding-right: 44px; }
.input-wrap > .icon ~ input { padding-left: 40px; }

.strength { height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.strength i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--danger); transition: width .25s, background .25s; }

/* ---------- Certificate of Results (admin/certificate.php) — always looks like white paper ---------- */
.cert-body { background: var(--surface-2); padding: 20px 16px 60px; }
.cert-toolbar { max-width: 820px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cert { position: relative; max-width: 820px; margin: 0 auto; padding: 48px 52px; background: #fff; color: #111827; border-radius: 6px; box-shadow: 0 10px 40px -12px rgba(0,0,0,.25); font-size: 13.5px; overflow: hidden; }
.cert .muted { color: #6b7280; }
.cert-watermark { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800; color: rgba(220, 38, 38, .08); transform: rotate(-24deg); pointer-events: none; letter-spacing: .1em; }
.cert-head { display: flex; align-items: center; gap: 18px; padding-bottom: 18px; border-bottom: 3px double #111827; }
.cert-logo { width: 64px; height: 64px; }
.cert-kicker { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #6b7280; font-weight: 700; }
.cert-head h1 { font-size: 26px; letter-spacing: -.02em; margin: 2px 0; color: #111827; }
.cert-title { font-size: 16px; font-weight: 600; color: #4338ca; }
.cert-note { margin-top: 14px; padding: 10px 14px; border: 1px solid #fecaca; background: #fef2f2; color: #991b1b; border-radius: 8px; }
.cert-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0 8px; }
.cert-stats div { border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; }
.cert-stats span { display: block; font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.cert-stats strong { font-size: 18px; color: #111827; }
.cert-stats strong.small { font-size: 12px; line-height: 1.4; font-weight: 600; }
.cert-h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .1em; color: #374151; margin: 24px 0 8px; }
.cert-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.cert-table th, .cert-table td { padding: 7px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; }
.cert-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; background: #f9fafb; }
.cert-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cert-table caption { text-align: left; font-weight: 700; padding: 6px 0; color: #111827; }
.cert-table caption small, .cert-table small { font-weight: 500; color: #6b7280; }
.cert-tally tr.win td { font-weight: 700; background: #eef2ff; }
.cert-seats { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.cert-seats b { font-size: 16px; color: #4338ca; }
.cert-attest { margin: 26px 0 8px; font-style: italic; color: #374151; }
.cert-signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 34px 28px; margin-top: 40px; }
.cert-sign { text-align: center; }
.cert-sign .line { min-height: 24px; border-bottom: 1px solid #111827; font-weight: 700; padding-bottom: 4px; }
.cert-sign span { display: block; margin-top: 6px; font-size: 12px; color: #4b5563; }
.cert-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 36px; padding-top: 12px; border-top: 1px solid #e5e7eb; font-size: 11.5px; color: #6b7280; }
@media (max-width: 640px) { .cert { padding: 28px 20px; } .cert-stats { grid-template-columns: 1fr 1fr; } .cert-head h1 { font-size: 20px; } }
@media print {
    .cert-body { background: #fff; padding: 0; }
    .cert-toolbar, .toasts { display: none !important; }
    .cert { box-shadow: none; max-width: none; padding: 0; border-radius: 0; }
    .cert-table tr, .cert-sign, .cert-tally { break-inside: avoid; }
    @page { margin: 16mm; }
}

/* ---------- EN | FIL language switch (voter pages) ---------- */
.lang-switch { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.lang-switch a { padding: 5px 9px; font-size: 12px; font-weight: 700; letter-spacing: .03em; border-radius: 7px; color: var(--muted); }
.lang-switch a:hover { color: var(--text); }
.lang-switch a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.auth-top { gap: 10px; align-items: center; }
@media (max-width: 960px) { .auth-top .lang-switch { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); } .auth-top .lang-switch a { color: rgba(255,255,255,.75); } .auth-top .lang-switch a.active { color: #4338ca; background: #fff; } }

/* ---------- Party badge (partylists) ---------- */
.party-badge { --party: #6366f1; display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; border-radius: 99px; color: var(--party); background: color-mix(in srgb, var(--party) 14%, transparent); border: 1px solid color-mix(in srgb, var(--party) 35%, transparent); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.party-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--party); flex-shrink: 0; }
.color-input { width: 52px; height: 40px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
.seat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seat-chip { --party: #6366f1; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; }
.seat-chip b { font-size: 16px; color: var(--party); }

/* ---------- Privacy notice page + consent checkbox ---------- */
.privacy h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 18px 0 6px; }
.privacy h3 .icon { color: var(--primary); width: 17px; height: 17px; }
.privacy ul { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 14px; display: grid; gap: 4px; }
.consent { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2); font-size: 13px; line-height: 1.5; color: var(--text-2); cursor: pointer; }
.consent input { margin-top: 3px; width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--primary); }
.consent:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.id-viewer { margin-top: 12px; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; min-height: 200px; }
.id-viewer img { max-width: 100%; max-height: 60vh; object-fit: contain; }

/* ---------- Small inline "Edit" (e.g. birthday in the Voters table) ---------- */
.mini-edit { margin-top: 4px; font-size: 12.5px; }
.mini-edit summary { cursor: pointer; color: var(--primary); font-weight: 600; list-style: none; display: inline; }
.mini-edit summary::-webkit-details-marker { display: none; }

.pw-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.pw-rules li { display: inline-flex; align-items: center; gap: 5px; transition: color .15s; }
.pw-rules li .icon { width: 14px; height: 14px; padding: 2px; border-radius: 50%; background: var(--surface-3); color: transparent; stroke-width: 3; transition: all .15s; }
.pw-rules li.ok { color: var(--success); }
.pw-rules li.ok .icon { background: var(--success); color: #fff; }
.hint .icon { width: 14px; height: 14px; vertical-align: -2px; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.card-body + .card-body { border-top: 1px solid var(--border); }
.file-drop {
    display: flex; align-items: center; gap: 14px; padding: 14px;
    border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2);
    cursor: pointer; transition: border-color .15s, background .15s;
}
.file-drop:hover { border-color: var(--primary); background: var(--primary-soft); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop .preview { width: 56px; height: 56px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; color: var(--muted); overflow: hidden; flex-shrink: 0; border: 1px solid var(--border); }
.file-drop .preview img { width: 100%; height: 100%; object-fit: cover; }
.file-drop strong { display: block; font-size: 14px; }
.file-drop small { color: var(--muted); }

/* Toggle switch */
.switch { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch strong { display: block; font-size: 14.5px; }
.switch small { color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 44px; height: 26px; background: var(--surface-3); border-radius: 99px; flex-shrink: 0; transition: background .2s; margin-top: 2px; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--primary-ring); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    min-width: 0; /* never wider than its column — wide tables scroll in .table-wrap */
}
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 650; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.stat { padding: 20px; display: flex; gap: 16px; align-items: flex-start; }
.stat > div { flex: 1; min-width: 0; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.stat-icon .icon { width: 21px; height: 21px; }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; margin-top: 2px; }
.stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Badges / chips / avatars ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
    font-size: 12px; font-weight: 600; border-radius: 99px; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
.chip .icon { width: 14px; height: 14px; }

.avatar { display: inline-grid; place-items: center; flex-shrink: 0; overflow: hidden; border-radius: 50%; background: var(--gradient); color: #fff; font-weight: 700; letter-spacing: .02em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 42px; height: 42px; font-size: 14px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.avatar-xl { width: 104px; height: 104px; font-size: 32px; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; font-size: 14px; border: 1px solid transparent; }
.alert .icon { margin-top: 1px; }
.alert strong { display: block; }
.alert-info { background: var(--info-soft); color: var(--text); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-info > .icon { color: var(--info); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-success > .icon { color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-warning > .icon { color: var(--warning); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-error > .icon { color: var(--danger); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 1000; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 13px 12px 13px 15px;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
    animation: toast-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
.toast > span { flex: 1; padding-top: 1px; }
.toast-success > .icon { color: var(--success); }
.toast-error > .icon { color: var(--danger); }
.toast-warning > .icon { color: var(--warning); }
.toast-info > .icon { color: var(--info); }
.toast-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; }
.toast-close .icon { width: 16px; height: 16px; }
.toast.leaving { animation: toast-out .25s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 10, 22, .55); backdrop-filter: blur(4px); animation: fade .2s; }
.modal-card { position: relative; width: min(440px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 26px; box-shadow: var(--shadow-lg); animation: pop .25s cubic-bezier(.2, .9, .3, 1.2); }
.modal-card.wide { width: min(560px, 100%); }
.modal-card h3 { font-size: 19px; margin-bottom: 6px; }
.modal-card > p { color: var(--muted); font-size: 14.5px; }
.modal-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; }
.modal-icon.primary { background: var(--primary-soft); color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(8px); } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 22px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.cell-user strong { display: block; font-weight: 600; }
.cell-user small { color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* ---------- Segmented tabs ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; max-width: 100%; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; font: 600 13.5px var(--font); color: var(--muted); background: none; border: 0; border-radius: 9px; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs .count { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.tabs .active .count { background: var(--primary-soft); color: var(--primary); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.empty-icon .icon { width: 24px; height: 24px; }
.empty h3 { font-size: 16px; }
.empty p { color: var(--muted); font-size: 14px; margin: 6px auto 16px; max-width: 360px; }

/* ---------- Progress bars ---------- */
.bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.bar.lead > i { background: var(--gradient); }
.bar-lg { height: 14px; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; letter-spacing: -.02em; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 4px 14px -4px rgba(139, 92, 246, .55); }
.brand-accent { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero .brand-accent { background: linear-gradient(135deg, #a5b4fc, #f0abfc); -webkit-background-clip: text; background-clip: text; }

/* ==========================================================================
   Auth (split-screen)
   ========================================================================== */
.auth { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 560px); min-height: 100vh; }
.auth-hero { position: relative; overflow: hidden; background: #0d0b25; color: #fff; }
.auth-hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .55), transparent 60%), radial-gradient(800px 500px at 100% 100%, rgba(217, 70, 239, .45), transparent 60%); }
.auth-hero::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%); }
.auth-admin .auth-hero { background: #07121f; }
.auth-admin .auth-hero::before { background: radial-gradient(1100px 600px at 0% 0%, rgba(14, 165, 233, .45), transparent 60%), radial-gradient(800px 500px at 100% 100%, rgba(99, 102, 241, .5), transparent 60%); }
.auth-hero-inner { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px; }
.auth-hero .brand { color: #fff; }
.auth-hero-copy { max-width: 520px; }
.auth-hero h1 { font-size: clamp(36px, 4.4vw, 58px); font-weight: 800; letter-spacing: -.045em; line-height: 1.02; margin: 18px 0 18px; }
.auth-hero p { font-size: 17px; color: rgba(255, 255, 255, .72); max-width: 440px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; font-size: 13px; font-weight: 600; border-radius: 99px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); backdrop-filter: blur(8px); }
.eyebrow .icon { width: 15px; height: 15px; }
.auth-hero-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.auth-hero-foot .badge { background: rgba(255,255,255,.12); color: #fff; }
.auth-hero-foot .badge-success { background: rgba(52, 209, 124, .2); color: #6ff0a6; }
.muted-on-dark { display: inline-flex; align-items: center; gap: 7px; color: rgba(255, 255, 255, .6); }
.muted-on-dark .icon { width: 15px; height: 15px; }
.orb { position: absolute; border-radius: 50%; filter: blur(2px); z-index: 1; opacity: .9; animation: float 14s ease-in-out infinite; }
.orb-1 { width: 260px; height: 260px; right: -60px; top: 18%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), rgba(139, 92, 246, .25) 40%, transparent 70%); }
.orb-2 { width: 140px; height: 140px; right: 26%; bottom: 14%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.3), rgba(217, 70, 239, .25) 45%, transparent 70%); animation-delay: -5s; }
.orb-3 { width: 80px; height: 80px; left: 48%; top: 12%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), rgba(99, 102, 241, .3) 45%, transparent 70%); animation-delay: -9s; }
@keyframes float { 50% { transform: translateY(-22px) translateX(10px); } }

.auth-main { display: flex; flex-direction: column; padding: 24px 40px; background: var(--surface); }
.auth-top { display: flex; justify-content: flex-end; }
.auth-card { width: 100%; max-width: 420px; margin: auto; padding: 24px 0; }
.auth-card-head { margin-bottom: 26px; }
.auth-card-head h2 { font-size: 28px; font-weight: 750; letter-spacing: -.035em; margin: 14px 0 6px; }
.auth-card .switch-link { text-align: center; margin-top: 22px; color: var(--muted); font-size: 14px; }
.auth-card .switch-link a { font-weight: 600; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 22px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-links .btn { border-color: var(--border); }
@media (max-width: 460px) { .auth-links { grid-template-columns: 1fr; } }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
:root[data-theme="dark"] input[type="date"], :root[data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; } /* light calendar icon in dark mode */
.migration-log { margin-bottom: 20px; border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; background: var(--surface-2); font-size: 13.5px; }
.migration-log summary { display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; color: var(--success); }
.migration-log ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); max-height: 200px; overflow: auto; }

/* ==========================================================================
   Voter shell
   ========================================================================== */
.topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 22px; height: 66px; }
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; font-weight: 600; font-size: 14px; color: var(--muted); border-radius: 10px; transition: background .15s, color .15s; }
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.active { color: var(--primary); background: var(--primary-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border: 1px solid var(--border); border-radius: 99px; }
.user-chip-name { font-size: 13.5px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottomnav { display: none; }
.page { padding-top: 30px; padding-bottom: 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 750; letter-spacing: -.035em; }
.page-head p { color: var(--muted); margin-top: 4px; }

.hero-card { position: relative; overflow: hidden; border-radius: var(--radius-xl); padding: 34px; color: #fff; background: #110d33; isolation: isolate; }
.hero-card::before { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(700px 300px at 0% 0%, rgba(99, 102, 241, .8), transparent 60%), radial-gradient(600px 300px at 100% 100%, rgba(217, 70, 239, .55), transparent 60%); }
.hero-card::after { content: ''; position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(90deg, transparent, #000 60%); }
.hero-card h1 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 800; letter-spacing: -.04em; margin: 12px 0 8px; }
.hero-card p { color: rgba(255,255,255,.78); max-width: 560px; font-size: 15.5px; }
.hero-card .row { margin-top: 22px; }
.hero-card .btn-light { --b-bg: #fff; --b-fg: #1b1640; --b-bd: transparent; }
.hero-card .btn-light:hover { background: #f0efff; color: #1b1640; }
.hero-card .btn-outline-light { --b-bg: rgba(255,255,255,.08); --b-fg: #fff; --b-bd: rgba(255,255,255,.22); }
.hero-card .btn-outline-light:hover { background: rgba(255,255,255,.16); color: #fff; }
.hero-card .badge { background: rgba(255,255,255,.14); color: #fff; }
.hero-card .badge-success { background: rgba(52,209,124,.22); color: #79f3ae; }
.hero-meta { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 26px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.14); }
.hero-meta div small { display: block; color: rgba(255,255,255,.6); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.hero-meta div strong { font-size: 18px; }

.countdown { display: flex; gap: 10px; margin-top: 4px; }
.countdown span { display: grid; place-items: center; min-width: 54px; padding: 8px 6px; border-radius: 12px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); }
.countdown b { font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown small { font-size: 10.5px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .06em; }

.steps { counter-reset: s; display: grid; gap: 14px; align-content: start; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-num { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-2); color: var(--muted); flex-shrink: 0; border: 1px solid var(--border); }
.step.done .step-num { background: var(--success-soft); color: var(--success); border-color: transparent; }
.step.current .step-num { background: var(--primary); color: #fff; border-color: transparent; }
.step strong { display: block; font-size: 14.5px; }
.step small { color: var(--muted); }

/* ---------- Ballot ---------- */
.ballot-progress { position: sticky; top: 66px; z-index: 40; padding: 14px 0; margin-bottom: 8px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.ballot-progress .bar { margin-top: 8px; height: 6px; }
.position-block { margin-bottom: 34px; scroll-margin-top: 140px; }
.position-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.position-head h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.position-head .num { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; background: var(--primary-soft); color: var(--primary); }
.position-head p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.cand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.cand {
    position: relative; display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
    background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px;
    transition: border-color .15s, box-shadow .2s, transform .2s;
}
.cand:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.cand input { position: absolute; opacity: 0; pointer-events: none; }
.cand-photo { aspect-ratio: 4 / 3.4; background: var(--surface-2); position: relative; overflow: hidden; }
.cand-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.cand:hover .cand-photo img { transform: scale(1.04); }
.cand-photo .ph { width: 100%; height: 100%; display: grid; place-items: center; background: var(--gradient); color: rgba(255,255,255,.95); font-size: 42px; font-weight: 800; letter-spacing: -.02em; }
.cand-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cand-body h3 { font-size: 16px; font-weight: 700; }
.cand-body p { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cand-check { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.92); color: transparent; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 10px rgba(0,0,0,.18); transition: all .18s; }
.cand-check .icon { width: 16px; height: 16px; stroke-width: 3; }
.cand input:checked ~ .cand-check { background: var(--primary); color: #fff; border-color: #fff; transform: scale(1.08); }
.cand:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring), var(--shadow); }
.cand:has(input:focus-visible) { box-shadow: 0 0 0 4px var(--primary-ring); }
.cand-select-label { margin-top: auto; padding-top: 8px; font-size: 13px; font-weight: 600; color: var(--primary); }
.cand:has(input:checked) .cand-select-label { color: var(--success); }
.cand.is-full { opacity: .45; cursor: not-allowed; }       /* "choose up to N" limit reached */
.cand.is-full:hover { transform: none; box-shadow: none; }
.cand input[type=checkbox] ~ .cand-check { border-radius: 8px; } /* square tick = you can pick several */
.cand.abstain { justify-content: center; align-items: center; text-align: center; min-height: 160px; border-style: dashed; background: transparent; }
.cand.abstain .cand-body { align-items: center; justify-content: center; }
.cand.abstain .cand-check { top: 12px; right: 12px; background: var(--surface-2); border-color: var(--border); }
.cand.static { cursor: default; }
.cand.static:hover { transform: none; }

.ballot-bar { position: sticky; bottom: 16px; z-index: 40; margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 14px 14px 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); flex-wrap: wrap; }
.review-list { display: grid; gap: 8px; margin: 18px 0 4px; }
.review-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.review-item span { color: var(--muted); }
.review-item strong { text-align: right; }
.review-item.abstained strong { color: var(--muted); font-weight: 500; font-style: italic; }

.receipt { text-align: center; padding: 40px 24px; }
.receipt-icon { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; background: var(--success-soft); color: var(--success); animation: pop .5s cubic-bezier(.2, .9, .3, 1.4); }
.receipt-icon .icon { width: 36px; height: 36px; }
.receipt h2 { font-size: 26px; letter-spacing: -.03em; }
.receipt p { color: var(--muted); margin-top: 6px; }
.receipt-code { display: inline-block; margin-top: 16px; padding: 8px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 13px; letter-spacing: .06em; }

.receipt-qr { display: flex; align-items: center; gap: 22px; max-width: 560px; margin: 22px auto 0; padding: 18px; text-align: left; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-2); }
.receipt-qr .qr { width: 148px; height: 148px; flex-shrink: 0; padding: 6px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-sm); }
.receipt-qr .qr svg { width: 100%; height: 100%; display: block; }
.receipt-qr-text .receipt-code { margin-top: 0; }
.receipt-qr-text p { color: var(--muted); font-size: 13.5px; margin: 10px 0 12px; }
@media (max-width: 560px) { .receipt-qr { flex-direction: column; text-align: center; } .receipt-qr-text .row { justify-content: center; } }
/* Printed receipt: only the receipt, compact, always fits on ONE page */
@media print {
    .receipt-qr .btn, .receipt .row { display: none; }
    html:has(.receipt), body:has(.receipt) { background: #fff; }
    body:has(.receipt) .topbar, body:has(.receipt) .bottomnav, body:has(.receipt) .toasts, body:has(.receipt) footer { display: none !important; }
    body:has(.receipt) main.page { padding: 0; margin: 0; max-width: none; }
    body:has(.receipt) main.page > :not(.receipt) { display: none !important; }
    .receipt { padding: 0 0 4px; border: 0; box-shadow: none; break-inside: auto; overflow: visible; border-radius: 0; }
    /* Always print in light colours (saves ink, even when dark mode is on) */
    .receipt {
        --surface: #fff; --surface-2: #f2f3f8; --surface-3: #e9eaf2; --border: #e4e6ef; --border-strong: #d3d6e3;
        --text: #0e1120; --text-2: #3a3f55; --muted: #6a7089; --success: #12a150; --success-soft: rgba(18, 161, 80, .12);
        --info: #0b84c6; --info-soft: rgba(11, 132, 198, .12); --primary: #5b5bf0;
        background: #fff; color: var(--text); color-scheme: light;
    }
    .receipt-icon { width: 44px; height: 44px; margin-bottom: 8px; border-radius: 14px; animation: none; }
    .receipt-icon .icon { width: 22px; height: 22px; }
    .receipt h2 { font-size: 20px; }
    .receipt p { margin-top: 2px; font-size: 12.5px; }
    .receipt-qr { margin-top: 12px; padding: 12px; gap: 16px; break-inside: avoid; }
    .receipt-qr .qr { width: 120px; height: 120px; box-shadow: none; }
    .receipt .review-list { margin-top: 12px !important; gap: 4px; }
    .receipt .review-item { padding: 6px 12px; font-size: 12.5px; break-inside: avoid; }
    .receipt .alert { margin-top: 10px !important; padding: 8px 12px; font-size: 11.5px; break-inside: avoid; }
    @page { margin: 12mm; }
}

.verify-result { text-align: center; padding: 8px 0; }
.verify-result .receipt-icon.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- Results ---------- */
.result-pos { padding: 22px; }
.result-pos + .result-pos { border-top: 1px solid var(--border); }
.result-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 0; }
.result-row .rank { font-weight: 700; color: var(--muted); font-size: 13px; text-align: center; }
.result-row.lead .rank { color: var(--warning); }
.result-row .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.result-row .who > div { min-width: 0; flex: 1; }
.result-row .who strong { display: flex; align-items: center; gap: 8px; font-size: 14.5px; margin-bottom: 6px; }
.result-row .who strong .icon { width: 16px; height: 16px; color: var(--warning); }
.result-row .num { text-align: right; min-width: 70px; }
.result-row .num b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.result-row .num small { color: var(--muted); }
.winner-card { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 16px; background: linear-gradient(135deg, var(--warning-soft), var(--primary-soft)); border: 1px solid var(--border); }
.winner-card .who small { color: var(--muted); display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.winner-card .who strong { font-size: 16px; }
.winner-card .trophy { margin-left: auto; color: var(--warning); }
.winner-card .trophy .icon { width: 26px; height: 26px; }

.donut { --p: 0; width: 132px; height: 132px; border-radius: 50%; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-3) 0); display: grid; place-items: center; flex-shrink: 0; }
.donut::before { content: ''; grid-area: 1 / 1; width: 100px; height: 100px; border-radius: 50%; background: var(--surface); }
.donut span { grid-area: 1 / 1; position: relative; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }

/* ==========================================================================
   Admin shell
   ========================================================================== */
.admin { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar-head { padding: 4px 8px; }
.sidebar-election { margin: 0 4px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 6px; justify-items: start; }
.sidebar-election .label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.sidebar-election strong { font-size: 14px; line-height: 1.3; }
.sidenav { display: grid; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; font-weight: 550; font-size: 14px; color: var(--text-2); border-radius: 10px; transition: background .12s, color .12s; }
.sidenav a .icon { color: var(--muted); }
.sidenav a:hover { background: var(--surface-2); color: var(--text); }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); }
.sidenav a.active .icon { color: var(--primary); }
.sidenav .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; border-radius: 99px; background: var(--danger); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.sidebar-foot .user-chip { border: 0; padding: 0; }
.sidebar-foot .user-chip strong { display: block; font-size: 13.5px; }
.sidebar-foot .user-chip small { color: var(--muted); font-size: 12px; }
.sidebar-scrim { display: none; }
.admin-main { min-width: 0; }
.admin-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.admin-title h1 { font-size: 22px; font-weight: 750; letter-spacing: -.03em; }
.admin-title p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.admin-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.admin-content { padding: 28px 32px 60px; display: grid; gap: 22px; align-content: start; }

.status-hero { display: flex; align-items: center; gap: 22px; padding: 24px; flex-wrap: wrap; }
.status-orb { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; flex-shrink: 0; }
.status-orb .icon { width: 30px; height: 30px; }
.status-orb.open { background: var(--success-soft); color: var(--success); }
.status-orb.closed, .status-orb.ended { background: var(--surface-2); color: var(--muted); }
.status-orb.scheduled { background: var(--info-soft); color: var(--info); }
.status-hero h2 { font-size: 22px; letter-spacing: -.03em; }
.status-hero p { color: var(--muted); margin-top: 3px; }
.status-hero form { margin-left: auto; }

.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 22px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .grow small { color: var(--muted); }
.dot-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.dot-ic .icon { width: 16px; height: 16px; }

.pos-chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.searchbar { position: relative; min-width: 240px; }
.searchbar .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.searchbar input { height: 38px; padding-left: 36px; font-size: 14px; }
.candidate-thumb { width: 44px; height: 44px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--gradient); display: grid; place-items: center; color: #fff; font-weight: 700; }
.candidate-thumb img { width: 100%; height: 100%; object-fit: cover; }
.switch.is-disabled { opacity: .45; cursor: not-allowed; }
.new-election { scroll-margin-top: 90px; border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.new-election .card-head h3 { display: flex; align-items: center; gap: 8px; }
.new-election .card-head h3 .icon { color: var(--primary); }
.new-election .step.done .step-num { background: var(--primary-soft); color: var(--primary); }
.history-card { color: var(--text); transition: transform .2s, box-shadow .2s, border-color .2s; }
.history-card:hover { color: var(--text); transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.history-card .list-item small { color: var(--muted); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone .card-head h3 { color: var(--danger); }
.kv { display: grid; gap: 10px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv span { color: var(--muted); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1080px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
    .auth { grid-template-columns: 1fr; }
    .auth-hero { min-height: auto; }
    .auth-hero-inner { padding: 26px 24px 30px; gap: 20px; }
    .auth-hero h1 { font-size: 34px; margin: 14px 0 10px; }
    .auth-hero p { font-size: 15px; }
    .orb-1 { width: 160px; height: 160px; }
    .auth-main { padding: 20px; }
    .auth-top { position: absolute; top: 24px; right: 20px; z-index: 10; } /* above the hero panel, or taps hit the logo instead */
    .auth-top .icon-btn { color: #fff; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); } /* sits on the purple hero in both themes */

    .admin { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; width: 280px; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .sidebar-scrim { position: fixed; inset: 0; z-index: 150; background: rgba(8, 10, 22, .5); }
    .sidebar.open + .sidebar-scrim { display: block; }
    .menu-btn { display: inline-grid; }
    .admin-top { padding: 14px 18px; }
    .admin-content { padding: 20px 18px 50px; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); } /* minmax(0,…): wide tables scroll inside the card instead of pushing it off-screen */
    .span-2 { grid-column: auto; }
}
@media (max-width: 760px) {
    .topnav, .user-chip-name { display: none; }
    .topbar .user-chip { padding: 0; border: 0; }
    .bottomnav { display: flex; position: fixed; z-index: 60; left: 12px; right: 12px; bottom: 12px; padding: 6px; justify-content: space-around; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); }
    .bottomnav a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 7px 4px; font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 12px; }
    .bottomnav a.active { color: var(--primary); background: var(--primary-soft); }
    .page { padding-bottom: 110px; padding-top: 20px; }
    .ballot-bar { bottom: 90px; }
    .hero-card { padding: 24px; border-radius: 22px; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-row { grid-template-columns: minmax(0, 1fr); }
    .table th, .table td { padding: 12px 14px; }
    .card-head, .card-body, .result-pos, .list-item { padding-left: 16px; padding-right: 16px; }
    .cand-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
    .cand-body p { -webkit-line-clamp: 2; }
    .toasts { right: 12px; left: 12px; bottom: 96px; width: auto; }
    .admin-body .toasts { bottom: 12px; }
    .admin-title p { display: none; }
    .admin-title h1 { font-size: 19px; }
    .admin-actions .btn span { display: none; }
    .admin-actions .btn { padding: 0 10px; }
    .status-hero form { margin-left: 0; width: 100%; }
    .status-hero form .btn { width: 100%; }
    .searchbar { min-width: 0; width: 100%; }
}
@media (max-width: 460px) {
    .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .stat-value { font-size: 24px; }
    .page-head h1 { font-size: 24px; }
}
@media print {
    .sidebar, .admin-actions, .menu-btn, .toasts, .topbar, .bottomnav { display: none !important; }
    .admin { display: block; }
    .admin-top { position: static; border: 0; }
    .card { break-inside: avoid; box-shadow: none; }
    .bar > i { transition: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
