/* EGU SRC Voting — single stylesheet */
:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --ink: #15181a;
  --ink-2: #4b5157;
  --ink-3: #7c838a;
  --line: #e2e5e0;
  --brand: #1b2a6b;
  --brand-ink: #ffffff;
  --brand-soft: #e8ecf8;
  --gold: #f3c33c;
  --ok: #0f7a3d;   --ok-bg: #e6f4ea;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --err: #b42318;  --err-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,20,.05), 0 4px 16px rgba(16,24,20,.06);
  /* categorical series (validated order) */
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100;
  --s5:#e87ba4; --s6:#008300; --s7:#6250d6; --s8:#e34948;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.text-center { text-align: center; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.narrow { width: 100%; max-width: 440px; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }

/* forms */
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--ink); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #cfd4cd; border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--brand) 25%, transparent); border-color: var(--brand); }
input[type=file] { padding: 8px; background: var(--surface-2); }
.big-input { font-size: 1.35rem; letter-spacing: .06em; text-transform: uppercase; padding: 14px 16px; font-weight: 600; }
.big-input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form label { flex: 1 1 160px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #121d4f; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #8f1c13; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-lg { padding: 14px 20px; font-size: 1.05rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--err); font: inherit; font-size: .85rem; cursor: pointer; padding: 0; text-decoration: underline; }

/* alerts & pills */
.alert { padding: 12px 14px; border-radius: 8px; margin: 0 0 14px; font-size: .95rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cb; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f1dca8; }
.alert-err { background: var(--err-bg); color: var(--err); border-color: #f5c2bd; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; padding: 6px 12px; border-radius: 999px; margin: 6px 0 16px; }
.status-pill.open { background: var(--ok-bg); color: var(--ok); }
.status-pill.closed { background: #eceeea; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eceeea; color: var(--ink-2); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-lead { background: #fff4d6; color: #7a5600; }

/* voter */
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.brand-mark { width: 52px; height: 52px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .04em; flex: none; box-shadow: inset 0 -3px 0 var(--gold); }
.fineprint { color: var(--ink-2); font-size: .85rem; padding-left: 18px; margin: 18px 0 0; }
.fineprint li + li { margin-top: 4px; }
.ballot-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 0; position: sticky; top: 0; z-index: 5; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-2); }
.ballot { padding-top: 20px; padding-bottom: 110px; max-width: 760px; }
fieldset.position { border: 1px solid var(--line); margin: 0 0 16px; }
fieldset.position legend { font-weight: 700; font-size: 1.1rem; padding: 0 6px; display: flex; gap: 10px; align-items: center; }
.pos-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: .85rem; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.choice { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; background: var(--surface); transition: border-color .15s, background .15s; }
.choice:hover { border-color: #b9c2bb; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 30%, transparent); }
.choice-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c3cac4; flex: none; }
.choice:has(input:checked) .tick { border-color: var(--brand); background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/14px no-repeat; }
.avatar { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar-initials { display: grid; place-items: center; font-weight: 700; color: var(--brand); background: var(--brand-soft); }
.avatar-sm { width: 36px; height: 36px; border-radius: 8px; font-size: .8rem; }
.submit-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; justify-content: center; gap: 10px; box-shadow: 0 -4px 16px rgba(0,0,0,.05); }
.dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(10,20,15,.45); }
.summary { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; gap: 8px; }
.summary li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.big-check { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 2.2rem; display: grid; place-items: center; margin: 0 auto 12px; font-weight: 800; }

/* admin */
.admin-bar { background: #111a45; color: #e8ebf5; }
.admin-bar .wrap { display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.admin-bar .logo { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.admin-bar .logo span { background: var(--gold); color: #111a45; font-size: .7rem; padding: 2px 6px; border-radius: 4px; }
.admin-bar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.admin-bar nav a { color: #c6cce4; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 600; font-size: .92rem; }
.admin-bar nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.admin-bar nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.admin-bar .who { font-size: .85rem; color: #a3aacb; }
.admin-bar .who a { color: #e8ebf5; }
.admin-main { padding: 22px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 4px; }
.kpi .sub { font-size: .8rem; color: var(--ink-3); }

.meter { height: 10px; background: #e9ece7; border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; width: 0; transition: width .8s cubic-bezier(.2,.7,.2,1); }

.race { display: flex; flex-direction: column; gap: 12px; }
.racer { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; transition: transform .4s; }
.racer .nm { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.racer .nums { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.racer .nums small { display: block; font-weight: 500; color: var(--ink-3); font-size: .78rem; }
.racer .bar { grid-column: 2 / 4; height: 14px; background: #eef0ec; border-radius: 4px; overflow: hidden; margin-top: -4px; }
.racer .bar > i { display: block; height: 100%; width: 0; border-radius: 0 4px 4px 0; transition: width .8s cubic-bezier(.2,.7,.2,1); }
.racer.leader .nm { color: var(--ink); }
.pos-card h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.pos-card h3 small { color: var(--ink-3); font-weight: 500; font-size: .8rem; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--ok); }
.live.stale { color: var(--err); }
.chart-box { position: relative; height: 240px; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; background: var(--surface-2); }
tbody tr:hover { background: #fafbf8; }
.table-wrap { overflow-x: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.pager { display: flex; gap: 6px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.feed li:last-child { border: 0; }
.cand-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cand-row:last-child { border-bottom: 0; }
details.edit > summary { cursor: pointer; color: var(--brand); font-size: .85rem; font-weight: 600; list-style: none; }
details.edit[open] { flex-basis: 100%; }
details.edit form { margin-top: 10px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.danger-zone { border-color: #f5c2bd; }

@media (max-width: 560px) {
  .kpi .value { font-size: 1.6rem; }
  .big-input { font-size: 1.15rem; }
  .card { padding: 16px; }
}
@media print {
  .admin-bar, .no-print, .submit-bar { display: none !important; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}

/* logo header (voter pages) */
.logo-head { text-align: center; margin-bottom: 18px; }
.logo-head img { display: block; max-width: 260px; max-height: 96px; width: auto; height: auto; margin: 0 auto 16px; }
.logo-head h1 { font-size: 1.45rem; }
.logo-head .status-pill { margin: 10px 0 0; }
.logo-preview { background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; padding: 16px; text-align: center; }
.logo-preview img { max-width: 240px; max-height: 90px; }
.admin-bar .logo img { height: 32px; max-width: 160px; object-fit: contain; width: auto; background: #fff; border-radius: 4px; padding: 3px 6px; }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* roles & accounts */
.admin-bar .logo .role-tag { white-space: nowrap; }
.admin-bar .logo .role-admin { background: #a9c4ff; color: #111a45; }
.admin-bar .logo .role-ec { background: #9be3b8; color: #0b3b22; }
.role-badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.role-badge.superadmin { background: #fff1c7; color: #6b4b00; }
.role-badge.admin { background: #e3ebff; color: #1b2a6b; }
.role-badge.ec { background: #dff5e7; color: #0f5a32; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.yes { color: var(--ok); font-weight: 700; }
.no { color: #b9bfc4; }
.audit-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe3cb; }
.audit-bad { background: var(--err-bg); color: var(--err); border: 1px solid #f5c2bd; }
.audit-banner { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .95rem; }
.act { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; font-weight: 600; }
.act-danger { color: var(--err); }
.act-warn { color: var(--warn); }
.temp-pass { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.2rem; font-weight: 700; letter-spacing: .05em; background: #fff; border: 1px dashed #bfe3cb; padding: 8px 12px; border-radius: 6px; display: inline-block; margin: 6px 0; user-select: all; }
