:root {
    color-scheme: light;
    --paper: #f7f7f5;
    --white: #fff;
    --ink: #151515;
    --muted: #585854;
    --line: #deded9;
    --soft: #eeeee9;
    --mono: 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}
p, h1, h2, dl, dd { margin: 0; }
[hidden], .js-only:not(.enhanced) { display: none !important; }
.frame { width: min(100% - 80px, 1080px); margin-inline: auto; }

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 40px; min-height: 68px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 680; white-space: nowrap; text-decoration: none; }
.brand-mark { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 26px; height: 26px; padding-bottom: 6px; background: var(--ink); border-radius: 4px; }
.brand-mark i { display: block; width: 3px; height: 5px; background: var(--white); }
.brand-mark i:nth-child(2) { height: 9px; }
.brand-mark i:nth-child(3) { height: 13px; }
.header-inner nav { display: flex; align-self: stretch; gap: 27px; }
.header-inner nav a { display: flex; align-items: center; position: relative; color: var(--muted); text-decoration: none; }
.header-inner nav a[aria-current] { color: var(--ink); font-weight: 650; }
.header-inner nav a[aria-current]::after { position: absolute; bottom: -1px; inset-inline: 0; height: 2px; background: var(--ink); content: ''; }
.header-inner nav a:hover, .header-link:hover, .back-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.sign-out { display: flex; align-items: center; }
.sign-out button { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.sign-out button:hover { text-decoration: underline; text-underline-offset: 4px; }
.header-link { margin-left: auto; white-space: nowrap; font-size: .9rem; font-weight: 600; text-decoration: none; }

.workspace { padding-block: 60px 72px; }
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 38px; }
.page-intro h1 { font-size: clamp(3rem, 7vw, 5rem); font-weight: 730; letter-spacing: -.05em; line-height: 1; }
.page-intro p:not(.live-status) { max-width: 55ch; margin-top: 14px; color: var(--muted); line-height: 1.5; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(102px, 1fr)); align-self: flex-end; border-top: 2px solid var(--ink); }
.metrics div { padding: 10px 16px 0; }
.metrics div + div { border-left: 1px solid var(--line); }
.metrics dt { color: var(--muted); font-size: .875rem; }
.metrics dd { padding-top: 2px; font-size: 2rem; font-weight: 650; line-height: 1.18; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(258px, 306px); gap: 22px; align-items: start; }
.sheet { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 9px; }
.sheet h2 { font-size: 1.14rem; font-weight: 680; letter-spacing: -.025em; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 64px; padding: 12px 24px; }
.form-sheet { padding: 22px 24px 24px; }
.form-sheet h2 { margin-bottom: 22px; }
.form-sheet label { display: block; margin-bottom: 8px; font-size: .9rem; font-weight: 600; }
input:not([type=hidden]) {
    width: 100%; min-width: 0; height: 45px; padding: 9px 12px;
    color: var(--ink); background: var(--white); border: 1px solid #a9a9a3; border-radius: 5px;
}
.form-error { margin-top: 8px; color: #9e2525; font-size: .9rem; line-height: 1.45; }
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 8px 15px; border: 1px solid transparent; border-radius: 5px;
    text-align: center; text-decoration: none; font-size: .9rem; font-weight: 650; line-height: 1.25;
}
.button.primary { background: var(--ink); color: var(--white); }
.button.primary:hover { background: #3a3a38; }
.button.secondary { background: var(--white); border-color: #bebeb7; color: var(--ink); }
.button.secondary:hover { background: var(--soft); border-color: #9b9b96; }
.button.compact { min-height: 37px; padding: 6px 11px; white-space: nowrap; }
.button.full { width: 100%; }
.form-sheet .button { margin-top: 16px; }
.login-workspace { max-width: 420px; }
.login-workspace h1 { margin-bottom: 22px; }
.login-workspace label:not(:first-of-type) { margin-top: 16px; }
.empty { display: grid; place-content: center; min-height: 172px; padding: 28px 20px; border-top: 1px solid var(--line); text-align: center; }
.empty p { color: var(--muted); line-height: 1.45; }
.empty .empty-title { margin-bottom: 5px; color: var(--ink); font-weight: 650; }

table { width: 100%; border-spacing: 0; text-align: left; }
thead th { font-size: .875rem; color: var(--muted); font-weight: 650; background: var(--paper); }
.team-table th, .team-table td { padding: 13px 14px; border-top: 1px solid var(--line); }
.team-table th:first-child { padding-left: 24px; }
.team-table td:last-child, .team-table th:last-child { width: 1%; padding-right: 24px; }
.team-name { font-weight: 650; overflow-wrap: anywhere; }
.identifier { display: block; margin-top: 3px; color: var(--muted); font: .8rem/1.45 var(--mono); overflow-wrap: anywhere; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.row-action { text-align: right; }

.back-link { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: .9rem; font-weight: 650; text-decoration: none; }
.qr-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.qr-controls { padding: 30px; }
.qr-controls h1 { font-size: 2.35rem; letter-spacing: -.04em; }
.details { margin-block: 22px; }
.details div { display: grid; gap: 5px; padding-block: 13px; border-top: 1px solid var(--line); }
.details dt { font-size: .84rem; font-weight: 640; color: var(--muted); }
.details dd { overflow-wrap: anywhere; }
.details .identifier { margin: 0; }
.short-url { font-size: .875rem; text-underline-offset: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted, .action-status { margin-top: 16px; color: var(--muted); line-height: 1.5; font-size: .875rem; }
.action-status:empty { display: none; }
.qr-poster { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 28px; }
.poster-brand { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 680; }
.poster-title { max-width: 100%; margin-top: 9px; font-size: clamp(1.7rem, 4vw, 2.45rem); font-weight: 735; letter-spacing: -.055em; line-height: 1.12; overflow-wrap: anywhere; }
.qr-poster img { display: block; width: min(100%, 272px); height: auto; margin-block: 4px; image-rendering: pixelated; }
.poster-instruction { font-size: 1.12rem; font-weight: 650; }
.poster-id { margin-top: 6px; }

.ballot-wrap { width: min(100% - 40px, 496px); margin: 68px auto; }
.ballot-sheet { padding: 35px; }
.ballot-sheet h1 { font-size: clamp(2rem, 8vw, 3.2rem); letter-spacing: -.045em; line-height: 1.05; overflow-wrap: anywhere; }
.ballot-label { margin-bottom: 10px; color: var(--muted); font-size: .95rem; font-weight: 640; }
.ballot-sheet > h1 + p { margin-top: 14px; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.ballot-sheet form { padding-top: 26px; margin-top: 25px; border-top: 1px solid var(--line); }
.ballot-sheet .button { margin-top: 20px; min-height: 47px; }
.ballot-sheet form .button { margin-top: 0; }
.ballot-note { margin-top: 15px; color: var(--muted); font-size: .875rem; line-height: 1.45; text-align: center; }
.success-mark { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 16px; background: var(--ink); color: white; border-radius: 50%; }

.ranking-workspace { width: min(100% - 80px, 900px); }
.live-status { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: .875rem; font-weight: 650; color: var(--muted); }
.live-status span:first-child { width: 7px; height: 7px; background: var(--ink); border: 1px solid var(--ink); border-radius: 50%; }
.live-status.offline span:first-child { background: transparent; }
.ranking-sheet { overflow: hidden; }
.ranking-table th, .ranking-table td { padding: 18px 22px; }
.ranking-table thead th { background: var(--white); }
.ranking-table tbody tr > * { border-top: 1px solid var(--line); }
.ranking-table td:first-child, .ranking-table th:first-child { width: 16%; }
.ranking-table td:last-child, .ranking-table th:last-child { width: 18%; }
.ranking-table .rank, .ranking-table .number { font-variant-numeric: tabular-nums; }
.ranking-table .rank { font-family: var(--mono); }
.ranking-table .leader { background: var(--soft); }
.ranking-table .leader .rank, .ranking-table .leader .number { font-weight: 700; }
.ranking-sheet .empty { border-top: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px) {
    .frame { width: calc(100% - 36px); }
    .workspace { padding-block: 38px 50px; }
    .admin-grid, .qr-layout { grid-template-columns: 1fr; }
    .admin-grid .form-sheet { grid-row: 1; }
    .page-intro { margin-bottom: 26px; align-items: flex-start; flex-direction: column; gap: 21px; }
    .metrics { align-self: flex-start; }
    .metrics div:first-child { padding-left: 0; }
}

@media (max-width: 540px) {
    .header-inner { gap: 12px 18px; min-height: 58px; }
    .admin .header-inner { display: grid; grid-template-columns: 1fr auto; padding-top: 14px; }
    .admin .header-inner nav { grid-row: 2; grid-column: 1 / -1; height: 38px; gap: 22px; }
    .admin .header-link { grid-row: 1; grid-column: 2; }
    .sheet-heading { padding-inline: 16px; }
    .team-table th, .team-table td { padding: 11px 8px; }
    .team-table th:first-child { padding-left: 16px; }
    .team-table td:last-child, .team-table th:last-child { padding-right: 16px; }
    .ballot-wrap { margin-block: 30px; }
    .ballot-sheet { padding: 25px 22px; }
    .ranking-table th, .ranking-table td { padding: 15px 13px; }
}

@media print {
    :root, body { background: #fff; color: #000; }
    .no-print { display: none !important; }
    .frame, .qr-layout { display: block; width: 100%; padding: 0; margin: 0; }
    .qr-poster { border: 0; }
    .qr-poster { padding-block: 30mm; }
    .qr-poster img { width: 90mm; }
}
