/* -------- Theme (shared across pages) -------- */
:root {
    --bg: #000;
    --panel: #111;
    --text: #fff;
    --muted: #bbb;
    --border: #8e3cda; /* purple */
    --accent: #8e3cda; /* purple */
    --accent-2: #ff7c25; /* orange */
    --neon: #b7ff40; /* slime green */
}

* {
    box-sizing: border-box
}

html, body {
    height: 100%
}

body {
    font-family: Montserrat, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 16px;
}

/* Layout */
.page {
    max-width: 960px;
    margin: 0 auto
}

.card {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin: 8px 0;
}

h1 {
    color: var(--neon);
    margin: 6px 0 8px;
    font-size: 22px;
}

h2 {
    color: var(--text);
    margin: 10px 0 8px;
    font-size: 18px;
}

.sub {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 8px
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

label {
    display: flex;
    align-items: center;
    gap: 10px
}

input[type=checkbox] {
    width: 22px;
    height: 22px
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 10px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
}

.btn:disabled {
    opacity: .5;
    cursor: default
}

.btn.secondary {
    background: #262626;
    border: 1px solid #333
}

.btn.warn {
    background: var(--accent-2)
}

.btn.block {
    display: block;
    width: 100%
}

/* Inputs */
.input, input[type=text], input[type=search], input[type=password], input[type=file] {
    width: 100%;
    padding: 12px 10px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #0b0b0b;
    color: #fff;
}

.codebox {
    display: flex;
    gap: 8px;
    margin-top: 10px
}

.codebox .input {
    flex: 1
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th, .table td {
    padding: 10px 12px;
    border-bottom: 1px solid #222;
    text-align: left
}

.table th {
    color: var(--muted);
    font-weight: 700
}

/* Toast */
.toast {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    background: #111;
    border: 2px solid var(--neon);
    color: var(--neon);
    padding: 12px;
    border-radius: 12px;
    display: none
}

#toast.show {
    display: block;
}

/* Images */
img.hero {
    max-width: 100%;
    border-radius: 12px;
    margin: 6px 0 10px
}

.thumb {
    width: 56px;
    height: 56px;
    object-fit: cover; /* crop without distortion */
    border-radius: 8px;
}

/* Pills & switcher (multi-ballot) */
.switchbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 10px
}

.switcher {
    display: flex;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap
}

.pill {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #333;
    border-radius: 999px;
    background: #0a0a0a
}

.pillballot {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #333;
    background: #0a0a0a;
    color: #ddd;
    font-weight: 700;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .05s;
}

.pillballot:hover {
    transform: translateY(-1px)
}

.pillballot.active {
    background: var(--neon);
    color: #0b0b0b;
    border-color: var(--neon);
    box-shadow: 0 0 0 2px #0b0b0b inset, 0 0 16px var(--neon);
}

.pillballot:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent)
}

/* Utility */
.hide {
    display: none !important
}


/* --- QR Scanner overlay (merged) --- */
.scanner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    /* keep buttons above iOS bottom bar */
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.scanner-overlay.show {
    display: flex;
}

/* constrain panel so it never hides under system UI */
.scanner-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
}

.scanner-panel > div[style*="position:relative"] { /* video wrapper */
    position: relative;
}

.scanner-video {
    display: block;
    width: 100%;
    height: auto;
    /* take the smaller of your original 70vh OR a safe-area-friendly calc */
    max-height: min(70vh, calc(100vh - 240px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    object-fit: cover; /* fill behind the square nicely */
}

/* action row stays visible above phone UI */
.scanner-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 2;
}

.scanner-actions .btn {
    flex: 1;
}

.scan-tip {
    color: var(--muted);
    font-size: 14px;
    margin: 8px 2px;
}

/* centered square frame with outside mask */
.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    /* square size: choose smaller of viewport side or panel width, with a cap */
    --box: min(70vmin, 80vw, 360px);
    width: var(--box);
    height: var(--box); /* ← square */
    transform: translate(-50%, -50%);
    border: 3px solid var(--neon);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35) inset; /* subtle mask outside frame */
    pointer-events: none;
}

/* on short screens, shrink frame a bit so buttons stay clear */
@media (max-height: 700px) {
    .scan-frame {
        --box: min(58vmin, 82vw, 320px);
    }
}

/* Admin layout */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 12px;
}

.admin-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.navlink {
    display: block;
    padding: 10px 12px;
    border: 1px solid #333;
    border-radius: 10px;
    background: #0a0a0a;
    color: #fff;
    text-decoration: none;
}

.navlink:hover {
    border-color: var(--accent)
}

.admin-main > .card + .card {
    margin-top: 12px
}

/* Simple 2-col form grid */
.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 680px) {
    .admin-layout {
        grid-template-columns: 1fr
    }

    .grid2 {
        grid-template-columns: 1fr
    }
}

.requires-auth {
    display: none;
}
/* ===== Admin polish (headings, spacing, thumbnails, rows) ===== */

/* Accent color helper (keeps working if you change theme later) */
:root {
    --accent: #9a6bff;           /* tweak if you want it warmer/cooler */
    --accent-glow: rgba(154,107,255,.55);
}

/* Card headings: louder, with a subtle accent bar + glow */
.card > h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;          /* ~20px */
    line-height: 1.2;
    letter-spacing: .2px;
    color: #fff;                 /* keep high contrast on dark */
    margin: 4px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.card > h2::before {
    content: "";
    width: 6px;
    height: 1.2em;
    border-radius: 6px;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow), 0 0 16px var(--accent-glow) inset;
}

/* Optional kicker inside h2: <small>…</small> */
.card > h2 small {
    margin-left: auto;
    font-size: .8rem;
    color: var(--muted, #aaa);
}

/* Slightly larger separation between admin cards */
.card + .card { margin-top: 14px; }

/* Rows feel more tappable, especially for "Edit" actions */
.row {
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.row:hover { background: rgba(255,255,255,.02); border-radius: 10px; }

/* Inputs/buttons line up better */
.input { height: 38px; }
.btn    { height: 38px; }

/* Thumbnails: square crop with no distortion */
.thumb {
    width: 56px; height: 56px;
    object-fit: cover;           /* crop, don’t stretch */
    border-radius: 8px;
    flex: 0 0 auto;
}

/* “Sub” text reads cleaner against dark bg */
.sub { color: rgba(255,255,255,.65); }

/* Tiny table/list separators when you have many items */
.divider {
    height: 1px; background: rgba(255,255,255,.06);
    margin: 6px 0;
}

/* Make the top admin menu (if you’re using it) stick just below header */
#menuBar {
    position: sticky;
    top: 8px; z-index: 50;
    background: var(--bg, #111);
    padding: 8px; border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset;
}

:root {
    --bg2: #f3f4f6; /* light surface */
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg2: #1f2937; /* dark surface */
    }
}