/* ============================================================================
   Sentinel — design system + application styles.

   Structure
     1.  Design tokens (light) and the dark override
     2.  Reset & base elements
     3.  Primitives: buttons, fields, badges, cards, tables, menus, dialogs
     4.  App shell: sidebar, topbar, main
     5.  Screens
     6.  Copilot
     7.  Responsive
     8.  Print — the field-form stylesheet
   ==========================================================================*/

/* ---------------------------------------------------------------------------
   1. TOKENS
   Status hues are chosen to stay separable under deuteranopia/protanopia:
   the "good" tone is a teal-leaning green and the "bad" tone a red with a
   distinctly lower lightness, and every status is *also* carried by a text
   label or glyph — colour is never the sole signal.
   ------------------------------------------------------------------------*/
:root {
  color-scheme: light;

  /* Surfaces & text.
     The canvas sits a full step below the card surface so white cards read as
     raised objects rather than regions of the same sheet; muted text is two
     steps darker than it used to be (AA on every surface it appears on). */
  --bg:            #edf1f5;
  --surface:       #ffffff;
  --surface-2:     #f0f3f7;
  --surface-3:     #e3e9ef;
  --surface-inset: #f7f9fc;
  --border:        #d5dde5;
  --border-strong: #a9b6c4;
  --text:          #0f151c;
  --text-2:        #3e4956;
  --text-3:        #5c6977;
  --text-on-brand: #ffffff;

  /* The navigation rail is deep brand navy in both themes: a constant, high-
     contrast anchor that tells you where you are at every scroll position. */
  --nav-bg:            #14283f;
  --nav-border:        #24405e;
  --nav-border-strong: #33506f;
  --nav-text:          #c9d6e4;
  --nav-text-dim:      #8fa5bc;
  --nav-accent:        #7db4ee;

  /* Brand */
  --brand:         #1a4a80;
  --brand-hover:   #143c6a;
  --brand-active:  #102f53;
  --brand-soft:    #e9f0f8;
  --brand-soft-2:  #d5e3f2;
  --brand-border:  #b3cbe4;
  --brand-text:    #1a4a80;

  /* Status. Text tones deepened and borders darkened one step so a pill or
     callout reads at a glance instead of washing into its background; solid
     variants exist for the counts that must shout (nav badges). */
  --ok:            #0b6047;
  --ok-soft:       #e2f4ee;
  --ok-border:     #83c9b1;
  --warn:          #7d4a06;
  --warn-soft:     #fdf1dd;
  --warn-border:   #e0bc7d;
  --danger:        #a82429;
  --danger-soft:   #fdeced;
  --danger-border: #e79ba0;
  --danger-solid:  #b02a30;
  --on-danger:     #ffffff;
  --info:          #1a4a80;
  --info-soft:     #e9f0f8;
  --info-border:   #b3cbe4;
  --neutral:       #4f5a66;
  --neutral-soft:  #eef1f4;
  --neutral-border:#c8d1da;

  /* Chart ink */
  --chart-line:    #1a4a80;
  --chart-point:   #1a4a80;
  --chart-grid:    #dde3ea;
  --chart-mean:    #0e6f55;
  --chart-1sd:     #cfd8e2;
  --chart-2sd:     #e9c78d;
  --chart-3sd:     #edb0b3;
  --chart-flag:    #b02a30;

  /* Categorical series slots for the validation charts.
     Fixed order, never cycled. Validated as a set against this surface for
     the lightness band, chroma floor, colour-vision-deficiency separation and
     contrast; a fifth series folds into "Other" rather than inventing a hue.
     Identity is always carried by a legend or a direct label as well as by
     colour, so these are never the sole signal. */
  --chart-s1:      #2a78d6;
  --chart-s2:      #eb6834;
  --chart-s3:      #1baf7a;
  --chart-s4:      #4a3aa7;
  --chart-ref:     #6c7783;   /* identity line, target line — recessive */
  --chart-limit:   #91560a;   /* allowable-error / verification limits */
  --chart-fill:    #cde2fb;   /* soft fill under a distribution or histogram */

  /* Spacing scale (4px base) */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;
  --sp-10: 64px;
  --sp-11: 80px;
  --sp-12: 112px;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(15, 21, 28, .07), 0 1px 3px rgba(15, 21, 28, .05);
  --sh-2: 0 2px 6px rgba(15, 21, 28, .09), 0 1px 2px rgba(15, 21, 28, .05);
  --sh-3: 0 8px 24px rgba(15, 21, 28, .10), 0 2px 6px rgba(15, 21, 28, .05);
  --sh-4: 0 20px 48px rgba(15, 21, 28, .16), 0 4px 12px rgba(15, 21, 28, .08);

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs:   11.5px;
  --fs-sm:   12.5px;
  --fs-base: 14px;
  --fs-md:   15.5px;
  --fs-lg:   18px;
  --fs-xl:   22px;
  --fs-2xl:  28px;
  --fs-3xl:  36px;
  --fs-4xl:  46px;

  --nav-w: 244px;
  --topbar-h: 60px;
  --dur: 180ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0c1014;
  --surface:       #151b22;
  --surface-2:     #1b232c;
  --surface-3:     #232d38;
  --surface-inset: #10161c;
  --border:        #29323d;
  --border-strong: #3b4653;
  --text:          #e9eef4;
  --text-2:        #adbac7;
  --text-3:        #8b98a6;
  --text-on-brand: #08111c;

  /* The rail keeps its own step: near-black with a blue cast, one shade apart
     from the canvas so the app's geography survives the theme change. */
  --nav-bg:            #0f151d;
  --nav-border:        #232d38;
  --nav-border-strong: #344351;
  --nav-text:          #b6c3d0;
  --nav-text-dim:      #8093a6;
  --nav-accent:        #78b0e8;

  --brand:         #78b0e8;
  --brand-hover:   #96c3f0;
  --brand-active:  #b0d2f5;
  --brand-soft:    #142334;
  --brand-soft-2:  #1b3048;
  --brand-border:  #2f4c6d;
  --brand-text:    #9cc6ef;

  --ok:            #55cfa8;
  --ok-soft:       #0e2a23;
  --ok-border:     #2a6f5b;
  --warn:          #f0b45e;
  --warn-soft:     #2c2114;
  --warn-border:   #6f5530;
  --danger:        #f28b8f;
  --danger-soft:   #2d1619;
  --danger-border: #71363c;
  --danger-solid:  #f28b8f;
  --on-danger:     #1c0f11;
  --info:          #78b0e8;
  --info-soft:     #142334;
  --info-border:   #2f4c6d;
  --neutral:       #97a4b2;
  --neutral-soft:  #1c242d;
  --neutral-border:#333d49;

  --chart-line:    #78b0e8;
  --chart-point:   #9cc6ef;
  --chart-grid:    #29323d;
  --chart-mean:    #55cfa8;
  --chart-1sd:     #3b4653;
  --chart-2sd:     #6d5227;
  --chart-3sd:     #6e3438;
  --chart-flag:    #f28b8f;

  /* The same four hues, re-stepped for the dark surface and re-validated as a
     set — not an automatic flip of the light values. */
  --chart-s1:      #3987e5;
  --chart-s2:      #d95926;
  --chart-s3:      #199e70;
  --chart-s4:      #9085e9;
  --chart-ref:     #8b98a6;
  --chart-limit:   #f0b45e;
  --chart-fill:    #1b3048;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .40);
  --sh-2: 0 2px 6px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .30);
  --sh-3: 0 8px 24px rgba(0, 0, 0, .50), 0 2px 6px rgba(0, 0, 0, .35);
  --sh-4: 0 20px 48px rgba(0, 0, 0, .60), 0 4px 12px rgba(0, 0, 0, .40);
}

/* ---------------------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------------------*/
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -0.011em; }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.021em; }
h2 { font-size: var(--fs-xl); letter-spacing: -0.016em; }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p  { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

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

ul, ol { margin: 0; padding-left: 1.25em; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }

svg { display: block; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
[data-theme="dark"] :focus-visible { outline-color: var(--brand); }

::selection { background: var(--brand-soft-2); color: var(--text); }

.skip-link {
  position: absolute; left: var(--sp-3); top: -60px; z-index: 200;
  background: var(--surface); color: var(--text);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); box-shadow: var(--sh-3);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--sp-3); text-decoration: none; }

.noscript { max-width: 40rem; margin: 15vh auto; padding: var(--sp-6); text-align: center; }

/* Utility */
.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;
}
.muted   { color: var(--text-3); }
.dim     { color: var(--text-2); }
.mono    { font-family: var(--font-mono); font-size: .93em; font-variant-numeric: tabular-nums; }
.nums    { font-variant-numeric: tabular-nums; }
.center  { text-align: center; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.row     { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap{ display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.col     { display: flex; flex-direction: column; gap: var(--sp-3); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-4); }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .085em;
  text-transform: uppercase; color: var(--text-3);
}

/* Boot splash */
.boot {
  min-height: 100vh; display: grid; place-content: center;
  justify-items: center; gap: var(--sp-4); color: var(--text-3);
}
.boot-mark {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand);
  animation: spin 900ms linear infinite;
}
.boot-text { font-size: var(--fs-sm); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   3. PRIMITIVES
   ------------------------------------------------------------------------*/

/* --- Buttons --- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  font: inherit; font-size: var(--fs-base); font-weight: 550;
  line-height: 1.2;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--sh-1);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; box-shadow: none; }

.btn-primary {
  --btn-bg: var(--brand); --btn-fg: var(--text-on-brand); --btn-bd: var(--brand);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-quiet { --btn-bg: transparent; --btn-bd: var(--border); box-shadow: none; }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-bd: var(--danger-border); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { min-height: 29px; padding: 4px 10px; font-size: var(--fs-sm); }
.btn-lg { min-height: 46px; padding: 12px 24px; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-multiline {
  white-space: normal; text-align: center; line-height: 1.35;
  padding-top: 10px; padding-bottom: 10px; height: auto;
}
.btn-icon { padding: 0; width: 34px; min-height: 34px; }
.btn-icon.btn-sm { width: 28px; min-height: 28px; }

.btn[data-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[data-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--text-2);
  animation: spin 700ms linear infinite;
}
.btn-primary[data-busy="true"]::after { color: var(--text-on-brand); }

.link-btn {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--brand-text); text-decoration: underline; text-underline-offset: 2px;
}

/* --- Fields --- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
}
.hint { font-size: var(--fs-sm); color: var(--text-3); }
.field-error { font-size: var(--fs-sm); color: var(--danger); font-weight: 550; }

.input, .select, .textarea {
  font: inherit; font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  min-height: 36px;
  width: 100%;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft-2);
}
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--surface-2); color: var(--text-3); cursor: not-allowed;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%236c7783' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238b98a6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.input-sm { min-height: 29px; padding: 3px 8px; font-size: var(--fs-sm); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid .span-2 { grid-column: 1 / -1; }

/* --- Badges & chips --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-sm); font-weight: 650; letter-spacing: .01em;
  padding: 2.5px 9px; border-radius: var(--r-full);
  border: 1px solid var(--neutral-border);
  background: var(--neutral-soft); color: var(--neutral);
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex: none;
}
.badge-plain::before { display: none; }
.badge-ok      { background: var(--ok-soft);      color: var(--ok);      border-color: var(--ok-border); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn);    border-color: var(--warn-border); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 7px; border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--text-3);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-phase { font-family: var(--font); letter-spacing: .02em; }

/* Attention counts are solid, not tinted: a number that means "something needs
   you" has to be legible from across the room, on any background it sits on. */
.pill-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--danger-solid); color: var(--on-danger);
  border: 1px solid transparent;
}

/* --- Cards & panels --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-pad { padding: var(--sp-5); }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: var(--fs-md); }
.card-body { padding: var(--sp-5); }
.card-body-flush { padding: 0; }
.card-foot {
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border);
  background: var(--surface-inset);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.panel {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-4);
}

/* Callouts carry a solid spine in their status hue — the border tint alone
   disappears at a glance; the spine does not. */
.callout {
  border: 1px solid var(--info-border); border-left: 4px solid var(--info);
  background: var(--info-soft);
  border-radius: var(--r-md); padding: var(--sp-4);
  display: flex; gap: var(--sp-3);
}
.callout-warn { border-color: var(--warn-border); border-left-color: var(--warn); background: var(--warn-soft); }
.callout-danger { border-color: var(--danger-border); border-left-color: var(--danger); background: var(--danger-soft); }
.callout-ok { border-color: var(--ok-border); border-left-color: var(--ok); background: var(--ok-soft); }
.callout h4 { font-size: var(--fs-base); margin-bottom: 2px; }
.callout p { font-size: var(--fs-sm); color: var(--text-2); }

/* --- Stat tiles ------------------------------------------------------------
   A tile that needs attention wears its state on the tile, not only in the
   digit: a coloured spine plus a wash behind the number. A calm tile keeps a
   neutral spine, so "fine" and "act" are distinguishable before you can read
   a single word. Driven off the value's own is-* class via :has(), so every
   existing screen gets this for free. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: var(--sp-3); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--r-md); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: 2px;
  text-align: left; box-shadow: var(--sh-1);
}
a.stat, button.stat { cursor: pointer; font: inherit; color: inherit; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
a.stat:hover, button.stat:hover { border-color: var(--border-strong); box-shadow: var(--sh-2); text-decoration: none; }
.stat-label { font-size: var(--fs-xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.stat-value { font-size: var(--fs-2xl); font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-note { font-size: var(--fs-sm); color: var(--text-3); }
.stat-value.is-warn { color: var(--warn); }
.stat-value.is-danger { color: var(--danger); }
.stat-value.is-ok { color: var(--ok); }
.stat:has(.stat-value.is-danger) {
  border-left-color: var(--danger);
  background: linear-gradient(105deg, var(--danger-soft), var(--surface) 55%);
}
.stat:has(.stat-value.is-warn) {
  border-left-color: var(--warn);
  background: linear-gradient(105deg, var(--warn-soft), var(--surface) 55%);
}
.stat:has(.stat-value.is-ok) { border-left-color: var(--ok); }
.stat:has(.stat-value.is-danger) .stat-label { color: var(--danger); }
.stat:has(.stat-value.is-warn)   .stat-label { color: var(--warn); }
.stat:has(.stat-value.is-ok)     .stat-label { color: var(--ok); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.tbl th {
  text-align: left; font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-strong);
  white-space: nowrap; background: var(--surface-2);
}
.tbl td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--brand-soft); }
.tbl .col-num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Progress --- */
.bar { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width 420ms var(--ease); }
.bar.is-ok > i { background: var(--ok); }
.bar.is-warn > i { background: var(--warn); }
.bar.is-danger > i { background: var(--danger); }

/* --- Menus --- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); right: 0;
  min-width: 232px; padding: var(--sp-2);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
}
.menu[hidden] { display: none; }
.menu-label {
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
}
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left; font: inherit; font-size: var(--fs-base);
  padding: 8px var(--sp-3); border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text); cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); text-decoration: none; }
.menu-item small { display: block; color: var(--text-3); font-size: var(--fs-xs); font-weight: 400; }
.menu-item strong { font-weight: 550; }
.menu-sep { height: 1px; background: var(--border); margin: var(--sp-2) 0; }

/* --- Dialog --- */
dialog.modal {
  padding: 0; border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: var(--sh-4);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
}
dialog.modal::backdrop { background: rgba(9, 14, 20, .5); backdrop-filter: blur(2px); }
[data-theme="dark"] dialog.modal::backdrop { background: rgba(0, 0, 0, .66); }
.modal-head { padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal-head h3 { font-size: var(--fs-lg); }
.modal-head p { color: var(--text-2); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.modal-body { padding: 0 var(--sp-5) var(--sp-5); max-height: 62vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border);
  background: var(--surface-inset); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-wide { width: min(880px, calc(100vw - 32px)); }

/* --- Toasts --- */
.toasts {
  position: fixed; z-index: 300; bottom: var(--sp-5); left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center; pointer-events: none;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--neutral);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-base);
  width: 100%;
}
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--brand); }
.toast .toast-close { margin-left: auto; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 240ms var(--ease); }
  @keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
}

/* --- Loading / empty / error states --- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  border-radius: var(--r-sm);
  min-height: 14px;
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s ease-in-out infinite; }
  @keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
}
.skeleton-stack { display: flex; flex-direction: column; gap: var(--sp-3); }

.state {
  display: grid; justify-items: center; text-align: center;
  gap: var(--sp-3); padding: var(--sp-9) var(--sp-5);
  color: var(--text-2);
}
.state h3 { color: var(--text); }
.state p { max-width: 46ch; font-size: var(--fs-base); }
.state-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
}
.state-error .state-icon { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

.inline-spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  animation: spin 700ms linear infinite;
}
@media (prefers-reduced-motion: reduce) { .inline-spinner, .boot-mark { animation-duration: 2.4s; } }

/* ---------------------------------------------------------------------------
   4. APP SHELL
   ------------------------------------------------------------------------*/
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }

.nav {
  grid-row: 1 / -1;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;

  /* Re-scope the primitive tokens for everything that lives on the rail —
     the brand mark, the avatar, ghost buttons, chips — so one block carries
     the navy treatment and no component needs to know it is in the sidebar. */
  --surface:       transparent;
  --surface-2:     rgba(255, 255, 255, .07);
  --surface-3:     rgba(255, 255, 255, .13);
  --surface-inset: rgba(255, 255, 255, .04);
  --border:        var(--nav-border);
  --border-strong: var(--nav-border-strong);
  --text:          #f2f6fb;
  --text-2:        var(--nav-text);
  --text-3:        var(--nav-text-dim);
  --brand:         var(--nav-accent);
  --brand-text:    var(--nav-accent);
  --brand-soft:    rgba(125, 180, 238, .14);
  --brand-soft-2:  rgba(125, 180, 238, .26);
  --brand-border:  var(--nav-border-strong);
}
.nav-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--nav-border);
  color: var(--text);
}
.nav-brand:hover { text-decoration: none; }
.brand-mark { flex: none; }
.brand-name { display: block; font-size: var(--fs-md); font-weight: 640; letter-spacing: -.015em; }
.brand-sub {
  display: block; font-size: var(--fs-xs); color: var(--text-3); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nav-list { list-style: none; margin: 0; padding: var(--sp-3) var(--sp-3); display: flex; flex-direction: column; gap: 1px; }
.nav-section { padding: var(--sp-4) var(--sp-3) var(--sp-1); }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px var(--sp-3); border-radius: var(--r-sm);
  color: var(--nav-text); font-size: var(--fs-base); font-weight: 520;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: #fff; text-decoration: none; }
.nav-link .ico { flex: none; color: var(--nav-text-dim); }
.nav-link:hover .ico { color: var(--nav-text); }
.nav-link[aria-current="page"] {
  background: var(--brand-soft-2); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--nav-accent);
}
.nav-link[aria-current="page"] .ico { color: var(--nav-accent); }
.nav-link .pill-count { margin-left: auto; }

.nav-foot { margin-top: auto; padding: var(--sp-3); border-top: 1px solid var(--nav-border); }
.nav-user { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); min-width: 0; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: var(--r-full);
  background: var(--brand-soft); color: var(--brand-text);
  display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--brand-border);
}
.nav-user-name { display: block; font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-role { display: block; font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: var(--sp-3) var(--sp-6);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  font-size: var(--fs-md); font-weight: 620; letter-spacing: -.012em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-sub { font-size: var(--fs-sm); color: var(--text-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.nav-toggle { display: none; }

main.main { padding: var(--sp-6); padding-bottom: var(--sp-11); max-width: 1360px; width: 100%; }
/* Clear the fixed Copilot FAB so it never occludes content in the bottom-right.
   FAB is 46px tall at --sp-5 from the edge; reserve height + gutter + breathing room. */
main.main > * { scroll-margin-bottom: 96px; }
main.main::after { content: ""; display: block; height: 84px; pointer-events: none; }
/* Right-hand rails sit under the FAB on tall pages — pad them individually so
   their last card's text clears it even when the page itself is not scrolled. */
.qc-layout > *:last-child,
.val-layout > *:last-child,
.month-layout > *:last-child { padding-bottom: 84px; }
.page-head { margin-bottom: var(--sp-6); }
.page-head h1 { font-size: var(--fs-2xl); letter-spacing: -.021em; }
.page-head p { color: var(--text-2); margin-top: var(--sp-2); max-width: 74ch; }

.section { margin-top: var(--sp-7); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.section-head h2 { font-size: var(--fs-lg); }

.backdrop-scrim { display: none; }

/* ---------------------------------------------------------------------------
   5. SCREENS
   ------------------------------------------------------------------------*/

/* --- 5a. Auth / marketing --- */
.marketing { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.mk-nav {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.mk-nav .grow { display: flex; }
.mk-main { flex: 1 1 auto; }
.mk-hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: var(--sp-10); align-items: center;
  max-width: 1180px; margin: 0 auto; padding: var(--sp-11) var(--sp-6);
}
.mk-hero h1 { font-size: var(--fs-4xl); letter-spacing: -.028em; line-height: 1.08; }
.mk-lede { font-size: var(--fs-md); color: var(--text-2); margin-top: var(--sp-5); max-width: 54ch; line-height: 1.62; }
.mk-cta { display: flex; gap: var(--sp-3); margin-top: var(--sp-7); flex-wrap: wrap; }
.mk-points { list-style: none; padding: 0; margin: var(--sp-7) 0 0; display: grid; gap: var(--sp-3); }
.mk-points li { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--fs-base); color: var(--text-2); }
.mk-points .ico { color: var(--ok); flex: none; margin-top: 2px; }

.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-3); padding: var(--sp-7); }
.auth-card h2 { font-size: var(--fs-xl); }
.auth-card .field + .field { margin-top: var(--sp-4); }
.auth-alt { margin-top: var(--sp-5); font-size: var(--fs-sm); color: var(--text-2); text-align: center; }
.auth-divider { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-5) 0; color: var(--text-3); font-size: var(--fs-sm); }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }

.mk-band { border-top: 1px solid var(--border); background: var(--surface); }
.mk-band-inner { max-width: 1180px; margin: 0 auto; padding: var(--sp-10) var(--sp-6); }
.mk-grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--sp-6); }
.mk-feature h3 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.mk-feature p { color: var(--text-2); font-size: var(--fs-base); }
.mk-feature .ico-box {
  width: 36px; height: 36px; border-radius: var(--r-sm); margin-bottom: var(--sp-4);
  display: grid; place-items: center; background: var(--brand-soft);
  color: var(--brand-text); border: 1px solid var(--brand-border);
}
.mk-foot { border-top: 1px solid var(--border); padding: var(--sp-6); text-align: center; color: var(--text-3); font-size: var(--fs-sm); }

/* --- 5b. Year Wheel --- */
.wheel-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--sp-7); align-items: start;
}
.wheel-stage {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-1);
  padding: var(--sp-5); position: relative;
}
.wheel-svg { width: 100%; height: auto; max-width: 620px; margin: 0 auto; overflow: visible; }

.seg { cursor: pointer; }
.seg-shape {
  transition: fill var(--dur) var(--ease), stroke var(--dur) var(--ease), transform 220ms var(--ease);
  transform-origin: 300px 300px;
}
.seg:hover .seg-shape { filter: brightness(1.03); }
[data-theme="dark"] .seg:hover .seg-shape { filter: brightness(1.22); }
.seg:focus { outline: none; }
.seg:focus-visible .seg-focus { opacity: 1; }
.seg-focus { opacity: 0; pointer-events: none; }
.seg-label { font-size: 13px; font-weight: 640; letter-spacing: .06em; fill: var(--text-2); pointer-events: none; }
.seg-num   { font-size: 11px; font-weight: 700; fill: var(--text-3); pointer-events: none; }
.seg.is-current .seg-label { fill: var(--brand-text); font-size: 14px; }
.seg.is-current .seg-num { fill: var(--brand-text); }
.seg-annual .seg-label { fill: var(--text-2); }

.wheel-hub-year { font-size: 13px; font-weight: 650; letter-spacing: .12em; fill: var(--text-3); }
.wheel-hub-pct { font-size: 44px; font-weight: 600; letter-spacing: -.02em; fill: var(--text); }
.wheel-hub-note { font-size: 12px; fill: var(--text-3); }
.wheel-hub-month { font-size: 13px; font-weight: 620; fill: var(--brand-text); }

@media (prefers-reduced-motion: no-preference) {
  .wheel-animate .seg-shape,
  .wheel-animate .seg-arc { opacity: 0; animation: seg-in 520ms var(--ease) forwards; }
  .wheel-animate .seg-label,
  .wheel-animate .seg-num { opacity: 0; animation: fade-in 380ms var(--ease) forwards; animation-delay: 420ms; }
  .wheel-animate .wheel-hub { opacity: 0; animation: fade-in 460ms var(--ease) 520ms forwards; }
  @keyframes seg-in { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
  @keyframes fade-in { to { opacity: 1; } }
}

.wheel-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: center; margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0,0,0,.12); flex: none; }
[data-theme="dark"] .legend-swatch { border-color: rgba(255,255,255,.16); }

.sys-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.sys-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text); text-align: left; width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0;
  font: inherit; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.sys-row:last-child { border-bottom: 0; }
.sys-row:hover { background: var(--surface-inset); text-decoration: none; }
.sys-row.is-current { background: var(--brand-soft); }
.sys-month { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em; color: var(--text-3); text-transform: uppercase; }
.sys-row.is-current .sys-month { color: var(--brand-text); }
.sys-name { display: block; font-size: var(--fs-base); font-weight: 550; line-height: 1.35; }
.sys-meta { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }

/* --- 5c. This Month --- */
.month-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-6); align-items: start; }
.scope-box {
  border-left: 3px solid var(--brand-border); background: var(--surface-inset);
  padding: var(--sp-3) var(--sp-4); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-2); font-size: var(--fs-base); line-height: 1.6;
}
.section-title {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text);
  position: sticky; top: var(--topbar-h); z-index: 8;
}

.check-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto auto;
  gap: var(--sp-3) var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.check-item:last-child { border-bottom: 0; }
.check-item.has-finding { background: var(--danger-soft); }
[data-theme="dark"] .check-item.has-finding { background: color-mix(in srgb, var(--danger-soft) 70%, transparent); }
.check-num {
  font-size: var(--fs-sm); font-weight: 700; color: var(--text-3);
  font-variant-numeric: tabular-nums; padding-top: 5px;
}
.check-text { font-size: var(--fs-base); line-height: 1.5; }
.check-tags { display: flex; gap: var(--sp-2); margin-top: 6px; flex-wrap: wrap; }

.yna { display: flex; gap: 4px; }
.yna input { position: absolute; opacity: 0; width: 0; height: 0; }
.yna label {
  display: grid; place-items: center;
  min-width: 38px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 650; cursor: pointer;
  transition: all var(--dur) var(--ease);
  user-select: none;
}
.yna label:hover { background: var(--surface-2); }
.yna input:checked + label { border-width: 1.5px; font-weight: 700; }
.yna input[value="Y"]:checked + label { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.yna input[value="N"]:checked + label { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.yna input[value="NA"]:checked + label { background: var(--neutral-soft); color: var(--neutral); border-color: var(--neutral); }
.yna input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }

.initials-field { width: 74px; }
.initials-field input { text-transform: uppercase; text-align: center; letter-spacing: .08em; font-weight: 600; }

.finding {
  grid-column: 1 / -1;
  margin-top: var(--sp-2);
  border: 1px solid var(--danger-border); background: var(--surface);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4);
  display: flex; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap;
}
.finding .ico { color: var(--danger); flex: none; margin-top: 2px; }
.finding-title { font-size: var(--fs-sm); font-weight: 650; color: var(--danger); }
.finding-note { font-size: var(--fs-sm); color: var(--text-2); }
@media (prefers-reduced-motion: no-preference) {
  .finding { animation: finding-in 260ms var(--ease); }
  @keyframes finding-in { from { opacity: 0; transform: translateY(-4px); } }
}

.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-3); min-height: 20px; }
.save-status.is-saved { color: var(--ok); }
.save-status.is-error { color: var(--danger); }

.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-4); }

.sig-preview {
  font-family: "Segoe Script", "Bradley Hand", "Snell Roundhand", cursive;
  font-size: var(--fs-xl); color: var(--text);
  border-bottom: 1px solid var(--border-strong);
  padding: var(--sp-2) var(--sp-1); min-height: 44px;
}

/* --- 5d. Personnel --- */
.person-card { display: grid; gap: var(--sp-4); }
.track { display: flex; gap: 4px; align-items: center; }
.track-step {
  flex: 1 1 0; height: 6px; border-radius: var(--r-full);
  background: var(--surface-3); position: relative;
}
.track-step.is-done { background: var(--ok); }
.track-label { font-size: var(--fs-xs); color: var(--text-3); }

.comp-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.comp-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  background: var(--surface-inset); border: 1px solid var(--border);
  flex-wrap: wrap;
}
.comp-row.is-due { border-color: var(--warn-border); border-left: 3px solid var(--warn); background: var(--warn-soft); }
.comp-row.is-overdue { border-color: var(--danger-border); border-left: 3px solid var(--danger); background: var(--danger-soft); }
/* A tinted pill on an identically tinted row is invisible — give badges that
   sit on a status-washed row a solid surface to stand on. */
.comp-row.is-due .badge, .comp-row.is-overdue .badge { background: var(--surface); }
[data-theme="dark"] .comp-row.is-due .badge,
[data-theme="dark"] .comp-row.is-overdue .badge { background: var(--surface-inset); }
.comp-label { font-size: var(--fs-sm); font-weight: 550; }
.comp-due { font-size: var(--fs-xs); color: var(--text-3); }

/* --- 5e. Instruments --- */
.cadence-group + .cadence-group { margin-top: var(--sp-4); }
.cadence-head {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}
.task-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--sp-3); align-items: center;
  padding: var(--sp-2) 0;
}
.task-name { font-size: var(--fs-base); line-height: 1.4; }
.task-note { font-size: var(--fs-xs); color: var(--text-3); }
.task-row.is-overdue .task-name { font-weight: 600; }

.instrument-head { display: flex; align-items: flex-start; gap: var(--sp-4); flex-wrap: wrap; }
.instrument-title h3 { font-size: var(--fs-md); }
.instrument-meta { font-size: var(--fs-sm); color: var(--text-3); }
.is-out-of-service { opacity: .78; }

/* --- 5f. QC --- */
.qc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-6); align-items: start; }
.lj-chart { width: 100%; height: auto; }
.lj-band-1 { fill: var(--chart-1sd); opacity: .34; }
.lj-band-2 { fill: var(--chart-2sd); opacity: .30; }
.lj-band-3 { fill: var(--chart-3sd); opacity: .28; }
.lj-grid { stroke: var(--chart-grid); stroke-width: 1; }
.lj-mean { stroke: var(--chart-mean); stroke-width: 1.5; stroke-dasharray: 6 4; }
.lj-axis-label { font-size: 10.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.lj-axis-title { font-size: 11px; fill: var(--text-3); font-weight: 600; }
.lj-line { fill: none; stroke: var(--chart-line); stroke-width: 1.6; stroke-linejoin: round; }
.lj-pt { fill: var(--surface); stroke: var(--chart-point); stroke-width: 1.8; cursor: pointer; transition: r var(--dur) var(--ease); }
.lj-pt:hover { r: 5.5; }
.lj-pt.is-flag { fill: var(--chart-flag); stroke: var(--chart-flag); }
.lj-pt.is-warn { fill: var(--warn); stroke: var(--warn); }
.lj-pt.is-involved { fill: var(--warn); stroke: var(--warn); }
.lj-pt.is-selected { stroke: var(--text); stroke-width: 2.6; }
.lj-pt:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.lj-flag-ring { fill: none; stroke: var(--chart-flag); stroke-width: 1.4; opacity: .5; }
@media (prefers-reduced-motion: no-preference) {
  .lj-flag-ring { animation: pulse-ring 2.4s ease-in-out infinite; }
  @keyframes pulse-ring { 0%,100% { opacity: .18; r: 9; } 50% { opacity: .62; r: 12; } }
}

.wg-verdict {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--danger-border); background: var(--danger-soft);
}
.wg-rule {
  font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: 700;
  color: var(--danger); letter-spacing: -.01em;
}
.wg-steps { list-style: none; padding: 0; margin: 0; counter-reset: wg; display: flex; flex-direction: column; gap: var(--sp-3); }
.wg-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--sp-3); font-size: var(--fs-base); line-height: 1.5; }
.wg-steps li::before {
  counter-increment: wg; content: counter(wg);
  width: 24px; height: 24px; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text);
  border: 1px solid var(--brand-border);
  font-size: var(--fs-xs); font-weight: 700;
}

/* --- 5f-2. Method validation ---------------------------------------------
   The charts share the Levey-Jennings anatomy: a recessive grid, a 1px frame,
   2px data lines, >=8px markers, tabular-numeral axis labels. What changes
   between protocols is the geometry, never the drawing hand.
   ------------------------------------------------------------------------*/
.val-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-6); align-items: start; }

/* Study roster */
.study-card + .study-card { margin-top: var(--sp-4); }
.study-head { display: flex; align-items: flex-start; gap: var(--sp-4); flex-wrap: wrap; }
.study-path {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--r-xs);
  border: 1px solid var(--brand-border); background: var(--brand-soft); color: var(--brand-text);
}
.study-path.is-establish { border-color: var(--warn-border); background: var(--warn-soft); color: var(--warn); }

/* The at-a-glance matrix: one cell per required characteristic. */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: var(--sp-2); }
.char {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--sp-2);
  align-items: start; padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-inset); text-align: left; width: 100%;
  font: inherit; color: var(--text); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.char:hover { border-color: var(--border-strong); text-decoration: none; }
.char .ico { margin-top: 2px; flex: none; }
.char-name { display: block; font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; }
.char-state { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 1px; }
.char.is-pass    { border-color: var(--ok-border);      background: var(--ok-soft); }
.char.is-pass    .ico, .char.is-pass .char-state { color: var(--ok); }
.char.is-fail    { border-color: var(--danger-border);  background: var(--danger-soft); }
.char.is-fail    .ico, .char.is-fail .char-state { color: var(--danger); }
.char.is-pending { border-color: var(--warn-border);    background: var(--warn-soft); }
.char.is-pending .ico, .char.is-pending .char-state { color: var(--warn); }
.char.is-missing { border-style: dashed; }
.char.is-missing .ico, .char.is-missing .char-state { color: var(--text-3); }

/* Data entry */
.entry-tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); padding: 0 var(--sp-2); }
.entry-tab {
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  padding: var(--sp-3) var(--sp-4); border: 0; background: none; cursor: pointer;
  color: var(--text-2); border-bottom: 3px solid transparent; margin-bottom: -1px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.entry-tab:hover { color: var(--text); border-bottom-color: var(--border-strong); background: var(--surface-2); }
.entry-tab[aria-selected="true"] {
  color: var(--brand-text); border-bottom-color: var(--brand); font-weight: 700;
  background: linear-gradient(to top, var(--brand-soft), transparent 82%);
}

.shape-hint {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--sp-3);
  border-left: 3px solid var(--brand-border); background: var(--surface-inset);
  padding: var(--sp-3) var(--sp-4); border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.shape-hint .ico { color: var(--brand-text); margin-top: 2px; }
.shape-cols { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.shape-col {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 7px; border-radius: var(--r-xs);
  background: var(--brand-soft); color: var(--brand-text); border: 1px solid var(--brand-border);
}
.shape-col.is-optional { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }

.paste-box {
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.65;
  min-height: 168px; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.parse-preview { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.parse-summary {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); background: var(--surface-inset);
  border-bottom: 1px solid var(--border); font-size: var(--fs-sm);
}
.parse-scroll { max-height: 268px; overflow: auto; }
.parse-preview .tbl th { position: sticky; top: 0; z-index: 2; }
.parse-preview .tbl td { padding: 5px var(--sp-4); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
tr.row-bad td { background: var(--danger-soft); }
.row-issue { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }

.grid-editor { overflow: auto; max-height: 420px; }
.grid-editor .input { min-height: 30px; padding: 3px 7px; font-size: var(--fs-sm); text-align: right; }
.grid-editor th.rowhead, .grid-editor td.rowhead {
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}

/* Charts */
.vchart { width: 100%; height: auto; }
.v-grid  { stroke: var(--chart-grid); stroke-width: 1; }
.v-frame { fill: none; stroke: var(--border-strong); stroke-width: 1; }
.v-axis-label { font-size: 10.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.v-axis-title { font-size: 11px; fill: var(--text-3); font-weight: 600; }
.v-point-label { font-size: 10px; fill: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }

.v-fit      { fill: none; stroke: var(--chart-s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.v-identity { fill: none; stroke: var(--chart-ref); stroke-width: 1.5; stroke-dasharray: 6 4; }
.v-mean     { fill: none; stroke: var(--chart-s3); stroke-width: 2; }
.v-limit    { fill: none; stroke: var(--chart-limit); stroke-width: 1.5; stroke-dasharray: 5 4; }
.v-loa      { fill: none; stroke: var(--chart-s2); stroke-width: 1.5; stroke-dasharray: 3 3; }
.v-band     { fill: var(--chart-fill); opacity: .5; }

.v-pt { fill: var(--chart-s1); stroke: var(--surface); stroke-width: 2; }
.v-pt.is-out { fill: var(--danger); }
.v-pt.is-flag { fill: var(--warn); }
.v-pt-hollow { fill: var(--surface); stroke: var(--chart-s1); stroke-width: 2; }

.v-bar { fill: var(--chart-s1); stroke: var(--surface); stroke-width: 2; }
.v-bar.s2 { fill: var(--chart-s2); }
.v-bar.s3 { fill: var(--chart-s3); }
.v-bar.s4 { fill: var(--chart-s4); }
.v-bar.is-out { fill: var(--danger); }
.v-hist { fill: var(--chart-s1); stroke: var(--surface); stroke-width: 2; }
.v-hist.is-outside { fill: var(--chart-ref); }

/* Sigma zones: an ordinal risk scale, so it wears the reserved status palette
   rather than a categorical hue. Every band also carries its sigma number and
   its grade word, so the colour is never the only signal. */
.v-zone-6 { fill: var(--ok);     opacity: .26; }
.v-zone-5 { fill: var(--ok);     opacity: .14; }
.v-zone-4 { fill: var(--warn);   opacity: .11; }
.v-zone-3 { fill: var(--warn);   opacity: .24; }
.v-zone-2 { fill: var(--danger); opacity: .17; }
.v-zone-x { fill: var(--danger); opacity: .30; }
.v-zone-line { stroke: var(--border-strong); stroke-width: 1; fill: none; }
.v-zone-label { font-size: 10px; font-weight: 700; fill: var(--text-2); letter-spacing: .04em; }
.v-op {
  fill: var(--surface); stroke: var(--text); stroke-width: 2.6;
}
.v-op-halo { fill: none; stroke: var(--text); stroke-width: 1.2; opacity: .45; }
@media (prefers-reduced-motion: no-preference) {
  .v-op-halo { animation: pulse-ring 2.4s ease-in-out infinite; }
}

.chart-legend {
  display: flex; flex-wrap: wrap; gap: var(--sp-4);
  margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border);
}
.chart-legend .legend-item { font-size: var(--fs-sm); color: var(--text-2); }
.legend-key { width: 16px; height: 3px; border-radius: 2px; flex: none; }
.legend-key.is-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-key.is-dash { background-image: linear-gradient(90deg, currentColor 55%, transparent 55%); background-size: 6px 100%; }

/* Verdicts — the statistic never appears without its plain-English reading. */
.vd {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--sp-3);
  padding: var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--neutral-border); background: var(--neutral-soft);
}
.vd .ico { margin-top: 2px; }
.vd-ok      { border-color: var(--ok-border);     background: var(--ok-soft); }
.vd-ok .ico, .vd-ok .vd-head { color: var(--ok); }
.vd-fail    { border-color: var(--danger-border); background: var(--danger-soft); }
.vd-fail .ico, .vd-fail .vd-head { color: var(--danger); }
.vd-warn    { border-color: var(--warn-border);   background: var(--warn-soft); }
.vd-warn .ico, .vd-warn .vd-head { color: var(--warn); }
.vd-head { font-size: var(--fs-md); font-weight: 700; letter-spacing: -.01em; }
.vd-plain { font-size: var(--fs-base); line-height: 1.55; margin-top: var(--sp-1); color: var(--text); }
.vd-stat { font-family: var(--font-mono); font-weight: 650; font-variant-numeric: tabular-nums; }

/* A number and its reading, side by side. Never a bare figure. */
.readout { display: grid; gap: var(--sp-3); }
.readout-row {
  display: grid; grid-template-columns: minmax(140px, 210px) minmax(0, 1fr);
  gap: var(--sp-2) var(--sp-4); align-items: baseline;
  padding-bottom: var(--sp-3); border-bottom: 1px dotted var(--border);
}
.readout-row:last-child { border-bottom: 0; padding-bottom: 0; }
.readout-figure { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.readout-value {
  font-size: var(--fs-lg); font-weight: 640; letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
}
.readout-value.is-ok { color: var(--ok); }
.readout-value.is-warn { color: var(--warn); }
.readout-value.is-danger { color: var(--danger); }
.readout-label { font-size: var(--fs-xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.readout-plain { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.55; }

.preview-banner { border-color: var(--warn-border); background: var(--warn-soft); }

/* --- 5g. Narrative --- */
.doc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  padding: var(--sp-9) var(--sp-10);
  max-width: 900px; margin: 0 auto;
}
.doc-head { text-align: center; padding-bottom: var(--sp-6); border-bottom: 2px solid var(--text); margin-bottom: var(--sp-7); }
.doc-lab { font-size: var(--fs-lg); font-weight: 650; letter-spacing: .01em; }
.doc-title { font-size: var(--fs-sm); font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); margin-top: var(--sp-2); }
.doc-note { font-size: var(--fs-sm); color: var(--text-3); margin-top: var(--sp-2); }
.doc-section { margin-bottom: var(--sp-8); }
.doc-h {
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-2);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.doc-body p { font-size: var(--fs-base); line-height: 1.72; margin-bottom: var(--sp-4); }
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-month { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: var(--sp-4); padding: var(--sp-2) 0; border-bottom: 1px dotted var(--border); font-size: var(--fs-base); }
.doc-month:last-child { border-bottom: 0; }
.doc-month-name { font-weight: 650; }
.doc-events-month { font-weight: 650; margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-base); }
.doc-event { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: var(--sp-4); padding: 3px 0; font-size: var(--fs-base); }
.doc-bullets { padding-left: 1.2em; }
.doc-bullets li { margin-bottom: var(--sp-2); line-height: 1.65; }
.doc-sigs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-8); margin-top: var(--sp-9); }
.sig-line { border-top: 1px solid var(--text); padding-top: var(--sp-2); margin-top: var(--sp-8); }
.sig-role { font-size: var(--fs-sm); font-weight: 600; }
.sig-name { font-size: var(--fs-sm); color: var(--text-2); }
.doc-edit-area { width: 100%; }

/* --- 5h. SOPs --- */
.sop-body {
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface-inset); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-5);
  max-height: 620px; overflow-y: auto;
}
.gap-mark {
  display: block; margin: var(--sp-3) 0; padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm); border-left: 3px solid var(--warn);
  background: var(--warn-soft); color: var(--text);
  font-family: var(--font); white-space: normal;
}
.gap-mark.sev-critical { border-left-color: var(--danger); background: var(--danger-soft); }
.gap-mark.sev-minor { border-left-color: var(--neutral); background: var(--neutral-soft); }
.gap-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-1); }
.gap-std { font-size: var(--fs-xs); font-weight: 650; color: var(--text-2); }
.gap-text { font-size: var(--fs-sm); color: var(--text); }
.gap-sugg { font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--sp-2); padding-left: var(--sp-3); border-left: 2px solid var(--border-strong); }

/* --- 5i. Pricing / Why --- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(266px, 1fr)); gap: var(--sp-5); align-items: stretch; }
.plan {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6); box-shadow: var(--sh-1);
}
.plan.is-featured { border-color: var(--brand); box-shadow: var(--sh-3); position: relative; }
.plan-flag {
  position: absolute; top: -11px; left: var(--sp-6);
  background: var(--brand); color: var(--text-on-brand);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 10px; border-radius: var(--r-full);
}
.plan-name { font-size: var(--fs-md); font-weight: 650; }
.plan-price { font-size: var(--fs-3xl); font-weight: 620; letter-spacing: -.03em; margin: var(--sp-3) 0 0; }
.plan-price small { font-size: var(--fs-base); font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.plan-for { font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--sp-2); min-height: 2.8em; }
.plan-features { list-style: none; padding: 0; margin: var(--sp-5) 0 var(--sp-6); display: grid; gap: var(--sp-3); }
.plan-features li { display: flex; gap: var(--sp-3); font-size: var(--fs-base); color: var(--text-2); align-items: flex-start; }
.plan-features .ico { color: var(--ok); flex: none; margin-top: 3px; }
.plan .btn { margin-top: auto; }

.value-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); gap: var(--sp-5); }
.value-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--sh-1); }
.value-card h3 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.value-card p { color: var(--text-2); }
.value-card .ico-box {
  width: 34px; height: 34px; border-radius: var(--r-sm); margin-bottom: var(--sp-4);
  display: grid; place-items: center; background: var(--brand-soft);
  color: var(--brand-text); border: 1px solid var(--brand-border);
}
.faq dt { font-weight: 620; margin-top: var(--sp-5); }
.faq dd { margin: var(--sp-2) 0 0; color: var(--text-2); }

.plan-modules { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.plan-modules .row-wrap { gap: var(--sp-2); }

/* The three-module story: one block per module, each ending in the specific
   defensible claim it is allowed to make. */
.mod {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden;
}
.mod + .mod { margin-top: var(--sp-5); }
.mod-head {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-5); border-bottom: 1px solid var(--border);
  background: var(--surface-inset);
}
.mod-index {
  flex: none; width: 36px; height: 36px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text);
  border: 1px solid var(--brand-border);
}
.mod-name { font-size: var(--fs-lg); font-weight: 640; letter-spacing: -.015em; }
.mod-sells { font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); margin-top: 3px; }
.mod-body { padding: var(--sp-5); display: grid; gap: var(--sp-5); }
.mod-lede { font-size: var(--fs-md); line-height: 1.62; max-width: 78ch; }
.mod-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--sp-6); }
@media (max-width: 900px) { .mod-cols { grid-template-columns: minmax(0, 1fr); } }
.mod-col .eyebrow { display: block; margin-bottom: var(--sp-3); }
.mod-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); }
.mod-list li { display: flex; gap: var(--sp-3); align-items: flex-start; color: var(--text-2); }
.mod-list .ico { color: var(--ok); flex: none; margin-top: 3px; }
.mod-who { color: var(--text-2); }
.mod-claim {
  border: 1px solid var(--brand-border); border-left-width: 3px;
  background: var(--brand-soft); border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
}
.mod-claim h4 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.mod-claim p { color: var(--text-2); line-height: 1.62; max-width: 78ch; }

/* The lot-change trigger — the demo moment. Diagram left, wording right. */
.trg-card { border-color: var(--brand-border); }
.trg-layout { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: var(--sp-7); align-items: start; }
@media (max-width: 900px) { .trg-layout { grid-template-columns: minmax(0, 1fr); } }
.trg-figure { display: flex; justify-content: center; }
.trg { width: 100%; max-width: 360px; height: auto; display: block; overflow: visible; }
.trg-node { fill: var(--surface-inset); stroke: var(--border-strong); stroke-width: 1.4; }
/* The gate is marked by a dashed outline as well as by colour, so it survives
   a monochrome printer and a colour-vision deficiency; the node also says in
   words that it is a gate. */
.trg-node.is-gate { stroke: var(--warn); stroke-width: 1.8; stroke-dasharray: 6 4; }
.trg-flow { fill: none; stroke: var(--brand); stroke-width: 2; }
.trg-arrow { fill: var(--brand); }
.trg-step { font-size: 10px; font-weight: 700; letter-spacing: .1em; fill: var(--text-2); }
.trg-title { font-size: 13px; font-weight: 650; fill: var(--text); }
.trg-sub { font-size: 10.5px; fill: var(--text-2); }
.trg-steps { list-style: none; counter-reset: trg; padding: 0; margin: 0; display: grid; gap: var(--sp-5); }
.trg-steps li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: var(--sp-4); }
.trg-steps li::before {
  counter-increment: trg; content: counter(trg);
  width: 26px; height: 26px; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--brand); color: var(--text-on-brand);
  font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums;
}
.trg-steps h4 { font-size: var(--fs-base); margin-bottom: var(--sp-1); }
.trg-steps p { color: var(--text-2); line-height: 1.6; }
.trg-note {
  margin-top: var(--sp-6); padding-top: var(--sp-4);
  border-top: 1px solid var(--border); color: var(--text-2); max-width: 88ch;
}

/* --- 5j. Corrective actions --- */
.ca-card { border-left: 3px solid var(--danger); }
.ca-card.is-closed { border-left-color: var(--ok); }
.ca-meta { font-size: var(--fs-sm); color: var(--text-3); }
.ca-field-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

/* --- 5k. Inventory --------------------------------------------------------
   Two things in here are load-bearing rather than decorative.

   The `.fig-*` set is how a money figure Sentinel is NOT certain about looks:
   a value that cannot be stated gets the same visual weight as one that can,
   because shrinking "we cannot say" into a footnote is how a $0 ends up being
   read as good news. And `.conf-badge.is-derived` carries a dashed outline as
   well as a different word, so an inferred figure cannot be mistaken for a
   measured one across a room — which is the distance a demo is watched from.

   No colour here is hardcoded; every one comes from a token, so light, dark
   and the monochrome print sheet are one implementation.
   ------------------------------------------------------------------------*/

/* Sub-navigation */
.iv-tabs {
  display: flex; flex-wrap: wrap; gap: var(--sp-1);
  border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5);
}
.iv-tab {
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-base); font-weight: 550;
  color: var(--text-2); border-bottom: 3px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.iv-tab:hover { color: var(--text); text-decoration: none; border-bottom-color: var(--border-strong); background: var(--surface-2); }
.iv-tab.is-current {
  color: var(--brand-text); border-bottom-color: var(--brand); font-weight: 650;
  background: linear-gradient(to top, var(--brand-soft), transparent 82%);
}

/* The ROI grid. `minmax(0, 1fr)` rather than the implicit `auto`: a grid item
   defaults to `min-width: auto`, so without this the widest sentence in the
   deepest readout sets the width of the whole screen and the page scrolls
   sideways on a phone. */
.roi-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
.roi-hero { border: 1px solid var(--brand-border); background: var(--brand-soft); }
.roi-hero-figure { display: flex; align-items: baseline; gap: var(--sp-4); flex-wrap: wrap; }
/* The one hero number on the screen. Proportional figures, not tabular:
   `tabular-nums` gives every digit the width of a zero, which reads loose at
   display size. Tabular is reserved for columns that must align. */
.roi-hero-value {
  font-size: var(--fs-4xl); font-weight: 650; letter-spacing: -.03em; line-height: 1.05;
}
.roi-hero-value.is-danger { color: var(--danger); }
.roi-hero-value.is-unstated { font-size: var(--fs-2xl); color: var(--text-2); font-weight: 600; }
.roi-hero-rate { font-size: var(--fs-md); color: var(--text-2); font-weight: 600; }
.roi-hero-statement {
  font-size: var(--fs-md); line-height: 1.55; color: var(--text); max-width: 74ch;
}

/* A figure and everything that qualifies it */
.fig { display: flex; flex-direction: column; gap: var(--sp-2); }
.fig-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.fig-value-row { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.fig-value {
  font-size: var(--fs-2xl); font-weight: 640; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.fig-value.is-ok { color: var(--ok); }
.fig-value.is-warn { color: var(--warn); }
.fig-value.is-danger { color: var(--danger); }
.fig-plain { font-size: var(--fs-base); line-height: 1.55; color: var(--text); max-width: 74ch; }
.fig-basis, .fig-sample {
  font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); max-width: 82ch;
}
.fig-basis-key { font-weight: 650; color: var(--text-3); }
.fig-caveats {
  margin: var(--sp-1) 0 0; padding-left: 1.15em;
  font-size: var(--fs-sm); line-height: 1.55; color: var(--text-2);
}
.fig-caveats li { margin-bottom: var(--sp-1); }

/* Cost coverage runs in one direction: the real number is HIGHER. */
.fig-coverage {
  display: flex; gap: var(--sp-2); align-items: flex-start;
  padding: var(--sp-3); border-radius: var(--r-sm);
  border: 1px solid var(--warn-border); background: var(--warn-soft);
  font-size: var(--fs-sm); line-height: 1.55; color: var(--text);
}
.fig-coverage .ico { color: var(--warn); flex: none; margin-top: 1px; }

/* "We cannot say" — same weight as a stated figure, never a footnote. */
.fig-null {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--sp-3);
  padding: var(--sp-4); border-radius: var(--r-md);
  border: 1px dashed var(--border-strong); background: var(--surface-2);
}
.fig-null-mark { color: var(--text-3); }
.fig-null-head { font-size: var(--fs-md); font-weight: 680; letter-spacing: -.01em; }
.fig-null-plain {
  font-size: var(--fs-sm); line-height: 1.6; color: var(--text-2);
  margin-top: var(--sp-1); max-width: 76ch;
}
.readout-value.is-unstated { color: var(--text-2); font-size: var(--fs-md); }

/* A derived figure must not read as a measured one. */
.conf-badge.is-derived { border-style: dashed; border-width: 1.5px; }
.conf-badge.is-partial-cost { border-style: dashed; }

.waste-sep { align-items: flex-start; }
.waste-sep .ico { color: var(--warn); flex: none; margin-top: 2px; }
.iv-total-row td { background: var(--surface-inset); }

/* Charts */
.iv-chart-wrap { width: 100%; }
.iv-chart { width: 100%; height: auto; display: block; overflow: visible; }
.iv-grid { stroke: var(--chart-grid); stroke-width: 1; }
.iv-baseline { stroke: var(--border-strong); stroke-width: 1; }
.iv-zero { stroke: var(--chart-ref); stroke-width: 1.5; }
.iv-criterion { stroke: var(--chart-limit); stroke-width: 1.5; stroke-dasharray: 5 3; }
.iv-boundary { stroke: var(--chart-limit); stroke-width: 2; stroke-dasharray: 5 3; }
.iv-expiry-line { stroke: var(--chart-flag); stroke-width: 1.5; stroke-dasharray: 4 3; }
.iv-axis-label { font-size: 11px; fill: var(--text-3); }
.iv-axis-title { font-size: 12px; font-weight: 620; fill: var(--text-2); }
.iv-cat-label { font-size: 12px; font-weight: 600; fill: var(--text-2); }
.iv-value-label { font-size: 12px; font-weight: 650; fill: var(--text); }
.iv-value-label.is-unstated { font-weight: 550; fill: var(--text-3); font-style: italic; }

/* The four fixed categorical slots. Assigned in order, never cycled. */
.iv-s1 { fill: var(--chart-s1); }
.iv-s2 { fill: var(--chart-s2); }
.iv-s3 { fill: var(--chart-s3); }
.iv-s4 { fill: var(--chart-s4); }
.iv-key-s1 { background: var(--chart-s1); }
.iv-key-s2 { background: var(--chart-s2); }
.iv-key-s3 { background: var(--chart-s3); }
.iv-key-s4 { background: var(--chart-s4); }
/* A bar with no value to draw is an empty track, not a zero-length bar. */
.iv-bar-empty {
  fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 4 3;
}

/* The expiry runway wears the reserved status ramp, never the categorical one,
   and every band ships with a label and a count as well as a colour. */
.iv-runway-critical { fill: var(--danger); }
.iv-runway-serious  { fill: var(--warn); }
.iv-runway-warning  { fill: var(--chart-limit); }
.iv-runway-watch    { fill: var(--chart-s1); }
.iv-runway-settled  { fill: var(--neutral); }
.iv-runway-unknown  { fill: var(--surface-3); }
.iv-key-critical { background: var(--danger); }
.iv-key-serious  { background: var(--warn); }
.iv-key-warning  { background: var(--chart-limit); }
.iv-key-watch    { background: var(--chart-s1); }
.iv-key-settled  { background: var(--neutral); }
.iv-key-unknown  { background: var(--surface-3); }

/* Before → after: one hue, two treatments. */
.iv-dumbbell { stroke: var(--chart-s1); stroke-width: 2; stroke-linecap: round; }
.iv-dot-before { fill: var(--surface); stroke: var(--chart-s1); stroke-width: 2; }
.iv-dot-after { fill: var(--chart-s1); stroke: var(--surface); stroke-width: 2; }
.iv-dot-after.is-out { fill: var(--danger); }
.iv-key-before { background: var(--surface); box-shadow: inset 0 0 0 2px var(--chart-s1); }
.iv-key-after { background: var(--chart-s1); }
.iv-key-criterion { color: var(--chart-limit); background: none; }
.iv-key-boundary { color: var(--chart-limit); background: none; }

.iv-line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.iv-line.is-thin { stroke: var(--chart-ref); stroke-width: 1.2; }
.iv-end-dot { fill: var(--chart-point); stroke: var(--surface); stroke-width: 2; }
.iv-run-pt { fill: var(--surface); stroke: var(--chart-ref); stroke-width: 1.6; }
.iv-run-pt.is-mine { fill: var(--chart-s1); stroke: var(--surface); stroke-width: 2; }
.iv-key-mine { background: var(--chart-s1); }
.iv-key-other { background: var(--surface); box-shadow: inset 0 0 0 2px var(--chart-ref); }

/* A ratio against a limit. The unfilled track is a lighter step of the same
   ramp, so state reads across the whole bar rather than only at the fill. */
.iv-meter { width: 100%; }
.iv-meter-track {
  position: relative; height: 10px; border-radius: var(--r-full);
  background: var(--brand-soft-2); overflow: visible;
}
.iv-meter-track > i {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--brand);
}
.iv-meter-track.is-low { background: var(--warn-soft); }
.iv-meter-track.is-low > i { background: var(--warn); }
.iv-meter-mark {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--text-2); border-radius: 1px;
}
@media (prefers-reduced-motion: no-preference) {
  .iv-meter-track > i { transition: width 420ms var(--ease); }
}

/* Catalog list */
.iv-item-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); margin-top: var(--sp-3); }
.iv-item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }
.iv-band-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 7px; vertical-align: baseline;
}
.iv-band-dot.is-critical { background: var(--danger); }
.iv-band-dot.is-serious { background: var(--warn); }
.iv-band-dot.is-warning { background: var(--chart-limit); }
.iv-band-dot.is-watch { background: var(--chart-s1); }
.iv-band-dot.is-settled { background: var(--neutral); }
.iv-band-dot.is-unknown { background: var(--surface-3); border: 1px solid var(--border-strong); }

/* Lot / lot-change two-column working layout */
.iv-lot-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-5); align-items: start; }
@media (max-width: 1100px) { .iv-lot-layout { grid-template-columns: minmax(0, 1fr); } }

.iv-dl { margin: 0; display: grid; gap: var(--sp-2); }
.iv-dl > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: var(--sp-3); align-items: baseline; }
.iv-dl dt { font-size: var(--fs-xs); font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.iv-dl dd { margin: 0; font-size: var(--fs-sm); color: var(--text); }

/* A number's plain reading, on its own full-width row under it. */
.tbl tr.iv-reading-row td {
  padding-top: 0; border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.tbl tr.iv-reading-row:hover { background: none; }

.tbl tr.is-cancelled td { opacity: .55; text-decoration: line-through; }
.tbl tr.is-cancelled td:last-child { text-decoration: none; }

/* The verbatim regulation. Quoted, not paraphrased. */
.iv-requirement { border-left: 3px solid var(--brand); }
.iv-verbatim {
  margin: var(--sp-2) 0 0; padding: var(--sp-4);
  border-left: 3px solid var(--border-strong); background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: var(--fs-base); line-height: 1.6; color: var(--text);
}

/* The three things a no-effect demonstration has to carry. */
.iv-gate { display: grid; gap: var(--sp-2); margin: var(--sp-3) 0; }
.iv-gate-item {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-sm);
  border: 1px solid var(--danger-border); background: var(--danger-soft);
  font-size: var(--fs-sm);
}
.iv-gate-item .ico { color: var(--danger); margin-top: 1px; }
.iv-gate-item.is-met { border-color: var(--ok-border); background: var(--ok-soft); }
.iv-gate-item.is-met .ico { color: var(--ok); }

/* The count sheet */
.count-input { width: 100%; max-width: 110px; text-align: right; }
.count-table td, .count-table th { padding: var(--sp-3); }
.count-lot { min-width: 180px; }
.count-write-box { display: none; }
.print-only { display: none; }

/* ---------------------------------------------------------------------------
   6. COPILOT
   ------------------------------------------------------------------------*/
.copilot-fab {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 52px; width: 52px; padding: 0; border-radius: var(--r-full);
  background: var(--brand); color: var(--text-on-brand);
  border: 1px solid var(--brand);
  box-shadow: var(--sh-3);
  font: inherit; font-size: var(--fs-base); font-weight: 600; cursor: pointer;
  overflow: hidden; white-space: nowrap;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease),
              width var(--dur) var(--ease), padding var(--dur) var(--ease);
}
/* Collapsed to a circle by default so it occludes as little content as possible;
   the label expands on hover/focus. Keeps it discoverable without covering text. */
.copilot-fab-label {
  max-width: 0; opacity: 0; overflow: hidden;
  transition: max-width var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.copilot-fab:hover, .copilot-fab:focus-visible {
  width: auto; padding: 0 18px;
}
.copilot-fab:hover .copilot-fab-label,
.copilot-fab:focus-visible .copilot-fab-label {
  max-width: 12ch; opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .copilot-fab, .copilot-fab > * { transition: none; }
}
.copilot-fab:hover { background: var(--brand-hover); }
.copilot-fab:active { transform: translateY(1px); }

.copilot {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 95;
  width: min(390px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 100px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--sh-4);
  overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .copilot { animation: copilot-in 220ms var(--ease); }
  @keyframes copilot-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
}
.copilot-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  background: var(--surface-inset);
}
.copilot-head h3 { font-size: var(--fs-base); }
.copilot-head p { font-size: var(--fs-xs); color: var(--text-3); }
.copilot-log { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.cp-msg { display: flex; flex-direction: column; gap: var(--sp-2); max-width: 92%; }
.cp-msg.is-user { align-self: flex-end; align-items: flex-end; }
.cp-bubble {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-base); line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--border);
}
.cp-msg.is-user .cp-bubble { background: var(--brand); color: var(--text-on-brand); border-color: var(--brand); }
.cp-actions { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.cp-action {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 550;
  padding: 5px 11px; border-radius: var(--r-full);
  background: var(--brand-soft); color: var(--brand-text);
  border: 1px solid var(--brand-border); cursor: pointer; font-family: inherit;
  text-align: left;
}
.cp-action:hover { background: var(--brand-soft-2); text-decoration: none; }
.copilot-form { display: flex; gap: var(--sp-2); padding: var(--sp-3); border-top: 1px solid var(--border); background: var(--surface-inset); }
.cp-suggests { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------------------------
   7. RESPONSIVE
   ------------------------------------------------------------------------*/
@media (max-width: 1180px) {
  .wheel-layout, .qc-layout, .month-layout, .val-layout { grid-template-columns: minmax(0, 1fr); }
  .mk-hero { grid-template-columns: minmax(0, 1fr); gap: var(--sp-8); padding: var(--sp-9) var(--sp-5); }
  .mk-hero h1 { font-size: var(--fs-3xl); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: fixed; z-index: 120; left: 0; top: 0; bottom: 0;
    width: min(280px, 84vw); height: 100vh;
    transform: translateX(-102%);
    transition: transform 240ms var(--ease);
    box-shadow: var(--sh-4);
  }
  .app.nav-open .nav { transform: translateX(0); }
  .app.nav-open .backdrop-scrim {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(9, 14, 20, .45);
  }
  .nav-toggle { display: inline-flex; }
  main.main { padding: var(--sp-4); }
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .doc { padding: var(--sp-6) var(--sp-5); }
  .doc-sigs { grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); }
}

@media (max-width: 640px) {
  :root { --fs-3xl: 30px; --fs-4xl: 34px; --fs-2xl: 24px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .check-item { grid-template-columns: 26px minmax(0, 1fr); }
  .check-item .yna { grid-column: 2; }
  .check-item .initials-field { grid-column: 2; }
  .section-title { position: static; }
  .task-row { grid-template-columns: minmax(0, 1fr); }
  .task-row > .row { justify-content: space-between; }
  .doc-month, .doc-event { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .doc-month-name { color: var(--text-2); }
  /* A figure and its reading stack rather than sitting side by side: at this
     width the two-column form leaves the reading four words wide. */
  .readout-row, .iv-item-grid, .iv-dl > div { grid-template-columns: minmax(0, 1fr); }
  .iv-dl > div { gap: 0; }
  .iv-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .iv-tab { padding: var(--sp-3); }
  .topbar-sub { display: none; }
  /* Topbar controls collapse to icons rather than wrapping or overflowing.
     Each keeps its aria-label, so the accessible name is unchanged. */
  .topbar .btn-label { display: none; }
  .topbar .btn { padding: 8px 10px; }
  .copilot { right: 8px; bottom: 8px; height: min(520px, calc(100vh - 72px)); }
  .copilot-fab { right: var(--sp-3); bottom: var(--sp-3); }
  .stat-value { font-size: var(--fs-xl); }

  /* At this width a header's trailing meta and a callout's trailing action
     have no room beside the text, so they drop onto their own line rather
     than being squeezed into a two-word column. */
  .card-head { flex-wrap: wrap; }
  .card-head > .col { align-items: flex-start !important; width: 100%; }
  .callout { flex-wrap: wrap; }
  .callout > .btn, .callout > a.btn { width: 100%; }
  .section-head { flex-wrap: wrap; }
  .mk-nav { padding: var(--sp-3) var(--sp-4); flex-wrap: wrap; }
  .doc { padding: var(--sp-5) var(--sp-4); }
}

/* ---------------------------------------------------------------------------
   8. PRINT — the field form.
   Everything that is software disappears. What remains is a black-and-white
   paper form a technologist can carry to the bench and fill in by hand.
   ------------------------------------------------------------------------*/
@media print {
  @page { size: letter portrait; margin: 0.6in 0.55in; }

  :root, [data-theme="dark"] {
    color-scheme: light !important;
    --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #fff;
    --surface-inset: #fff;
    --border: #999; --border-strong: #555;
    --text: #000; --text-2: #222; --text-3: #444;
    --brand: #000; --brand-text: #000; --brand-soft: #fff; --brand-soft-2: #fff;
    --brand-border: #999;
    --ok: #000; --ok-soft: #fff; --ok-border: #999;
    --warn: #000; --warn-soft: #fff; --warn-border: #999;
    --danger: #000; --danger-soft: #fff; --danger-border: #555;
    --danger-solid: #fff; --on-danger: #000;
    --neutral: #000; --neutral-soft: #fff; --neutral-border: #999;
    --sh-1: none; --sh-2: none; --sh-3: none; --sh-4: none;

    /* Chart ink becomes a grey ramp, so a legend swatch or any other mark set
       from a token inline still reproduces on a monochrome printer. The ramp is
       ordered so adjacent series stay distinguishable by lightness alone. */
    --chart-s1: #000; --chart-s2: #777; --chart-s3: #383838; --chart-s4: #aaa;
    --chart-ref: #666; --chart-limit: #000; --chart-fill: #eee;
    --chart-line: #000; --chart-point: #000; --chart-grid: #bbb;
    --chart-mean: #000; --chart-flag: #000;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 10.5pt;
    line-height: 1.42;
  }

  /* No FAB on paper, so no FAB clearance either. */
  main.main::after { display: none; }
  .qc-layout > *:last-child, .month-layout > *:last-child,
  .val-layout > *:last-child { padding-bottom: 0; }

  /* Chrome: gone. */
  .nav, .topbar, .copilot, .copilot-fab, .toasts, .skip-link,
  .backdrop-scrim, dialog.modal, .no-print, .nav-toggle,
  .menu, .wheel-legend, .mk-nav, .mk-foot,
  .btn, button, .link-btn, .cp-action,
  .save-status, .state-icon {
    display: none !important;
  }

  /* Anything explicitly marked for paper survives. */
  .print-only { display: block !important; }
  .print-show, .print-show * { display: revert !important; }

  .app { display: block !important; }
  main.main { padding: 0 !important; max-width: none !important; }

  /* Two-column working layouts collapse: on paper the side rails are either
     hidden or irrelevant, and a reserved empty column wastes the sheet. */
  .month-layout, .qc-layout, .wheel-layout, .val-layout, .stats, .review-grid, .form-grid {
    display: block !important;
  }
  .col { display: block !important; }

  /* --- Validation on paper -------------------------------------------------
     The charts survive: an inspector's packet is not a packet without them,
     and every mark is stroked so it reproduces on a monochrome printer. The
     entry apparatus (paste box, tabs, grid editor) does not — it is software.
     Every verdict keeps its plain-English sentence, which is the part a
     reviewer initials. */
  .entry-tabs, .paste-box, .grid-editor, .parse-preview, .entry-panel,
  .preview-banner { display: none !important; }

  .vchart { max-width: 6.6in; break-inside: avoid; }
  .v-grid { stroke: #bbb !important; }
  .v-frame { stroke: #000 !important; }
  .v-axis-label, .v-axis-title, .v-point-label, .v-zone-label { fill: #000 !important; }
  .v-fit, .v-mean { stroke: #000 !important; stroke-width: 1.6 !important; }
  .v-identity { stroke: #666 !important; }
  .v-limit, .v-loa { stroke: #000 !important; stroke-dasharray: 4 3 !important; }
  .v-band { fill: #eee !important; opacity: 1 !important; }
  /* Fills become white with a black outline so shapes stay distinguishable
     without relying on ink coverage; out-of-limit marks stay solid black. */
  .v-pt, .v-pt-hollow, .v-bar, .v-hist {
    fill: #fff !important; stroke: #000 !important; stroke-width: 1.2 !important;
  }
  .v-pt.is-out, .v-bar.is-out, .v-hist.is-outside { fill: #000 !important; }
  .v-pt.is-flag { fill: #888 !important; }
  .v-zone-6, .v-zone-5, .v-zone-4, .v-zone-3, .v-zone-2, .v-zone-x {
    fill: #000 !important;
  }
  .v-zone-6 { opacity: .04 !important; }
  .v-zone-5 { opacity: .09 !important; }
  .v-zone-4 { opacity: .15 !important; }
  .v-zone-3 { opacity: .22 !important; }
  .v-zone-2 { opacity: .30 !important; }
  .v-zone-x { opacity: .40 !important; }
  .v-zone-line { stroke: #000 !important; }
  .v-op { fill: #fff !important; stroke: #000 !important; stroke-width: 2 !important; }
  .v-op-halo { stroke: #000 !important; animation: none !important; }

  .vd, .char, .readout-row, .chart-legend { break-inside: avoid; }
  .vd { border: 1px solid #000 !important; background: #fff !important; }
  .vd .ico, .vd-head { color: #000 !important; }
  .char { border: 1px solid #666 !important; background: #fff !important; }
  .char::after { font-size: 8.5pt; }
  .readout-value { color: #000 !important; }
  .chart-legend { border-top: 1px solid #999 !important; }
  .legend-key { border: 1px solid #000; }
  .study-path { border: 1px solid #000 !important; background: #fff !important; color: #000 !important; border-radius: 0 !important; }

  .card, .panel, .doc, .callout, .stat, .plan, .value-card, .auth-card, .wheel-stage {
    border: 1px solid #999 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    break-inside: avoid;
  }
  .doc { padding: 0 !important; border: 0 !important; max-width: none !important; }
  .card-head, .card-foot, .section-title { background: #fff !important; }
  .section-title { position: static !important; border-top: 1px solid #555; }

  a { color: #000 !important; text-decoration: none !important; }

  h1, h2, h3, h4 { break-after: avoid; }
  .check-item, .doc-section, .comp-row, .task-row, .finding { break-inside: avoid; }
  .check-item { background: #fff !important; padding: 7pt 0 !important; border-bottom: 1px solid #ccc !important; }
  .check-item.has-finding { background: #fff !important; }

  /* Y / N / NA become tick boxes to mark with a pen. */
  .yna { gap: 10pt; }
  .yna input { display: none !important; }
  .yna label {
    display: inline-block !important;
    min-width: 0 !important; height: auto !important; padding: 0 !important;
    border: 0 !important; background: #fff !important; color: #000 !important;
    font-weight: 500 !important; font-size: 10pt;
  }
  .yna label::before {
    content: ""; display: inline-block;
    width: 10pt; height: 10pt; margin-right: 4pt;
    border: 1px solid #000; vertical-align: -1pt;
  }
  .yna input:checked + label { font-weight: 700 !important; }
  .yna input:checked + label::before {
    content: "\2713";
    font-size: 8pt; line-height: 9pt; text-align: center; font-weight: 700;
  }

  /* Written fields become ruled lines. */
  .input, .textarea, .select, .initials-field input {
    border: 0 !important; border-bottom: 1px solid #000 !important;
    border-radius: 0 !important; background: #fff !important; color: #000 !important;
    box-shadow: none !important; padding: 0 !important; min-height: 16pt !important;
  }
  .textarea { min-height: 40pt !important; }

  .badge {
    border: 1px solid #666 !important; background: #fff !important; color: #000 !important;
    border-radius: 0 !important;
  }
  .badge::before { display: none !important; }
  .pill-count { border: 1px solid #000 !important; }
  .chip {
    border: 0 !important; background: #fff !important; color: #333 !important;
    padding: 0 !important; font-size: 8.5pt;
  }
  .chip::before { content: "["; }
  .chip::after { content: "]"; }

  /* A date picker has no meaning on paper. */
  input[type="date"]::-webkit-calendar-picker-indicator { display: none !important; }

  .finding {
    border: 1px solid #000 !important; border-left-width: 3px !important;
    background: #fff !important;
  }

  .bar { border: 1px solid #666; height: 8pt; }
  .bar > i { background: #666 !important; }

  .sig-preview, .sig-line { border-color: #000 !important; }

  /* --- Inventory on paper --------------------------------------------------
     The value report and the expiry board print as read-only evidence: figures,
     their basis and their caveats, in black and white. The count sheet prints
     as something else entirely — a blank field form a technologist fills in
     with a pen at the fridge door. That second one is a real bench workflow and
     it is the reason this block exists.
     ----------------------------------------------------------------------*/
  .roi-grid, .iv-lot-layout, .iv-item-grid, .iv-item-list, .iv-gate { display: block !important; }
  .roi-grid > *, .iv-lot-layout > *, .iv-item-list > * { margin-bottom: 10pt; }

  .roi-hero { border: 1.5px solid #000 !important; background: #fff !important; }
  .roi-hero-value { font-size: 26pt !important; color: #000 !important; }
  .roi-hero-value.is-unstated { font-size: 16pt !important; }
  .roi-hero-statement { font-size: 11pt !important; }

  /* Every qualifier survives. A figure printed without its basis, its sample
     size and its coverage is a number somebody can quote out of context. */
  .fig, .fig-null, .readout-row, .iv-band, .iv-gate-item, .iv-chart-wrap, .iv-verbatim {
    break-inside: avoid;
  }
  .fig-basis, .fig-sample, .fig-plain, .fig-caveats, .readout-plain { color: #000 !important; }
  .fig-coverage {
    border: 1px solid #000 !important; background: #fff !important;
    border-left-width: 3px !important;
  }
  .fig-null { border: 1px dashed #000 !important; background: #fff !important; }
  .fig-null-mark { color: #000 !important; }
  /* The confidence word has to survive a monochrome printer, so it is carried
     by the border style as well as by the text. */
  .conf-badge.is-derived, .conf-badge.is-partial-cost {
    border: 1px dashed #000 !important;
  }
  .iv-verbatim { border-left: 3px solid #000 !important; background: #fff !important; }
  .iv-gate-item { border: 1px solid #000 !important; background: #fff !important; }
  .iv-gate-item.is-met::after { content: " [met]"; font-weight: 700; }
  .iv-gate-item:not(.is-met)::after { content: " [NOT MET]"; font-weight: 700; }

  .iv-chart { max-width: 6.6in; }
  .iv-grid { stroke: #bbb !important; }
  .iv-baseline, .iv-zero { stroke: #000 !important; }
  .iv-criterion, .iv-boundary, .iv-expiry-line { stroke: #000 !important; stroke-dasharray: 4 3 !important; }
  .iv-axis-label, .iv-axis-title, .iv-cat-label, .iv-value-label { fill: #000 !important; }
  /* Bars become an ordered grey ramp so adjacent causes stay distinguishable
     by lightness alone; the direct labels carry the values regardless. */
  .iv-s1 { fill: #000 !important; }
  .iv-s2 { fill: #777 !important; }
  .iv-s3 { fill: #383838 !important; }
  .iv-s4 { fill: #aaa !important; }
  .iv-bar-empty { fill: #fff !important; stroke: #000 !important; }
  .iv-runway-critical { fill: #000 !important; }
  .iv-runway-serious { fill: #555 !important; }
  .iv-runway-warning { fill: #888 !important; }
  .iv-runway-watch { fill: #bbb !important; }
  .iv-runway-settled { fill: #ddd !important; }
  .iv-runway-unknown { fill: #f0f0f0 !important; }
  .iv-line { stroke: #000 !important; }
  .iv-line.is-thin { stroke: #666 !important; }
  .iv-dumbbell { stroke: #000 !important; }
  .iv-dot-before, .iv-run-pt { fill: #fff !important; stroke: #000 !important; }
  .iv-dot-after, .iv-run-pt.is-mine, .iv-end-dot { fill: #000 !important; stroke: #fff !important; }
  .iv-dot-after.is-out { fill: #000 !important; stroke: #000 !important; }
  .legend-key.is-dot { border: 1px solid #000; }
  .iv-key-s1 { background: #000 !important; }
  .iv-key-s2 { background: #777 !important; }
  .iv-key-s3 { background: #383838 !important; }
  .iv-key-s4 { background: #aaa !important; }
  .iv-meter { display: none !important; }
  .iv-band-dot { border: 1px solid #000; background: #fff !important; }

  /* --- Why Sentinel on paper ----------------------------------------------
     The page is handed across a table as often as it is read on a screen, so
     it prints as a plain black-and-white document: the three modules, the
     lot-change flow, and the placeholder pricing exactly as the screen shows
     it — a contact prompt, never a number.
     ----------------------------------------------------------------------*/
  .mod-cols, .trg-layout, .plan-modules { display: block !important; }
  .mod, .mod-claim, .value-card, .plan {
    border: 1px solid #999 !important; background: #fff !important;
    border-radius: 0 !important; box-shadow: none !important;
  }
  .mod { break-inside: avoid; margin-bottom: 10pt; }
  .mod-head { background: #fff !important; border-bottom: 1px solid #555 !important; }
  .mod-index { border: 1px solid #666 !important; background: #fff !important; }
  .mod-claim { border-left: 3px solid #000 !important; margin-top: 8pt; }
  .mod-lede, .mod-who, .mod-list li, .mod-claim p { color: #000 !important; }
  .mod-col + .mod-col { margin-top: 8pt; }

  /* Taller than a page, so it is allowed to flow; the individual steps are
     not, because half a step at a page break is unreadable. */
  .trg-card { break-inside: auto !important; }
  .trg-steps li, .trg-note { break-inside: avoid; }
  .trg-figure { margin-bottom: 10pt; }
  .trg { max-width: 3.1in; }
  .trg-node { fill: #fff !important; stroke: #000 !important; }
  /* The gate keeps its dashed outline: on a monochrome printer the line style
     is what distinguishes it, never the colour. */
  .trg-node.is-gate { stroke: #000 !important; stroke-dasharray: 6 4 !important; }
  .trg-flow { stroke: #000 !important; }
  .trg-arrow { fill: #000 !important; }
  .trg-step, .trg-sub { fill: #333 !important; }
  .trg-title { fill: #000 !important; }
  .trg-steps p { color: #000 !important; }
  .trg-steps li::before { background: #000 !important; color: #fff !important; }

  .plan-price { font-size: 18pt !important; }
  .plan-features li, .plan-for { color: #000 !important; }

  /* --- The physical count sheet ------------------------------------------- */
  /* The generic card rule keeps a card on one page; a count sheet is a list
     that has to flow across as many pages as the fridge needs. */
  .count-sheet {
    border: 0 !important; break-inside: auto !important;
  }
  .count-sheet .card-body-flush, .count-sheet .table-wrap, .count-table, .count-table tbody {
    break-inside: auto !important;
  }
  /* The header row repeats on every page, so page four still says which column
     is which. */
  .count-table thead { display: table-header-group; }
  .count-print-note { font-size: 9.5pt; margin-bottom: 8pt; }
  .count-print-note p { margin-bottom: 3pt; }
  .count-table { font-size: 9.5pt; }
  .count-table th {
    border-bottom: 1.5px solid #000 !important; background: #fff !important;
    padding: 4pt 5pt !important; font-size: 8.5pt;
  }
  .count-table td {
    padding: 7pt 5pt !important; border-bottom: 1px solid #999 !important;
    vertical-align: middle;
  }
  .count-table tr { break-inside: avoid; }
  .count-lot strong { font-size: 10.5pt; }
  .count-lot .hint { color: #333 !important; font-size: 8.5pt; }
  /* The pen goes here. A ruled box rather than an underline, because a box is
     unambiguous about where the number belongs when the sheet is on a trolley. */
  .count-write-box {
    display: inline-block !important;
    width: 78pt; height: 20pt;
    border: 1px solid #000; border-radius: 0;
  }
  .count-initials .count-write-box { width: 46pt; }
  /* Blind by default: the expected quantity is deliberately left off the paper
     so the count is independent of what the system already believes. The
     toggle is a class on <html>, so switching it is a style change rather than
     a re-render — a sheet with forty typed numbers on it must never be rebuilt
     because somebody changed a print option. */
  html.count-blind .count-expected { display: none !important; }
  html.count-blind .count-note-open { display: none !important; }
  html:not(.count-blind) .count-note-blind { display: none !important; }

  .count-table .col-num { text-align: right; }

  .print-header { display: block !important; }
  .table-wrap { overflow: visible !important; }
  .sop-body { max-height: none !important; overflow: visible !important; border: 0 !important; padding: 0 !important; }
  .modal-body { max-height: none !important; overflow: visible !important; }
}

/* The paper masthead only exists on paper. */
.print-header { display: none; }
@media print {
  .print-header {
    border-bottom: 2px solid #000; padding-bottom: 6pt; margin-bottom: 12pt;
  }
  .print-header .ph-lab { font-size: 13pt; font-weight: 700; }
  .print-header .ph-title { font-size: 10pt; letter-spacing: .08em; text-transform: uppercase; }
  .print-header .ph-meta { font-size: 9pt; margin-top: 4pt; }
  .print-sig-block { display: block !important; margin-top: 18pt; break-inside: avoid; }
  .print-sig-block .psb-row { display: flex; gap: 24pt; margin-top: 20pt; }
  .print-sig-block .psb-line { flex: 1; border-top: 1px solid #000; padding-top: 3pt; font-size: 9pt; }
}
.print-sig-block { display: none; }

/* ============================================================================
   9. DEMO MODE, THE GUIDED TOUR, AND PUBLIC SAMPLE REPORTS

   Every colour below is a token. Nothing here is hardcoded, so the light and
   dark themes and the monochrome print stylesheet all fall out of section 1
   without this block knowing anything about them.

   The share page (`/s/:token`) is server-rendered HTML outside the SPA, so it
   links this same stylesheet — which is why the `.share-*` rules live here
   rather than in a second file that would drift.
   ==========================================================================*/

/* ---------------------------------------------------------------------------
   The demo strip — permanent, on every screen of a demo laboratory.

   Deliberately not dismissible. A demo that stops announcing itself is how
   somebody ends up entering real competency records into a tenant that
   evaporates in two hours.
   ------------------------------------------------------------------------*/
/* A visibility class that outranks a component's own `display`, for the cases
   where the `hidden` attribute is silently overridden by a layout rule. */
.is-hidden { display: none !important; }

.demo-banner-slot:empty { display: none; }

.demo-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5);
  background: var(--warn-soft);
  border-bottom: 1px solid var(--warn-border);
  color: var(--text);
}
.demo-banner > .ico { color: var(--warn); flex: none; }
.demo-banner .grow { display: flex; flex-direction: column; gap: 2px; min-width: 18ch; }
.demo-banner strong { font-size: var(--fs-sm); }
.demo-banner-sub { font-size: var(--fs-xs); color: var(--text-2); }

/* The always-visible half of the demo marking: the sidebar does not scroll, so
   this chip is on screen at every scroll position of every screen, and the
   strip above the topbar carries the detail. */
.demo-chip {
  display: inline-block;
  margin-left: var(--sp-2);
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: .02em;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------------
   /demo splash
   ------------------------------------------------------------------------*/
.demo-splash {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-5);
  background: var(--bg);
}
.demo-splash h1 { font-size: var(--fs-xl); margin-top: var(--sp-4); }
.demo-splash p { color: var(--text-2); max-width: 52ch; }

/* ---------------------------------------------------------------------------
   The guided tour.

   NOTHING HERE COVERS THE APP. There is no scrim and no backdrop: the spotlight
   is an outline with pointer-events: none, and the panel is a corner card. A
   visitor can keep using the product with the tour open, which is the point.
   ------------------------------------------------------------------------*/
.tour-root {
  position: fixed;
  right: var(--sp-5);
  /* Clears the fixed Copilot FAB (52px at --sp-5) so the tour never sits on top
     of a control the visitor might want. */
  bottom: calc(var(--sp-5) + 52px + var(--sp-3));
  z-index: 60;
  width: min(420px, calc(100vw - var(--sp-8)));
  /* The container is transparent to the mouse; only the card inside is not, so
     the page underneath stays clickable right up to the card's edge. */
  pointer-events: none;
}

.tour-panel {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  padding: var(--sp-5);
  max-height: min(70vh, 620px);
  /* The card itself never scrolls; only .tour-scroll inside it does, so the
     navigation stays reachable however long a stop's copy is. */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tour-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.tour-head { display: flex; align-items: flex-start; gap: var(--sp-3); flex: none; }
.tour-eyebrow {
  flex: 1;
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand-text);
}
.tour-title {
  font-size: var(--fs-lg);
  margin: var(--sp-2) 0 var(--sp-3);
  flex: none;
  /* tabindex="-1" for the announcement; the outline is the app's own. */
  outline-offset: 3px;
}
.tour-body p {
  font-size: var(--fs-sm);
  color: var(--text-2);
  margin-bottom: var(--sp-3);
}
.tour-body p:last-child { margin-bottom: 0; }
.tour-missing {
  font-size: var(--fs-sm);
  color: var(--text-2);
  background: var(--neutral-soft);
  border: 1px solid var(--neutral-border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.tour-dots {
  display: flex;
  gap: var(--sp-2);
  list-style: none;
  margin: var(--sp-4) 0 var(--sp-4);
  padding: 0;
  flex: none;
}
.tour-dots li {
  height: 4px;
  flex: 1;
  border-radius: var(--r-full);
  background: var(--surface-3);
}
.tour-dots li.is-done { background: var(--brand-border); }
.tour-dots li.is-current { background: var(--brand); }

.tour-nav { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; flex: none; }
.tour-dots { flex: none; }

/* The spotlight: an outline, never a mask. */
.tour-spot {
  position: absolute;
  z-index: 55;
  pointer-events: none;
  border: 2px solid var(--brand);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 3px var(--brand-soft-2);
}
@media (prefers-reduced-motion: no-preference) {
  .tour-spot { transition: top var(--dur) var(--ease), left var(--dur) var(--ease),
                           width var(--dur) var(--ease), height var(--dur) var(--ease); }
}

@media (max-width: 720px) {
  .tour-root {
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: calc(var(--sp-3) + 52px + var(--sp-3));
    width: auto;
  }
  .tour-panel { max-height: 58vh; }
}

/* ---------------------------------------------------------------------------
   The public share page.

   Served by the Worker at /s/:token, outside the SPA. It is deliberately plain:
   the reader is a medical director who was sent a link, not a user of the
   product, and the page has one job — say what this is, hand over the PDF, and
   get out of the way.
   ------------------------------------------------------------------------*/
.share-body { background: var(--bg); }

.share-page {
  max-width: 68ch;
  margin: 0 auto;
  padding: var(--sp-9) var(--sp-5) var(--sp-10);
}

.share-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-8); }
.share-brand { font-weight: 650; letter-spacing: -.01em; font-size: var(--fs-md); }

.share-sample {
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text);
  margin-bottom: var(--sp-6);
}

.share-title { font-size: var(--fs-2xl); letter-spacing: -.02em; }
.share-lab {
  font-size: var(--fs-md);
  color: var(--text-2);
  margin-top: var(--sp-2);
}
.share-blurb {
  color: var(--text-2);
  margin-top: var(--sp-4);
  line-height: 1.62;
}

.share-actions { margin-top: var(--sp-7); }
.share-meta {
  margin-top: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.share-cta {
  margin-top: var(--sp-9);
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.share-cta h2 { font-size: var(--fs-lg); }
.share-cta p { color: var(--text-2); margin-top: var(--sp-3); line-height: 1.62; }
.share-cta-links { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-5); }

.share-foot {
  margin-top: var(--sp-9);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* On paper the share page keeps its substance and drops its furniture. The
   global print block already hides .no-print and every button. */
@media print {
  .share-page { max-width: none; padding: 0; }
  .share-head { margin-bottom: 12pt; }
  .share-sample { border: 1pt solid #000; }
}


/* --- Sample tracking: the tray grid ------------------------------------- */
.sg-wrap { margin-top: var(--sp-4); }
.sg-edge {
  text-align: center; font-size: var(--fs-xs); color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; padding: var(--sp-1) 0;
}
.sg-grid {
  display: grid; gap: 3px; align-items: stretch;
  background: var(--surface-inset); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--sp-2);
}
.sg-rowlabel {
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); color: var(--text-3); padding: 0 var(--sp-2);
}
.sg-cell {
  position: relative; aspect-ratio: 1; min-width: 22px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); font-size: var(--fs-xs); color: var(--text-3);
}
.sg-cell.is-occupied { background: var(--brand); border-color: var(--brand); }
.sg-cell.is-occupied .sg-link {
  position: absolute; inset: 0; border-radius: 50%;
  color: var(--text-on-brand); display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: var(--fs-xs);
}
.sg-cell.is-next { border-style: dashed; border-color: var(--warn); box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 30%, transparent); }
.sg-cell.is-flash { outline: 2px solid var(--ok); outline-offset: 1px; }
.sg-legend { display: flex; gap: var(--sp-4); margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-3); flex-wrap: wrap; }
.sg-key { display: inline-flex; align-items: center; gap: 6px; }
.sg-swatch {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); display: inline-block;
}
.sg-swatch.is-occupied { background: var(--brand); border-color: var(--brand); }
.sg-swatch.is-next { border-style: dashed; border-color: var(--warn); }
@media print {
  .sg-grid { break-inside: avoid; }
}
