:root {
  --bg: #f6f4ef;
  --bg-accent: #efe9dd;
  --surface: #ffffff;
  --ink: #1e1b16;
  --ink-soft: #5d574c;
  --ink-faint: #8a8378;
  --line: #e0dad0;
  --brand: #9a3412;
  --brand-soft: #fdece4;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --ok: #1b7a4b;
  --warn-soft: #fff6da;
  --warn-line: #e6cf8a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 27, 22, 0.05), 0 8px 28px rgba(30, 27, 22, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --bg-accent: #1e1c15;
    --surface: #201e18;
    --ink: #f2ece1;
    --ink-soft: #bcb4a6;
    --ink-faint: #8d867a;
    --line: #35322a;
    --brand: #f0864f;
    --brand-soft: #33231a;
    --danger: #ff8a80;
    --danger-soft: #3a1f1d;
    --ok: #6fd39b;
    --warn-soft: #332c15;
    --warn-line: #6b5a2c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

/* A CSS `display` on an element also carrying the `hidden` attribute would
   otherwise win over the browser default and show it anyway - which is how a
   broken <img> appeared before the logo had loaded. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 420px at 50% -180px, var(--bg-accent), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 660px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ---------- masthead ---------- */
.masthead { text-align: center; margin-bottom: 26px; }

/* The institute crest. Sized generously but capped so a tall logo cannot
   push the form off the first screen. */
.crest {
  display: block;
  height: 84px;
  width: auto;
  max-width: min(280px, 70%);
  margin: 0 auto 18px;
  object-fit: contain;
}

/* Most crests are dark artwork on a transparent ground, which disappears on a
   dark page - so give it a light plate to sit on. */
@media (prefers-color-scheme: dark) {
  .crest {
    background: #fff;
    padding: 10px 14px;
    border-radius: 12px;
  }
}

@media (max-width: 460px) {
  .crest { height: 68px; margin-bottom: 14px; }
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

.masthead h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 5.4vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lede {
  margin: 0 auto;
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---------- cards & sections ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 24px 24px;
}

.fieldset { padding: 18px 0 4px; }
.fieldset + .fieldset { border-top: 1px solid var(--line); margin-top: 6px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 15px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.step {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- fields ---------- */
.field { margin-bottom: 18px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 460px) { .row { grid-template-columns: 1fr; gap: 0; } }

label, legend {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.req { color: var(--brand); }

.optional {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  text-transform: lowercase;
}

input[type="text"], input[type="tel"], input[type="email"],
input[type="password"], input[type="date"], input[type="time"], select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  transition: border-color 0.15s, box-shadow 0.15s;
}

select { appearance: none; background-image: none; }

input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-faint); }
.error { margin: 6px 0 0; font-size: 13px; font-weight: 500; color: var(--danger); }

/* phone: country code + number side by side */
.field--phone { display: flex; flex-wrap: wrap; gap: 12px; }
.field--phone .sub { flex: 0 0 150px; }
.field--phone .sub--grow { flex: 1 1 180px; }
.field--phone .hint, .field--phone .error { flex: 1 0 100%; margin-top: 0; }

/* ---------- choices ---------- */
.choice { margin: 0; padding: 0; border: 0; }
.choice legend { padding: 0; }

.segmented { display: flex; gap: 10px; flex-wrap: wrap; }

.seg { position: relative; flex: 1 1 120px; margin: 0; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }

.seg span {
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.seg span:hover { border-color: var(--brand); }

.seg input:checked + span {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.seg input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- alerts ---------- */
.alert {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.notice--warn {
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--ink);
}

.notice code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.18);
  font-size: 13px;
}

/* ---------- actions ---------- */
.actions { margin-top: 8px; text-align: center; }

.btn {
  width: 100%;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}

@media (prefers-color-scheme: dark) { .btn { color: #22160f; } }

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.btn--ghost {
  width: auto;
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
  font-weight: 500;
}

@media (prefers-color-scheme: dark) { .btn--ghost { color: var(--ink-soft); } }

.fineprint { margin: 12px 0 0; font-size: 12px; color: var(--ink-faint); }

/* ---------- honeypot ---------- */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- success ---------- */
.success { text-align: center; padding: 34px 24px 28px; }

.tick {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--ok);
  font-size: 26px;
  font-weight: 700;
}

.success h2 { margin: 0 0 8px; font-size: 24px; }
.success > p { margin: 0 auto 20px; max-width: 42ch; color: var(--ink-soft); }

.summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 18px;
  max-width: 420px;
  margin: 0 auto 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  font-size: 14px;
}

.summary dt { color: var(--ink-faint); }
.summary dd { margin: 0; font-weight: 500; }

/* ==========================================================================
   Organiser dashboard (admin.html)
   ========================================================================== */

.shell--narrow { max-width: 420px; }
.shell--wide { max-width: 1180px; }

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.dash-head h1 {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 30px);
  letter-spacing: -0.02em;
}

.dash-head .eyebrow { margin-bottom: 2px; }

.dash-who {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ---------- stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.tile-n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.tile-l { font-size: 13px; color: var(--ink-faint); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.search {
  flex: 1 1 260px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

.search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.toolbar select {
  width: auto;
  padding: 10px 12px;
  font-size: 14px;
}

.btn--sm {
  width: auto;
  padding: 9px 14px;
  font-size: 14px;
}

.btn--export {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.result-count {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-faint);
}

/* ---------- table ---------- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow-x: auto;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.grid th[data-sort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover { color: var(--brand); }
.grid th.is-sorted { color: var(--brand); }

.grid th.is-sorted::after {
  content: ' ▲';
  font-size: 9px;
}

.grid th.is-sorted[aria-sort="descending"]::after { content: ' ▼'; }

.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}

.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--bg-accent); }

.grid a { color: inherit; text-decoration: none; }
.grid a:hover { color: var(--brand); text-decoration: underline; }

.cell-strong { display: block; font-weight: 500; }
.cell-sub { display: block; font-size: 12px; color: var(--ink-faint); }
.cell-actions { text-align: right; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-faint);
}

.pill--yes {
  border-color: transparent;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.link-danger {
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.link-danger:hover { color: var(--danger); text-decoration: underline; }
.link-danger[disabled] { opacity: 0.5; cursor: default; }

.empty {
  margin: 0;
  padding: 34px 16px;
  text-align: center;
  color: var(--ink-faint);
}


/* ---------- "waking the server up" notice ---------- */
.waking {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--warn-line);
  border-radius: 10px;
  background: var(--warn-soft);
  font-size: 14px;
  line-height: 1.5;
}

.waking strong { display: block; margin-bottom: 2px; }
.waking-sub { display: block; color: var(--ink-soft); font-size: 13px; }

.spinner {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}
