/* GatePass — one stylesheet for both halves of the system.
   Deliberately self-contained: the attendee's page has to open on a stranger's
   phone on a venue's weak signal, so there is nothing here to fetch but this
   file. System fonts, icons drawn inline, no images. */

/* ===================================================================== tokens */

:root {
  /* Neutrals lean towards the navy, so the greys look chosen, not inherited. */
  --page: #f2f4f8;
  --panel: #ffffff;
  --sunk: #f6f8fb;
  --ink: #131b27;
  --soft: #536079;
  --faint: #8590a2;
  --line: #dde2ea;
  --line-strong: #c8d0db;

  /* Lanyard navy — the colour the app already had. */
  --brand: #1c4a78;            /* fills, with white on top */
  --brand-hover: #163c62;
  --brand-text: #1c4a78;       /* links and accents on a light surface */
  --brand-soft: #e8eff7;
  --band: #1c4a78;             /* the strip across the top of attendee pages */
  --focus: #2f6fb3;
  --focus-ring: rgba(47, 111, 179, .35);

  /* What a scan means, said first in colour. */
  --in: #127548;   --in-bg: #e5f4ec;   --in-line: #a6d6bb;   --in-fill: #12784a;
  --out: #1c4a78;  --out-bg: #e8eff7;  --out-line: #adc4de;  --out-fill: #1c4a78;
  --hold: #8a5a12; --hold-bg: #fcf2df; --hold-line: #e8cb93; --hold-fill: #95600f;
  --danger: #a32626; --danger-bg: #fcebeb; --danger-line: #ecb4b4; --danger-fill: #b02a2a;

  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(19, 27, 39, .05), 0 8px 22px -14px rgba(19, 27, 39, .22);
  --shadow-lg: 0 2px 6px rgba(19, 27, 39, .06), 0 24px 48px -20px rgba(19, 27, 39, .35);

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

/* Dark follows the device's own setting - unless the organiser has chosen with
   the theme switch (theme.js), which puts data-theme="light" or "dark" on
   <html>. The dark colours are written twice, here and just below, because a
   media query and a chosen theme cannot share one rule: change them together. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d121a;
    --panel: #151c26;
    --sunk: #111821;
    --ink: #e7ecf3;
    --soft: #a5b1c2;
    --faint: #788599;
    --line: #263040;
    --line-strong: #344155;

    /* Darker than the old light-blue accent: white text needs the contrast. */
    --brand: #3270b4;
    --brand-hover: #3d7fc6;
    --brand-text: #8fbdee;
    --brand-soft: #172a40;
    --band: #142f4d;
    --focus: #6fa6e0;
    --focus-ring: rgba(111, 166, 224, .4);

    --in: #5fd197;   --in-bg: #10281b;   --in-line: #225c3e;   --in-fill: #187d4e;
    --out: #8fc0ea;  --out-bg: #132335;  --out-line: #2b4b6e;  --out-fill: #2a6299;
    --hold: #e6bd6a; --hold-bg: #2a2110; --hold-line: #5c4720; --hold-fill: #95600f;
    --danger: #f19a9a; --danger-bg: #2c1516; --danger-line: #6a2c2c; --danger-fill: #b02a2a;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 24px -14px rgba(0, 0, 0, .7);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 28px 56px -20px rgba(0, 0, 0, .85);
  }
}

/* Dark, chosen: the same colours as above, whatever the device says. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0d121a;
  --panel: #151c26;
  --sunk: #111821;
  --ink: #e7ecf3;
  --soft: #a5b1c2;
  --faint: #788599;
  --line: #263040;
  --line-strong: #344155;

  --brand: #3270b4;
  --brand-hover: #3d7fc6;
  --brand-text: #8fbdee;
  --brand-soft: #172a40;
  --band: #142f4d;
  --focus: #6fa6e0;
  --focus-ring: rgba(111, 166, 224, .4);

  --in: #5fd197;   --in-bg: #10281b;   --in-line: #225c3e;   --in-fill: #187d4e;
  --out: #8fc0ea;  --out-bg: #132335;  --out-line: #2b4b6e;  --out-fill: #2a6299;
  --hold: #e6bd6a; --hold-bg: #2a2110; --hold-line: #5c4720; --hold-fill: #95600f;
  --danger: #f19a9a; --danger-bg: #2c1516; --danger-line: #6a2c2c; --danger-fill: #b02a2a;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 24px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 28px 56px -20px rgba(0, 0, 0, .85);
}

/* Light, chosen: the colours at the top already are light; this only tells the
   browser, so its own scrollbars and form controls match. */
:root[data-theme="light"] { color-scheme: light; }

/* ======================================================================= base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

/* Several blocks lay themselves out with flex or grid; the hidden attribute has
   to win over that, or a "hidden" panel stays on screen. */
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--brand-text); text-underline-offset: 2px; }

:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.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;
}

.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

.mark { width: 26px; height: 26px; flex: none; }
.mark .m-tile { fill: var(--brand); }
.mark .m-ring { stroke: #fff; }
.mark .m-dot { fill: #fff; }
/* On the navy band and the sign-in panel the mark turns over. */
.on-brand .mark .m-tile { fill: #fff; }
.on-brand .mark .m-ring { stroke: var(--band); }
.on-brand .mark .m-dot { fill: var(--band); }

.wordmark {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 750; font-size: 1.05rem; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}

.lede { color: var(--soft); }
.sub { color: var(--soft); font-size: .9rem; margin-top: 3px; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ==================================================================== buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--brand); color: #fff;
  border: 1px solid var(--brand); border-radius: var(--radius-sm);
  padding: .7rem 1.1rem; min-height: 44px;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn:active { transform: translateY(1px); }

.btn.secondary { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--sunk); border-color: var(--faint); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--soft); }
.btn.ghost:hover { background: var(--sunk); color: var(--ink); }

.btn.danger { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-bg); }

.btn.sm { min-height: 36px; padding: .45rem .8rem; font-size: .875rem; }
.btn.lg { min-height: 52px; padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn.wide { width: 100%; }
.btn.icon-only { padding: 0; width: 40px; min-height: 40px; }
.btn.icon-only.sm { width: 36px; min-height: 36px; }

.btn:disabled { opacity: .6; cursor: default; pointer-events: none; }

/* Working: a spinner where the icon would be, so a slow network still answers. */
.btn.is-busy { pointer-events: none; }
.btn.is-busy .icon { display: none; }
.btn.is-busy::before {
  content: ""; width: 1em; height: 1em; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====================================================================== forms */

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label, .label { font-weight: 600; font-size: .92rem; }
.hint { color: var(--faint); font-size: .84rem; font-weight: 400; }

input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%;
  font: inherit; font-size: 1rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .68rem .85rem;
  min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring);
}
input:user-invalid { border-color: var(--danger); }
input[type=date] { min-height: 46px; }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer; }
.select-wrap::after {
  content: ""; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--soft); border-bottom: 2px solid var(--soft);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

/* A box with a button inside it — show password, copy. */
.input-group { position: relative; }
.input-group input { padding-right: 3rem; }
.input-addon {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--soft); cursor: pointer;
}
.input-addon:hover { background: var(--sunk); color: var(--ink); }

/* Radio rows big enough to hit with a thumb, which is how they will be used. */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .8rem .95rem; min-height: 52px; cursor: pointer; font-weight: 500;
  transition: border-color .15s, background-color .15s;
}
.choice input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 22px; height: 22px; margin: 0;
  border: 2px solid var(--line-strong); border-radius: 50%; background: var(--panel);
  transition: border-color .15s;
}
.choice input:checked {
  border-color: var(--brand);
  background: radial-gradient(circle, var(--brand) 0 42%, var(--panel) 47%);
}
/* Several days at once: a square box with a tick, the way a checkbox looks. */
.choice.tick input { border-radius: 6px; }
.choice.tick input:checked {
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.choice:hover { border-color: var(--faint); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ===================================================================== alerts */

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid; border-radius: var(--radius-sm);
  padding: .75rem .9rem; font-size: .92rem;
}
.alert .icon { margin-top: .12em; }
.alert.error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); font-weight: 600; }
.alert.info { background: var(--sunk); border-color: var(--line); color: var(--soft); }
.alert.hold { background: var(--hold-bg); border-color: var(--hold-line); color: var(--hold); font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: .24rem .6rem; border-radius: 999px; white-space: nowrap;
  background: var(--sunk); color: var(--faint); border: 1px solid var(--line);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.in { background: var(--in-bg); color: var(--in); border-color: var(--in-line); }
.pill.out { background: var(--out-bg); color: var(--out); border-color: var(--out-line); }
.pill.hold { background: var(--hold-bg); color: var(--hold); border-color: var(--hold-line); }

.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text);
  font-weight: 700; font-size: .95rem; text-transform: uppercase;
}

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ============================================================ attendee pages */

/* The strip across the top: whose event this is, before anything else. */
.band {
  background: var(--band); color: #fff;
  padding: max(16px, env(safe-area-inset-top)) 18px 24px;
}
.band-inner { max-width: 520px; margin: 0 auto; }
.band-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  opacity: .82; margin-bottom: 14px;
}
.band-brand .mark { width: 20px; height: 20px; }
.band-event { font-size: 1.35rem; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; text-wrap: balance; }
.band-dates { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: .92rem; opacity: .85; }

/* The event's logos, on white above the band: a logo is drawn for a white page,
   and a dark one would vanish on the navy. */
.logo-strip { background: #fff; border-bottom: 1px solid var(--line); padding: max(10px, env(safe-area-inset-top)) 18px 10px; }
.logo-strip-inner { max-width: 520px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; }
.logo-strip img { display: block; max-height: 52px; max-width: 46%; object-fit: contain; }
.logo-strip .right { margin-left: auto; }
.logo-strip + .band { padding-top: 18px; }

.sheet { max-width: 520px; margin: 0 auto; padding: 24px 18px 56px; }
.sheet-head { margin-bottom: 20px; display: flex; flex-direction: column; gap: 6px; }
.sheet-head h1 { font-size: 1.6rem; }

.form-card { padding: 20px 18px; display: flex; flex-direction: column; gap: 22px; }
.form-section { display: flex; flex-direction: column; gap: 16px; }
.form-section + .form-section { padding-top: 22px; border-top: 1px solid var(--line); }
.section-title {
  font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint);
}

.links { margin-top: 24px; text-align: center; font-size: .92rem; }
.links a { color: var(--soft); }
.links a:hover { color: var(--ink); }

/* ---------- the pass: the one screen that matters ----------
   Big enough to read while walking, and for someone at the door to read from a
   step away. The colour does the talking before the words are read. */
.pass {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: pass-in .35s ease-out both;
}
.pass-head {
  background: var(--pass-fill); color: #fff;
  padding: 26px 22px 24px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px;
}
.pass-badge {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center;
}
.pass-badge .icon { width: 34px; height: 34px; stroke-width: 2.6; }
.pass-badge .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .45s .2s ease-out forwards; }
.pass-word { font-size: 2.5rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }

.pass-body { padding: 20px 22px 18px; }
.pass-name { font-size: 1.4rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.pass-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 14px 0 0; font-size: .95rem; }
.pass-meta dt { color: var(--faint); }
.pass-meta dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* The tear line, with a notch cut from each edge like a ticket stub. */
.pass-tear { position: relative; height: 0; margin: 0 20px; border-top: 2px dashed var(--line-strong); }
.pass-tear::before, .pass-tear::after {
  content: ""; position: absolute; top: -12px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--page);
}
.pass-tear::before { left: -31px; }
.pass-tear::after { right: -31px; }

.pass-stub { padding: 16px 22px 20px; display: flex; gap: 10px; align-items: flex-start; color: var(--soft); font-size: .95rem; }
.pass-stub .icon { margin-top: .15em; color: var(--faint); }

.pass.in { --pass-fill: var(--in-fill); }
.pass.out { --pass-fill: var(--out-fill); }
.pass.hold { --pass-fill: var(--hold-fill); }
.pass.hold .pass-word { font-size: 1.9rem; }

@keyframes pass-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- their own code, for the door scanner and the ID card ---------- */
.my-code {
  margin-top: 18px; padding: 14px;
  display: flex; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.my-code-qr { flex: none; width: 124px; border-radius: 8px; overflow: hidden; }
.my-code-qr svg, .id-pass-qr svg { display: block; width: 100%; height: auto; }
.my-code-text { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.my-code-text h2 { font-size: 1rem; }
.my-code-text p { font-size: .88rem; color: var(--soft); }
.my-code-text a {
  display: inline-flex; align-items: center; gap: 2px; margin-top: 2px;
  font-size: .9rem; font-weight: 600; text-decoration: none;
}
/* Monospace and spaced out: it is read aloud and typed in by hand. */
.code-id { font-family: var(--mono); font-weight: 700; letter-spacing: .12em; color: var(--ink) !important; }
@media (max-width: 360px) { .my-code { flex-direction: column; align-items: flex-start; } }

.id-pass { padding: 22px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.id-pass-qr { width: min(100%, 300px); margin-bottom: 6px; border-radius: 10px; overflow: hidden; }
.id-pass .code-id { font-size: 1.3rem; }
.id-pass-name { margin-top: 6px; font-size: 1.3rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }

/* A shared phone: whoever is scanning taps their own name. */
.people { display: flex; flex-direction: column; gap: 10px; }
.person-link {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px; min-height: 64px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: 1.02rem;
  transition: border-color .15s;
}
.person-link:hover { border-color: var(--brand); }
.person-link .chev { margin-left: auto; color: var(--faint); }

/* A page with one thing to say: a code nobody recognises, an error. */
.state {
  max-width: 440px; margin: 0 auto; padding: 72px 22px 48px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
}
.state-icon {
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--hold-bg); color: var(--hold); margin-bottom: 4px;
}
.state-icon .icon { width: 30px; height: 30px; }
.state h1 { font-size: 1.5rem; }
.state .lede { max-width: 38ch; }

/* ==================================================================== sign in */

.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }

.login-brand {
  position: relative; overflow: hidden;
  background: var(--band); color: #fff;
  padding: 22px 22px 26px;
  display: flex; flex-direction: column;
}
.login-brand .wordmark { color: #fff; font-size: 1.1rem; }
.login-brand .wordmark .mark { width: 30px; height: 30px; }
.login-pitch {
  margin-top: 16px; max-width: 17ch;
  font-size: 1.35rem; font-weight: 750; line-height: 1.18; letter-spacing: -.025em;
}
.login-points { display: none; }
.login-art { display: none; }

.login-panel { position: relative; display: flex; align-items: center; justify-content: center; padding: 32px 20px 48px; }
/* The theme switch, tucked in the sign-in side's top corner. */
.login-theme { position: absolute; top: 14px; right: 14px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login-card h2 { font-size: 1.6rem; }
.login-card .lede { margin-top: -10px; }
.login-foot { font-size: .85rem; color: var(--faint); text-align: center; }
.caps { display: flex; align-items: center; gap: 6px; color: var(--hold); font-size: .84rem; font-weight: 600; }

@media (min-width: 880px) {
  .login { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .login-brand { padding: 48px 56px; justify-content: space-between; }
  .login-pitch { margin-top: 0; font-size: clamp(2rem, 1.2rem + 1.6vw, 2.7rem); }
  .login-points {
    display: flex; flex-direction: column; gap: 14px;
    list-style: none; padding: 0; margin: 30px 0 0; font-size: 1.02rem; opacity: .92;
  }
  .login-points li { display: flex; align-items: center; gap: 12px; }
  .login-points .icon { opacity: .8; }
  .login-brand-foot { font-size: .85rem; opacity: .6; }
  /* A finder square drawn large and faint: the corner of a QR code, the thing
     this whole system is about. */
  .login-art {
    display: block; position: absolute; right: -150px; bottom: -150px;
    width: 440px; height: 440px; opacity: .06; pointer-events: none;
  }
}
@media (max-width: 879px) { .login-brand-foot { display: none; } }

/* ============================================================ organiser panel */

.appbar { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
.appbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px; min-height: 62px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.event-switch { display: flex; align-items: center; gap: 8px; flex: 1 1 300px; min-width: 0; max-width: 560px; }
.event-switch .select-wrap { flex: 1; min-width: 0; }
.event-switch select { min-height: 40px; font-weight: 600; font-size: .95rem; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.menu-list button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font: inherit; font-size: .92rem; text-align: left;
  padding: .6rem .7rem; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink); cursor: pointer;
}
.menu-list button:hover { background: var(--sunk); }
.menu-list .icon { color: var(--soft); }

/* The light / dark switch (theme.js): one button, showing the mode it is in.
   All three icons are in it; only the current one shows. */
.theme-switch .icon { display: none; }
.theme-switch[data-mode="auto"] .t-auto,
.theme-switch[data-mode="light"] .t-light,
.theme-switch[data-mode="dark"] .t-dark { display: block; }

@media (max-width: 720px) {
  .appbar-inner { padding: 8px 14px; gap: 8px; }
  .event-switch { order: 5; flex-basis: 100%; max-width: none; }
  .hide-sm { display: none; }
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 20px 72px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 720px) { .wrap { padding: 16px 14px 56px; gap: 16px; } }

.card-pad { padding: 20px; }
@media (max-width: 720px) { .card-pad { padding: 16px; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { font-size: 1.1rem; }

/* ---------- the live count: the number the organiser actually watches ---------- */
.live-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.live-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-title h1 { font-size: 1.45rem; }
.live-at { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-at .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--in); animation: pulse 2s ease-out infinite; }
.live-at.stale .dot { background: var(--hold); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(18, 120, 74, .45); }
  70% { box-shadow: 0 0 0 8px rgba(18, 120, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 120, 74, 0); }
}

.stats { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 12px; }
.stat {
  background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; min-height: 104px;
}
.stat .n { font-size: 2.1rem; font-weight: 750; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--soft); font-size: .76rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.stat.hero { background: var(--in-bg); border-color: var(--in-line); }
.stat.hero .n { font-size: 3.5rem; color: var(--in); }
.stat.hero .k { color: var(--in); }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { min-height: 0; padding: 12px 12px; }
  .stat .n { font-size: 1.6rem; }
  .stat .k { font-size: .68rem; }
  .stat.hero { grid-column: 1 / -1; }
  .stat.hero .n { font-size: 3rem; }
}

.breakdown { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.breakdown:has(.chips:empty + .chips:empty) { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips:empty { display: none; }
.chip-label { font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin-right: 4px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: .28rem .75rem; font-size: .88rem; color: var(--soft);
}
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- people beside the code ---------- */
/* Side by side only where the people table still has room to breathe; below
   that the table takes the full width and the code sits underneath it. */
.board { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 1180px) { .board { grid-template-columns: minmax(0, 1fr); } }

.code-card { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 14px; }
.code-card h2 { font-size: 1.1rem; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.qr img { width: 100%; height: auto; display: block; aspect-ratio: 1; }
@media (max-width: 1180px) {
  .code-card { position: static; }
  .qr { max-width: 260px; }
}
/* Full width but not a phone: the code on the left, its link and buttons beside it. */
@media (min-width: 640px) and (max-width: 1180px) {
  .code-card {
    display: grid; grid-template-columns: 200px minmax(0, 1fr); column-gap: 24px; row-gap: 12px;
    grid-template-areas: "qr head" "qr address" "qr actions" "qr .";
  }
  .code-head { grid-area: head; }
  .code-card .qr { grid-area: qr; align-self: start; }
  .code-card .address { grid-area: address; align-self: start; }
  .code-actions { grid-area: actions; flex-direction: row; flex-wrap: wrap; }
  .code-actions .btn.wide { width: auto; }
}
.code-door { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.code-door h3 { font-size: 1rem; }
.code-door .sub { margin: 0 0 4px; }
@media (min-width: 640px) and (max-width: 1180px) {
  .code-door .stack { flex-direction: row; flex-wrap: wrap; }
  .code-door .btn.wide { width: auto; }
}
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

.address {
  display: flex; align-items: center; gap: 4px;
  background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 4px 4px 4px 12px;
}
.address code { flex: 1; min-width: 0; font-family: var(--mono); font-size: .82rem; color: var(--ink); overflow-wrap: anywhere; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; }
.seg label { margin: 0; font-size: .85rem; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .42rem .78rem; border-radius: 7px; color: var(--soft); white-space: nowrap; transition: background-color .15s, color .15s; }
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
/* On a phone the filter stays one row and slides sideways, rather than wrapping
   its last option onto a line of its own. (After the rules above, so it wins.) */
@media (max-width: 720px) {
  .seg { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
}

.search { position: relative; flex: 1 1 220px; max-width: 380px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 2.4rem; min-height: 40px; }

/* position: relative so anything absolutely positioned inside - the hidden
   "Actions" header - is clipped here too, instead of widening the whole page. */
.scroll { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; white-space: nowrap;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--faint); background: var(--sunk);
  padding: .65rem .8rem; border-bottom: 1px solid var(--line);
}
td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--sunk); }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.col-school { min-width: 180px; }
td.col-days { white-space: nowrap; }
.person-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.person-cell .avatar { width: 34px; height: 34px; font-size: .82rem; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { display: block; color: var(--soft); font-size: .82rem; }
.table-empty { text-align: center; padding: 36px 16px; color: var(--soft); }
.table-empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* No events yet: say what this is and offer the one button that matters. */
.empty {
  max-width: 560px; margin: 32px auto; padding: 56px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
}
.empty-art {
  width: 84px; height: 84px; border-radius: 22px; margin-bottom: 6px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text);
}
.empty-art .icon { width: 40px; height: 40px; stroke-width: 1.7; }
.empty h1 { font-size: 1.6rem; }
.empty p { color: var(--soft); max-width: 46ch; }
.empty .btn { margin-top: 8px; }

/* ===================================================================== dialogs */

.dialog {
  border: 0; padding: 0; border-radius: 16px;
  background: var(--panel); color: var(--ink);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5);
}
.dialog.narrow { width: min(420px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(9, 14, 22, .55); }
.dialog[open] { animation: pop .18s ease-out; }
.dialog form { display: flex; flex-direction: column; max-height: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.dialog-head h2 { font-size: 1.2rem; }
.dialog-body { padding: 8px 20px 20px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--sunk);
  border-radius: 0 0 16px 16px;
}
.dialog.wide { width: min(720px, calc(100vw - 24px)); }
/* A dialog with no form of its own lays out the same way. */
.dialog-frame { display: flex; flex-direction: column; max-height: inherit; }
.dialog-section { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-section h3 { font-size: 1rem; }

/* The two logo slots, side by side. */
.logo-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.logo-slot { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunk); }
.logo-slot-name { font-size: .85rem; font-weight: 600; color: var(--soft); }
.logo-preview {
  height: 72px; display: grid; place-items: center;
  background: #fff; border: 1px dashed var(--line-strong); border-radius: 8px; overflow: hidden;
}
.logo-preview img { max-width: 100%; max-height: 64px; object-fit: contain; }
@media (max-width: 520px) { .logo-slots { grid-template-columns: 1fr; } }

/* The form's questions: name, asked, required, and a remove button. */
.ff { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.ff-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 52px 72px 40px; gap: 8px; align-items: center;
  padding: 8px 12px; border-top: 1px solid var(--line); font-size: .92rem;
}
.ff-row:first-child { border-top: 0; }
.ff-head { background: var(--sunk); font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.ff-row > input[type=checkbox] { width: 18px; height: 18px; justify-self: center; accent-color: var(--brand); }
.ff-head span:nth-child(2), .ff-head span:nth-child(3) { text-align: center; }
.ff-name { font-weight: 600; }
.ff-row input[type=text] { min-height: 38px; padding: .4rem .6rem; font-size: .92rem; }
.ff-custom { background: var(--brand-soft); }
.ff-custom-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ff-custom-kind { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 6px; }
.ff-custom-kind select { min-height: 38px; padding-top: .3rem; padding-bottom: .3rem; font-size: .9rem; }
.ff-custom-kind input[hidden] { display: none !important; }
#custom-fields { display: contents; }
.ff-add { max-width: 280px; }
@media (max-width: 520px) {
  .ff-row { grid-template-columns: minmax(0, 1fr) 40px 56px 36px; padding: 8px; }
  .ff-custom-kind { grid-template-columns: 1fr; }
}

/* "Registration numbers start with": the prefix, and how the numbers will read. */
.prefix-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prefix-row input { max-width: 150px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; }
td.col-no { white-space: nowrap; font-family: var(--mono); font-weight: 600; }

/* Email settings: the test, set apart at the bottom. */
.mail-test { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.mail-test label { font-weight: 600; font-size: .92rem; }
.mail-test-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mail-test-row input { flex: 1 1 220px; min-width: 0; }

/* Users: one row each, and the form to add or change one. */
.user-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-main .pill { margin-left: 6px; vertical-align: 1px; }
.user-form { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--sunk); }
.user-form h3 { font-size: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ======================================================================= toast */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: .7rem 1.1rem; border-radius: 10px;
  background: var(--ink); color: var(--page);
  font-weight: 600; font-size: .92rem;
  box-shadow: 0 14px 32px -10px rgba(0, 0, 0, .45);
  animation: pop .18s ease-out;
}
.toast.err { background: var(--danger-fill); color: #fff; }

/* =================================================================== the poster */

.poster { min-height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 32px 16px 48px; }
/* Paper, in every theme: this page exists to be printed. */
.poster-sheet {
  width: min(100%, 210mm); background: #fff; color: #131b27;
  padding: 16mm 14mm; border-radius: 6px; box-shadow: var(--shadow-lg);
  text-align: center; display: flex; flex-direction: column; align-items: center;
}
.poster-logos { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12mm; margin-bottom: 10pt; }
.poster-logos img { display: block; max-height: 24mm; max-width: 45%; object-fit: contain; }
.poster-logos .right { margin-left: auto; }
.poster-kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12pt; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #1c4a78;
}
.poster-kicker .mark { width: 24px; height: 24px; }
.poster-kicker .mark .m-tile { fill: #1c4a78; }
.poster h1 { margin-top: 12pt; font-size: 30pt; line-height: 1.1; color: #131b27; }
.poster-dates { margin-top: 6pt; font-size: 14pt; color: #536079; }
.poster-code { margin: 18pt 0 12pt; padding: 10pt; border: 2.5px solid #131b27; border-radius: 16pt; background: #fff; }
.poster-code svg { width: min(70vw, 104mm); height: auto; display: block; }
.poster-cta { font-size: 24pt; font-weight: 800; letter-spacing: -.01em; color: #131b27; }
.poster-steps {
  list-style: none; padding: 0; margin: 16pt 0 0; width: 100%; max-width: 172mm;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12pt; text-align: left;
}
.poster-steps li { display: flex; align-items: flex-start; gap: 9pt; font-size: 11.5pt; color: #3a4558; line-height: 1.4; }
.poster-steps strong { color: #131b27; }
.step-n {
  width: 22pt; height: 22pt; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: #1c4a78; color: #fff; font-weight: 700; font-size: 11pt;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.poster-address { margin-top: 18pt; font-size: 11pt; color: #536079; overflow-wrap: anywhere; }
.poster-address strong { font-family: var(--mono); color: #131b27; }
.poster-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
@media (max-width: 600px) {
  .poster-sheet { padding: 22px 16px; }
  .poster h1 { font-size: 22pt; }
  .poster-steps { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .poster { padding: 0; min-height: 0; }
  .poster-sheet { box-shadow: none; padding: 0; width: auto; }
  .poster-code svg { width: 110mm; }
}

/* ====================================================================== motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-delay: 0s !important;
    animation-iteration-count: 1 !important; transition-duration: .01ms !important;
  }
}

/* The certificate's design, beside its preview. */
.prefix-row .select-wrap { flex: 0 1 260px; min-width: 180px; }

/* The owner's own logo, in place of the GatePass mark: on a white tile, so a
   dark logo still shows on the navy band and in dark mode. */
img.brand-logo { object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }

/* The contact number: its country code, then the number. */
.phone-row { display: flex; gap: 8px; align-items: stretch; }
.phone-row input { flex: 1; min-width: 0; }
.phone-cc { flex: 0 0 7.75rem; min-width: 0; }
.phone-cc select { width: 100%; }
.phone-cc-fixed {
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 0 .9rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--sunk);
  font-weight: 600; color: var(--soft);
}

/* In the form builder: how the contact number is asked, under its row. */
.ff-phone { background: var(--sunk); border-top: 0; padding-top: 0; }
.ff-phone[hidden] { display: none; }
.ff-phone-main { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 2px; }
.ff-phone-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; color: var(--soft); }
.ff-phone-line .select-wrap { flex: 1 1 180px; min-width: 150px; }
.ff-phone-line select { min-height: 38px; padding-top: .3rem; padding-bottom: .3rem; font-size: .9rem; }
.ff-phone .choice { font-size: .88rem; }
