/* ==========================================================================
   Prototype chrome — device frames, prototype bar, toaster, tour.
   Structural, brand-neutral. Copy into <POC>/assets/css/components.css and
   re-skin with the project's tokens. Requires the token contract.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Phone. A fixed 390x844 canvas scaled to always fit the viewport, so the
   whole device is visible without scrolling the browser. On a real handset
   the frame disappears and the app fills the screen.
   -------------------------------------------------------------------------- */
.phone-stage {
  --phone-fit: 1;
  height: 100dvh; overflow: hidden;
  display: grid; grid-template-columns: auto; place-content: center; place-items: center;
  column-gap: var(--s-10);
  padding: var(--s-4) var(--gutter) calc(var(--pocbar-h) + var(--s-4));
  background: var(--surface-2);
}
.phone {
  position: relative; flex: none;
  width: 390px; height: 844px;
  transform: scale(var(--phone-fit)); transform-origin: center;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  border: 10px solid #15130f; border-radius: 46px;
  box-shadow: 0 40px 80px -20px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(0 0 0 / 0.08);
  overflow: hidden;
}
.phone::before {                      /* notch */
  content: ''; position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  width: 120px; height: 34px; background: #15130f; border-radius: 20px; z-index: 5;
}
.phone-status {
  display: flex; align-items: center; justify-content: space-between;
  height: 54px; padding: 12px 28px 0; font-size: var(--t-14); font-weight: 600; flex: none;
}
.phone-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  scrollbar-width: none; position: relative; display: flex; flex-direction: column;
}
.phone-scroll::-webkit-scrollbar { display: none; }
.phone-scroll > * { flex-shrink: 0; }   /* or horizontal card rows collapse */
.phone-tabbar {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: 84px; padding: 8px 8px 24px; flex: none;
  border-top: 1px solid var(--line); background: var(--surface);
}
.phone-tabbar a {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  border-radius: var(--r-ctl); min-height: 44px; text-decoration: none;
}
.phone-tabbar a .ico { width: 24px; height: 24px; }
.phone-tabbar a[aria-current="page"] { color: var(--primary); }
.phone-home {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: 134px; height: 5px; border-radius: 3px; background: var(--ink); opacity: .9; z-index: 4;
}
.phone { --app-gutter: var(--s-4); }

/* The narration column beside the device: what this screen proves. */
.phone-caption {
  display: none; align-self: center; max-width: 34ch; text-align: left;
  font-size: var(--t-14); line-height: 1.55; color: var(--ink-2);
}
.phone-caption strong {
  display: block; color: var(--ink); font-family: var(--font-display);
  font-size: var(--t-18); font-weight: 600; margin-bottom: var(--s-2);
}
@media (min-width: 1100px) {
  .phone-stage { grid-template-columns: auto minmax(260px, 34ch); }
  .phone-caption { display: block; }
}

/* Step the scale down so the device always fits the window height. */
@media (max-height: 940px) { .phone-stage { --phone-fit: .95; } }
@media (max-height: 880px) { .phone-stage { --phone-fit: .90; } }
@media (max-height: 820px) { .phone-stage { --phone-fit: .84; } }
@media (max-height: 770px) { .phone-stage { --phone-fit: .78; } }
@media (max-height: 700px) { .phone-stage { --phone-fit: .72; } }
@media (max-height: 640px) { .phone-stage { --phone-fit: .66; } }

/* On an actual handset the app IS the page. The frame, notch, status bar and
   home indicator disappear; the app fills the screen minus the prototype bar. */
@media (max-width: 600px) {
  .phone-stage { --phone-fit: 1; padding: 0; height: 100dvh; grid-template-columns: 1fr; background: var(--bg); }
  .phone { width: 100%; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; transform: none; }
  .phone::before, .phone-status, .phone-home { display: none; }
  .phone-caption { display: none; }
  /* The bar is fixed over the viewport, so the app must give up its height or
     the tab bar hides behind it. */
  body.has-pocbar .phone-stage,
  body.has-pocbar .phone { height: calc(100dvh - var(--pocbar-h)); }
  .phone-tabbar { padding-bottom: 8px; height: 64px; }
}

/* --------------------------------------------------------------------------
   Tablet — staff-facing landscape surfaces (kitchen display, POS, field app).
   -------------------------------------------------------------------------- */
.tablet-stage {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-4);
  padding: var(--s-8) var(--gutter) calc(var(--pocbar-h) + var(--s-10));
  min-height: 100dvh; background: var(--surface-3);
}
.tablet {
  --tablet-fit: 1;
  position: relative; width: 1024px; height: 768px;
  transform: scale(var(--tablet-fit)); transform-origin: top center;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border: 12px solid #15130f; border-radius: 28px;
  box-shadow: 0 40px 80px -24px rgb(0 0 0 / 0.35);
}
.tablet-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 1140px) { .tablet-stage { --tablet-fit: .82; } }
@media (max-width: 940px)  { .tablet-stage { --tablet-fit: .66; } }
@media (max-width: 760px)  { .tablet-stage { --tablet-fit: .50; } }

/* --------------------------------------------------------------------------
   Bottom sheet — the mobile-native alternative to a modal.
   -------------------------------------------------------------------------- */
.phone-sheet-scrim {
  position: absolute; inset: 0; z-index: var(--z-layer);
  background: rgb(0 0 0 / 0.4); opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease);
}
.phone-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: calc(var(--z-layer) + 1);
  max-height: 82%; display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-lg) var(--r-lg) 0 0;
  transform: translateY(100%); transition: transform var(--dur-3) var(--ease-out);
}
.phone-sheet::before {
  content: ''; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong);
  margin: 10px auto 2px; flex: none;
}
.phone-sheet-body { overflow-y: auto; padding: var(--s-4) var(--app-gutter) var(--s-6); }
.layer-open .phone-sheet-scrim { opacity: 1; pointer-events: auto; }
.layer-open .phone-sheet { transform: translateY(0); }

/* In-frame push notification — lands every time in a demo. */
.push {
  position: absolute; left: 8px; right: 8px; top: 58px; z-index: var(--z-toast);
  display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  background: var(--bg); border-radius: var(--r-card); box-shadow: var(--e-3);
  transform: translateY(-140%); transition: transform var(--dur-3) var(--ease-out);
}
.push.in { transform: translateY(0); }

/* --------------------------------------------------------------------------
   Prototype bar — the client's remote control, on every page.
   -------------------------------------------------------------------------- */
.pocbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-pocbar);
  height: var(--pocbar-h); display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4); font-size: var(--t-12);
  background: var(--drench); color: var(--on-drench);
  box-shadow: 0 -4px 20px rgb(0 0 0 / 0.2);
}
.pocbar .tagword {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  color: var(--accent); font-weight: 500;
}
.pocbar .roles { display: flex; gap: 2px; }
.pocbar .roles a {
  padding: 4px 10px; border-radius: var(--r-full); color: var(--on-drench-muted);
  text-decoration: none; white-space: nowrap;
}
.pocbar .roles a:hover { color: var(--on-drench); background: var(--drench-2); }
.pocbar .roles a[aria-current="true"] { background: var(--primary); color: var(--on-primary); }
.pocbar .mods { display: flex; gap: 4px; }
.pocbar .tag-module {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 6px;
  border: 1px solid var(--drench-line); border-radius: var(--r-full);
  color: var(--on-drench-muted); text-decoration: none;
}
.pocbar .spacer { flex: 1; }
.pocbar button.link {
  background: none; border: 0; color: var(--on-drench-muted);
  font: inherit; cursor: pointer; padding: 4px 6px; white-space: nowrap;
}
.pocbar button.link:hover { color: var(--on-drench); }
body.has-pocbar { padding-bottom: 0; }
@media (max-width: 720px) {
  .pocbar .hide-sm { display: none; }
  /* Never let the bar clip its own controls: let it scroll instead. */
  .pocbar { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .pocbar::-webkit-scrollbar { display: none; }
  .pocbar > * { flex: none; }
  .pocbar .spacer { flex: 1 0 var(--s-4); }
}
@media (max-width: 420px) { .pocbar .tagword { display: none; } }

/* Module map overlay: outlines the elements proving each module. */
body.show-sow [data-module] { outline: 1px dashed var(--accent-strong); outline-offset: 2px; position: relative; }
body.show-sow [data-module]::after {
  content: attr(data-module); position: absolute; top: -8px; right: -6px; z-index: 2;
  font-family: var(--font-mono); font-size: 9px; line-height: 1;
  padding: 3px 5px; border-radius: var(--r-full);
  background: var(--accent); color: var(--on-accent);
}

/* --------------------------------------------------------------------------
   Toaster
   -------------------------------------------------------------------------- */
.toaster {
  position: fixed; right: var(--s-4); bottom: calc(var(--pocbar-h) + var(--s-4));
  z-index: var(--z-toast); display: flex; flex-direction: column-reverse;
  gap: var(--s-2); pointer-events: none;
}
body:not(.has-pocbar) .toaster { bottom: var(--s-4); }
.toast {
  max-width: 42ch; padding: var(--s-3) var(--s-4);
  background: var(--drench); color: var(--on-drench);
  border-radius: var(--r-ctl); box-shadow: var(--e-3);
  font-size: var(--t-14); animation: toast-in var(--dur-3) var(--ease-out);
}
.toast.ok { background: var(--success); } .toast.warn { background: var(--warning); color: var(--on-accent); }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Guided tour
   -------------------------------------------------------------------------- */
.tour-scrim { position: fixed; inset: 0; z-index: var(--z-tour); background: rgb(0 0 0 / 0.55); }
.tour-hole { position: fixed; z-index: calc(var(--z-tour) + 1); border-radius: var(--r-card);
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.55), 0 0 0 3px var(--accent); pointer-events: none; }
.tour-pop {
  position: fixed; z-index: calc(var(--z-tour) + 2); max-width: 34ch;
  padding: var(--s-4); background: var(--bg); color: var(--ink);
  border-radius: var(--r-card); box-shadow: var(--e-3);
}
.tour-pop .step { font-family: var(--font-mono); font-size: var(--t-11); color: var(--muted); }
.tour-pop h3 { font-size: var(--t-16); margin: var(--s-1) 0 var(--s-2); }
.tour-pop p { font-size: var(--t-14); line-height: 1.5; color: var(--ink-2); }
.tour-pop .row { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-4); }

/* Section reveal — set by prototype.js, off under reduced motion. */
.rv.pre { opacity: 0; transform: translateY(14px); }
.rv.in  { opacity: 1; transform: none; transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }

/* Accessibility floor */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  padding: var(--s-3) var(--s-4); background: var(--primary); color: var(--on-primary);
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ==========================================================================
   ECO AUDITORS — product components. Form archetype: Soft Instrument.
   Every radius, border, height and padding reads a token. Circles carry data;
   rectangles carry text and controls.
   ========================================================================== */

/* ---- Brand mark -------------------------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: var(--s-3); color: var(--ink); text-decoration: none; }
.logo svg { width: 34px; height: 34px; flex: none; }
.logo .wm { font-family: var(--font-display); font-size: var(--t-18); line-height: 1; letter-spacing: var(--tracking-heading); }
.logo .by { display: block; margin-top: 3px; font: 400 var(--t-11)/1 var(--font-body); color: var(--muted); letter-spacing: 0; }
.logo.lg svg { width: 56px; height: 56px; } .logo.lg .wm { font-size: var(--t-28); } .logo.lg .by { font-size: var(--t-13); margin-top: 6px; }
.on-drench .logo, .logo.inv { color: var(--on-drench); } .on-drench .logo .by, .logo.inv .by { color: var(--on-drench-muted); }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--h-ctl); padding: 0 18px; border-radius: var(--r-ctl);
  border: var(--bw) solid transparent; background: none; color: var(--ink);
  font: 600 var(--t-15)/1.1 var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--primary); color: var(--on-primary); }
.btn.pri:hover { background: var(--primary-strong); color: var(--on-primary); }
.btn.sec { background: var(--surface); border-color: var(--line-strong); }
.btn.sec:hover, .btn.quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn.quiet { color: var(--primary); padding: 0 12px; }
.btn.mark { background: var(--accent); color: var(--on-accent); }
.btn.mark:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger-ink); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { min-height: var(--h-ctl-sm); padding: 0 12px; font-size: var(--t-14); position: relative; }
.btn.sm::after { content: ""; position: absolute; inset: -4px 0; }            /* keeps a 44px hit area */
.btn.round { width: var(--h-ctl); padding: 0; border-radius: var(--r-full); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface-2); border-color: var(--line); color: var(--muted); cursor: not-allowed; transform: none; }
.btn.loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.loading::before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--on-primary); border-right-color: transparent; animation: spin 700ms linear infinite;
}
.btn.sec.loading::before, .btn.quiet.loading::before { border-color: var(--primary); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Fields ------------------------------------------------------------ */
.field { display: grid; gap: 6px; }
.field > label, .field > .lbl { font-weight: 600; font-size: var(--t-15); }
.field .why { font-weight: 400; color: var(--muted); font-size: var(--t-14); }    /* the plain reason beside a field */
.field .help { font-size: var(--t-14); color: var(--muted); }
.input, .field input[type="text"], .field input[type="email"], .field input[type="search"], .field input[type="date"],
.field input[type="number"], .field input[type="password"], .field select, .field textarea {
  width: 100%; min-height: var(--h-ctl); padding: 0 14px; border: var(--bw) solid var(--line-strong);
  border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.field textarea { padding: 12px 14px; min-height: 104px; line-height: 1.5; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted-2); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2);
}
.field select { appearance: none; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.field.err input, .field.err select, .field.err textarea { border-color: var(--danger); }
.field .msg { display: flex; gap: 6px; align-items: flex-start; font-size: var(--t-14); color: var(--danger-ink); }
.field.ok input { border-color: var(--success); }
.field.ai input { background: var(--accent-soft); }                 /* a value the assistant read; a person has not confirmed it */
.field.ai .help { color: var(--ink-2); }

.choice { display: flex; align-items: flex-start; gap: var(--s-3); min-height: var(--h-ctl); padding: 10px 0; cursor: pointer; }
.choice input { appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border: var(--bw-strong) solid var(--line-strong);
  border-radius: 6px; background: var(--surface); display: grid; place-items: center; cursor: pointer;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out); }
.choice input[type="radio"] { border-radius: 50%; }
.choice input:checked { background: var(--primary); border-color: var(--primary); }
.choice input[type="checkbox"]:checked::after { content: ""; width: 11px; height: 6px; border: 2px solid var(--on-primary); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.choice input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-primary); }

.toggle { display: inline-flex; align-items: center; gap: var(--s-3); min-height: var(--h-ctl); cursor: pointer; font-weight: 500; }
.toggle input { appearance: none; flex: none; width: 46px; height: 28px; margin: 0; border-radius: var(--r-full); background: var(--line-strong); position: relative; cursor: pointer; transition: background var(--dur-2) var(--ease-out); }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); transition: transform var(--dur-2) var(--ease-out); }
.toggle input:checked { background: var(--primary); }
.toggle input:checked::after { transform: translateX(18px); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: calc(var(--r-ctl) + 4px); background: var(--surface-2); }
.seg button { min-height: calc(var(--h-ctl) - 8px); padding: 0 14px; border: var(--bw) solid transparent; border-radius: var(--r-ctl); background: none; font: 600 var(--t-14)/1.1 var(--font-body); color: var(--ink-2); transition: background var(--dur-1) var(--ease-out); }
.seg button:hover { background: var(--surface-3); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }

.search { position: relative; }
.search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px !important; }

.drop {
  display: grid; justify-items: center; gap: 6px; padding: var(--s-6) var(--pad-card); text-align: center;
  border: var(--bw-strong) dashed var(--line-strong); border-radius: var(--r-card); background: var(--surface); cursor: pointer;
  transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.drop:hover, .drop.over { background: var(--primary-soft); border-color: var(--primary); }
.drop:focus-within { outline: 2px solid var(--primary); outline-offset: 3px; }
.drop .ico { color: var(--primary); }
.drop.err { border-color: var(--danger); background: var(--danger-soft); }
.file { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; min-height: var(--h-row); padding: 8px 0; border-top: var(--row-rule); }
.file:first-child { border-top: 0; }
.file .bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.file .bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--primary); border-radius: 2px; transition: width var(--dur-3) var(--ease-out); }

/* ---- Status pills: colour is never alone, every pill carries a shape ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px 0 7px;
  border-radius: var(--r-full); background: var(--t, var(--surface-2)); color: var(--ink);
  font-weight: 600; font-size: var(--t-13); white-space: nowrap;
}
.pill .ico { width: 16px; height: 16px; color: var(--c, var(--primary)); stroke-width: 2; }
.pill.low     { --c: var(--success); --t: var(--success-soft); }
.pill.notlow  { --c: var(--danger);  --t: var(--danger-soft); }
.pill.assess  { --c: var(--info);    --t: var(--info-soft); }
.pill.await   { --c: var(--warning); --t: var(--warning-soft); }
.pill.ok      { --c: var(--primary); --t: var(--primary-soft); }
.pill.closed  { --c: var(--muted);   --t: var(--surface-2); }
.pill.draft   { background: none; border: var(--bw) dashed var(--muted-2); --c: var(--muted); }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; white-space: nowrap; border-radius: 6px; background: var(--surface-2); font-size: var(--t-12); font-weight: 600; color: var(--ink-2); }

/* ---- Surfaces ---------------------------------------------------------- */
.card { background: var(--surface); border: var(--rule); border-radius: var(--r-card); padding: var(--pad-card); box-shadow: var(--elev-card); }
.card.tone { background: var(--surface-2); border-color: transparent; }
.card.click { cursor: pointer; transition: border-color var(--dur-2) var(--ease-out), background var(--dur-2) var(--ease-out); }
.card.click:hover { border-color: var(--primary); }
.card > h3 { margin-bottom: var(--s-3); }
.bub { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); }
.bub.mark { background: var(--accent); color: var(--on-accent); }

.kv { display: grid; }
.kv > div { display: grid; grid-template-columns: minmax(96px, 0.4fr) minmax(0, 1fr); gap: var(--s-3); padding: 10px 0; border-top: var(--row-rule); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--muted); } .kv dd { font-weight: 500; }

.list > li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; min-height: var(--h-row); padding: 12px 0; border-top: var(--row-rule); }
.list > li:first-child { border-top: 0; }

/* Tables: hairline between rows, nothing between columns, figures right */
.tbl { font-size: var(--t-15); }
.tbl th { text-align: left; font-weight: 600; font-size: var(--t-13); color: var(--muted); padding: 0 var(--s-4) var(--s-3) 0; white-space: nowrap; border-bottom: var(--rule-strong); }
.tbl th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.tbl th button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
.tbl th[aria-sort] button { color: var(--ink); }
.tbl td { height: var(--h-row); padding: 10px var(--s-4) 10px 0; border-bottom: var(--row-rule); border-right: var(--cell-rule); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--dur-1) var(--ease-out); }
.tbl tbody tr:hover { background: var(--primary-soft); }
.tbl tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.tbl .num, .tbl th.num { text-align: right; }
.tbl td:first-child, .tbl th:first-child { padding-left: var(--s-3); }
.bulk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4); border-radius: var(--r-ctl); background: var(--ink); color: var(--surface); }
.bulk .btn { color: var(--surface); } .bulk .btn:hover { background: var(--ink-2); color: var(--surface); }

.tabs { display: flex; gap: var(--s-5); border-bottom: var(--rule); overflow-x: auto; }
.tabs button, .tabs a { position: relative; min-height: var(--h-ctl); padding: 0 2px; border: 0; background: none; font: 600 var(--t-15)/1 var(--font-body); color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); }
.tabs [aria-selected="true"]::after, .tabs [aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); box-shadow: inset 0 0 0 1px var(--ink); }

details.acc { border-top: var(--row-rule); }
details.acc summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: var(--h-row); cursor: pointer; font-weight: 600; list-style: none; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: ""; width: 9px; height: 9px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform var(--dur-2) var(--ease-out); }
details.acc[open] summary::after { transform: rotate(-135deg); }
details.acc > div { padding: 0 0 var(--s-4); color: var(--ink-2); max-width: var(--measure); }

/* ---- App shell: icon rail ---------------------------------------------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--s-4) 0; background: var(--surface); border-right: var(--rule); z-index: var(--z-sticky); }
.rail .logo { margin-bottom: var(--s-4); }
.rail a, .rail button { position: relative; width: var(--h-ctl); height: var(--h-ctl); display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.rail a:hover, .rail button:hover { background: var(--surface-2); color: var(--ink); }
.rail [aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.rail .tip { position: absolute; left: calc(100% + 10px); top: 50%; transform: translate(-4px, -50%); padding: 6px 10px; border-radius: 6px; background: var(--ink); color: var(--surface); font: 500 var(--t-13)/1 var(--font-body); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.rail a:hover .tip, .rail a:focus-visible .tip, .rail button:hover .tip, .rail button:focus-visible .tip { opacity: 1; transform: translate(0, -50%); }
.rail .count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font: 700 var(--t-11)/18px var(--font-body); text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.rail .end { margin-top: auto; display: grid; gap: 6px; }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); min-height: 64px; padding: var(--s-2) var(--gutter); background: var(--bg); border-bottom: var(--rule); }
.topbar .crumbs { display: flex; align-items: center; gap: var(--s-2); margin-right: auto; font-size: var(--t-14); color: var(--muted); min-width: 0; }
.topbar .crumbs a { color: var(--muted); text-decoration: none; } .topbar .crumbs a:hover { color: var(--ink); text-decoration: underline; }
.topbar .crumbs b { color: var(--ink); font-weight: 600; }
.who { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-14); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft-2); color: var(--primary-strong); font-weight: 700; font-size: var(--t-13); flex: none; }
.page { padding: var(--s-6) var(--gutter) var(--s-9); min-width: 0; width: 100%; max-width: var(--page-max); margin-inline: auto; }
/* the top bar spans the screen, but its contents line up with the page below it */
.topbar { padding-inline: max(var(--gutter), calc((100% - var(--page-max)) / 2 + var(--gutter))); }
/* long lines are hard to read on a wide screen; tables, grids and flex rows are unaffected */
.page :where(p) { max-width: 80ch; }
/* boards use every column of a wide screen */
.c-board, .e-megaboard, .c-register { --page-max: 100%; }
/* letters and documents read best narrower */
.c-reports, .a-rules { --page-max: 1220px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s-3) var(--s-6); margin-bottom: var(--s-6); }
.page-head h1 { font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem); }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px var(--s-2) calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: var(--rule); }
  .rail .logo, .rail .tip { display: none; } .rail .end { margin: 0; display: contents; }
  body.has-rail { padding-bottom: 72px; }
  body.has-rail.has-pocbar { padding-bottom: calc(72px + var(--pocbar-h)); }
  body.has-pocbar .rail { bottom: var(--pocbar-h); }
}

/* ---- Layers ------------------------------------------------------------ */
.scrim { position: fixed; inset: 0; z-index: var(--z-layer); background: oklch(0.22 0.03 220 / 0.42); opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease-out); }
.scrim.on { opacity: 1; pointer-events: auto; }
.modal { position: fixed; z-index: calc(var(--z-layer) + 1); left: 50%; top: 50%; width: min(92vw, 560px); max-height: 86vh; overflow: auto; padding: var(--s-6); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--elev-modal); opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, calc(-50% + 12px)); transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2); }
.modal.on { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, -50%); transition-delay: 0s; }
.drawer { position: fixed; z-index: calc(var(--z-layer) + 1); top: 0; right: 0; bottom: 0; width: min(94vw, 480px); overflow: auto; padding: var(--s-6); background: var(--surface); border-left: var(--rule); visibility: hidden; transform: translateX(102%); transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3); }
.drawer.on { transform: none; visibility: visible; box-shadow: var(--elev-modal); transition-delay: 0s; }
.pop { position: absolute; z-index: var(--z-layer); min-width: 220px; padding: var(--s-2); border-radius: var(--r-card); background: var(--surface); border: var(--rule); box-shadow: var(--elev-pop); }
.pop button, .pop a { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: var(--h-ctl); padding: 0 var(--s-3); border: 0; border-radius: var(--r-ctl); background: none; text-align: left; text-decoration: none; color: var(--ink); }
.pop button:hover, .pop a:hover { background: var(--surface-2); }
.toast { border-radius: var(--r-ctl); box-shadow: var(--elev-pop); }

/* ---- The ring glyph ---------------------------------------------------- */
.g { display: block; width: 100%; height: auto; overflow: visible; }
.g path { fill: none; }
.g .band { stroke: var(--primary); stroke-opacity: 0.2; }
.g .edge { stroke: var(--primary); stroke-width: 1.6; }
.g .day  { stroke: var(--primary); stroke-width: 0.6; stroke-opacity: 0.4; }
.g .band.fill { stroke: none; fill: var(--primary); fill-opacity: 0.2; }
.g .cur .band { stroke: var(--accent); stroke-opacity: 1; }
.g .cur .band.fill { fill: var(--accent); fill-opacity: 1; }
.g .cur .edge { stroke: var(--ink); stroke-width: 1.3; }
.g .cur .day { stroke: var(--ink); stroke-opacity: 0.28; }
.g .dash { stroke: var(--muted); stroke-opacity: 0.6; stroke-width: 1; stroke-dasharray: 3 6; }
.g .ai .edge { stroke-dasharray: 0.012 0.012; }                       /* drafted by the assistant, not yet confirmed by a person */
.g .hit { stroke: transparent; pointer-events: stroke; cursor: pointer; }
.g .kn { stroke: var(--danger); stroke-width: 1.5; }
.g .core { fill: var(--ink); } .g .pith { fill: var(--primary); }
.g .healed .kn { stroke: var(--primary); } .g .healed .core { fill: var(--primary); }   /* a scar that was mitigated: it stays in the record, grown over */
.g.sm .band { stroke-opacity: 0.82; } .g.sm .band.fill { fill-opacity: 0.82; } .g.sm .cur .edge { stroke-width: 0.7; }
.g.sm .dash { stroke-width: 0.6; stroke-opacity: 0.5; stroke-dasharray: 2.2 2.4; } .g.sm .kn { stroke-width: 0.9; }
.g .ring { transition: opacity var(--dur-2) var(--ease-out); }
.g.sel .ring { opacity: 0.3; } .g.sel .ring.on { opacity: 1; }
.g .ln { stroke-width: 0.55; } .g .tint { stroke-opacity: 0.09; }
.g .low { stroke: var(--success); } .g .assess { stroke: var(--info); } .g .notlow { stroke: var(--danger); }
.g.draw .s { animation: ring-draw var(--dur, calc(500ms + var(--k) * 25ms)) var(--ease-out) backwards; animation-delay: calc(var(--k) * var(--step, var(--stagger-ring))); }
.g.draw .dash, .g.draw .fill, .g.draw .core, .g.draw .pith { animation: ring-fade 500ms var(--ease-out) backwards; animation-delay: calc(var(--k, 0) * var(--step, var(--stagger-ring))); }
@keyframes ring-draw { from { stroke-dasharray: 1 1; stroke-dashoffset: 1; } to { stroke-dasharray: 1 1; stroke-dashoffset: 0; } }
@keyframes ring-fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes breathe { to { transform: scale(1.01); } }
.rise.in { animation: rise 600ms var(--ease-out) backwards; animation-delay: calc(var(--n, 0) * 70ms); }
.breathe { animation: breathe 8s ease-in-out infinite alternate; }
.tilt { transition: transform var(--dur-3) var(--ease-out); }
.ring-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.ring-legend li { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-14); }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--primary); }
.dot.cur { background: var(--accent); border: var(--bw) solid var(--ink); }
.dot.next { background: none; border: var(--bw) dashed var(--muted); }
.dot.scar { width: 8px; height: 8px; margin: 0 3px; background: var(--ink); outline: 1.5px solid var(--danger); outline-offset: 2px; }

/* ---- Release runway ---------------------------------------------------- */
.runway .track { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); margin: 8px 7px 12px 0; }
.runway .track span { position: absolute; }
.runway .dd { inset: 0 auto 0 0; border-radius: 3px; background: var(--primary); }
.runway .late { top: 0; bottom: 0; background: var(--danger); border-radius: 0 3px 3px 0; }
.runway .done { top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--primary); }
.runway .done.bad { background: var(--danger); }
.runway .sail { top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--surface); border: var(--bw-strong) solid var(--ink); }

/* ---- Case card and board ----------------------------------------------- */
.case { display: grid; grid-template-columns: 56px minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 1.3fr); gap: var(--s-4) var(--s-5); align-items: center; }
.case .g { width: 56px; }
.case .id, .kcard .id { font-weight: 650; color: var(--primary); font-size: var(--t-14); text-decoration: none; }
.case h4 span { font-weight: 400; color: var(--muted); font-size: var(--t-14); }
.case .where { display: grid; gap: 6px; justify-items: start; }
@media (max-width: 980px) { .case { grid-template-columns: 56px minmax(0, 1fr); } .case .where, .case .runway { grid-column: 1 / -1; } }

.board { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(264px, 1fr); gap: var(--s-3); overflow-x: auto; padding-bottom: var(--s-4); scroll-snap-type: x proximity; }
.col { scroll-snap-align: start; display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-card); background: var(--surface-2); min-height: 240px; transition: background var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.col > header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 4px 6px 8px; font-weight: 650; font-size: var(--t-14); }
.col > header .n { color: var(--muted); font-weight: 500; }
.col.over { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--ink); }
.col.locked { opacity: 0.72; }
.col .none { margin: auto; text-align: center; color: var(--muted); font-size: var(--t-14); padding: var(--s-4); }
.kcard { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-ctl); background: var(--surface); border: var(--rule); cursor: grab; transition: border-color var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.kcard:hover { border-color: var(--primary); }
.kcard:active { cursor: grabbing; }
.kcard.drag { box-shadow: var(--elev-pop); transform: rotate(1.5deg); }
.kcard.fixed { cursor: default; }
.kcard .g { width: 40px; }
.kcard h4 { font-size: var(--t-15); }
.kcard .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-2); margin-top: 6px; font-size: var(--t-13); color: var(--muted); }
.days { font-weight: 700; color: var(--ink); }
.days.soon { background: var(--accent); padding: 0 6px; border-radius: 4px; }
.days.late { color: var(--danger-ink); }

/* ---- Evidence strength: a reading, never a decision -------------------- */
.ev { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s-4); align-items: center; }
.ev svg { width: 96px; height: 96px; } .ev circle { fill: none; stroke-width: 7; }
.ev .bg { stroke: var(--surface-3); } .ev .fg { stroke: var(--primary); stroke-dasharray: 2.2 3.2; }
.ev text { font-family: var(--font-display); font-size: 30px; fill: var(--ink); text-anchor: middle; }

/* ---- The assistant: drafted and flagged, a person decides --------------- */
.flag { border: var(--rule); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.flag > .what { padding: var(--pad-card); }
.flag .finding { font-family: var(--font-display); font-size: clamp(1.3rem, 1rem + 1vw, 1.75rem); line-height: 1.2; margin: var(--s-2) 0 var(--s-3); text-wrap: balance; }
.checkpoint { display: grid; grid-template-columns: 1fr 1fr; border-top: var(--rule); }
.checkpoint > div { padding: var(--s-4) var(--pad-card); }
.checkpoint > div + div { border-left: var(--rule); }
.checkpoint h4 { display: flex; align-items: center; gap: var(--s-2); margin-bottom: 4px; }
.checkpoint .by-ai { background: repeating-linear-gradient(135deg, transparent 0 7px, var(--surface-2) 7px 8px); }
@media (max-width: 640px) { .checkpoint { grid-template-columns: 1fr; } .checkpoint > div + div { border-left: 0; border-top: var(--rule); } }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 8px; border-radius: 6px; border: var(--bw) dashed var(--line-strong); font-size: var(--t-12); font-weight: 600; color: var(--ink-2); }

/* ---- Stage stepper ----------------------------------------------------- */
.stages { display: grid; gap: 2px; }
.stage { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; width: 100%; min-height: var(--h-ctl); padding: 4px 12px; border: 0; border-radius: var(--r-ctl); background: none; color: var(--ink); line-height: 1.25; text-align: left; }
.stage .d { color: var(--muted); font-size: var(--t-14); }
.stage:hover { background: var(--surface-2); }
.stage[aria-current="true"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

/* ---- States ------------------------------------------------------------ */
.empty { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-8) var(--s-5); text-align: center; }
.empty .g { width: 120px; }
.empty h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-22); }
.empty p { max-width: 44ch; color: var(--muted); }
.banner { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border-radius: var(--r-ctl); background: var(--surface-2); }
.banner.warn { background: var(--warning-soft); } .banner.warn .ico { color: var(--warning-ink); }
.banner.err  { background: var(--danger-soft); }  .banner.err .ico  { color: var(--danger-ink); }
.banner.ok   { background: var(--success-soft); } .banner.ok .ico   { color: var(--success-ink); }
.banner.info { background: var(--info-soft); }    .banner.info .ico { color: var(--info-ink); }
.skel { border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: skel 1.4s ease-in-out infinite; color: transparent; user-select: none; }
.skel.ring { width: 56px; height: 56px; border-radius: 50%; }
@keyframes skel { to { background-position: -200% 0; } }

/* ---- Sound toggle ------------------------------------------------------ */
.sound { display: inline-flex; align-items: center; gap: var(--s-2); }
.sound .bars { display: inline-flex; align-items: end; gap: 2px; height: 14px; }
.sound .bars i { width: 3px; height: 4px; border-radius: 1px; background: currentColor; }
.sound[aria-pressed="true"] .bars i { animation: bars 900ms ease-in-out infinite alternate; }
.sound[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: 150ms; } .sound[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: 300ms; }
@keyframes bars { to { height: 14px; } }

/* ---- Shared by the dashboard and the style guide ------------------------ */
.app-main { min-width: 0; }
.whole { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: var(--s-6); align-items: center; }
.whole figure { width: 100%; max-width: 320px; justify-self: center; }
.key li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 12px 0; border-top: var(--row-rule); }
.key li:first-child { border: 0; }
@media (max-width: 760px) { .whole { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .banner { grid-template-columns: 24px minmax(0, 1fr); } .banner > :last-child:not(p) { grid-column: 2; justify-self: start; } }
/* A thin meter: used for contract volume, upload progress, confidence. */
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; width: var(--p, 0%); border-radius: 3px; background: var(--primary); }
.meter.low > i { background: var(--warning); }
.field.ai textarea { background: var(--accent-soft); }
p > .ico, li > .ico, span > .ico, strong > .ico { display: inline-block; vertical-align: -0.2em; }
@media (max-width: 640px) { .btn { white-space: normal; text-align: left; padding-block: 8px; line-height: 1.25; } .btn.round { padding: 0; } }

.pocbar a.link { color: var(--on-drench-muted); text-decoration: none; font-size: var(--t-12); padding: 0 var(--s-2); display: inline-flex; align-items: center; min-height: 32px; }
.pocbar a.link:hover { color: var(--on-drench); }

.tour-pop { border: var(--rule); box-shadow: var(--elev-modal); transition: top var(--dur-2) var(--ease-out), left var(--dur-2) var(--ease-out); }
.tour-pop .step { font-family: var(--font-body); font-weight: 600; }
.tour-pop h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-22); }
.tour-hole { box-shadow: 0 0 0 9999px oklch(0.22 0.03 220 / 0.55), 0 0 0 3px var(--accent); transition: top var(--dur-2) var(--ease-out), left var(--dur-2) var(--ease-out), width var(--dur-2) var(--ease-out), height var(--dur-2) var(--ease-out); }
.field.search:has(> label:not(.vh)) .ico { top: auto; bottom: calc((var(--h-ctl) - 20px) / 2); transform: none; }   /* a search field with a visible label: centre the icon on the input, not the whole field */
