/* Knights Hall Pass: shared tokens and components in St. Thomas Aquinas black
   and gold. Every color a rule paints comes from a token here, so dark mode
   is one block below. */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;

  --canvas: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --surface-3: #f1ede3;
  --ink: #1b1d22;
  --slate: #555a64;
  --muted: #80858f;
  --line: #e7e2d7;
  --line-strong: #d4cdbd;

  --chrome: #16181c;
  --chrome-2: #23262c;
  --chrome-3: #2f3239;
  --chrome-ink: #f3efe4;
  --chrome-muted: #a9a595;

  --gold: #c9a13b;
  --gold-bright: #e6c469;
  --gold-rgb: 230, 196, 105;
  --gold-ink: #7d6013;
  --gold-soft: #faf3e0;
  --gold-line: #ecd9a3;
  --on-gold: #211a07;

  --chart: #a8831f;
  --chart-track: #f1e6c6;

  --red: #b8433d;
  --red-soft: #fcebea;
  --red-line: #f1c4c1;
  --green: #2c7a57;
  --green-soft: #e8f4ee;
  --green-line: #bfe0cf;
  --blue: #2b67ad;
  --blue-soft: #e9f1fb;
  --blue-line: #bcd3ef;
  --amber: #a86412;
  --amber-soft: #fdf1e0;
  --purple: #6b55a3;
  --purple-soft: #f0ecf8;

  --shadow-1: 0 1px 2px rgba(22, 24, 28, .05), 0 1px 3px rgba(22, 24, 28, .04);
  --shadow-2: 0 2px 4px rgba(22, 24, 28, .04), 0 6px 16px rgba(22, 24, 28, .06);
  --shadow-3: 0 10px 20px rgba(22, 24, 28, .08), 0 24px 56px rgba(22, 24, 28, .14);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--gold);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --canvas: #0f0f0e;
  --surface: #1a1a18;
  --surface-2: #211f1c;
  --surface-3: #2a2823;
  --ink: #f4f0e6;
  --slate: #cbc4b4;
  --muted: #9d9686;
  --line: #34322c;
  --line-strong: #4d4a3f;
  --chrome: #0b0b0a;
  --chrome-2: #161614;
  --chrome-3: #22211d;
  --gold-ink: #e6c469;
  --gold-soft: #2c2616;
  --gold-line: #574a24;
  --chart: #b08c30;
  --chart-track: #332c19;
  --red: #f08a82;
  --red-soft: #3a1c1a;
  --red-line: #6b2f2b;
  --green: #74cfa3;
  --green-soft: #15291f;
  --green-line: #2a5a43;
  --blue: #8fbaf0;
  --blue-soft: #16233a;
  --blue-line: #2c4a75;
  --amber: #f0b060;
  --amber-soft: #33240f;
  --purple: #b6a4e8;
  --purple-soft: #231e36;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-3: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0f0f0e;
    --surface: #1a1a18;
    --surface-2: #211f1c;
    --surface-3: #2a2823;
    --ink: #f4f0e6;
    --slate: #cbc4b4;
    --muted: #9d9686;
    --line: #34322c;
    --line-strong: #4d4a3f;
    --chrome: #0b0b0a;
    --chrome-2: #161614;
    --chrome-3: #22211d;
    --gold-ink: #e6c469;
    --gold-soft: #2c2616;
    --gold-line: #574a24;
    --chart: #b08c30;
    --chart-track: #332c19;
    --red: #f08a82;
    --red-soft: #3a1c1a;
    --red-line: #6b2f2b;
    --green: #74cfa3;
    --green-soft: #15291f;
    --green-line: #2a5a43;
    --blue: #8fbaf0;
    --blue-soft: #16233a;
    --blue-line: #2c4a75;
    --amber: #f0b060;
    --amber-soft: #33240f;
    --purple: #b6a4e8;
    --purple-soft: #231e36;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, .35);
    --shadow-3: 0 16px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

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

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--gold-ink); }
[hidden] { display: none !important; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible { outline: 0; box-shadow: var(--focus); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-family: var(--font-display); color: var(--ink); }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
h2 { font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
h3 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.slate { color: var(--slate); }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { margin: 0 0 6px; color: var(--gold-ink); font-size: 11px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.ui-icon { flex: 0 0 auto; display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink);
  font-weight: 620; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s var(--ease);
}
.btn:hover { border-color: var(--gold); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { border-color: var(--chrome); background: var(--chrome); color: #fff; }
.btn.primary:hover { background: var(--chrome-3); }
:root[data-theme="dark"] .btn.primary { border-color: var(--gold-bright); background: var(--gold-bright); color: var(--on-gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { border-color: var(--gold-bright); background: var(--gold-bright); color: var(--on-gold); } }
.btn.gold { border-color: var(--gold-bright); background: var(--gold-bright); color: var(--on-gold); }
.btn.gold:hover { background: #dcb750; }
.btn.danger { border-color: var(--red-line); color: var(--red); background: var(--surface); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: var(--surface); } /* dark text on the lighter dark-mode red */
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { min-height: 48px; padding: 0 22px; font-size: 15.5px; border-radius: 12px; }
.btn.icon-only { width: 40px; padding: 0; }
.btn.sm.icon-only { width: 32px; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; align-content: start; }
.field > span, .label { color: var(--slate); font-size: 12.5px; font-weight: 650; }
.field small, .hint { color: var(--muted); font-size: 12.5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], input[type="time"], input[type="tel"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); outline: 0; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(var(--gold-rgb), .25); }
input::placeholder, textarea::placeholder { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; align-items: start; }
.form-error { min-height: 20px; margin: 0 0 10px; color: var(--red); font-size: 13px; font-weight: 600; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--chrome); flex: 0 0 auto; }
.check strong { display: block; font-size: 13.5px; font-weight: 620; }
.check span { color: var(--muted); font-size: 12.5px; }

/* Toggle switch built on a checkbox */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s var(--ease); }
.switch input:checked + .track { background: var(--chart); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

/* ---------- Cards, chips, tables ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; flex-wrap: wrap; }
.card-head p { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 4px 20px 20px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--slate); }
.chip.gold { background: var(--gold-soft); color: var(--gold-ink); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.purple { background: var(--purple-soft); color: var(--purple); }
.chip .ui-icon { width: 13px; height: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
table.data th button.sort { border: 0; background: none; padding: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; display: inline-flex; align-items: center; gap: 4px; }
table.data th button.sort[aria-sort] { color: var(--ink); }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tr.clickable { cursor: pointer; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
.cell-name strong { display: block; font-weight: 620; }
.cell-name span { color: var(--muted); font-size: 12.5px; }

.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; background: var(--gold-soft); color: var(--gold-ink); font-weight: 750; font-size: 13px; letter-spacing: .02em; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 20px; color: var(--muted); text-align: center; }
.empty .ui-icon { width: 34px; height: 34px; color: var(--line-strong); }
.empty strong { color: var(--slate); font-size: 14.5px; }

/* Meter: filled track in the chart hue on a lighter step of the same ramp. */
.meter { position: relative; height: 6px; border-radius: 99px; background: var(--chart-track); overflow: hidden; }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--chart); transition: width .4s var(--ease); }
.meter.warn > i { background: var(--amber); }
.meter.bad > i { background: var(--red); }

/* ---------- Modal, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(12, 12, 10, .5); backdrop-filter: blur(3px); animation: fade .15s ease; }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-3); animation: pop .2s var(--ease); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 8px; }
.modal-head p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.modal-body { padding: 10px 24px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 14px 24px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--chrome); color: #fff; box-shadow: var(--shadow-3); font-weight: 560; animation: pop .2s var(--ease); }
.toast.error { background: var(--red); }
.toast .ui-icon { color: var(--gold-bright); }
.toast.error .ui-icon { color: #fff; }

.secret-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px dashed var(--gold); border-radius: 12px; background: var(--gold-soft); }
.secret-box code { font-size: 18px; font-weight: 700; letter-spacing: .02em; color: var(--ink); word-break: break-all; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--gold-line); background: var(--gold-soft); color: var(--ink); }
.notice .ui-icon { color: var(--gold-ink); margin-top: 1px; }
.notice.red { border-color: var(--red-line); background: var(--red-soft); }
.notice.red .ui-icon { color: var(--red); }
.notice.green { border-color: var(--green-line); background: var(--green-soft); }
.notice.green .ui-icon { color: var(--green); }
.notice.blue { border-color: var(--blue-line); background: var(--blue-soft); }
.notice.blue .ui-icon { color: var(--blue); }
.notice strong { display: block; }
.notice p { color: var(--slate); font-size: 13px; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--gold); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
