/* ==========================================================================================
   Tieout design system: one foundation for the public site, staff workspace and client portal.
   An operational workspace: white surfaces, slate text and one blue action color.
   Each surface adds only its layout (site.css, app.css,
   portal.css) and sets --text-size on <body>. Fonts are self-hosted: docs/image-sources.md.
   ========================================================================================== */

@font-face { font-family: "Inter"; src: url("/assets/inter-latin.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/assets/instrument-sans-latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  /* slate */
  --ink: #172b4d;            /* headings, table rules, dark surfaces */
  --ink-2: #243b5a;
  --ink-3: #42546d;
  --on-ink: #ffffff;
  --on-ink-2: #d5deeb;

  /* the one accent */
  --accent: #245cba;
  --accent-2: #1b478f;       /* hover */
  --accent-bg: #edf3fe;
  --accent-line: #c7d8f5;

  /* surfaces */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #d9e1eb;
  --border-2: #e8edf3;
  --control-line: #7c8a9d;

  /* text */
  --text: #1f2937;
  --text-2: #475569;
  --text-3: #5b6b80;

  /* meaning */
  --link: #2054a4;
  --focus: #245cba;
  --ok: #1c6b45;     --ok-bg: #e8f4ee;     --ok-line: #b9dcc9;
  --warn: #84580a;   --warn-bg: #fbf3e2;   --warn-line: #ead8ab;   --warn-dot: #c98a12;
  --bad: #a4262c;    --bad-bg: #fbecec;    --bad-line: #efc4c6;
  --info: #1f4fd8;   --info-bg: #edf1fd;   --info-line: #c3d0f5;

  /* type */
  --head: "Inter", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --text-size: 15px;

  /* one spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --radius: 4px;
  --control-h: 38px;
  --touch-h: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--text-size)/1.5 var(--sans);
       font-feature-settings: "cv11", "ss03"; -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent-2); text-decoration-thickness: 2px; }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 600; line-height: 1.2; letter-spacing: -.012em; margin: 0; color: var(--text); }
p { margin: 0 0 var(--s3); }
small { font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--border-2); margin: var(--s4) 0; }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }
.num, td.num, th.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.num, td.num, th.num { text-align: right; white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* Visible keyboard focus everywhere; never removed. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: var(--s2); top: -120px; z-index: 100; background: var(--surface); color: var(--text);
             padding: var(--s2) var(--s3); border: 2px solid var(--focus); border-radius: var(--radius); }
.skip-link:focus { top: var(--s2); }

/* ---------- the wordmark: two records, offset, joined by the action color ---------- */
.tie-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.tie-brand:hover { color: var(--ink); }
.tie-mark { width: 24px; height: 24px; flex: none; display: block; }
.tie-mark .rec { fill: currentColor; }
.tie-mark .tie { fill: var(--accent); }
.tie-word { font: 700 22px/1 var(--head); letter-spacing: -.045em; }

/* ---------- icons ---------- */
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- buttons: blue is the action; secondary controls are outlined ---------- */
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control-h); padding: 0 var(--s4); border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font: 600 14px/1.2 var(--sans); text-decoration: none; cursor: pointer;
  white-space: nowrap; }
.btn:hover, button:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; text-decoration: none; }
.btn.secondary, button.secondary, .btn.quiet, button.quiet, .btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover, button.secondary:hover, .btn.quiet:hover, button.quiet:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--control-line); }
.btn.link, button.link { background: none; border-color: transparent; color: var(--link); padding: 0 var(--s2); }
.btn.link:hover, button.link:hover { background: var(--accent-bg); color: var(--accent-2); }
.btn.danger, button.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover, button.danger:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn.small, button.small { min-height: 30px; padding: 0 var(--s3); font-size: 13px; }
.btn[aria-disabled="true"], button:disabled, .btn.disabled { background: var(--surface-2); color: var(--text-3);
  border-color: var(--border-2); cursor: not-allowed; }
.btn svg.i { width: 15px; height: 15px; }

/* ---------- form fields ---------- */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=date], select, textarea {
  font: inherit; font-size: max(14px, .95em); color: var(--text); background: var(--surface);
  border: 1px solid var(--control-line); border-radius: var(--radius); min-height: var(--control-h); padding: 6px 10px; max-width: 100%; }
textarea { min-height: 96px; width: 100%; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
label { font-weight: 600; }
.field { display: grid; gap: var(--s1); margin-bottom: var(--s4); }
.field .hint { font-size: .88em; color: var(--text-2); font-weight: 400; }
.field-error { color: var(--bad); font-size: .9em; }
input[aria-invalid="true"] { border-color: var(--bad); }

/* ---------- status: one dot + a word, colour carries meaning ---------- */
.status, .st { display: inline-flex; align-items: center; gap: 6px; font-size: .92em; white-space: nowrap; color: var(--text); }
.status::before, .st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9aa3af; flex: none; }
.status.ok::before, .st.ok::before { background: var(--ok); }
.status.warn::before, .st.warn::before { background: var(--warn-dot); }
.status.bad::before, .st.bad::before { background: var(--bad); }
.status.info::before, .st.info::before { background: var(--accent); }
.status.bad, .st.bad { color: var(--bad); }

/* ---------- small labels ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 18px; padding: 0 6px;
       border: 1px solid var(--border); border-radius: 4px; color: var(--text-2); background: var(--surface); white-space: nowrap; }
.tag.ok, .tag.high { color: var(--ok); border-color: var(--ok-line); background: var(--ok-bg); }
.tag.warn, .tag.low { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
.tag.bad { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); }
.tag.info, .tag.new { color: var(--info); border-color: var(--info-line); background: var(--info-bg); }
.tag.dup { color: var(--text-3); }
/* SYNTHETIC is unmissable and never decorative: graphite, square, the same everywhere. */
.synthetic-mark, .prac { display: inline-flex; align-items: center; font: 600 11px/18px var(--sans); letter-spacing: .06em;
  text-transform: uppercase; color: #fff; background: var(--ink-3); border-radius: 3px; padding: 0 6px; white-space: nowrap; }

/* ---------- a wide table scrolls inside itself. position: absolutely positioned screen-reader text inside must scroll with it, not widen the page ---------- */
.table-scroll { overflow-x: auto; position: relative; }

/* ---------- evidence: one treatment for text read from a document, everywhere ---------- */
.evidence { display: block; font: 12px/1.5 var(--mono); color: var(--text-2); border-left: 2px solid var(--accent-line); padding-left: var(--s2);
  overflow-wrap: anywhere; }

/* ---------- notices ---------- */
.notice, .flash { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4); margin: 0 0 var(--s4);
  border: 1px solid var(--info-line); background: var(--info-bg); border-radius: var(--radius); color: var(--text); }
.notice.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.notice.bad, .leak, .err { border: 1px solid var(--bad-line); background: var(--bad-bg); color: var(--text); padding: var(--s3) var(--s4);
  border-radius: var(--radius); margin: 0 0 var(--s4); }
.notice.ok { border-color: var(--ok-line); background: var(--ok-bg); }
.notice svg.i, .flash svg.i { margin-top: 2px; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--text-2); }
.empty strong { display: block; color: var(--text); font-size: 1.05em; margin-bottom: var(--s1); }

/* ---------- disclosure ---------- */
details > summary { cursor: pointer; }
details > summary::marker { color: var(--text-3); }

/* ---------- demo / synthetic banner (all surfaces) ---------- */
.demo-banner, .demo { background: var(--ink); color: var(--on-ink); padding: 5px var(--s4); font-size: 13px; text-align: center; font-weight: 500; }
.demo-banner a, .demo a { color: inherit; }

/* ---------- onboarding: a ledger of steps, read from the records ---------- */
.onboard { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.onboard li { position: relative; padding: 0 0 var(--s4) 36px; counter-increment: step; }
.onboard li:last-child { padding-bottom: 0; }
.onboard li::before { content: counter(step); position: absolute; left: 0; top: 0; z-index: 1; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--control-line); background: var(--surface); text-align: center; font: 600 12px/22px var(--sans); color: var(--text-2); }
.onboard li:not(:last-child)::after { content: ""; position: absolute; left: 11.5px; top: 24px; bottom: 0; width: 1px; background: var(--border); }
.onboard li.done::before { content: "✓"; background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.onboard li.now::before { background: var(--accent); border-color: var(--accent); color: #fff; }
.qr svg { display: block; max-width: 100%; height: auto; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.codes code { user-select: all; font-size: 15px; }
a.who { color: inherit; text-decoration: none; }
a.who:hover { text-decoration: underline; }

/* On a phone a long button label wraps, whatever font the device ends up with. */
@media (max-width: 640px) { .btn, button { white-space: normal; text-align: center; } }

/* ---------- printing: content only ---------- */
@media print {
  body { background: #fff; color: #000; }
  .no-print, .demo-banner, .demo, .skip-link { display: none !important; }
  a { color: inherit; text-decoration: none; }
}
