/* Named component library. Each class block matches a template in
   templates/components/. Components read tokens only. */

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--size-1);
  line-height: var(--leading);
  font-variant-numeric: var(--numeric);
}
a { color: var(--action); text-underline-offset: 2px; }
a:hover { color: var(--action-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { color: var(--text); font-weight: 600; line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: var(--size-4); }
h2 { font-size: var(--size-3); }
h3 { font-size: var(--size-2); }
p { margin: 0 0 var(--space-3); }
.muted { color: var(--text-secondary); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.num { text-align: right; font-variant-numeric: var(--numeric); white-space: nowrap; }

/* Shell: the top bar. On a phone the menu folds behind one "Menu" button
   (a details element; shell.js closes it on narrow screens and keeps it open
   on wide ones, so without script everything still shows). */
.skip-link { position: absolute; left: var(--space-4); top: -4rem; z-index: 50; padding: var(--space-2) var(--space-4); background: var(--surface); color: var(--action); border: 2px solid var(--focus); border-radius: var(--radius); font-weight: 600; }
.skip-link:focus { top: var(--space-2); }
.shell-top {
  position: relative; display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.wordmark { font-weight: 700; font-size: var(--size-2); color: var(--text); text-decoration: none; letter-spacing: 0.01em; white-space: nowrap; }
.wordmark span { color: var(--brand-grey); font-weight: 500; }
.shell-drawer { flex: 1; min-width: 0; }
.shell-drawer > summary { display: none; }
.shell-drawer-body { display: flex; align-items: center; gap: var(--space-4); }
.shell-top nav { display: flex; align-items: center; gap: var(--space-4); flex: 1; }
.shell-top nav a { text-decoration: none; color: var(--text-secondary); }
.shell-top nav a:hover { color: var(--text); }
.shell-top nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.shell-account { display: flex; align-items: center; gap: var(--space-3); }
.shell-account form { margin: 0; }
.shell-user { color: var(--text-secondary); font-size: var(--size-0); }
.shell-test { font-size: var(--size-0); white-space: nowrap; }
.shell-persona { display: flex; align-items: center; gap: var(--space-2); font-size: var(--size-0); color: var(--text-secondary); }
.shell-persona select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 2px var(--space-2); max-width: 18rem; }
/* The display switch: Match device, Light or Dark. */
.shell-theme { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--size-0); color: var(--text-secondary); }
.shell-theme select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 2px var(--space-2); }
/* The "Firm" menu in the top bar: a details element, no script. */
.shell-more { position: relative; }
.shell-more > summary { cursor: pointer; color: var(--text-secondary); list-style: none; }
.shell-more > summary::-webkit-details-marker { display: none; }
.shell-more > summary::after { content: " \25BE"; font-size: var(--size-0); }
.shell-more[data-current] > summary { color: var(--text); font-weight: 600; }
.shell-menu { position: absolute; top: calc(100% + var(--space-2)); left: 0; z-index: 20; min-width: 14rem; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-2) 0; }
.shell-top nav .shell-menu a { padding: var(--space-2) var(--space-4); }
.shell-top nav .shell-menu a:hover { background: var(--surface-sunk); color: var(--text); }
@media (max-width: 860px) {
  .shell-top { flex-wrap: wrap; gap: 0; padding: var(--space-2) var(--space-4); min-height: 3.25rem; }
  .shell-drawer { flex-basis: 100%; }
  .shell-drawer > summary {
    display: inline-flex; align-items: center; gap: var(--space-2); position: absolute; top: var(--space-2); right: var(--space-4);
    min-height: 2.25rem; padding: 0 var(--space-3); cursor: pointer; list-style: none; font-weight: 600; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  }
  .shell-drawer > summary::-webkit-details-marker { display: none; }
  .shell-drawer > summary svg { width: 1.1rem; height: 1.1rem; }
  .shell-drawer[open] > summary { background: var(--surface-sunk); }
  .shell-drawer[open] .shell-drawer-body { animation: drawer-in 180ms var(--ease) both; }
  .shell-drawer-body { flex-direction: column; align-items: stretch; gap: 0; padding-top: var(--space-2); }
  .shell-top nav { flex-direction: column; align-items: stretch; gap: 0; }
  .shell-top nav > a, .shell-more > summary { display: flex; align-items: center; min-height: 2.75rem; border-bottom: 1px solid var(--border); }
  .shell-menu { position: static; min-width: 0; border: none; box-shadow: none; padding: 0 0 var(--space-2) var(--space-4); }
  .shell-top nav .shell-menu a { padding: var(--space-2) 0; min-height: 2.75rem; display: flex; align-items: center; }
  .shell-theme { min-height: 2.75rem; border-bottom: 1px solid var(--border); }
  .shell-account { justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) 0 var(--space-1); }
  .shell-persona { flex: 1 1 100%; flex-wrap: wrap; }
  .shell-persona select { flex: 1; max-width: none; min-height: 2.75rem; }
}
@keyframes drawer-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.page { max-width: var(--max-width); margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6); }
.page-head { margin-bottom: var(--space-5); }
.eyebrow { color: var(--action); text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--size-0); font-weight: 600; margin-bottom: var(--space-1); }
.lede { color: var(--text-secondary); max-width: 70ch; }

/* Banner: environment and data rules */
.banner { padding: var(--space-2) var(--space-5); font-size: var(--size-0); background: var(--caution-bg); color: var(--text); border-bottom: 1px solid var(--border); }

/* Button */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius);
  border: 1px solid var(--action); background: var(--action); color: var(--on-action);
}
.btn:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--on-action); }
.btn--secondary { background: transparent; color: var(--action); }
.btn--secondary:hover { background: var(--surface-sunk); color: var(--action); }
.btn--neutral { background: transparent; color: var(--text); border-color: var(--border-strong); } /* send back, reopen */
.btn--small { padding: var(--space-1) var(--space-3); font-size: var(--size-0); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow); margin-bottom: var(--space-4); }
.card > h2, .card > h3 { margin-top: 0; }
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Status chip: colour, icon and word together */
.chip { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.05em 0.6em; border-radius: var(--radius-pill); font-size: var(--size-0); font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.chip svg { width: 0.95em; height: 0.95em; }
.chip--good { color: var(--good); background: var(--good-bg); }
.chip--caution { color: var(--caution); background: var(--caution-bg); }
.chip--problem { color: var(--problem); background: var(--problem-bg); }
.chip--neutral { color: var(--neutral); background: var(--neutral-bg); }

/* Journey line: the metro map of stages (main navigation inside a file) */
.journey { display: flex; align-items: flex-start; gap: 0; margin: var(--space-4) 0 var(--space-5); overflow-x: auto; padding-bottom: var(--space-2); }
.journey-stop { flex: 1 1 0; min-width: 92px; position: relative; text-align: center; text-decoration: none; color: var(--text); }
.journey-stop::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 4px; background: var(--border); z-index: 0; }
.journey-stop:first-child::before { display: none; }
.journey-stop.is-closed::before, .journey-stop.is-part::before, .journey-stop.is-open::before { background: var(--brand-green); }
.journey-dot { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border-strong); background: var(--surface); font-size: var(--size-0); font-weight: 700; color: var(--text-secondary); }
.is-closed .journey-dot { background: var(--good); border-color: var(--good); color: var(--on-action); }
.is-open .journey-dot { border-color: var(--action); color: var(--action); }
.is-part .journey-dot { border-color: var(--brand-green); background: linear-gradient(90deg, var(--brand-green) 50%, var(--surface) 50%); color: var(--text); }
.is-later .journey-dot { border-style: dashed; }
.journey-name { display: block; font-size: var(--size-0); margin-top: var(--space-1); line-height: 1.2; }
.journey-state { display: block; font-size: 0.75rem; color: var(--text-secondary); }
.journey { scroll-snap-type: x proximity; }
.journey-stop { scroll-snap-align: center; }
.journey-stop[aria-current="step"] .journey-dot { box-shadow: 0 0 0 4px var(--good-bg); }
/* shell.js marks a line wider than the screen, so its cut edges fade. */
.journey.is-scrollable { -webkit-mask-image: linear-gradient(to right, transparent, #000 1.5rem, #000 calc(100% - 1.5rem), transparent); mask-image: linear-gradient(to right, transparent, #000 1.5rem, #000 calc(100% - 1.5rem), transparent); }

/* Gate checklist */
.gate { list-style: none; padding: 0; margin: 0; }
.gate li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.gate li:last-child { border-bottom: none; }
.gate .gate-detail { grid-column: 2; color: var(--text-secondary); font-size: var(--size-0); }
.gate .gate-cite { grid-column: 2; font-size: 0.8rem; color: var(--text-secondary); }

/* Typed table */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table th { text-align: left; font-weight: 600; font-size: var(--size-0); color: var(--text); background: var(--surface-sunk); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-strong); }
.table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.table .cast-ok { color: var(--good); }
.table .cast-bad { color: var(--problem); font-weight: 700; }

/* Sign-off block */
.signoffs { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: var(--size-0); }
.signoff { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.1em 0.5em; background: var(--surface-sunk); }
.signoff--stale { border-color: var(--caution); background: var(--caution-bg); }

/* Review note pin */
.note { border-left: 4px solid var(--caution); background: var(--surface); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0; }
.note--blocker { border-left-color: var(--problem); }
.note--cleared { border-left-color: var(--good); opacity: 0.8; }

/* Queue item: one action per item */
.queue { list-style: none; margin: 0; padding: 0; }
.queue li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }

/* Empty state: says what to do next. "clear" is the good kind of empty
   (nothing waiting); "start" is a place that has nothing in it yet. */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-secondary); background: var(--surface-sunk); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: 50%; background: var(--neutral-bg); color: var(--neutral); }
.empty-icon svg { width: 1.5rem; height: 1.5rem; }
.empty--clear .empty-icon { background: var(--good-bg); color: var(--good); }
.empty strong { display: block; color: var(--text); font-size: var(--size-2); line-height: 1.25; }
.empty p { max-width: 46ch; margin: 0; }
.empty .btn { margin-top: var(--space-2); }

/* Forms */
.form-row { margin-bottom: var(--space-4); }
.form-row label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
.form-row .help { font-size: var(--size-0); color: var(--text-secondary); }
/* A question with options: the question is the legend, the options plain. */
.form-choices { border: none; padding: 0; margin-left: 0; margin-right: 0; min-width: 0; }
.form-choices legend { font-weight: 600; padding: 0; margin-bottom: var(--space-1); }
.form-row.form-choices label { display: flex; align-items: center; gap: var(--space-2); font-weight: 400; margin-bottom: var(--space-1); }
.form-choices label input { margin: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: var(--space-2); max-width: 100%; }
textarea { width: 100%; min-height: 6em; }
.errorlist { color: var(--problem); list-style: none; padding: 0; margin: var(--space-1) 0; font-size: var(--size-0); }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.messages li { padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--good-bg); margin-bottom: var(--space-2); }
.messages li.error { background: var(--problem-bg); }
.messages li.warning { background: var(--caution-bg); }

/* Side panel: detail on demand */
.with-panel { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-5); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); align-self: start; position: sticky; top: var(--space-4); min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 860px) {
  .with-panel { grid-template-columns: minmax(0, 1fr); }   /* a wide table scrolls in its wrap, never the page */
  .panel { position: static; }
  .shell-top { flex-wrap: wrap; }
}

/* Client Room components: progress with numeric label, drop zone, item rows, tabs. */
.cr-progress-label { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--size-0); color: var(--text-secondary); margin-bottom: var(--space-1); }
.cr-progress-label strong { color: var(--text); font-size: var(--size-1); }
.cr-progress-bar { height: 0.8rem; background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.cr-progress-bar > span { display: block; height: 100%; background: var(--brand-green); transform-origin: left center; animation: grow-x var(--duration) var(--ease) both; }
.cr-counts { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.cr-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.cr-filters a { display: inline-block; padding: var(--space-1) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-pill); text-decoration: none; color: var(--text); font-size: var(--size-0); background: var(--surface); }
.cr-filters a[aria-current="true"] { border-color: var(--action); color: var(--action); font-weight: 600; }
.cr-table-wrap { overflow-x: auto; }
.cr-cat td { background: var(--surface-sunk); font-weight: 600; font-size: var(--size-0); color: var(--text-secondary); }
.cr-num { white-space: nowrap; font-variant-numeric: var(--numeric); font-weight: 600; }
.cr-meta { display: block; font-size: var(--size-0); color: var(--text-secondary); }
.cr-drop { display: block; border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: var(--space-4); text-align: center; background: var(--surface-sunk); }
.cr-drop strong { display: block; }
.cr-drop input[type="file"] { display: block; width: 100%; margin: var(--space-3) auto 0; background: var(--surface); }
.cr-items { list-style: none; margin: 0; padding: 0; }
.cr-items li { border-bottom: 1px solid var(--border); }
.cr-items li:last-child { border-bottom: none; }
.cr-row { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) 0; text-decoration: none; color: var(--text); }
.cr-row:hover { color: var(--text); }
.cr-row .cr-num { min-width: 2.75rem; }
.cr-row .cr-main { flex: 1; min-width: 0; }
.cr-row .cr-title { color: var(--action); text-decoration: underline; text-underline-offset: 2px; }
.cr-row > span:last-child { display: flex; flex-wrap: wrap; gap: var(--space-1); justify-content: flex-end; max-width: 50%; }
@media (max-width: 40rem) {
  .cr-row { flex-wrap: wrap; }
  .cr-row > span:last-child { max-width: none; flex-basis: 100%; justify-content: flex-start; padding-left: calc(2.75rem + var(--space-3)); }
}
.cr-reason { display: block; border-left: 4px solid var(--problem); background: var(--problem-bg); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0; border-radius: 0 var(--radius) var(--radius) 0; }
.cr-example { border-left: 4px solid var(--border-strong); padding: var(--space-1) var(--space-3); color: var(--text-secondary); margin: var(--space-3) 0; }
.cr-thread { list-style: none; padding: 0; margin: 0; }
.cr-thread li { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.cr-thread li:last-child { border-bottom: none; }
.cr-thread p { margin: var(--space-1) 0 0; white-space: pre-line; }
.cr-dates { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
.cr-dates dt { color: var(--text-secondary); font-size: var(--size-0); }
.cr-dates dd { margin: 0; }
.cr-inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.cr-inline form { margin: 0; }
.cr-checks { list-style: none; padding: 0; margin: 0; }
.cr-checks li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.cr-checks li:last-child { border-bottom: none; }
.cr-checks input[type="checkbox"] { width: 1.15rem; height: 1.15rem; margin-top: 0.3rem; }
.cr-checks label { font-weight: 600; }
.cr-fieldset { border: none; padding: 0; margin: 0 0 var(--space-4); }
.cr-fieldset legend { font-weight: 600; font-size: var(--size-2); padding: 0; margin-bottom: var(--space-1); }
.cr-form input:not([type="checkbox"]):not([type="file"]), .cr-form select, .cr-form textarea { width: 100%; }
.cr-history { list-style: none; padding: 0; margin: 0; font-size: var(--size-0); }
.cr-history li { padding: var(--space-1) 0; border-bottom: 1px solid var(--border); }
.cr-digest { white-space: pre-wrap; font-family: var(--font); font-size: var(--size-0); background: var(--surface-sunk); padding: var(--space-3); border-radius: var(--radius); margin: var(--space-2) 0 0; }
.cr-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin: 0 0 var(--space-2); }
.cr-tabs a { padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--text-secondary); border-bottom: 3px solid transparent; white-space: nowrap; }
.cr-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--action); font-weight: 600; }
.cr-back { display: inline-block; margin-bottom: var(--space-3); }
.cr-portal { max-width: 46rem; margin: 0 auto; }
.cr-portal .page-head h1 { font-size: var(--size-3); }
@media (max-width: 600px) {
  .cr-portal .btn { width: 100%; justify-content: center; }
  .cr-portal .card { padding: var(--space-3) var(--space-4); }
  .cr-tabs a { flex: 1; text-align: center; padding: var(--space-2) var(--space-1); }
}

/* Data in components: sub-navigation, import steps, difference rows. */
.ld-nav { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-5); padding: 0; list-style: none; }
.ld-nav a { display: inline-block; padding: var(--space-1) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-pill); text-decoration: none; color: var(--text); font-size: var(--size-0); background: var(--surface); }
.ld-nav a[aria-current="page"] { border-color: var(--action); color: var(--action); font-weight: 600; }
.ld-nav .ld-count { color: var(--text-secondary); font-weight: 400; }
.ld-kv { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-4); margin: 0 0 var(--space-3); }
.ld-kv dt { color: var(--text-secondary); font-size: var(--size-0); }
.ld-kv dd { margin: 0; font-variant-numeric: var(--numeric); }
.ld-meta { display: block; font-size: var(--size-0); color: var(--text-secondary); }
.ld-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: var(--space-2) 0; }
.ld-wrap { overflow-x: auto; margin-bottom: var(--space-4); }
.ld-table td.num, .ld-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: var(--numeric); }
.ld-table tr.ld-area td { background: var(--surface-sunk); font-weight: 600; }
.ld-table tr.ld-subtotal td { font-weight: 600; border-top: 1px solid var(--border-strong); }
.ld-table tr.ld-attention td { background: var(--caution-bg); }
.ld-table td.ld-indent { padding-left: var(--space-5); }
.ld-table details summary { cursor: pointer; }
.ld-table details ul { list-style: none; margin: var(--space-2) 0 0; padding: 0; font-size: var(--size-0); color: var(--text-secondary); }
.ld-table details li { display: flex; justify-content: space-between; gap: var(--space-4); }
.ld-reason { border-left: 4px solid var(--problem); background: var(--problem-bg); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0 var(--space-3); border-radius: 0 var(--radius) var(--radius) 0; }
.ld-note { border-left: 4px solid var(--border-strong); padding: var(--space-1) var(--space-3); color: var(--text-secondary); margin: var(--space-3) 0; }
.ld-message { width: 100%; min-height: 12em; font-size: var(--size-0); background: var(--surface-sunk); }
.ld-checks { list-style: none; padding: 0; margin: 0; }
.ld-checks li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.ld-checks li:last-child { border-bottom: none; }
.ld-checks .ld-meta { grid-column: 2; }
.ld-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); margin: var(--space-3) 0; }
.ld-stat { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); background: var(--surface-sunk); }
.ld-stat strong { display: block; font-size: var(--size-3); line-height: 1.1; font-variant-numeric: var(--numeric); }
.ld-stat span { font-size: var(--size-0); color: var(--text-secondary); }
.ld-inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: 0; }
.ld-inline select { max-width: 22rem; }
.ld-diff { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); background: var(--surface); }
.ld-diff h3 { font-size: var(--size-1); margin-bottom: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.ld-diff form { margin: var(--space-2) 0; }
.ld-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-3); }
.ld-hash { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; word-break: break-all; }
.ld-radio { display: flex; gap: var(--space-4); flex-wrap: wrap; list-style: none; padding: 0; margin: 0; }
.ld-radio label { font-weight: 400; display: inline-flex; gap: var(--space-2); align-items: center; }
.ld-fields { list-style: none; padding: 0; margin: 0; font-size: var(--size-0); }
.ld-fields li { padding: var(--space-1) 0; border-bottom: 1px solid var(--border); }
.ld-fields li:last-child { border-bottom: none; }

/* Response design components: assertion matrix and procedure rows. */
.rs-nav { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.rs-nav a { display: inline-block; padding: var(--space-1) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-pill); text-decoration: none; color: var(--text); font-size: var(--size-0); background: var(--surface); }
.rs-nav a[aria-current="page"] { border-color: var(--action); color: var(--action); font-weight: 600; }
.rs-wrap { overflow-x: auto; }
.rs-matrix th.rs-a, .rs-matrix td.rs-a { text-align: center; width: 2.6rem; padding-left: var(--space-1); padding-right: var(--space-1); }
.rs-matrix th.rs-a.is-relevant { color: var(--action); text-decoration: underline; text-underline-offset: 3px; }
.rs-tick { color: var(--good); font-weight: 700; }
.rs-ref { white-space: nowrap; font-variant-numeric: var(--numeric); font-weight: 600; }
.rs-meta { display: block; font-size: var(--size-0); color: var(--text-secondary); }
.rs-tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.rs-list { list-style: none; margin: 0; padding: 0; }
.rs-list li { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-1) var(--space-3); align-items: start; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.rs-list li:last-child { border-bottom: none; }
.rs-inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.rs-inline form { margin: 0; }
.rs-letter { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); max-width: 72ch; }
.rs-letter h3 { margin-top: var(--space-4); }
.rs-letter p { white-space: pre-line; }
.rs-checks { list-style: none; padding: 0; margin: 0; }
.rs-checks li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.rs-checks li:last-child { border-bottom: none; }
.rs-checks .rs-meta { grid-column: 2; }
.rs-fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); }
.rs-fieldset legend { font-weight: 600; padding: 0 var(--space-1); }
.rs-choices ul, .rs-choices div { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.rs-choices label { font-weight: 400; display: inline-flex; gap: var(--space-1); align-items: center; }
.rs-criterion.is-off td { color: var(--text-secondary); }
.rs-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--size-0); word-break: break-all; }
.rs-pager { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); }

/* Review components: notes, the partner review schedule and its print layout. */
/* Review module layout. Tokens only; no colours of its own. */
/* Tabs within a module (Review): the current tab is underlined in the
   action colour. On a phone the strip scrolls sideways instead of wrapping,
   with the current tab brought into view by shell.js. */
.review-tabs { display: flex; flex-wrap: wrap; gap: 0 var(--space-1); margin: 0 0 var(--space-5); border-bottom: 1px solid var(--border); font-size: var(--size-0); }
.review-tabs a { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0 var(--space-3); margin-bottom: -1px; border-bottom: 2px solid transparent; text-decoration: none; color: var(--text-secondary); white-space: nowrap; transition: color 150ms var(--ease), border-color 150ms var(--ease); }
.review-tabs a:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.review-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--action); }
@media (max-width: 640px) {
  .review-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .review-tabs::-webkit-scrollbar { display: none; }
  .review-tabs a { scroll-snap-align: start; min-height: 2.75rem; }
  .review-tabs.is-scrollable { -webkit-mask-image: linear-gradient(to right, transparent, #000 1.5rem, #000 calc(100% - 1.5rem), transparent); mask-image: linear-gradient(to right, transparent, #000 1.5rem, #000 calc(100% - 1.5rem), transparent); }
}
/* A card that folds behind its heading (a filter form on a phone). */
.fold > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); cursor: pointer; list-style: none; font-weight: 600; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "\25BE"; color: var(--text-secondary); transition: transform 150ms var(--ease); }
.fold[open] > summary { margin-bottom: var(--space-3); }
.fold[open] > summary::after { transform: rotate(180deg); }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.filters .filters-label { font-size: var(--size-0); color: var(--text-secondary); margin-right: var(--space-1); }
.stat { font-size: var(--size-4); font-weight: 600; line-height: 1; margin: 0 0 var(--space-2); }
.stat-card h3 { font-size: var(--size-0); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); }
.note-head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-1); }
.note-meta { font-size: var(--size-0); color: var(--text-secondary); margin: 0; overflow-wrap: anywhere; }
.card summary { overflow-wrap: anywhere; }   /* a long file name in a fold wraps rather than widen the page */
.note p.note-text { margin: 0 0 var(--space-1); white-space: pre-line; }
.ref { font-variant-numeric: var(--numeric); letter-spacing: 0.03em; font-weight: 700; white-space: nowrap; }
.thread { list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.thread li { border-bottom: 1px solid var(--border); padding: var(--space-3) 0; }
.thread li:last-child { border-bottom: none; }
.thread .who { font-weight: 600; }
.prose { white-space: pre-line; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0 0 var(--space-4); font-size: var(--size-0); }
.dl dt { font-weight: 600; }
.dl dd { margin: 0; }
.panel h3 { margin-top: var(--space-4); }
.panel h3:first-child { margin-top: 0; }
.panel form + form { margin-top: var(--space-4); }
.alert { border-left: 4px solid var(--problem); }
.caution { border-left: 4px solid var(--caution); }
.inline { display: inline; }
.table-wrap { overflow-x: auto; }
.table td.ref-cell, .table td.date-cell { white-space: nowrap; }
.form-grid { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.form-grid .form-row { margin-bottom: 0; }
.form-row input[type="text"], .form-row select { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.schedule-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.schedule-section { break-inside: avoid-page; }
.print-only { display: none; }
/* Field mode (epic 2J): the photo shown for the legibility check. */
.fm-preview { display: block; max-width: 100%; height: auto; margin-bottom: var(--space-2); border: 1px solid var(--border-strong); }
/* In this file: the engagement's own pages, on every page of the file. */
.file-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.file-head .eyebrow { margin: 0; }
.file-nav > summary { display: none; }
.file-nav ul { display: flex; flex-wrap: wrap; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.file-nav a { display: inline-flex; align-items: center; min-height: 2rem; padding: 0 var(--space-3); border-radius: var(--radius-pill); text-decoration: none; color: var(--text-secondary); font-size: var(--size-0); }
.file-nav a:hover { background: var(--surface-sunk); color: var(--text); }
.file-nav a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border-strong); }
@media (max-width: 860px) {
  .file-nav { flex-basis: 100%; }
  .file-nav > summary { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.25rem; cursor: pointer; color: var(--text); font-weight: 600; font-size: var(--size-0); list-style: none; }
  .file-nav > summary::-webkit-details-marker { display: none; }
  .file-nav > summary::after { content: "\25BE"; transition: transform 150ms var(--ease); }
  .file-nav[open] > summary::after { transform: rotate(180deg); }
  .file-nav ul { padding-bottom: var(--space-2); }
  .file-nav a { min-height: 2.75rem; border: 1px solid var(--border); background: var(--surface); }
}

/* KPI row: stat tiles (label, value, an optional note or meter). Values use
   proportional figures; columns of numbers keep tabular ones. */
.kpis { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 var(--space-4); }
.kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .kpis--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
.card .kpi { background: var(--surface-sunk); border-color: transparent; box-shadow: none; padding: var(--space-2) var(--space-3); }
.kpi-label { font-size: var(--size-0); color: var(--text-secondary); }
.kpi-value { font-size: var(--size-4); font-weight: 600; line-height: 1.05; font-variant-numeric: lining-nums proportional-nums; }
.card .kpi-value { font-size: var(--size-3); }
.kpi-note { font-size: var(--size-0); color: var(--text-secondary); }
/* Tiles side by side share their rows, so a label that wraps keeps every
   number in the row on one line. */
@supports (grid-template-rows: subgrid) {
  .kpis { row-gap: 0; margin-bottom: var(--space-1); }
  .kpi { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: var(--space-1); align-content: start; margin-bottom: var(--space-3); }
  .kpi > * { align-self: start; }
  .kpi-label { align-self: end; }
}
a.kpi { text-decoration: none; transition: border-color 150ms var(--ease), transform 150ms var(--ease); }
a.kpi:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

/* Meter: a ratio against a limit. The fill carries the state, the track is
   a lighter step of the same hue, and the number beside it says the value. */
.meter { display: block; height: 6px; margin-top: var(--space-1); border-radius: var(--radius-pill); background: var(--good-bg); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; width: var(--value, 0%); border-radius: var(--radius-pill); background: var(--good); transform-origin: left center; animation: grow-x var(--duration) var(--ease) both; }
.meter--wide { height: 8px; margin: 0 0 var(--space-4); }
.kpi-of { font-size: var(--size-1); font-weight: 400; color: var(--text-secondary); }
.cell-note { display: block; font-size: var(--size-0); color: var(--text-secondary); margin-top: 2px; }
.cell-meter { display: block; min-width: 7rem; }
.cell-meter .meter { margin-top: 0.45em; }
/* A side panel's list of tools: a link and a line on what it is for. */
.tool-list { list-style: none; margin: 0; padding: 0; }
.tool-list li { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.tool-list li:last-child { border-bottom: none; }
.tool-list a { font-weight: 600; text-decoration: none; }
.tool-list a:hover { text-decoration: underline; }
.tool-list span { display: block; font-size: var(--size-0); color: var(--text-secondary); }
.meter--caution { background: var(--caution-bg); }
.meter--caution > span { background: var(--caution); }
.meter--problem { background: var(--problem-bg); }
.meter--problem > span { background: var(--problem); }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Skeleton: the shape of what is loading, instead of a blank or a spinner. */
.skeleton { display: block; position: relative; overflow: hidden; background: var(--surface-sunk); border-radius: var(--radius); }
.kpi .skeleton { background: var(--border); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-title { height: 1.5em; width: 70%; margin: var(--space-2) 0 var(--space-3); }
.skeleton-text { height: 0.85em; margin: 0.6em 0; }
.skeleton-value { height: 1.4em; width: 50%; }
.w-40 { width: 40%; } .w-60 { width: 60%; } .w-75 { width: 75%; } .w-90 { width: 90%; }
@keyframes shimmer { to { transform: translateX(100%); } }
/* Content htmx swaps in fades in; a card waiting on its own request dims. */
.htmx-added { opacity: 0; }
.card { transition: opacity 250ms var(--ease); }
.card:has(form.htmx-request) { opacity: 0.6; cursor: progress; }

/* A table that becomes a list of labelled cards on a phone (each cell
   carries data-label; the roles keep the table semantics). */
@media (max-width: 640px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack { border: none; background: transparent; }
  .table--stack tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
  .card .table--stack tr { background: var(--surface-sunk); border-color: transparent; }
  .table--stack td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 2px var(--space-3); padding: var(--space-1) 0; border: none; }
  .table--stack td::before { content: attr(data-label); color: var(--text-secondary); font-size: var(--size-0); padding-top: 0.15em; grid-column: 1; grid-row: 1; }
  .table--stack td > * { grid-column: 2; justify-self: start; }
  .table--stack td > .cell-meter { justify-self: stretch; }
  .table--stack td.stack-hide { display: none; }
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}

@media print {
  .shell-top, .journey, .banner, .messages, .review-tabs, .file-nav, .skip-link, .no-print { display: none !important; }
  .print-only { display: block; }
  body { background: var(--surface); font-size: 11pt; }
  .page { max-width: none; padding: 0; }
  .card { box-shadow: none; padding: var(--space-3) 0; border: none; border-top: 1px solid var(--border-strong); border-radius: 0; }
  .table { font-size: 10pt; }
  a { color: var(--text); text-decoration: none; }
}
