/* fastVote operator UI.
   Calm, system-native look: neutral surfaces, one accent colour, generous
   spacing. Readability wins over decoration — every colour pair below
   meets WCAG AA for body text, and status is always paired with a label. */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
    "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter",
    "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --fill: #ececf0;          /* secondary button / hover fill */
  --fill-strong: #e1e1e6;
  --fg: #1d1d1f;
  --fg-secondary: #424245;
  --muted: #6e6e73;
  --separator: #e3e3e8;
  --border: #d2d2d7;
  --header-bg: rgba(251, 251, 253, 0.8);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-fg: #ffffff;
  --link: #0066cc;
  --focus: rgba(0, 113, 227, 0.4);

  /* Semantic colours: strong = text/icon, tint = background wash. */
  --green: #1d7a35;   --green-tint: #e3f4e7;
  --red: #c4161c;     --red-tint: #fdeaea;
  --orange: #a44a00;  --orange-tint: #fdf0e1;
  --purple: #7d3aa8;  --purple-tint: #f3eaf9;
  --blue: #0060c0;    --blue-tint: #e6f0fc;
  --gray: #5a5a60;    --gray-tint: #ededf0;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.05), 0 12px 40px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-raised: #2c2c2e;
    --fill: #2c2c2e;
    --fill-strong: #3a3a3c;
    --fg: #f5f5f7;
    --fg-secondary: #d1d1d6;
    --muted: #a1a1a6;
    --separator: #2e2e31;
    --border: #3a3a3c;
    --header-bg: rgba(22, 22, 23, 0.8);

    --accent: #0a84ff;
    --accent-hover: #409cff;
    --link: #4aa3ff;
    --focus: rgba(10, 132, 255, 0.55);

    --green: #4cd964;   --green-tint: rgba(48, 209, 88, 0.16);
    --red: #ff6961;     --red-tint: rgba(255, 69, 58, 0.16);
    --orange: #ffb340;  --orange-tint: rgba(255, 159, 10, 0.16);
    --purple: #da8fff;  --purple-tint: rgba(191, 90, 242, 0.18);
    --blue: #64b5ff;    --blue-tint: rgba(10, 132, 255, 0.18);
    --gray: #c7c7cc;    --gray-tint: rgba(142, 142, 147, 0.2);

    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 12px 40px rgba(0, 0, 0, 0.5);
  }
}

/* Explicit choice from the theme switch (static/theme.js) overrides the OS
   preference. Keep these values in sync with the media-query block above. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-raised: #2c2c2e;
  --fill: #2c2c2e;
  --fill-strong: #3a3a3c;
  --fg: #f5f5f7;
  --fg-secondary: #d1d1d6;
  --muted: #a1a1a6;
  --separator: #2e2e31;
  --border: #3a3a3c;
  --header-bg: rgba(22, 22, 23, 0.8);

  --accent: #0a84ff;
  --accent-hover: #409cff;
  --link: #4aa3ff;
  --focus: rgba(10, 132, 255, 0.55);

  --green: #4cd964;   --green-tint: rgba(48, 209, 88, 0.16);
  --red: #ff6961;     --red-tint: rgba(255, 69, 58, 0.16);
  --orange: #ffb340;  --orange-tint: rgba(255, 159, 10, 0.16);
  --purple: #da8fff;  --purple-tint: rgba(191, 90, 242, 0.18);
  --blue: #64b5ff;    --blue-tint: rgba(10, 132, 255, 0.18);
  --gray: #c7c7cc;    --gray-tint: rgba(142, 142, 147, 0.2);

  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--fg);
  line-height: 1.2;
  margin: 0 0 0.75rem;
}
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.022em; }
h2 { font-size: 1.375rem; font-weight: 650; letter-spacing: -0.016em; }
h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

hr, .divider {
  border: none;
  border-top: 1px solid var(--separator);
  margin: 1rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--fill);
  color: var(--fg);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}

::selection { background: var(--focus); }

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 max(1.25rem, env(safe-area-inset-left));
  min-height: 3.25rem;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: var(--fg);
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 7px;
  background: linear-gradient(180deg, #1a8cff 0%, #0066d6 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}
.brand-event {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-weight: 400;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a,
.topnav .nav-button {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--fg-secondary);
  font: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.topnav a:hover,
.topnav .nav-button:hover { background: var(--fill); color: var(--fg); text-decoration: none; }
.topnav a[aria-current="page"] { background: var(--fg); color: var(--bg); font-weight: 550; }
.topnav form { display: contents; }
.topnav .theme-toggle { gap: 0.35rem; }
.theme-toggle .theme-icon { width: 1rem; height: 1rem; flex: none; }
.theme-toggle .theme-icon[hidden] { display: none; }
.topnav .nav-sep {
  width: 1px;
  height: 1.25rem;
  margin: 0 0.35rem;
  background: var(--separator);
  flex: none;
}

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding-top: 0.5rem; padding-bottom: 0.35rem; gap: 0.35rem; }
  .topnav { margin-left: -0.5rem; width: calc(100% + 0.5rem); }
  .brand-event { max-width: 55vw; }
}

/* ---------------------------------------------------------------- layout */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
.page-head { margin: 0.25rem 0 1.5rem; }
.page-head h1 { margin-bottom: 0.25rem; }
.page-head p { color: var(--muted); font-size: 1.0625rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.625rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card > h2:first-child,
.card > h3:first-child { margin-top: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.card-head h2, .card-head h3 { margin: 0; }
.card.tone-danger { box-shadow: var(--shadow), inset 0 0 0 1px var(--orange); }
.card.tone-danger h2 { color: var(--orange); }
.card.tone-success { background: var(--green-tint); box-shadow: none; }

.grid { display: grid; gap: 1.25rem; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.two > .card { margin-bottom: 0; }
.grid + .card, .grid + section { margin-top: 1.25rem; }
@media (max-width: 800px) { .grid.two { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .container { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1.25rem 1.1rem; border-radius: var(--radius); }
  h1 { font-size: 1.75rem; }
  .page-head.row { align-items: flex-start; }
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; flex-wrap: wrap; }
.row.gap { gap: 0.5rem; justify-content: flex-start; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: stretch; }
.field-row > .field-narrow { flex: 0 0 8rem; }
.field-row > .field-grow { flex: 1 1 16rem; }
.actions { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.inline { display: inline; }
.form-note { margin-top: 1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.warn { color: var(--orange); }
.lead { font-size: 1.0625rem; color: var(--fg-secondary); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.footer { text-align: center; color: var(--muted); padding: 1.5rem; }

/* ------------------------------------------------------------- stat tile */

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  padding: 0.5rem 1.05rem;
  border: 0;
  border-radius: 980px;
  background: var(--fill);
  color: var(--fg);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--fill-strong); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-hover); }

.btn.ghost { background: transparent; color: var(--link); }
.btn.ghost:hover { background: var(--blue-tint); }

.btn.danger { background: var(--red-tint); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }

.btn.warning { background: var(--orange); color: #fff; }
.btn.warning:hover { filter: brightness(1.08); }

.btn.small { min-height: 2rem; padding: 0.3rem 0.8rem; font-size: 0.8125rem; }

.btn-group { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.btn-group form { display: contents; }

/* ----------------------------------------------------------------- forms */

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 550;
  font-size: 0.9375rem;
  color: var(--fg);
}

input[type="text"], input[type="number"], input[type="password"],
input[type="search"], input[type="email"], input:not([type]),
textarea, select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 400;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 5rem; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
select:disabled, input:disabled { opacity: 0.6; cursor: not-allowed; }

input[type="file"] {
  font: inherit;
  font-size: 0.9375rem;
  color: var(--fg-secondary);
  padding: 0.85rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  width: 100%;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 500;
  margin-right: 0.85rem;
  padding: 0.4rem 0.95rem;
  border: 0;
  border-radius: 980px;
  background: var(--fill-strong);
  color: var(--fg);
  cursor: pointer;
}

input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.15rem 0 0;
  accent-color: var(--accent);
  flex: none;
}

.field-help { color: var(--muted); font-size: 0.8125rem; font-weight: 400; line-height: 1.4; }

/* Checkbox / radio row with title + description. */
.choice-row {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
  font-weight: 400;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}
.choice-row:hover { background: var(--fill); }
.choice-row strong { display: block; font-weight: 600; }
.choice-row .field-help { display: block; margin-top: 0.15rem; }
.choice-list { display: flex; flex-direction: column; gap: 0.5rem; }

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
legend { font-weight: 600; margin-bottom: 0.5rem; padding: 0; }

.search-field { flex: 1 1 18rem; }
/* Search reads as a filled, borderless bar (like a system search field)
   rather than a boxed form input; focus lifts it to the surface colour. */
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 2.5rem;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border-color: transparent;
  border-radius: 999px;
  background-color: var(--fill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
  font-size: 0.9375rem;
}
input[type="search"]:hover { background-color: var(--fill-strong); }
input[type="search"]:focus {
  background-color: var(--surface);
  border-color: var(--accent);
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

/* -------------------------------------------------------------- disclosure */

details.card > summary,
details.disclosure > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 1.0625rem;
}
details.disclosure > summary { font-size: 0.9375rem; color: var(--link); font-weight: 500; }
details.card > summary::-webkit-details-marker,
details.disclosure > summary::-webkit-details-marker { display: none; }
details.card > summary::after,
details.disclosure > summary::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  opacity: 0.55;
  flex: none;
}
details.card > summary::after { margin-left: auto; }
details[open].card > summary::after,
details[open].disclosure > summary::before { transform: rotate(45deg); }
details.card > summary .muted { font-weight: 400; font-size: 0.9375rem; }
details[open].card > summary { margin-bottom: 1rem; }
details.card > summary:focus-visible { border-radius: 6px; }

/* ---------------------------------------------------------------- tables */

.table-scroll {
  overflow-x: auto;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.data th, .data td {
  text-align: left;
  padding: 0.75rem 0.75rem;
  border-bottom: 1px solid var(--separator);
  vertical-align: middle;
}
.data th {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  border-bottom-color: var(--border);
}
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr { transition: background-color 0.1s ease; }
.data tbody tr:hover { background: color-mix(in srgb, var(--fill) 55%, transparent); }
.data th:first-child, .data td:first-child { padding-left: 0.25rem; }
.data th:last-child, .data td:last-child { padding-right: 0.25rem; }
.data.compact th, .data.compact td { padding-top: 0.55rem; padding-bottom: 0.55rem; font-size: 0.9375rem; }
.data.compact th { font-size: 0.8125rem; }
.data td.num, .data th.num { text-align: right; }
.data td.actions-cell { text-align: right; white-space: nowrap; }
.data td.actions-cell .btn + .btn,
.data td.actions-cell form + .btn,
.data td.actions-cell .btn + form,
.data td.actions-cell form + form { margin-left: 0.35rem; }
.data td.actions-cell form { display: inline; }
.data tr.warn td { color: var(--orange); }
.data .title-cell { font-weight: 500; }
.data .id-cell { color: var(--muted); }

.kv {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(8rem, 2fr);
  margin: 0;
}
.kv dt, .kv dd {
  margin: 0;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--separator);
}
.kv dt { color: var(--muted); padding-right: 1rem; }
.kv dd { overflow-wrap: anywhere; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; font-size: 0.875rem; }
}

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  background: var(--gray-tint);
  color: var(--gray);
}
.pill::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: currentColor;
}

.status-prepared, .status-archived, .outcome-pending, .choice-unclear { background: var(--gray-tint); color: var(--gray); }
.status-running {background: var(--blue-tint); color: var(--blue); }
.status-frozen { background: var(--purple-tint); color: var(--purple); }
.status-finalized, .outcome-accepted, .choice-yes { background: var(--green-tint); color: var(--green); }
.status-withdrawn, .outcome-invalid, .choice-unrecognized { background: var(--orange-tint); color: var(--orange); }
.outcome-rejected, .choice-no { background: var(--red-tint); color: var(--red); }
.choice-abstain { background: var(--gray-tint); color: var(--fg-secondary); }

.pill.status-running::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .pill.status-running::before { animation: none; }
  .btn:active { transform: none; }
}

/* -------------------------------------------------------------- counters */

.counters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0.25rem 0 1rem;
}
@media (max-width: 720px) { .counters { grid-template-columns: repeat(2, 1fr); } }
.counter {
  position: relative;
  padding: 1rem 1.1rem 0.9rem;
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.counter::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: currentColor;
}
.counter .value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.counter .label {
  margin-top: 0.3rem;
  font-size: 0.875rem;
  color: var(--fg-secondary);
  font-weight: 500;
}
.counter.yes { color: var(--green); }
.counter.no { color: var(--red); }
.counter.abstain { color: var(--gray); }
.counter.unrecognized { color: var(--orange); }

/* --------------------------------------------------------------- notices */

.banner, .notice {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  background: var(--blue-tint);
  color: var(--fg);
}
.banner.success, .notice.success { background: var(--green-tint); }
.notice.error, .err {
  background: var(--red-tint);
  color: var(--red);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  font-weight: 500;
}
.notice.warning { background: var(--orange-tint); color: var(--fg); }
.notice.warning strong:first-child { color: var(--orange); }

.import-report {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: var(--green-tint);
  border-radius: var(--radius);
}
.import-report details { margin-top: 0.5rem; }
.import-report ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* --------------------------------------------------------------- scanner */

.scanner-code {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  background: var(--orange-tint);
  color: var(--fg);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

.scanner-qr {
  display: block;
  width: 12rem;
  max-width: 100%;
  height: auto;
  margin: 0.75rem 0;
  padding: 0.5rem;
  background: #fff;
  border-radius: var(--radius);
}

.pin-display {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
}

.marker-thumb {
  border-radius: 4px;
  background: #fff;
  vertical-align: middle;
}

/* ------------------------------------------------------ auth / standalone */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 26rem;
  padding: 2.25rem 2rem 2rem;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}
.auth-card.wide { max-width: 34rem; }
.auth-card .brand-mark { width: 2.75rem; height: 2.75rem; border-radius: 12px; font-size: 1.4rem; margin-bottom: 1.25rem; }
.auth-card h1 { font-size: 1.75rem; margin-bottom: 0.4rem; }
.auth-card > .muted { margin-bottom: 1.5rem; }
.auth-card .btn.primary { min-height: 2.9rem; font-size: 1rem; }
.auth-foot {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--separator);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.7;
}

/* Participant self-check page. */
.check-wrap { max-width: 680px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }
.check-head { margin-bottom: 1.5rem; }
.check-head .eyebrow { margin-bottom: 0.35rem; }
.check-head h1 { margin-bottom: 0.25rem; }
.check-foot { margin-top: 1.5rem; font-size: 0.875rem; color: var(--muted); text-align: center; }
.recorded-meta { display: block; font-size: 0.8125rem; color: var(--muted); margin-top: 0.3rem; }
.choice-none { color: var(--muted); font-style: italic; }
.vote-list { list-style: none; margin: 0; padding: 0; }
.vote-item { display: flex; flex-direction: column; gap: 1rem; }
.vote-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.vote-item-head h2 { font-size: 1.1875rem; margin: 0; }
.vote-item-head .eyebrow { margin-bottom: 0.2rem; }
.vote-item-body { display: flex; flex-direction: column; gap: 0.35rem; }
.vote-item-body .pill { font-size: 0.9375rem; padding: 0.3rem 0.8rem; }
.vote-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.vote-buttons .btn { min-height: 3rem; font-size: 1rem; font-weight: 600; }

.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* ------------------------------------------------------------- vote page */

.vote-hero { display: flex; flex-direction: column; gap: 1rem; }
.vote-hero h1 { font-size: 1.875rem; margin: 0; }
.vote-hero .top-label { color: var(--muted); font-weight: 500; }
.vote-hero .motion { color: var(--fg-secondary); font-size: 1.0625rem; max-width: 70ch; white-space: pre-line; }
.meta-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; }
.meta-item { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9375rem; }
.meta-item > span:last-child:not(.pill) { color: var(--fg); font-weight: 500; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--separator);
}
.toolbar form { display: contents; }
.toolbar .spacer { flex: 1; }

/* Vote lifecycle stepper: done steps carry a check mark, the current one is
   filled, so progress never depends on colour alone. */
.stepper {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0;
  counter-reset: none;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
}
.step + .step::before {
  content: "";
  width: clamp(1rem, 4vw, 2.5rem);
  height: 2px;
  margin: 0 0.6rem;
  border-radius: 2px;
  background: var(--separator);
}
.step-done + .step::before { background: var(--accent); }
.step-dot {
  display: inline-grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--border);
  background: var(--surface);
  flex: none;
}
.step-done { color: var(--fg-secondary); }
.step-done .step-dot { background: var(--blue-tint); border-color: transparent; color: var(--accent); }
.step-current { color: var(--fg); font-weight: 650; }
.step-current .step-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--focus); }
@media (max-width: 560px) {
  .stepper { flex-wrap: nowrap; }
  .step + .step::before { width: 0.9rem; margin: 0 0.35rem; }
  .toolbar > form:last-child .btn.primary,
  .toolbar > .btn.primary { flex: 1 1 100%; }
  .step-label { font-size: 0.8125rem; }
  .step:not(.step-current) .step-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
}

/* Icon-only button (gear) and its popover menu. */
.icon-btn { width: 2.5rem; padding: 0; }
.icon-btn svg { width: 1.2rem; height: 1.2rem; }
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: var(--fill-strong); }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 20;
  min-width: 18rem;
  max-width: calc(100vw - 2rem);
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
  background: var(--surface-raised);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.menu-item {
  display: block;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--fill); }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--red-tint); }

/* ------------------------------------------------------------------ modal */

dialog.modal {
  width: min(26rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--surface-raised);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
  overflow: auto;
}
dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
dialog.modal[open] { animation: modal-in 0.2s ease-out; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.modal-body { position: relative; padding: 1.75rem 1.75rem 1.5rem; text-align: center; }
.modal-body h2 { margin-bottom: 0.35rem; }
.modal-body .eyebrow { margin-bottom: 0.25rem; }
.modal-body .eyebrow[hidden] { display: none; }
.modal-close-form { position: absolute; top: 0.75rem; right: 0.75rem; margin: 0; }
.modal-close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--fg-secondary);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--fill-strong); color: var(--fg); }

/* QR codes need dark-on-white for reliable scanning, also in dark mode. */
.qr-frame {
  display: inline-block;
  margin: 1.25rem auto 1rem;
  padding: 0.85rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.qr-frame img {
  display: block;
  width: min(18rem, 64vw);
  height: auto;
  image-rendering: pixelated;
}
.qr-dialog-code { margin-bottom: 0.75rem; }
.qr-dialog-code .scanner-code { font-size: 1.5rem; padding: 0.35rem 0.8rem; }
.qr-link { margin-top: 0.4rem; }
.scanner-qr { cursor: zoom-in; }

@media (prefers-reduced-motion: reduce) {
  dialog.modal[open] { animation: none; }
}

/* Confirmation dialog (static/confirm.js). */
dialog.modal-confirm { width: min(24rem, calc(100vw - 2rem)); }
.modal-confirm .modal-body { text-align: left; padding: 1.5rem; }
.modal-confirm h2 { font-size: 1.1875rem; }
.modal-confirm [data-confirm-message] { margin-bottom: 1.25rem; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.btn.destructive { background: var(--red); color: #fff; }
.btn.destructive:hover { filter: brightness(1.08); }
.menu-sep { margin: 0.3rem 0.4rem; border: 0; border-top: 1px solid var(--separator); }
.next-vote-link { max-width: 100%; }
.next-vote-title {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  opacity: 0.85;
}
.next-vote-title::before { content: "· "; }
