:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --text: #1c211b;
  --muted: #6b7266;
  --line: #dcdad0;
  --accent: #4b6b3a;
  --accent-text: #ffffff;
  --present: #4b6b3a;
  --danger: #a3392b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14170f;
    --surface: #1d2117;
    --text: #e6e7df;
    --muted: #9aa191;
    --line: #333a2a;
    --accent: #9dbf7f;
    --accent-text: #14170f;
    --present: #9dbf7f;
    --danger: #e0806f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.12em; color: var(--text); }
.brand img { height: 40px; width: auto; }
.emblem { display: block; margin: 0 auto 16px; height: auto; }
.topbar nav { display: flex; gap: 16px; }
.topbar nav a { color: var(--muted); }
.topbar nav a.active { color: var(--text); font-weight: 600; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 28px 0 8px; }
.muted { color: var(--muted); }
.saved { color: var(--present); }
.lead { margin: -8px 0 20px; color: var(--muted); }
.expired { color: var(--danger); font-weight: 600; }
.expired .badge { border-color: currentColor; color: inherit; }
input.expired { border-color: var(--danger); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin: 0 0 20px;
}
.card h2:first-child { margin-top: 0; }
.narrow { max-width: 440px; margin: 48px auto; }
.row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.row .grow { flex: 1 1 220px; }
.row .hint { flex-basis: 100%; margin: 0; }
.row.mark { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.row.copy { flex-wrap: nowrap; margin-bottom: 16px; }
.row.copy input { flex: 1; }
.stack { display: grid; gap: 14px; max-width: 440px; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; align-items: start; }

label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 1rem; color: var(--text); }
input, select, button { font: inherit; color: inherit; }
input:not([type="checkbox"]), select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  min-width: 0;
}
button {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; padding: 0; background: none; color: var(--accent); }
button.danger { color: var(--danger); }
button.danger:not(.link) { border-color: var(--danger); }
button:disabled { opacity: 0.6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.badge {
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
}

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 200px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; max-width: 640px; margin: 0 0 16px; }
.stats div { display: flex; flex-direction: column-reverse; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.stats dt { font-size: 0.8rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stats + .muted { margin-top: -4px; }
.grid td.pct { font-weight: 600; }

.filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.filter a { padding: 4px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.9rem; }
.filter a:hover { text-decoration: none; border-color: var(--accent); color: var(--text); }
.filter a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.range { gap: 12px; margin: 0 0 16px; }
.range a { padding: 8px 0; font-size: 0.9rem; }

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.scroll tbody tr:last-child > *, .scroll tfoot tr:last-child > * { border-bottom: 0; }
.scroll:has(tfoot) tbody tr:last-child > * { border-bottom: 1px solid var(--line); }
/* The grid is only as wide as its columns. Stretched to the page, a few events would spread out and leave each
   dot and count far from the heading it belongs under. */
.scroll.hug { display: inline-block; max-width: 100%; vertical-align: top; }
.grid { width: auto; }
.grid th:first-child { position: sticky; left: 0; background: var(--surface); }
.grid .event, .grid td.present, .grid td.absent, .grid td.count { text-align: center; }
.grid td.count { font-variant-numeric: tabular-nums; }
.grid .event a { display: grid; color: var(--text); font-weight: 600; }
.grid .event .muted { font-weight: 400; font-size: 0.75rem; }
.record { width: auto; }
.record .mark, .record td.present, .record td.absent, .record td.pending { text-align: center; }
.record td.pending { color: var(--muted); font-size: 0.85rem; }
td.present { color: var(--present); }
td.absent { color: var(--line); }

.qr { text-align: center; }
.qr-code { display: block; }
.qr-code svg { width: min(100%, 420px); height: auto; border-radius: 8px; }
/* Two columns only where each still fits a name and its Remove button. */
.attendees { padding: 0; margin: 0; list-style: none; columns: 2 200px; column-gap: 32px; }
.attendees li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 0; break-inside: avoid; }

.timeline { padding: 0; list-style: none; }
.timeline li { display: flex; gap: 16px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.timeline .when { color: var(--muted); min-width: 170px; font-variant-numeric: tabular-nums; }
.timeline form { margin-left: auto; }
.status { min-height: 1.5em; color: var(--danger); }
