:root {
  font: 16px/1.55 system-ui, sans-serif;
  color-scheme: light;
  color: var(--ink);
  background: var(--page);
  --ink: #24252b;
  --page: #f7f5f6;
  --header: #421320;
  --accent-text: #681a2b;
  --accent-soft: #f8e1e7;
  --accent: #9d233b;
  --line: #e2dce0;
  --muted: #555862;
  --header-edge: #be4258;
  --header-ink: #fff;
  --mark-bg: #f7dee4;
  --mode-ink: #efd4dc;
  --surface: #fff;
  --hero-end: #fbebef;
  --heading: #421320;
  --accent-pressed: #421320;
  --accent-hover: #681a2b;
  --focus: #9d233b;
  --tab-border: #cdb7be;
  --control-border: #cbc2c8;
  --group-bg: #f5edf0;
  --group-ink: #542233;
  --primary-ink: #7b1b30;
  --backup-ink: #614619;
  --backup-bg: #f5ecd8;
  --track: #f8f5f6;
  --backup-stripe-a: #a16e24;
  --backup-stripe-b: #82551a;
  --error: #952638;
  --danger-ink: #a32533;
  --danger-bg: #fff0f1;
  --overlay: #4213209c;
  --shadow: #40172312;
}
:root[data-theme="light"] {
  --page: #f3f6fa;
  --surface: #fff;
  --ink: #182537;
  --header: #fff;
  --header-ink: #172c4a;
  --header-edge: #cfdaea;
  --mode-ink: #405777;
  --mark-bg: #e2ecfb;
  --accent: #25569b;
  --accent-text: #1c467f;
  --accent-soft: #e7effc;
  --accent-hover: #1c467f;
  --accent-pressed: #163762;
  --focus: #25569b;
  --heading: #172c4a;
  --muted: #46586f;
  --line: #d8e1ee;
  --control-border: #aebdd1;
  --tab-border: #aebdd1;
  --hero-end: #edf4ff;
  --group-bg: #edf2f9;
  --group-ink: #294466;
  --primary-ink: #1c467f;
  --track: #f3f6fb;
  --overlay: #172c4a9c;
  --shadow: #172c4a12;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101722;
  --surface: #1a2433;
  --ink: #eef3fb;
  --header: #0c131e;
  --header-ink: #f1f5fc;
  --header-edge: #486a9b;
  --mode-ink: #c5d5eb;
  --mark-bg: #233f61;
  --accent: #3763a4;
  --accent-text: #bdd8fb;
  --accent-soft: #243b58;
  --accent-hover: #285186;
  --accent-pressed: #203f69;
  --focus: #9ac7ff;
  --heading: #f3f7ff;
  --muted: #b2bfd2;
  --line: #37475d;
  --control-border: #62768f;
  --tab-border: #62768f;
  --hero-end: #22354f;
  --group-bg: #233247;
  --group-ink: #d5e4f9;
  --primary-ink: #cbe2ff;
  --backup-ink: #ffe1a2;
  --backup-bg: #49371b;
  --track: #141d2b;
  --backup-stripe-a: #bd8836;
  --backup-stripe-b: #906124;
  --overlay: #02060ccc;
  --shadow: #0004;
  --error: #ffadb9;
  --danger-ink: #ffc1ca;
  --danger-bg: #502633;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.topbar { min-height: 66px; padding: 12px max(5vw, 20px); display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--header); color: var(--header-ink); border-bottom: 3px solid var(--header-edge); }
.theme-picker { min-width: 112px; }
.theme-picker select { color: var(--ink); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.brand, .account { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 1.1rem; font-weight: 750; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--mark-bg); color: var(--accent-text); }
#mode { color: var(--mode-ink); font-size: .875rem; }
main { width: min(1200px, 92vw); margin: 0 auto; padding: 36px 0 64px; }
.intro { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 18px; margin-bottom: 25px; padding: clamp(18px, 4vw, 36px);
  background: linear-gradient(112deg, var(--surface) 45%, var(--hero-end));
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 13px;
}
.eyebrow { color: var(--accent-text); font-size: .875rem; font-weight: 800; letter-spacing: .11em; }
h1 { color: var(--heading); overflow-wrap: anywhere; font-size: clamp(2rem, 5vw, 3.25rem); margin: 4px 0 0; letter-spacing: -.045em; line-height: 1.15; }
h2 { margin: 0 0 18px; line-height: 1.2; }
p { color: var(--muted); }
.intro p { margin: 7px 0 0; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: white; font-weight: 700; padding: 8px 15px; cursor: pointer; }
button:hover { filter: brightness(.9); }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.danger { color: var(--danger-ink); background: var(--danger-bg); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(145px, 100%), 1fr)); gap: 12px; margin-bottom: 22px; }
.stat, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.stat { padding: 12px 17px; color: var(--muted); box-shadow: 0 2px 6px var(--shadow); }
.stat strong { display: block; font-size: 1.8rem; color: var(--accent-text); line-height: 1.2; font-variant-numeric: tabular-nums; }
#tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab {
  min-height: 44px;
  padding: 9px 14px;
  border-color: var(--tab-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: 0 1px 2px var(--shadow);
}
.tab[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.tab:hover { filter: none; }
@media (hover: hover) {
  .tab:hover { background: var(--accent-soft); border-color: var(--accent); }
  .tab[aria-current="page"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
}
.tab:active, .tab[aria-current="page"]:active {
  background: var(--accent-pressed);
  border-color: var(--accent-pressed);
  color: white;
}
.tab:focus-visible { outline-color: var(--focus); outline-offset: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; padding: 15px; }
.filters label { flex: 1 1 145px; }
label { display: grid; gap: 4px; font-size: .875rem; font-weight: 700; min-width: 0; }
input, select, textarea { color: inherit; border: 1px solid var(--control-border); border-radius: 7px; padding: 8px 10px; background: var(--surface); min-width: 0; width: 100%; }
input::placeholder, textarea::placeholder { color: var(--muted); }
select { appearance: none; padding-right: 30px; background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 16px center / 5px 5px no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 11px center / 5px 5px no-repeat, var(--surface); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 11px 14px; border-block: 1px solid var(--line); vertical-align: middle; }
th { color: var(--group-ink); font-size: .875rem; background: var(--group-bg); white-space: nowrap; }
td:first-child { font-weight: 700; }
td:last-child { text-align: right; }
td[colspan] { text-align: center; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; color: var(--primary-ink); background: var(--accent-soft); font-size: .875rem; white-space: nowrap; }
.tag.backup { color: var(--backup-ink); background: var(--backup-bg); }
.table-footer { margin: 9px 15px; font-size: .875rem; }
.login { max-width: 460px; margin: 28px auto; padding: 24px; }
.login h1 { font-size: 2rem; }
.login form, #fields { display: grid; gap: 10px; }
.login button { margin-top: 8px; }
dialog { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 14px; width: min(94vw, 550px); max-height: 94vh; padding: 23px; }
dialog::backdrop { background: var(--overlay); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: end; }
.actions span { flex: 1; }
#form-status, #status { color: var(--error); }
#form-status:empty { margin: 14px 0; }
#status:empty { display: none; }
.scope-option { display: flex; align-items: center; margin: 7px 0; gap: 8px; }
.scope-option input { width: 18px; height: 18px; margin: 0; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 8px; }

.page-actions, .timeline-legend { display: flex; flex-wrap: wrap; gap: 8px; }
#election-picker { max-width: 480px; margin-bottom: 18px; }
#day-schedule { border-top: 1px solid var(--line); padding: 16px 15px 20px; }
#day-heading { margin: 0 0 8px; font-size: 1.2rem; }
.timeline-legend { margin-bottom: 10px; }
.timeline-scroll { overflow-x: auto; }
.timeline-chart { min-width: 690px; --labels: 180px; }
.timeline-row { display: grid; grid-template-columns: var(--labels) minmax(0, 1fr); align-items: stretch; gap: 14px; }
.timeline-axis { position: relative; height: 28px; }
.timeline-tick { position: absolute; transform: translateX(-50%); font-size: .8rem; color: var(--muted); white-space: nowrap; }
.timeline-tick:first-child { transform: none; }
.timeline-tick:last-child { transform: translateX(-100%); }
.timeline-group { margin: 10px 0 0; padding: 6px 8px; border-radius: 6px; background: var(--group-bg); color: var(--group-ink); font-size: .95rem; }
.timeline-label { padding: 4px 0; line-height: 1.3; font-size: .875rem; }
.timeline-label small { display: block; color: var(--muted); }
.timeline-track { position: relative; margin-block: 3px; min-height: 27px; border-inline: 1px solid var(--line); background-color: var(--track); background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); }
.timeline-bar { position: absolute; top: 2px; bottom: 2px; min-width: 2px; border-radius: 5px; background: var(--accent); }
.timeline-bar.backup { background: repeating-linear-gradient(135deg, var(--backup-stripe-a) 0 5px, var(--backup-stripe-b) 5px 10px); }
.timeline-label .tag { margin-inline-start: 4px; font-size: .75rem; }
@media (max-width: 630px) {
  .topbar { flex-wrap: wrap; }
  .account { flex-wrap: wrap; }
  .timeline-chart { --labels: 148px; }
}
#print-info { display: none; }
@media print {
  @page { margin: 12mm; size: landscape; }
  :root { color: #000; background: white; font-size: 11pt; color-scheme: light !important; }
  main { width: 100%; padding: 0; }
  .topbar, .intro, .stats, nav, .filters, #day-schedule, #election-picker, #status, #users-help, dialog, th:last-child, td:last-child:not([colspan]) { display: none !important; }
  #print-info { display: block; margin-bottom: 10px; }
  #print-info h2 { margin: 0; }
  #print-info p { margin: 4px 0; color: #333; }
  .panel { border: 0; background: white; }
  .table-wrap { overflow: visible; }
  tr { break-inside: avoid; }
  th, td { padding: 5px 7px; white-space: normal; color: black; }
  th { background: white; }
  .tag { background: transparent; color: black !important; padding-inline: 0; }
}
.candidate { display: grid; grid-template-columns: minmax(0, 2fr) minmax(65px, 1fr) auto; gap: 8px; align-items: end; margin: 8px 0; }
td:last-child > button + button { margin-inline-start: 4px; }
