/* ==========================================================================
   Starr King PCW — design system

   Structure: TypeUI `minimal` — restrained surface, whitespace rhythm, few
   colours, hierarchy carried by type and spacing.
   Admin density: TypeUI `ant` — 12/14/16/20/24/32 type scale, explicit
   interaction states (hover, focus-visible, active, disabled, loading, error),
   data-dense tables.
   Brand: the Starr King green/cream palette is preserved exactly.

   Rule: components reference tokens. Raw values live in this :root block only.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Brand palette (unchanged) ─────────────────────────────────────────── */
  --sk-white:       rgb(252,252,252);
  --sk-cream:       rgb(245,237,229);
  --sk-warm-light:  rgb(240,236,223);
  --sk-green-light: rgb(183,216,199);
  --sk-green-mid:   rgb(93,150,122);
  --sk-green-dark:  rgb(38,100,69);
  --sk-green-deep:  rgb(30,74,52);
  --sk-olive-light: rgb(218,229,183);
  --sk-olive-mid:   rgb(183,202,121);
  --sk-brown-dark:  rgb(49,47,46);
  --sk-gray-mid:    rgb(117,114,111);

  /* ── Neutral ramp ──────────────────────────────────────────────────────────
     Collapsed from 40+ ad-hoc greys and two pasted palettes (a Tailwind slate
     ramp and Bootstrap alert greys). Each step is the dominant value that was
     already in use, so mapping onto it does not change appearance. */
  --n-900: #102033;
  --n-800: #1e293b;
  --n-700: #334155;
  --n-600: #475569;
  --n-500: #64748b;
  --n-400: #94a3b8;
  --n-300: #cbd5e1;
  --n-250: #e2e8f0;
  --n-200: #e5e7eb;
  --n-150: #eef0f2;
  --n-100: #f1f5f9;
  --n-50:  #f8fafc;
  --n-0:   #ffffff;

  /* Inverse surfaces never follow the theme: text on a dark fill stays white,
     and a dark surface stays dark, in both light and dark mode. */
  --surface-inverse: #102033;
  --on-inverse: #ffffff;
  --on-inverse-muted: rgba(255,255,255,.82);
  --tint-green: rgb(232,242,236);
  --on-accent: #312f2e;

  /* ── Status: success ─────────────────────────────────────────────────────── */
  --ok-fg:       #15803d;
  --ok-fg-soft:  #1a7a4a;
  --ok-bg:       #f0fdf4;
  --ok-bg-alt:   #d4edda;
  --ok-border:   #86efac;
  --ok-strong:   #22c55e;

  /* ── Status: warning / attention ─────────────────────────────────────────── */
  --warn-fg:        #9a3412;
  --warn-fg-dark:   #7c2d12;
  --warn-fg-alt:    #856404;
  --warn-bg:        #fff7ed;
  --warn-bg-alt:    #fff3cd;
  --warn-bg-soft:   #fffbeb;
  --warn-border:    #fed7aa;
  --warn-border-2:  #fde68a;
  --warn-strong:    #c2410c;
  --warn-fg-flash:  #f57f17;
  --warn-amber:     #fbbf24;
  --warn-amber-2:   #eab308;

  /* ── Status: danger ──────────────────────────────────────────────────────── */
  --bad-fg:         #b91c1c;
  --bad-fg-strong:  #be123c;
  --bad-fg-dark:    #881337;
  --bad-fg-alt:     #721c24;
  --bad-bg:         #fef2f2;
  --bad-bg-alt:     #f8d7da;
  --bad-bg-soft:    #fff1f2;
  --bad-border:     #fca5a5;
  --bad-strong:     #f87171;

  /* ── Status: info ────────────────────────────────────────────────────────── */
  --info-fg:      #1565c0;
  --info-strong:  #2563eb;
  --info-bg:      #eff6ff;
  --info-bg-soft: #edf4fa;
  --info-border:  #9ab2cb;

  /* ── Accents ─────────────────────────────────────────────────────────────── */
  --gold:        #c4a35a;
  --gold-dark:   #8b6914;
  --orange:      #f97316;
  --navy:        #1e3a5f;

  /* ── Semantic aliases (names unchanged — every component uses these) ─────── */
  --primary:    var(--sk-green-dark);
  --primary-dk: var(--sk-green-deep);
  --accent:     var(--sk-olive-mid);
  --cream:      var(--sk-cream);
  --warm-gray:  var(--sk-gray-mid);
  --text:       var(--sk-brown-dark);
  --text-lt:    var(--sk-gray-mid);
  --white:      var(--sk-white);
  --border:     rgb(210,203,195);
  --success:    var(--ok-fg);
  --error:      var(--bad-fg);
  --info:       var(--info-strong);
  --muted:      var(--n-500);
  --surface:    var(--white);
  --surface-2:  var(--n-50);
  --surface-alt: var(--n-50);
  --card-bg:     var(--n-50);
  --error-bg:    var(--bad-bg);

  /* ── Spacing — the 4/8/12/16/24/32 rhythm shared by minimal and ant ─────── */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* ── Type scale — 12/14/16/20/24/32 ─────────────────────────────────────── */
  --font-sans: 'Avenir', 'Proxima Nova', 'DIN Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --text-xs:   .75rem;
  --text-sm:   .875rem;
  --text-base: 1rem;
  --text-lg:   1.25rem;
  --text-xl:   1.5rem;
  --text-2xl:  2rem;
  --leading-tight: 1.25;
  --leading:       1.5;

  /* ── Shape and depth ─────────────────────────────────────────────────────── */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  18px;
  --radius-pill: 99px;
  --elev-1: 0 1px 2px rgba(49,47,46,.08);
  --elev-2: 0 2px 8px rgba(49,47,46,.12);
  --elev-3: 0 8px 32px rgba(49,47,46,.2);
  --shadow: var(--elev-2);

  /* ── Focus — one visible ring, keyboard-first (WCAG 2.2 AA) ─────────────── */
  --focus-color: var(--sk-green-dark);
  --focus-soft:  rgba(38,100,69,.25);
  --focus-ring:  0 0 0 3px var(--focus-soft);

  /* ── Layout ──────────────────────────────────────────────────────────────── */
  --container: 1100px;
  --container-sm: 600px;
  --tap-target: 44px;

  /* ── Motion ──────────────────────────────────────────────────────────────── */
  --dur-1: .12s;
  --dur-2: .2s;
  --ease: cubic-bezier(.4,0,.2,1);

  /* ── Depth ordering ──────────────────────────────────────────────────────── */
  --z-nav: 100;
  --z-overlay: 9000;
  --z-skip: 9999;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: var(--leading);
  -webkit-text-size-adjust: 100%;
}

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

/* One focus treatment for the whole app. Buttons, links, inputs and summary
   all get a visible ring; nothing relies on the browser default alone. */
:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: var(--z-skip);
  background: var(--surface-inverse);
  color: var(--on-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-weight: 600;
  transition: top var(--dur-2) var(--ease);
}
.skip-link:focus { top: var(--space-3); text-decoration: none; }

.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;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.navbar {
  background: var(--sk-green-dark);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
  position: relative;
  z-index: var(--z-nav);
}
.navbar-brand {
  color: var(--on-inverse);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}
.navbar-brand span { font-size: var(--text-sm); font-weight: 400; opacity: .85; }
.navbar-links a {
  color: var(--on-inverse);
  margin-left: var(--space-5);
  font-size: var(--text-sm);
  opacity: .9;
  white-space: nowrap;
}
.navbar-links a:hover { opacity: 1; text-decoration: none; }
.navbar-links a.active { opacity: 1; border-bottom: 2px solid rgba(255,255,255,.8); padding-bottom: .1rem; }

/* Staff nav: grouped links, rendered by admin/js/admin-nav.js. These rules used
   to be injected into <head> at runtime, which caused a flash of unstyled nav
   and kept them invisible to the stylesheet. */
.navbar-links { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .1rem; }
.nav-group { display: flex; align-items: center; gap: .15rem; }
.nav-group + .nav-group { border-left: 1px solid rgba(255,255,255,.25); padding-left: .65rem; margin-left: .35rem; }
.nav-group-label { font-size: var(--text-xs); letter-spacing: .08em; text-transform: uppercase; opacity: .6; margin-right: .25rem; }
.navbar-links a[aria-current="page"] { opacity: 1; border-bottom: 2px solid rgba(255,255,255,.85); padding-bottom: .1rem; }

/* Sortable table headers (admin/js/makeups.js). */
.th-sort { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: inherit; cursor: pointer; text-align: left; }
.th-sort:hover { text-decoration: underline; }
.th-sort::after { content: attr(data-indicator); margin-left: .3rem; opacity: .8; }

/* Hamburger toggle (mobile) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all var(--dur-2) var(--ease);
}

@media (max-width: 600px) {
  .navbar { padding: .6rem var(--space-4); flex-wrap: wrap; }
  .navbar-brand span { display: none; }
  .nav-toggle { display: flex; }
  .navbar-links {
    display: none;
    flex-direction: column;
    width: 100%;
    padding: var(--space-2) 0 var(--space-1);
    gap: .1rem;
  }
  .navbar-links.open { display: flex; }
  .navbar-links a {
    margin-left: 0;
    padding: var(--space-2) var(--space-1);
    font-size: .95rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .navbar-links a:last-child { border-bottom: none; }
}
.navbar-links .nav-badge {
  background: rgba(255,255,255,.35);
  border-radius: var(--radius-pill);
  padding: .05em .45em;
  font-size: var(--text-xs);
  margin-left: var(--space-1);
}

/* ── Layout containers ───────────────────────────────────────────────────── */
.container    { max-width: var(--container); margin: 0 auto; padding: var(--space-5); }
.container-sm { max-width: var(--container-sm); margin: 0 auto; padding: var(--space-5); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--elev-2);
  margin-bottom: var(--space-5);
}
.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--primary-dk);
  margin-bottom: var(--space-4);
  line-height: var(--leading-tight);
}

/* ── Stat boxes ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.stat-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.2rem var(--space-4);
  text-align: center;
  box-shadow: var(--elev-2);
  border-top: 4px solid var(--primary);
}
.stat-box.gold  { border-top-color: var(--accent); }
.stat-box.green { border-top-color: var(--success); }
.stat-box.red   { border-top-color: var(--error); }
.stat-number { font-size: var(--text-2xl); font-weight: 700; color: var(--text); line-height: var(--leading-tight); }
.stat-label  { font-size: var(--text-xs); color: var(--text-lt); text-transform: uppercase; letter-spacing: .05em; margin-top: var(--space-1); }

/* ── Tables — dense, scannable, ant-style header treatment ───────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th {
  background: var(--sk-warm-light);
  color: var(--warm-gray);
  text-align: left;
  padding: .65rem .9rem;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
td { padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--tint-green); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2em .6em;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: var(--leading-tight);
}
.badge-green  { background: var(--ok-bg);      color: var(--ok-fg); }
.badge-red    { background: var(--bad-bg);     color: var(--bad-fg); }
.badge-gold   { background: var(--sk-olive-light); color: var(--sk-green-deep); }
.badge-gray   { background: var(--n-100);      color: var(--n-600); }
.badge-blue   { background: var(--info-bg);    color: var(--info-fg); }
.badge-orange { background: var(--warn-bg);    color: var(--warn-fg); }

/* ── Buttons — every state is explicit ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: var(--leading-tight);
  transition: opacity var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  text-align: center;
  text-decoration: none;
}
.btn:hover { opacity: .88; transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); opacity: 1; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.btn[aria-busy="true"] { cursor: progress; opacity: .7; }
.btn-primary   { background: var(--primary);   color: var(--white); }
.btn-secondary { background: var(--warm-gray); color: var(--white); }
.btn-gold      { background: var(--accent);    color: var(--on-accent); }
.btn-danger    { background: var(--error);     color: var(--white); }
.btn-success   { background: var(--success);   color: var(--white); }
.btn-outline   { background: transparent; border: 2px solid var(--primary); color: var(--primary-dk); }
.btn-sm        { padding: .3rem .75rem; font-size: var(--text-xs); min-height: 2rem; }
.btn-lg        { padding: .85rem var(--space-6); font-size: var(--text-lg); border-radius: var(--radius); min-height: var(--tap-target); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }
label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--warm-gray); margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=tel], input[type=date],
input[type=time], input[type=number], input[type=password],
select, textarea {
  width: 100%;
  min-height: 2.4rem;
  padding: .55rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--white);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--bad-fg);
  box-shadow: 0 0 0 3px rgba(185,28,28,.18);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Alerts / Flash ──────────────────────────────────────────────────────── */
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
}
.flash-success { background: var(--ok-bg);   color: var(--ok-fg);   border-left: 4px solid var(--ok-strong); }
.flash-error   { background: var(--bad-bg);  color: var(--bad-fg);  border-left: 4px solid var(--bad-strong); }
.flash-info    { background: var(--info-bg); color: var(--info-fg); border-left: 4px solid var(--info-strong); }
.flash-warning { background: var(--warn-bg-soft); color: var(--warn-fg); border-left: 4px solid var(--warn-amber); }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.page-title { font-size: var(--text-xl); font-weight: 700; color: var(--text); line-height: var(--leading-tight); }
.page-purpose { max-width: 62ch; color: var(--text-lt); margin: -.25rem 0 var(--space-5); font-size: var(--text-sm); }

/* ── Divider ─────────────────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-lt); }
.empty-state .icon { font-size: var(--text-2xl); margin-bottom: var(--space-3); }

/* ── Mode tabs — one surface, several jobs ───────────────────────────────── */
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  padding: var(--space-1);
  background: var(--sk-warm-light);
  border-radius: var(--radius-lg);
}
.mode-tab {
  flex: 1 1 auto;
  min-height: var(--tap-target);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--warm-gray);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.mode-tab:hover { color: var(--primary-dk); }
.mode-tab[aria-selected="true"] {
  background: var(--white);
  color: var(--primary-dk);
  box-shadow: var(--elev-1);
}
.mode-panel[hidden] { display: none; }

/* ── Kiosk / PIN ─────────────────────────────────────────────────────────── */
.kiosk-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sk-green-dark) 0%, var(--sk-green-mid) 100%);
  padding: var(--space-5);
}
.kiosk-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2.5rem var(--space-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--elev-3);
  text-align: center;
}
.kiosk-title { font-size: var(--text-xl); font-weight: 700; color: var(--primary-dk); margin-bottom: var(--space-1); }
.kiosk-subtitle { font-size: var(--text-sm); color: var(--text-lt); margin-bottom: var(--space-6); }
.pin-display { font-size: 2.5rem; letter-spacing: .5rem; min-height: 3rem; margin-bottom: var(--space-5); color: var(--text); font-weight: 700; }
.pin-btn-submit {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--space-4);
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--dur-1) var(--ease);
  touch-action: manipulation;
}
.pin-btn-submit:hover    { opacity: .88; }
.pin-btn-submit:disabled { opacity: .45; cursor: not-allowed; }

/* ── GPS status ──────────────────────────────────────────────────────────── */
.gps-status {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  display: none;
}
.gps-status.checking {
  background: var(--sk-warm-light);
  color: var(--sk-brown-dark);
  display: flex;
  align-items: center;
  gap: .6rem;
  justify-content: center;
}
.gps-status.error {
  background: var(--bad-bg);
  color: var(--bad-fg);
  border-left: 4px solid var(--bad-strong);
  display: block;
}

/* ── Today's sessions banner ─────────────────────────────────────────────── */
.sessions-banner {
  background: var(--tint-green);
  border: 1.5px solid var(--sk-green-light);
  border-radius: var(--radius);
  padding: .65rem .9rem;
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  text-align: left;
}
.sessions-banner .session-item { color: var(--primary-dk); font-weight: 600; }
.sessions-banner .no-sessions  { color: var(--text-lt); font-style: italic; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-wrap { background: var(--sk-warm-light); border-radius: var(--radius-pill); height: 12px; overflow: hidden; margin: var(--space-2) 0; }
.progress-bar { height: 100%; background: var(--sk-green-mid); border-radius: var(--radius-pill); transition: width .4s var(--ease); }
.progress-bar.over  { background: var(--success); }
.progress-bar.under { background: var(--accent); }
.progress-bar.behind { background: var(--error); }

/* ── Obligation badges ───────────────────────────────────────────────────── */
.obligation-card {
  border-radius: var(--radius);
  padding: .6rem .9rem;
  margin-bottom: var(--space-2);
  border-left: 4px solid var(--border);
  background: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.obligation-card.ok       { border-color: var(--success); }
.obligation-card.upcoming { border-color: var(--accent); }
.obligation-card.urgent   { border-color: var(--orange); }
.obligation-card.overdue  { border-color: var(--error); background: var(--bad-bg-soft); }

/* ── Camera widget ───────────────────────────────────────────────────────── */
.camera-widget { margin-bottom: var(--space-5); text-align: center; }
.camera-widget video { width: 100%; max-width: 320px; border-radius: var(--radius-lg); background: var(--surface-inverse); display: block; margin: 0 auto; }
.camera-controls { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; margin-top: .6rem; }
.camera-preview { width: 120px; height: 90px; object-fit: cover; border-radius: var(--radius); margin: var(--space-3) auto 0; border: 2px solid var(--primary); display: none; }

/* ── Spinner — loading state ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid var(--sk-green-light);
  border-top-color: var(--sk-green-dark);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-overlay);
}

/* ── Utilities ───────────────────────────────────────────────────────────────
   These exist so no page needs an inline style attribute. Each is a token, not
   a value. Layout only — anything expressing a design decision belongs in a
   component class above. */

/* display */
.u-flex        { display: flex; }
.u-inline-flex { display: inline-flex; }
.u-block       { display: block; }
.u-inline-block{ display: inline-block; }
.u-grid        { display: grid; }
.u-hidden      { display: none; }

/* flex */
.u-wrap        { flex-wrap: wrap; }
.u-nowrap      { flex-wrap: nowrap; }
.u-col         { flex-direction: column; }
.u-flex-1      { flex: 1 1 auto; }
.u-items-start { align-items: flex-start; }
.u-items-center{ align-items: center; }
.u-items-end   { align-items: flex-end; }
.u-items-baseline { align-items: baseline; }
.u-justify-start  { justify-content: flex-start; }
.u-justify-center { justify-content: center; }
.u-justify-between{ justify-content: space-between; }
.u-justify-end    { justify-content: flex-end; }
.u-self-start  { align-self: flex-start; }
.u-self-center { align-self: center; }

/* gap */
.u-gap-1 { gap: var(--space-1); }
.u-gap-2 { gap: var(--space-2); }
.u-gap-3 { gap: var(--space-3); }
.u-gap-4 { gap: var(--space-4); }
.u-gap-5 { gap: var(--space-5); }

/* margin */
.u-m-0    { margin: 0; }
.u-mt-0   { margin-top: 0; }
.u-mt-1   { margin-top: var(--space-1); }
.u-mt-2   { margin-top: var(--space-2); }
.u-mt-3   { margin-top: var(--space-3); }
.u-mt-4   { margin-top: var(--space-4); }
.u-mt-5   { margin-top: var(--space-5); }
.u-mb-0   { margin-bottom: 0; }
.u-mb-1   { margin-bottom: var(--space-1); }
.u-mb-2   { margin-bottom: var(--space-2); }
.u-mb-3   { margin-bottom: var(--space-3); }
.u-mb-4   { margin-bottom: var(--space-4); }
.u-mb-5   { margin-bottom: var(--space-5); }
.u-ml-0   { margin-left: 0; }
.u-ml-1   { margin-left: var(--space-1); }
.u-ml-2   { margin-left: var(--space-2); }
.u-mr-1   { margin-right: var(--space-1); }
.u-mr-2   { margin-right: var(--space-2); }
.u-mx-auto{ margin-left: auto; margin-right: auto; }
.u-my-0   { margin-top: 0; margin-bottom: 0; }

/* padding */
.u-p-0  { padding: 0; }
.u-p-1  { padding: var(--space-1); }
.u-p-2  { padding: var(--space-2); }
.u-p-3  { padding: var(--space-3); }
.u-p-4  { padding: var(--space-4); }
.u-py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.u-py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.u-py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.u-px-1 { padding-left: var(--space-1); padding-right: var(--space-1); }

/* typography */
.u-fs-xs   { font-size: var(--text-xs); }
.u-fs-sm   { font-size: var(--text-sm); }
.u-fs-base { font-size: var(--text-base); }
.u-fs-lg   { font-size: var(--text-lg); }
.u-fs-xl   { font-size: var(--text-xl); }
.u-fw-400  { font-weight: 400; }
.u-fw-500  { font-weight: 500; }
.u-fw-600  { font-weight: 600; }
.u-fw-700  { font-weight: 700; }
.u-text-left   { text-align: left; }
.u-text-center { text-align: center; }
.u-text-right  { text-align: right; }
.u-italic   { font-style: italic; }
.u-uppercase{ text-transform: uppercase; }
.u-tracked  { letter-spacing: .05em; }
.u-leading-tight { line-height: var(--leading-tight); }
.u-nowrap-text { white-space: nowrap; }
.u-mono     { font-family: var(--font-mono); }

/* colour — semantic only */
.u-text-muted   { color: var(--text-lt); }
/* Legacy name used across admin markup and JS templates. */
.muted { color: var(--text-lt); font-size: var(--text-sm); }
.u-text-strong  { color: var(--text); }
.u-text-primary { color: var(--primary-dk); }
.u-text-ok      { color: var(--ok-fg); }
.u-text-warn    { color: var(--warn-fg); }
.u-text-danger  { color: var(--bad-fg); }
.u-text-white   { color: var(--on-inverse); }
.u-bg-transparent { background: transparent; }
.u-bg-surface   { background: var(--white); }
.u-bg-soft      { background: var(--n-50); }

/* sizing */
.u-w-full   { width: 100%; }
.u-w-auto   { width: auto; }
.u-mw-full  { max-width: 100%; }
.u-mw-sm    { max-width: var(--container-sm); }
.u-mw-prose { max-width: 62ch; }
.u-minw-0   { min-width: 0; }
.u-h-full   { height: 100%; }

/* misc */
.u-radius     { border-radius: var(--radius); }
.u-radius-lg  { border-radius: var(--radius-lg); }
.u-radius-pill{ border-radius: var(--radius-pill); }
.u-border     { border: 1px solid var(--border); }
.u-border-0   { border: none; }
.u-relative   { position: relative; }
.u-pointer    { cursor: pointer; }
.u-overflow-x { overflow-x: auto; }
.u-object-contain { object-fit: contain; }
.u-opacity-70 { opacity: .7; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .nav-group-label { display: none; }
  .container { padding: var(--space-4); }
}
@media (max-width: 768px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .card        { padding: var(--space-4); }
}
@media (max-width: 600px) {
  .container, .container-sm { padding: var(--space-3); }
  .mode-tabs { flex-direction: column; }
  .mode-tab  { width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .kiosk-card  { padding: 1.75rem var(--space-4); }
  .page-title  { font-size: var(--text-lg); }
  .btn         { width: 100%; }
  .btn-sm      { width: auto; }
}

/* ── Dark mode ──────────────────────────────────────────────────────────────
   The neutral ramp inverts so anything built on --n-* adapts without a
   per-component override. Status families are redeclared rather than
   re-targeted per class. */
.dark {
  --n-900: #e8eaed;
  --n-800: #dfe3e8;
  --n-700: #c9d1da;
  --n-600: #b6c0cb;
  --n-500: #9aa6b3;
  --n-400: #6b7684;
  --n-300: #4a545f;
  --n-250: #3b444e;
  --n-200: #353c45;
  --n-150: #2c323a;
  --n-100: #262b32;
  --n-50:  #1e2329;
  --n-0:   #12161a;

  --ok-fg:      #a5d6a7;
  --ok-bg:      rgb(27,50,28);
  --ok-bg-alt:  rgb(27,50,28);
  --ok-border:  rgb(46,84,48);
  --warn-fg:    #ffcc80;
  --warn-bg:    rgb(50,30,10);
  --warn-bg-alt: rgb(50,40,10);
  --warn-bg-soft: rgb(50,40,10);
  --warn-fg-flash: #ffe082;
  --warn-border: rgb(84,58,20);
  --bad-fg:     #ef9a9a;
  --bad-bg:     rgb(50,20,20);
  --bad-bg-alt: rgb(50,20,20);
  --bad-bg-soft: rgb(45,20,20);
  --bad-border: rgb(84,32,32);
  --info-fg:    #90caf9;
  --info-bg:    rgb(20,35,55);

  --primary:    rgb(93,150,122);
  --primary-dk: rgb(140,196,165);
  --accent:     rgb(183,202,121);
  --cream:      rgb(24,26,27);
  --warm-gray:  rgb(160,157,154);
  --text:       rgb(220,215,208);
  --text-lt:    rgb(140,137,133);
  --white:      rgb(32,35,36);
  --border:     rgb(55,52,49);
  --shadow:     0 2px 8px rgba(0,0,0,.4);
  --elev-1:     0 1px 2px rgba(0,0,0,.5);
  --elev-2:     0 2px 8px rgba(0,0,0,.4);
  --elev-3:     0 8px 32px rgba(0,0,0,.6);
  --focus-color: rgb(140,196,165);
  --focus-soft: rgba(140,196,165,.3);
  --sk-warm-light: rgb(38,41,42);
  --sk-green-light: rgb(38,70,55);
  --sk-green-mid:   rgb(93,150,122);
  --sk-green-dark:  rgb(55,100,76);
  --sk-green-deep:  rgb(140,196,165);
  --sk-brown-dark:  rgb(220,215,208);
  --sk-gray-mid:    rgb(140,137,133);
  --sk-cream:       rgb(24,26,27);
  --sk-olive-light: rgb(50,58,30);
  --sk-olive-mid:   rgb(140,158,80);
  background: rgb(18,20,21);
  color-scheme: dark;
  --info-bg-soft: rgb(20,35,55);
  --info-border:  rgb(45,70,100);
  --tint-green:   rgb(38,48,42);
}

.dark body { background: rgb(18,20,21); }
.dark .navbar { background: rgb(30,45,38); }
.dark th { background: rgb(38,41,42); color: rgb(160,157,154); }
.dark td { border-bottom-color: rgb(45,42,39); }
.dark tr:hover td { background: rgb(38,48,42); }
.dark input, .dark select, .dark textarea {
  background: rgb(38,41,42);
  color: rgb(220,215,208);
  border-color: rgb(65,62,58);
}
.dark input:focus, .dark select:focus, .dark textarea:focus {
  border-color: var(--primary);
}
.dark .kiosk-body { background: linear-gradient(135deg, rgb(22,38,30) 0%, rgb(38,65,52) 100%); }
.dark .obligation-card { background: var(--white); }
.dark .sessions-banner { background: rgb(28,40,33); border-color: rgb(50,80,62); }
.dark .mode-tabs { background: rgb(38,41,42); }
.dark .mode-tab[aria-selected="true"] { background: rgb(48,52,55); }

/* Dark mode toggle button */
#dark-toggle {
  background: none;
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: var(--radius-pill);
  color: var(--on-inverse);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-xs);
  padding: .2rem .65rem;
  margin-left: var(--space-4);
  opacity: .85;
  transition: opacity var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
  white-space: nowrap;
  line-height: 1.6;
}
#dark-toggle:hover { opacity: 1; border-color: rgba(255,255,255,.7); }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  .navbar, .btn, form, .mode-tabs, .skip-link { display: none !important; }
  body { background: #fff; }
  table th { background: #eee !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
