/* Votaciones CSD Royal: sistema visual
   Colores del escudo del club: negro y oro. Flat: las superficies se separan por tono, no por bordes. */

:root {
    --bg: #efefeb;
    --surface: #ffffff;
    --surface-2: #e6e6e1;
    --ink: #17171a;
    --ink-2: #3a3b40;
    --muted: #65666e;
    --line: #d5d5cf;
    --gold: #edb812;
    --gold-strong: #d9a400;
    --gold-soft: #fbf0c7;
    --on-gold: #17171a;
    --ok: #1d7f52;
    --ok-soft: #dcf0e5;
    --warn: #9a6200;
    --warn-soft: #fdecc8;
    --bad: #c2352b;
    --bad-soft: #fbe2df;
    --info-soft: #e3e7f0;
    --bar: #17171a;
    --on-bar: #f4f4f0;
    --on-bar-muted: #a9a9a3;
    --focus: #2f6fdb;

    --r-sm: 10px;
    --r: 14px;
    --r-lg: 20px;
    --pill: 999px;

    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --s7: 48px;

    --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);

    --featured-bg: var(--ink);
    --featured-fg: var(--bg);
    --lead-fill: var(--ink);
    --result-fill: var(--gold);

    color-scheme: light;
}

/* Oscuro: sigue al sistema salvo que la persona elija un tema (data-theme en <html>) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f0f11;
        --surface: #1b1b1f;
        --surface-2: #26262b;
        --ink: #f1f1ec;
        --ink-2: #d2d2cc;
        --muted: #9a9aa2;
        --line: #34343a;
        --gold-soft: #3a3010;
        --ok: #4cc08a;
        --ok-soft: #12301f;
        --warn: #f0b545;
        --warn-soft: #3a2b0c;
        --bad: #f0786d;
        --bad-soft: #3c1714;
        --info-soft: #23262e;
        --bar: #000000;
        --focus: #7aa7ff;
        --featured-bg: var(--surface-2);
        --featured-fg: var(--ink);
        --lead-fill: var(--gold);
        --result-fill: var(--muted);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0f0f11;
    --surface: #1b1b1f;
    --surface-2: #26262b;
    --ink: #f1f1ec;
    --ink-2: #d2d2cc;
    --muted: #9a9aa2;
    --line: #34343a;
    --gold-soft: #3a3010;
    --ok: #4cc08a;
    --ok-soft: #12301f;
    --warn: #f0b545;
    --warn-soft: #3a2b0c;
    --bad: #f0786d;
    --bad-soft: #3c1714;
    --info-soft: #23262e;
    --bar: #000000;
    --focus: #7aa7ff;
    --featured-bg: var(--surface-2);
    --featured-fg: var(--ink);
    --lead-fill: var(--gold);
    --result-fill: var(--muted);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; line-height: 1.3; font-weight: 600; }
h3 { font-size: 1rem; line-height: 1.35; font-weight: 600; }
a { color: inherit; }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bar);
    color: var(--on-bar);
    padding-top: var(--safe-t);
}

.topbar-in {
    max-width: var(--page-w, 720px);
    margin: 0 auto;
    padding: 10px var(--s4);
    display: flex;
    align-items: center;
    gap: var(--s3);
    min-height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}

.brand img { width: 36px; height: 36px; flex: none; }
.brand-name { font-weight: 600; font-size: .95rem; line-height: 1.2; }
.brand-sub { display: block; font-size: .75rem; color: var(--on-bar-muted); font-weight: 400; }

.topbar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: -8px;
    border-radius: var(--pill);
    color: var(--on-bar);
    text-decoration: none;
    font-size: 1.3rem;
    flex: none;
}

.topbar-title { font-weight: 600; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }

.topnav { display: none; gap: 2px; }
.topnav a {
    color: var(--on-bar-muted);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--pill);
    font-size: .9rem;
    font-weight: 500;
}
.topnav a[aria-current="page"] { color: var(--on-bar); background: rgba(255, 255, 255, .1); }

.avatar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 0;
    color: var(--on-bar);
    font: inherit;
    padding: 4px;
    border-radius: var(--pill);
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--pill);
    background: var(--gold);
    color: var(--on-gold);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .9rem;
    flex: none;
}

/* ---------- Página ---------- */
.page {
    max-width: var(--page-w, 720px);
    margin: 0 auto;
    padding: var(--s5) var(--s4) calc(var(--s7) + var(--safe-b));
}

.page-wide { --page-w: 1120px; }

.page-head { margin-bottom: var(--s5); }
.page-head p { margin-top: 6px; color: var(--muted); max-width: 60ch; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); }

.section { margin-top: var(--s6); }
.section > h2 { margin-bottom: var(--s3); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.count { color: var(--muted); font-weight: 500; }

.panel {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: var(--s5) var(--s4);
}

@media (min-width: 640px) {
    .panel { padding: var(--s5); }
}

.stack > * + * { margin-top: var(--s3); }

/* ---------- Botones ---------- */
.btn {
    --btn-bg: var(--surface-2);
    --btn-fg: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--pill);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: 600 .95rem/1 var(--font);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    transition: transform .12s var(--ease), background-color .15s, opacity .15s;
}

.btn:active { transform: scale(.97); }
.btn i { font-size: 1.15em; }
.btn-gold { --btn-bg: var(--gold); --btn-fg: var(--on-gold); }
.btn-ink { --btn-bg: var(--ink); --btn-fg: var(--bg); }
.btn-danger { --btn-bg: var(--bad-soft); --btn-fg: var(--bad); }
.btn-plain { --btn-bg: transparent; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; }
.btn-icon.btn-sm { width: 38px; min-height: 38px; }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }

@media (hover: hover) and (pointer: fine) {
    .btn:hover { filter: brightness(.96); }
    .btn-gold:hover { background: var(--gold-strong); filter: none; }
    .topnav a:hover { color: var(--on-bar); }
    .row-link:hover { background: var(--surface-2); }
    .option:hover { background: var(--surface-2); }
}

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- Etiquetas de estado ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--pill);
    font-size: .78rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--ink-2);
    white-space: nowrap;
}

.tag i { font-size: 1rem; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-gold { background: var(--gold-soft); color: var(--ink); }

/* ---------- Avisos ---------- */
.note {
    display: flex;
    gap: var(--s3);
    align-items: flex-start;
    padding: var(--s3) var(--s4);
    border-radius: var(--r);
    background: var(--info-soft);
    font-size: .9rem;
}

.note > i { font-size: 1.3rem; flex: none; margin-top: 1px; }
.note-ok { background: var(--ok-soft); }
.note-ok > i { color: var(--ok); }
.note-warn { background: var(--warn-soft); }
.note-warn > i { color: var(--warn); }
.note-bad { background: var(--bad-soft); }
.note-bad > i { color: var(--bad); }

.toasts {
    position: fixed;
    z-index: 60;
    left: 0;
    right: 0;
    top: calc(var(--safe-t) + 12px);
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 0 var(--s4);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 520px;
    width: 100%;
    padding: 12px 14px 12px 16px;
    border-radius: var(--r);
    background: var(--ink);
    color: var(--bg);
    font-size: .9rem;
    box-shadow: 0 10px 30px rgba(10, 10, 12, .22);
    animation: toast-in .35s var(--ease);
}

.toast > i { font-size: 1.25rem; flex: none; }
.toast-ok > i { color: #5fd39b; }
.toast-bad > i { color: #ff8e84; }
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: inherit; opacity: .7; font-size: 1.1rem; cursor: pointer; padding: 4px; }
.toast.is-out { opacity: 0; transform: translateY(-8px); transition: .25s var(--ease); }

@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- Listas de votaciones / filas ---------- */
.rows { display: grid; gap: 8px; }

.row-link {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--s3);
    padding: var(--s4);
    background: var(--surface);
    border-radius: var(--r);
    text-decoration: none;
    color: inherit;
    transition: background-color .15s;
    touch-action: manipulation;
}

.row-link:active { background: var(--surface-2); }
.row-link > i { color: var(--muted); font-size: 1.2rem; }
.row-title { font-weight: 600; line-height: 1.35; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; color: var(--muted); font-size: .85rem; }
.row-meta span { display: inline-flex; align-items: center; gap: 5px; }
.row-meta i { font-size: 1rem; }

/* Votación pendiente destacada */
.featured {
    display: block;
    padding: var(--s5) var(--s4);
    border-radius: var(--r-lg);
    background: var(--featured-bg);
    color: var(--featured-fg);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.featured + .featured { margin-top: var(--s3); }
.featured h3 { font-size: 1.2rem; line-height: 1.3; max-width: 32ch; }
.featured p { margin-top: 6px; opacity: .75; font-size: .9rem; max-width: 52ch; }
.featured .row-meta { color: inherit; opacity: .8; }
.featured .btn { margin-top: var(--s4); }

.featured::after {
    content: "";
    position: absolute;
    right: -38px;
    bottom: -38px;
    width: 150px;
    height: 150px;
    background: url(../img/escudo.png) center / contain no-repeat;
    opacity: .14;
    pointer-events: none;
}


.empty {
    text-align: center;
    padding: var(--s7) var(--s4);
    background: var(--surface);
    border-radius: var(--r-lg);
}

.empty > i { font-size: 2.2rem; color: var(--muted); }
.empty h3 { margin-top: var(--s3); }
.empty p { margin: 6px auto 0; color: var(--muted); max-width: 40ch; }
.empty .btn { margin-top: var(--s4); }

/* ---------- Página de votar ---------- */
.vote-head h1 { margin-top: var(--s3); }
.vote-head .lead { margin-top: var(--s2); color: var(--ink-2); max-width: 62ch; white-space: pre-line; }

.facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: var(--s5);
}

.fact { background: var(--surface); border-radius: var(--r); padding: var(--s3) var(--s4); }
.fact dt { font-size: .8rem; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-weight: 600; }
.fact-wide { grid-column: 1 / -1; }

.meter { height: 8px; border-radius: var(--pill); background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--gold); border-radius: inherit; transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

.options { display: grid; gap: 8px; margin-top: var(--s3); }

.option {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s3);
    min-height: 64px;
    padding: var(--s3) var(--s4);
    background: var(--surface);
    border-radius: var(--r);
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color .15s, box-shadow .15s, transform .12s var(--ease);
}

.option:active { transform: scale(.985); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option-text { flex: 1; font-weight: 500; font-size: 1.02rem; line-height: 1.35; }

.option-mark {
    width: 26px;
    height: 26px;
    border-radius: var(--pill);
    box-shadow: inset 0 0 0 2px var(--line);
    display: grid;
    place-items: center;
    flex: none;
    transition: background-color .15s, box-shadow .15s;
}

.option-mark::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: var(--pill);
    background: var(--on-gold);
    transform: scale(0);
    transition: transform .2s var(--ease);
}

.option:has(input:checked) { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold); }
.option input:checked + .option-mark { background: var(--gold); box-shadow: none; }
.option input:checked + .option-mark::after { transform: scale(1); }
.option input:focus-visible + .option-mark { outline: 2px solid var(--focus); outline-offset: 2px; }

.actionbar {
    position: sticky;
    bottom: 0;
    z-index: 15;
    margin: var(--s5) calc(var(--s4) * -1) 0;
    padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-b));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.actionbar-hint { text-align: center; font-size: .8rem; color: var(--muted); margin-top: 8px; }

.done {
    text-align: center;
    padding: var(--s6) var(--s4);
    background: var(--surface);
    border-radius: var(--r-lg);
}

.done-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--s4);
    border-radius: var(--pill);
    display: grid;
    place-items: center;
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 2rem;
    animation: pop .5s var(--ease) both;
}

@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.done .picked { margin-top: var(--s4); display: inline-block; padding: 10px 18px; border-radius: var(--r); background: var(--gold-soft); font-weight: 600; }

/* Resultados */
.results { display: grid; gap: var(--s4); }
.result-top { display: flex; justify-content: space-between; gap: var(--s3); font-size: .95rem; }
.result-top b { font-weight: 600; }
.result-top span { color: var(--muted); white-space: nowrap; }
.result .meter > span { background: var(--result-fill); }
.result.is-lead .meter > span { background: var(--lead-fill); }


/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field + .field, .field + .grid-2, .grid-2 + .field { margin-top: var(--s4); }
.label { font-weight: 500; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--muted); }
.hint.is-ok { color: var(--ok); }
.hint.is-bad { color: var(--bad); }

.input {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 400 16px/1.4 var(--font);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}

.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 45%, transparent); }
.input.is-ok { border-color: var(--ok); }
.input.is-bad { border-color: var(--bad); }
textarea.input { min-height: 96px; resize: vertical; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-wrap .btn-icon { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); min-height: 44px; }

.grid-2 { display: grid; gap: var(--s4); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: .92rem;
    user-select: none;
}

.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
    width: 22px;
    height: 22px;
    flex: none;
    border-radius: 7px;
    box-shadow: inset 0 0 0 2px var(--line);
    display: grid;
    place-items: center;
    margin-top: 1px;
    color: var(--on-gold);
    font-size: .9rem;
    transition: background-color .15s, box-shadow .15s;
}

.check .box i { opacity: 0; transform: scale(.5); transition: .15s var(--ease); }
.check input:checked + .box { background: var(--gold); box-shadow: none; }
.check input:checked + .box i { opacity: 1; transform: none; }
.check input:indeterminate + .box { background: var(--gold); box-shadow: none; }
.check input:indeterminate + .box::before { content: ""; width: 10px; height: 2px; background: var(--on-gold); border-radius: 2px; }
.check input:indeterminate + .box i { display: none; }
.check input:focus-visible + .box { outline: 2px solid var(--focus); outline-offset: 2px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--r); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 11px; font-size: .85rem; font-weight: 500; color: var(--muted); text-align: center; transition: .15s; }
.seg span i { font-size: 1.35rem; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); }

.opt-list { display: grid; gap: 8px; }
.opt-item { display: flex; gap: 8px; align-items: center; }
.opt-item .input { flex: 1; }
.opt-num { width: 28px; flex: none; text-align: center; color: var(--muted); font-weight: 600; font-size: .9rem; }

.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.form-actions .btn { flex: 1 1 auto; }
@media (min-width: 640px) { .form-actions .btn { flex: 0 0 auto; } }

.drop {
    display: grid;
    place-items: center;
    gap: 8px;
    text-align: center;
    padding: var(--s6) var(--s4);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    cursor: pointer;
}
.drop > i { font-size: 2rem; color: var(--muted); }
.drop.is-over { background: var(--gold-soft); }

.code {
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: .82rem;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: var(--s3) var(--s4);
    overflow-x: auto;
    white-space: pre;
}

/* ---------- Selector de votantes ---------- */
.picker-tools { display: grid; gap: 8px; }
.picker-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.picker-list {
    margin-top: var(--s3);
    max-height: min(56dvh, 460px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface-2);
    border-radius: var(--r);
    padding: 4px;
}

.pick {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    cursor: pointer;
    user-select: none;
}
.pick:has(input:checked) { background: var(--surface); }
.pick-name { font-weight: 500; font-size: .92rem; line-height: 1.3; }
.pick-sub { font-size: .78rem; color: var(--muted); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.picker-empty { padding: var(--s5); text-align: center; color: var(--muted); font-size: .9rem; }

/* ---------- Combobox propio ---------- */
.combo { position: relative; }
.combo-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 50px;
    padding: 0 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 400 16px/1.3 var(--font);
    text-align: left;
    cursor: pointer;
}
.combo-btn .ph { color: var(--muted); }
.combo-btn[aria-expanded="true"] { border-color: var(--ink); }
.combo-btn .is-placeholder { color: var(--muted); }

/* ---------- Capas: menú, popover, diálogo ---------- */
.pop {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: 0 16px 40px rgba(10, 10, 12, .18), 0 0 0 1px color-mix(in srgb, var(--line) 60%, transparent);
    padding: 6px;
    animation: pop-in .18s var(--ease);
}
.pop-search { padding: 4px 4px 8px; }
.pop-search .input { min-height: 44px; }
.pop-list { max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
.pop-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--ink);
    font: 400 .95rem/1.3 var(--font);
    cursor: pointer;
}
.pop-item[aria-selected="true"], .pop-item:focus-visible { background: var(--surface-2); outline: none; }
.pop-item small { display: block; color: var(--muted); font-size: .78rem; }
.pop-empty { padding: 14px; color: var(--muted); font-size: .9rem; text-align: center; }

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }

.menu {
    position: absolute;
    z-index: 40;
    right: var(--s4);
    top: calc(100% - 4px);
    min-width: 230px;
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--r);
    box-shadow: 0 16px 40px rgba(10, 10, 12, .25);
    padding: 6px;
    animation: pop-in .18s var(--ease);
}
.menu-who { padding: 10px 12px 12px; }
.menu-who b { display: block; font-weight: 600; line-height: 1.3; }
.menu-who span { font-size: .8rem; color: var(--muted); }
.menu a, .menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: inherit;
    font: 500 .92rem/1.2 var(--font);
    text-decoration: none;
    cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.menu i { font-size: 1.15rem; color: var(--muted); }
.menu hr { border: 0; height: 1px; background: var(--surface-2); margin: 4px 6px; }

.sheet {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 8, 10, .5); animation: fade .2s ease both; }
.sheet-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 92dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 10px var(--s5) calc(var(--s5) + var(--safe-b));
    animation: sheet-up .32s var(--ease) both;
}
.sheet-grip { width: 40px; height: 5px; border-radius: var(--pill); background: var(--line); margin: 0 auto var(--s4); }
.sheet-icon { width: 52px; height: 52px; border-radius: var(--pill); display: grid; place-items: center; font-size: 1.6rem; background: var(--gold-soft); margin-bottom: var(--s4); }
.sheet-icon.is-bad { background: var(--bad-soft); color: var(--bad); }
.sheet-card h2 { font-size: 1.25rem; }
.sheet-body { margin-top: 8px; color: var(--ink-2); }
.sheet-quote { margin-top: var(--s4); padding: 14px 16px; border-radius: var(--r); background: var(--gold-soft); font-weight: 600; font-size: 1.05rem; }
.sheet-actions { display: grid; gap: 8px; margin-top: var(--s5); }
.sheet.is-out .sheet-card { animation: sheet-down .22s ease-in both; }
.sheet.is-out .sheet-backdrop { animation: fade .22s ease reverse both; }

@media (min-width: 640px) {
    .sheet { align-items: center; padding: var(--s4); }
    .sheet-card { border-radius: 24px; padding-bottom: var(--s5); animation-name: modal-in; }
    .sheet-grip { display: none; }
    .sheet.is-out .sheet-card { animation-name: modal-out; }
    .sheet-actions { grid-auto-flow: column; grid-auto-columns: 1fr; }
    .sheet-actions .btn-plain { order: -1; }
}

@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes modal-out { to { opacity: 0; transform: scale(.97); } }

/* ---------- Selector de fecha y hora propio ---------- */
.dt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); }
.dt-head b { font-weight: 600; text-transform: capitalize; }
.dt-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dt-dow { font-size: .75rem; color: var(--muted); padding: 6px 0; }
.dt-day {
    aspect-ratio: 1;
    border: 0;
    border-radius: var(--pill);
    background: none;
    color: var(--ink);
    font: 500 .92rem/1 var(--font);
    cursor: pointer;
    max-height: 46px;
}
.dt-day.is-out { color: var(--muted); opacity: .45; }
.dt-day.is-today { box-shadow: inset 0 0 0 1.5px var(--line); }
.dt-day.is-sel { background: var(--gold); color: var(--on-gold); font-weight: 700; box-shadow: none; }
.dt-time { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: var(--s4); }
.dt-col { background: var(--surface-2); border-radius: var(--r); height: 168px; overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y mandatory; padding: 4px; }
.dt-col button {
    display: block;
    width: 100%;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--ink);
    font: 500 1rem/1 var(--font);
    scroll-snap-align: center;
    cursor: pointer;
}
.dt-col button.is-sel { background: var(--surface); font-weight: 700; box-shadow: inset 0 0 0 2px var(--gold); }
.dt-colon { font-weight: 700; font-size: 1.2rem; }
.dt-label { font-size: .8rem; color: var(--muted); margin-top: var(--s4); }

/* ---------- Admin ---------- */
.stat-line {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.stat { background: var(--surface); border-radius: var(--r); padding: var(--s3) var(--s4); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }

.vote-row { background: var(--surface); border-radius: var(--r); padding: var(--s4); display: grid; gap: 10px; }
.vote-row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.vote-row a.title { font-weight: 600; text-decoration: none; line-height: 1.35; }
.vote-row .meter { margin-top: 0; height: 6px; }
.vote-row-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: var(--s3); padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
    flex: none;
    border: 0;
    border-radius: var(--pill);
    padding: 8px 14px;
    background: var(--surface);
    color: var(--muted);
    font: 500 .85rem/1 var(--font);
    cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--pill); margin-bottom: var(--s4); }
.tabs button {
    flex: 1;
    border: 0;
    background: none;
    border-radius: var(--pill);
    padding: 10px 8px;
    color: var(--muted);
    font: 500 .88rem/1 var(--font);
    cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.manage { display: grid; gap: var(--s4); }
@media (min-width: 960px) {
    .tabs { display: none; }
    .manage { grid-template-columns: 1fr 1.2fr 1fr; align-items: start; }
    .manage [role="tabpanel"][hidden] { display: block !important; }
}

.people { display: grid; gap: 2px; max-height: 420px; overflow-y: auto; overscroll-behavior: contain; margin: 0 -8px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.person-name { flex: 1; min-width: 0; font-size: .92rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.opt-view { display: grid; gap: 6px; }
.opt-view div { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); font-weight: 500; }
.opt-view span { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tabla que se vuelve fichas en móvil */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8rem; padding: 0 12px 8px; }
.table td { padding: 12px; background: var(--surface); vertical-align: middle; }
.table tr td:first-child { border-radius: var(--r) 0 0 var(--r); }
.table tr td:last-child { border-radius: 0 var(--r) var(--r) 0; }
.table { border-spacing: 0 6px; border-collapse: separate; }
.td-name b { display: block; font-weight: 600; }
.td-name span { font-size: .8rem; color: var(--muted); }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn + .btn, .td-actions form { margin-left: 4px; }
.td-actions form { display: inline; }

@media (max-width: 760px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; }
    .table { border-spacing: 0; }
    .table tr { background: var(--surface); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
    .table td { padding: 0; background: none; border-radius: 0 !important; }
    .table td:not(.td-actions) { grid-column: 1; }
    .table td.td-actions { grid-column: 2; grid-row: 1 / span 3; align-self: center; display: flex; flex-direction: column; gap: 4px; }
    .table td.td-actions .btn + .btn, .table td.td-actions form { margin-left: 0; }
    .table td[data-label] { font-size: .82rem; color: var(--muted); }
    .table td[data-label]:empty { display: none; }
    .table td.td-hide-m { display: none; }
}

.search { position: relative; }
.search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.1rem; pointer-events: none; }
.search .input { padding-left: 42px; }

/* ---------- Ingreso ---------- */
.auth {
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr;
    background: var(--bar);
}

.auth-top {
    color: var(--on-bar);
    padding: calc(var(--safe-t) + var(--s6)) var(--s5) var(--s6);
    max-width: 460px;
    width: 100%;
    margin: 0 auto;
}

.auth-top img { width: 76px; height: 76px; }
.auth-top h1 { margin-top: var(--s5); font-size: 1.85rem; }
.auth-top p { margin-top: 6px; color: var(--on-bar-muted); max-width: 34ch; }

.auth-card {
    background: var(--bg);
    border-radius: 28px 28px 0 0;
    padding: var(--s6) var(--s5) calc(var(--s6) + var(--safe-b));
}

.auth-card form, .auth-card .auth-foot, .auth-card .note { max-width: 420px; margin-left: auto; margin-right: auto; }
.auth-card .note { margin-bottom: var(--s4); }
.auth-foot { margin-top: var(--s5); text-align: center; font-size: .8rem; color: var(--muted); }

@media (min-width: 720px) {
    .auth { grid-template-rows: 1fr; grid-template-columns: 1fr 1fr; }
    .auth-top { align-self: center; padding: var(--s7); }
    .auth-top img { width: 104px; height: 104px; }
    .auth-top h1 { font-size: 2.4rem; }
    .auth-card { border-radius: 0; display: flex; flex-direction: column; justify-content: center; padding: var(--s7); }
    .auth-card form, .auth-card .auth-foot, .auth-card .note { width: 100%; }
}

/* ---------- Página de error ---------- */
.error-page { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); text-align: center; }
.error-page img { width: 88px; height: 88px; margin: 0 auto var(--s5); }
.error-code { font-size: clamp(3.5rem, 12vw, 5.5rem); font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.error-page h1 { font-size: 1.4rem; margin-top: var(--s3); }
.error-page p { margin: 8px auto 0; color: var(--muted); max-width: 40ch; }
.error-page .btn { margin-top: var(--s5); }

@media (min-width: 900px) {
    .topnav { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Tema y extras de ingreso ---------- */
.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: var(--pill);
    background: rgba(255, 255, 255, .08);
    color: var(--on-bar);
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation;
}
.theme-btn .ph-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ph-sun { display: inline; }
:root[data-theme="dark"] .theme-btn .ph-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-btn .ph-sun { display: inline; }
    :root:not([data-theme="light"]) .theme-btn .ph-moon { display: none; }
}

.auth-brand { display: flex; align-items: center; justify-content: space-between; }
.auth-alt { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: var(--s3); max-width: 420px; margin-left: auto; margin-right: auto; }
.input-code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.input-code::placeholder { letter-spacing: .4em; }
.log { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .78rem; background: var(--surface-2); border-radius: var(--r-sm); padding: var(--s3); max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin-top: var(--s3); }

/* Formularios angostos: el contenido se alinea a la izquierda con la barra superior, no se centra aparte */
.page-narrow > * { max-width: var(--narrow-w, 760px); }
.topbar-in { position: relative; }
.menu { right: var(--s4); }
@media (min-width: 640px) { .grid-2 > .field + .field { margin-top: 0; } }

/* ---------- Actas ---------- */
.acta-layout { display: grid; gap: var(--s5); align-items: start; }
@media (min-width: 1000px) {
    .acta-layout { grid-template-columns: 300px 1fr; }
    .acta-side { position: sticky; top: 84px; }
}
.acta-side .btn-row { flex-wrap: wrap; }

/* La hoja es papel blanco también en tema oscuro: es el documento tal como se imprime */
.acta-paper {
    background: #ffffff;
    color: #1c1c20;
    color-scheme: light;
    border-radius: var(--r-lg);
    padding: 22px 18px 28px;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    overflow-wrap: anywhere;
}
@media (min-width: 640px) { .acta-paper { padding: 52px 56px 56px; } }
.acta-paper .acta { font-size: 15px; }
.acta-paper .acta .a-title { font-size: clamp(26px, 4vw, 31px); }
@media (max-width: 639px) {
    .acta-paper .acta .a-head tr { display: flex; flex-wrap: wrap; align-items: center; }
    .acta-paper .acta .a-head .a-club { flex: 1; }
    .acta-paper .acta .a-head .a-folio { flex-basis: 100%; width: auto; text-align: left; padding-top: 14px; }
    .acta-paper .acta .a-facts td, .acta-paper .acta .a-facts .a-facts-n { display: block; padding: 0 0 10px; width: auto; }
    .acta-paper .acta .a-result, .acta-paper .acta .a-table, .acta-paper .acta .a-part, .acta-paper .acta .a-note { margin-left: 0; }
    .acta-paper .acta .a-sec .a-table { width: 100%; }
    .acta-paper .acta .a-signs td { display: block; width: auto; padding: 0 0 22px; }
    .acta-paper .acta .a-audit table, .acta-paper .acta .a-audit tbody, .acta-paper .acta .a-audit tr, .acta-paper .acta .a-audit td { display: block; border: 0; }
    .acta-paper .acta .a-audit thead { display: none; }
    .acta-paper .acta .a-audit tr { padding: 6px 0; }
    .acta-paper .acta .a-verify td { display: table-cell; }
}

.acta-picks { display: grid; gap: 6px; }
.acta-pick { background: var(--surface-2); border-radius: var(--r); padding: 12px 14px; }
.acta-pick:has(input:checked) { background: var(--gold-soft); }
.acta-pick-note { display: none; margin-top: 12px; padding-left: 36px; }
.acta-pick:has(input:checked) .acta-pick-note { display: block; }
.acta-pick-note .input { background: var(--surface); }

.acta-signers { display: grid; gap: var(--s4); }
.acta-signer { border: 0; margin: 0; padding: 0; display: grid; gap: 0 12px; }
.acta-signers { gap: var(--s5); }
.acta-signer .field + .field { margin-top: 10px; }
@media (min-width: 640px) {
    .acta-signer { grid-template-columns: 1fr 1.3fr 1.5fr; }
    .acta-signer .field + .field { margin-top: 0; }
}

.signer-list { display: grid; gap: 2px; margin: 16px -8px 0; }
.signer-row { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; }
.signer-who { flex: 1; min-width: 0; font-size: .9rem; line-height: 1.3; }
.signer-who b { font-weight: 500; display: block; }
.signer-who .pick-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sign-panel { max-width: 820px; margin: var(--s5) auto 0; }
.sign-pad {
    position: relative;
    height: 200px;
    background: #ffffff;
    border-radius: var(--r);
    box-shadow: inset 0 0 0 1px var(--line);
    touch-action: none;
}
.sign-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; border-radius: inherit; }
.sign-pad-line { position: absolute; left: 24px; right: 24px; bottom: 48px; height: 1px; background: #c9c9c2; pointer-events: none; }
.sign-pad-hint {
    position: absolute; left: 24px; bottom: 56px;
    font-size: .85rem; color: #9a9aa2; pointer-events: none;
    transition: opacity .2s var(--ease);
}
.sign-pad.has-ink .sign-pad-hint { opacity: 0; }
.sign-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }

.sign-modes { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.sign-modes span { flex-direction: row; justify-content: center; gap: 8px; }
.sign-modes span i { font-size: 1.15rem; }
.sign-drop {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; padding: 20px;
    background: var(--surface-2); border-radius: var(--r);
    cursor: pointer; text-align: center;
    transition: background .15s var(--ease);
}
.sign-drop:hover { background: var(--gold-soft); }
#sign-photo:focus-visible + .sign-drop { outline: 2px solid var(--focus); outline-offset: 2px; }
.sign-drop-empty { display: grid; justify-items: center; gap: 6px; max-width: 42ch; }
.sign-drop-empty i { font-size: 2rem; color: var(--muted); }
.sign-drop-empty b { font-weight: 600; }
.sign-drop-empty span { font-size: .85rem; color: var(--muted); }
.sign-drop.has-photo { background: #ffffff; box-shadow: inset 0 0 0 1px var(--line); }
.sign-drop.has-photo .sign-drop-empty { display: none; }
.sign-drop img { width: 100%; max-width: 600px; height: auto; display: block; }
.sign-drop.is-busy { opacity: .6; pointer-events: none; }

/* ---------- Verificar acta ---------- */
.verify-result { background: var(--surface); border-radius: var(--r-lg); padding: 22px; margin-bottom: var(--s5); }
.verify-head { display: flex; gap: 14px; align-items: flex-start; }
.verify-head > i { font-size: 2.1rem; line-height: 1; flex: none; }
.verify-ok .verify-head > i { color: var(--ok); }
.verify-warn .verify-head > i { color: var(--warn); }
.verify-bad .verify-head > i { color: var(--bad); }
.verify-head h2 { font-size: 1.15rem; }
.verify-head p { margin-top: 4px; color: var(--muted); font-size: .92rem; }
.verify-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 20px 0 0; padding: 16px; background: var(--surface-2); border-radius: var(--r); }
.verify-facts dt { font-size: .78rem; color: var(--muted); }
.verify-facts dd { margin: 2px 0 0; font-weight: 500; font-size: .92rem; }
.verify-facts .verify-wide { grid-column: 1 / -1; }
.verify-result h3 { font-size: .95rem; margin: 20px 0 8px; }
.verify-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.verify-list li { display: grid; gap: 2px; font-size: .92rem; }
.verify-list li span { color: var(--muted); }
.verify-code { font-variant-numeric: tabular-nums; letter-spacing: .04em; text-transform: uppercase; }
.file-pick {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-radius: var(--r);
    background: var(--surface-2); cursor: pointer; font-weight: 500;
    overflow-wrap: anywhere;
}
.file-pick i { font-size: 1.4rem; color: var(--muted); }
.file-pick:hover { background: var(--gold-soft); }
#pdf:focus-visible + .file-pick { outline: 2px solid var(--focus); outline-offset: 2px; }
