/* East 2 West portal: self-hosted design system. No web fonts, no CDN, no inline style (CSP 'self').
   Tokens first, then base, layout, components, desk, resident, charts, phone, print. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;

  --paper: #f6f4ef;          /* page */
  --surface: #ffffff;        /* cards */
  --surface-2: #f0ede6;      /* table heads, wells */
  --ink: #17201f;
  --ink-2: #4c5856;          /* secondary text */
  --line: #dfdad0;
  --brand: #0e6b66;          /* pine teal */
  --brand-ink: #ffffff;
  --brand-soft: #e2f1ee;
  --accent: #b8692b;         /* Texas sunset */
  --accent-soft: #f8ebdf;
  --ok: #1f7a3d; --ok-soft: #e4f3e8;
  --warn: #8a5a00; --warn-soft: #fbf1d9;
  --bad: #b3261e; --bad-soft: #fbe7e5;
  --info: #22568f; --info-soft: #e5eef9;
  --focus: #3b82f6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(15 30 28 / 6%), 0 6px 24px rgb(15 30 28 / 6%);
  --gutter: clamp(16px, 4vw, 32px);
  --tap: 44px;

  /* charts (phase 6) */
  --chart-bg: #f1efe9; --chart-ink: #4a5359; --chart-bar: #0e6b66; --chart-up: #1f7a3d; --chart-down: #b3261e;
  --s0: #0e6b66; --s1: #b8692b; --s2: #5b4b8a; --s3: #7a7a2e;
}
/* Portal is pinned to the light scheme (Will 2026-11-16): no dark-mode override.
   color-scheme: light above keeps form controls and scrollbars light too. */

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  font: 16px/1.55 var(--font); color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 0.6em; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); font-weight: 750; }
h2 { font-size: 1.25rem; font-weight: 700; margin-top: 1.4em; }
h3 { font-size: 1.05rem; font-weight: 700; }
.card > h2:first-child, .card > h1 + h2 { margin-top: 0; }
p, ul, ol, dl { margin: 0 0 1em; }
p { text-wrap: pretty; }
a { color: var(--brand); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.05em 0.35em; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
pre code { background: none; border: 0; padding: 0; }
img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-soft); }
.muted, .hint { color: var(--ink-2); }
.hint { font-size: 0.9rem; }
small, .small { font-size: 0.875rem; }

/* ------------------------------------------------------------------ layout */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 12px var(--gutter); padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap);
  font-weight: 750; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none;
}
.brand::before {
  content: ""; width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: #fff url("/static/logo.png") center / 28px no-repeat;
  box-shadow: inset 0 0 0 1px var(--line);
}
.top nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.top nav a, .top nav button.link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: 0.95rem;
}
.top nav a:hover, .top nav button.link:hover { background: var(--surface-2); color: var(--ink); }
.top nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }

main {
  flex: 1; width: 100%; max-width: 920px; margin: 0 auto;
  padding: clamp(16px, 3vw, 32px) var(--gutter) 48px;
  padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.foot {
  padding: 20px var(--gutter); padding-bottom: max(20px, env(safe-area-inset-bottom));
  text-align: center; color: var(--ink-2); font-size: 0.875rem; border-top: 1px solid var(--line);
}

/* -------------------------------------------------------------- components */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(18px, 3vw, 28px); margin: 0 0 20px;
}
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 20px; }
.cards > .card { margin: 0; }

.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 55%),
    linear-gradient(160deg, color-mix(in srgb, var(--brand) 14%, var(--surface)) 0%, var(--surface) 70%);
}
.hero h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); }
.hero-photo {
  display: block; width: 100%; height: clamp(130px, 20vw, 210px);
  object-fit: cover; border-radius: var(--radius-sm); margin: 0 0 1.2rem;
}

/* buttons */
button, .button, input[type="submit"] {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: 11px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font: 650 1rem/1 var(--font); letter-spacing: 0.005em;
  text-decoration: none; cursor: pointer; box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
}
button:hover, .button:hover { filter: brightness(1.07); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: progress; }
button.secondary, .button.secondary {
  background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: none;
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); filter: none; }
button.danger, .button.danger { background: var(--bad); color: #fff; }
button.link {
  background: none; border: 0; box-shadow: none; padding: 0; min-height: 0; color: var(--brand);
  font-weight: 550; text-decoration: underline; text-underline-offset: 0.18em;
}
form.inline { display: inline; margin: 0; }

/* forms */
form { margin: 0 0 1em; }
form > label, form > div > label, .grid-form label, fieldset > label {
  display: grid; gap: 6px; margin: 0 0 14px; font-weight: 600; font-size: 0.95rem;
}
input, select, textarea {
  font: 400 16px/1.4 var(--font); color: var(--ink);   /* 16px: no iPhone zoom */
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 70%, var(--ink-2));
  border-radius: 10px; padding: 10px 12px; min-height: var(--tap); width: 100%; max-width: 32rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent);
}
input[type="checkbox"], input[type="radio"] {
  width: 20px; height: 20px; min-height: 0; max-width: none; margin: 2px 0 0; padding: 0; flex: none;
  accent-color: var(--brand);
}
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
  display: flex; align-items: flex-start; gap: 10px; font-weight: 450; min-height: var(--tap); padding: 8px 0; margin: 0;
}
input[type="file"] { padding: 8px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 16px 6px; margin: 0 0 18px; }
legend { font-weight: 700; padding: 0 6px; }
.grid-form { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.grid-form button { margin-bottom: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters label { margin: 0; }
.filters input, .filters select { width: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }  /* honeypot */
input[inputmode="numeric"][autocomplete="one-time-code"] {
  font: 600 1.5rem/1 var(--mono); letter-spacing: 0.35em; text-align: center; max-width: 14rem;
}

/* messages */
.error, .warn, .note, .ok, .alert, .message, .bad, .confirm {
  border-radius: var(--radius-sm); padding: 12px 14px 12px 42px; position: relative; border: 1px solid transparent;
}
.error::before, .warn::before, .note::before, .ok::before, .alert::before, .message::before, .bad::before, .confirm::before {
  position: absolute; left: 14px; top: 11px; font-weight: 800; width: 18px; text-align: center;
}
.error, .bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.error::before, .bad::before { content: "!"; }
.warn, .alert, .confirm { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.warn::before, .alert::before, .confirm::before { content: "!"; }
.note, .message { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.note::before, .message::before { content: "i"; font-style: italic; font-family: Georgia, serif; }
.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.ok::before { content: "\2713"; }
td.bad, td.ok, td.warn, span.bad, span.ok, span.warn, li.bad, li.ok, li.warn {
  padding: inherit; background: none; border: 0; border-radius: 0;
}
td.bad::before, td.ok::before, td.warn::before, span.bad::before, span.ok::before, span.warn::before,
li.bad::before, li.ok::before, li.warn::before { content: none; }
.error a, .warn a, .note a, .alert a, .message a, .confirm a { color: inherit; font-weight: 650; }
.park-offline { font-weight: 600; }
.banners { display: grid; gap: 10px; margin-bottom: 20px; }
.banners > * { margin: 0; }
.next { margin-top: 1em; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 650; letter-spacing: 0.01em; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); vertical-align: middle;
}
.badge-review { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.status { color: var(--ink-2); font-weight: 450; }

/* lists */
.stats { list-style: none; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stats li { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.steps { list-style: none; counter-reset: step; padding: 0; display: grid; gap: 12px; margin: 1.25em 0 1.5em; }
.steps li { counter-increment: step; position: relative; padding: 4px 0 0 48px; min-height: 34px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 750;
}
dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
dt { color: var(--ink-2); font-weight: 600; }
dd { margin: 0; }
details { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 14px; margin: 0 0 14px; background: var(--surface); }
details[open] { padding-bottom: 12px; }
summary { cursor: pointer; font-weight: 650; min-height: var(--tap); display: flex; align-items: center; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "\25B8"; margin-right: 8px; color: var(--brand); transition: transform 0.15s ease; }
details[open] > summary::before { transform: rotate(90deg); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-2); font-weight: 700; position: sticky; top: 0; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
tr.row-error td { background: var(--bad-soft); }
tr.row-ok td { background: var(--ok-soft); }
td .button, td button { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
td.total, .total { font-weight: 750; }

/* public: pad board */
.board { list-style: none; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.board .pad {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 700;
}
.board .pad em { font-style: normal; font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.board .pad.state-open em::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.board .pad.state-held { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.board .pad.state-held em { color: var(--warn); }
.board .pad.state-issued { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.board .pad.state-issued em { color: var(--brand); }

/* the one-time key */
.key .passphrase { margin: 0.6em 0 0.4em; }
.passphrase code, .key code {
  display: block; padding: 18px 20px; border-radius: var(--radius); text-align: center; overflow-wrap: anywhere;
  font: 700 clamp(1.4rem, 1rem + 2.4vw, 2.2rem)/1.25 var(--mono); letter-spacing: 0.02em;
  background: var(--brand-soft); color: var(--brand); border: 2px dashed color-mix(in srgb, var(--brand) 45%, transparent);
  -webkit-user-select: all; user-select: all;
}
.spoken { color: var(--ink-2); font-size: 1.05rem; text-align: center; }
.keys code, .codes code { -webkit-user-select: all; user-select: all; }
.codes { columns: 2; list-style: none; padding: 0; }
.codes li { margin-bottom: 6px; }
img.qr { background: #fff; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* auth pages */
.auth { max-width: 460px; margin-left: auto; margin-right: auto; }
.auth input:not([type="checkbox"]):not([type="radio"]) { max-width: none; }
.auth button[type="submit"] { width: 100%; }
.terms h2 { margin-top: 1.6em; }

/* ------------------------------------------------------------------- desk */
body.desk main { max-width: 1240px; }
.desk-top nav { gap: 2px 4px; }
.desk-top nav a { font-size: 0.875rem; min-height: 34px; padding: 0 10px; }
.nav-group {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 6px 0 12px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent);
}
@media (min-width: 1100px) {
  body.desk { display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: 1fr; }
  body.desk .desk-top {
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; align-content: start; align-items: stretch;
    flex-direction: column; flex-wrap: nowrap; gap: 14px; padding: 18px 14px;
    border-bottom: 0; border-right: 1px solid var(--line); background: var(--surface);
  }
  body.desk .desk-top nav { flex-direction: column; flex-wrap: nowrap; margin: 0; gap: 1px; }
  body.desk .desk-top nav a { border-radius: 9px; }
  body.desk .nav-group { padding: 14px 10px 4px; min-height: 0; }
  body.desk main { margin: 0; padding-top: 28px; }
}
.desk .card { padding: clamp(16px, 2.4vw, 24px); }
.desk h1 { font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.9rem); }
.queue li, .results li { margin-bottom: 6px; }
.printable { background: var(--surface); }

/* --------------------------------------------------------------- resident */
.resident-nav { align-items: center; }

/* ----------------------------------------------------------------- charts */
svg.chart { display: block; width: 100%; max-width: 760px; height: auto; margin: 0.5rem 0 1rem; border-radius: var(--radius-sm); }
.chart-bg { fill: var(--chart-bg); }
.chart-label, .chart-value, .chart-legend, .chart-note { fill: var(--chart-ink); font-size: 12px; font-family: var(--font); }
.chart-note { font-size: 14px; }
.chart-bar { fill: var(--chart-bar); }
.chart-axis { stroke: var(--chart-ink); stroke-width: 1; opacity: 0.6; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.s0 { stroke: var(--s0); } .chart-line.s1 { stroke: var(--s1); }
.chart-line.s2 { stroke: var(--s2); } .chart-line.s3 { stroke: var(--s3); }
circle.chart-line.s0 { fill: var(--s0); } circle.chart-line.s1 { fill: var(--s1); }
.chart-legend.s0 { fill: var(--s0); } .chart-legend.s1 { fill: var(--s1); }
.chart-legend.s2 { fill: var(--s2); } .chart-legend.s3 { fill: var(--s3); }
.chart-node.up { fill: var(--chart-up); } .chart-node.down { fill: var(--chart-down); }

/* ------------------------------------------------------------------ phone */
@media (max-width: 720px) {
  .top { gap: 6px; padding-bottom: 8px; }
  .top nav {
    margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter) 4px; width: calc(100% + var(--gutter) * 2);
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a, .top nav button.link { flex: none; white-space: nowrap; background: var(--surface-2); min-height: 40px; }
  .nav-group { flex: none; }
  .card { border-radius: 12px; }
  input, select, textarea { max-width: none; }
  form > button[type="submit"], .key .button { width: 100%; }
  dl { grid-template-columns: 1fr; gap: 2px; }
  dd { margin-bottom: 8px; }
  .codes { columns: 1; }
}

/* ---------------------------------------------------------- accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .card, button, .button, .badge, .board .pad { border: 1px solid CanvasText; }
  .brand::before { forced-color-adjust: none; }
}

/* ------------------------------------------------------------------ print */
@media print {
  :root { color-scheme: light; --paper: #fff; --surface: #fff; --ink: #000; --ink-2: #333; --line: #bbb; }
  .top, .foot, nav, form, button, .button, .hp { display: none !important; }
  body.desk { display: block; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  a { color: #000; text-decoration: none; }
  .table-wrap { overflow: visible; border: 0; }
  th { position: static; }
}
