/* Sacred Command Center · base and shared components.
   Built on brand-tokens.css (the kit, unchanged) and theme.css (semantic tokens, Dark default, Light under
   :root[data-theme="light"] only). Colors come from semantic tokens only: no hex, no rgba here (tests/static.mjs S-a2).
   Type: Montserrat only, no italics, no serif. Radii 8 (buttons, inputs, chips) / 10 (cards, containers) / 14 (sheets).
   Motion: transform and opacity; press scales to 0.97 on pointer-down; feedback inside 200 ms, moves inside 500 ms.
   Order: 0 base and type · 1 icons · 2 buttons · 3 inputs · 4 segmented control and tabs · 5 marks · 6 rows and lists ·
          7 cards, stats, states · 8 sheets, menus, toasts · 9 layout helpers. Shell is css/shell.css, the Zoho-style
          list/board/record kit is css/kit.css, HQ's carried-over screens are css/legacy-hq.css. */

/* ── 0 · Base and type scale ───────────────────────────────────────────────────────────── */
:root {
  /* type: 13 caption/label floor · 14 table cell · 16 body (17 on phones) · 18 titles · 20 sheet titles · 28 page title · 40 stat */
  --fs-caption: 0.8125rem;
  --fs-cell:    0.875rem;
  --fs-body:    1rem;
  --fs-h3:      1.125rem;
  --fs-h2:      1.25rem;
  --fs-title:   1.75rem;
  --fs-head-title: 1.25rem;
  --fs-stat:    2.5rem;
  --lh-body:    1.5;

  /* data tables (PLAN 2.8): row 44 px for a finger, 40 px for a fine pointer at 1024 px and up (Standard); Compact 36;
     Comfortable 44. Setup > Personal > Appearance sets html[data-density]. Cell text 14 px, header 13 px caps. */
  --row-h:   44px;
  --th-h:    36px;
  --cell-px: 0.75rem;
  --cell-w:  500;      /* cell weight: 500 on Dark, 400 on Light (set under the light theme below) */

  /* layout */
  --safe-top: env(safe-area-inset-top, 0px);
  --crit-h: 0px;       /* height of the critical banner while one shows (CriticalBanner sets it); the banner takes the notch, so --top is the larger of the two */
  --top: max(var(--safe-top), var(--crit-h));   /* what sticks under the top bar clears the banner too */
  --side-w: 264px;
  --rail-w: 72px;
  --head-h: 56px;
  --bar-h: 64px;
  --filter-w: 260px;
  --gutter: var(--s-3);
  --fab: 56px;
}
:root[data-theme="light"] { --cell-w: 400; }
/* iOS 16.4 floor: the kit's --spring is a CSS linear() curve (Safari 17.2+); older Safari drops the whole transition, so it falls back to the ease-out curve. */
@supports not (transition-timing-function: linear(0, 1)) { :root { --spring: var(--ease-out); } }
@media (min-width: 768px) { :root { --gutter: var(--s-4); } }
@media (min-width: 1024px) { :root { --gutter: var(--s-4); } }
@media (pointer: fine) and (min-width: 1024px) {
  :root { --row-h: 40px; }
  :root[data-density="compact"] { --row-h: 36px; --th-h: 32px; }
  :root[data-density="compact"] .page-head .eyebrow { display: none; }
  :root[data-density="compact"] .page-head { margin-bottom: var(--s-2); }
  :root[data-density="compact"] .view { padding-top: var(--s-2); }
  :root[data-density="compact"] .lv-head { min-height: 32px; }
  :root[data-density="compact"] .lv-bar { min-height: 36px; }
  :root[data-density="compact"] .view:has(.lv-main) { padding-top: var(--s-1); padding-bottom: var(--s-2); }
  :root[data-density="comfortable"] { --row-h: 44px; }
}

html {
  /* Focus never lands under the sticky header (WCAG 2.4.11), or under the phone's bottom bar and capture button */
  scroll-padding-top: calc(var(--top) + var(--head-h) + var(--s-2));
  font-size: 100%;
  font-family: var(--font);
  font-synthesis: none;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (max-width: 767px) {
  html { font-size: 106.25%; scroll-padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--fab) + var(--s-4)); }   /* 17 px body on phones */
}
/* iOS: honour the phone's Text Size setting (Dynamic Type), then put Montserrat back. iOS Safari only. */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 767px) { html { font: -apple-system-body; font-family: var(--font); } }
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; text-align: inherit; }
img, svg { display: block; max-width: 100%; }
em, i, cite, var, dfn, address { font-style: normal; }   /* Brand Kit v1.1: no italics anywhere */
strong, b { font-weight: 700; }
a { color: var(--link); text-decoration-line: underline; text-decoration-color: var(--link-line); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
@media (hover: hover) { a:hover { text-decoration-thickness: 2px; } }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--on-accent); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num, .tnum, .tab-n { font-variant-numeric: tabular-nums; }
.caption { font-size: var(--fs-caption); line-height: 1.45; letter-spacing: var(--caption-ls); color: var(--text-3); }
.caption.center { text-align: center; }
.muted, .c2 { color: var(--text-2); }
.prose { color: var(--text-2); max-width: var(--measure); }
.prose + .prose { margin-top: var(--s-2); }
.mono { font-family: var(--font-mono); }   /* ONLY inside a depicted terminal or log mockup */
html.has-sheet { overflow: hidden; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.clamp1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; }

/* Press feedback: pointer-down scale for buttons and pressable cards (the kit base covers plain buttons). */
:where(.kcard, .card--link) { transition: transform var(--t-press) var(--ease-out), border-color var(--t-feedback) var(--ease-out), background-color var(--t-feedback) var(--ease-out); }
:where(.card--link):active { transform: scale(var(--press-scale)); }
/* Wide surfaces highlight instead of scaling (a 400 px header shrinking reads as a jump). */
:where(.ctr-head, .row--link, .menu-item, .nav-item, .nav-child, .nav-fold, .tab-item, .tbtn, .th-btn, .cell-link, .pal-row, .rail-b, .fp-gh, .fp-saved-b, .col-fold, .pager-n, .stage-b, .more-row, .rf-show, .kcard-link, .chip-x, .tab, .circle, .link-btn, .setup-gh button, .setup-nav a, .setup-back):active { transform: none; }
/* Small controls set their own height; the kit's 44 px minimum is for .btn and .icon-btn (and every target is 44 px to hit through ::after). */
button, [role="button"] { min-height: 0; }

/* ── 1 · Icons: one sprite, 24 px grid, 1.5 px stroke, round caps, currentColor ───────── */
.i { width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.i--20 { width: 20px; height: 20px; }
.i--16 { width: 16px; height: 16px; stroke-width: 1.75; }
/* HQ's carried-over screens name their icons .icon .s14/.s18/.s20 */
.icon { width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon.s20 { width: 20px; height: 20px; }
.icon.s18 { width: 18px; height: 18px; }
.icon.s14 { width: 14px; height: 14px; stroke-width: 1.75; }
.icon.inl { margin-right: 4px; color: var(--text-2); }

/* ── 2 · Buttons ───────────────────────────────────────────────────────────────────────── */
/* Two tiers. Page-level actions keep 04b's style (Bold 700 caps 13 px, +0.1em): .btn. Everything that works on the
   page's data (Filter, Sort, Columns, mass actions, row and stage menus) is the quieter toolbar tier: .tbtn
   (sentence case, SemiBold 14 px, icon plus label, hover wash, 44 px hit area on touch). One crimson-filled button per view. */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-button);
  background: transparent; color: var(--text);
  font-size: var(--button-size); font-weight: 700; line-height: 1.1; letter-spacing: var(--button-ls); text-transform: uppercase;
  text-decoration: none; white-space: nowrap; user-select: none; -webkit-user-select: none;
}
.btn .i, .btn .icon { width: 20px; height: 20px; margin-left: -4px; }
.btn .i--trail { margin: 0 -4px 0 0; }
.btn--primary, .btn.prominent { background: var(--accent); color: var(--on-accent); }
.btn--primary:active, .btn.prominent:active { background: var(--accent-press); }
.btn--secondary, .btn.tinted, .btn.gray { border-color: var(--line-strong); }
.btn--secondary:active, .btn.tinted:active, .btn.gray:active { background: var(--hover); }
.btn--quiet, .btn.plain { color: var(--text-2); }
.btn--quiet:active, .btn.plain:active { background: var(--hover); }
.btn--danger, .btn.gray-destructive, .btn.destructive { border-color: var(--accent); color: var(--danger-text); }
.btn--danger .i, .btn.gray-destructive .icon, .btn.destructive .icon { color: var(--accent-mark); }
.btn--danger:active, .btn.gray-destructive:active, .btn.destructive:active { background: var(--accent-press); border-color: var(--accent-press); color: var(--on-accent); }
@media (hover: hover) {
  .btn--primary:hover, .btn.prominent:hover { background: var(--accent-hover); }
  .btn--secondary:hover, .btn.tinted:hover, .btn.gray:hover { border-color: var(--text-3); background: var(--hover); }
  .btn--quiet:hover, .btn.plain:hover { background: var(--hover); color: var(--text); }
  .btn--danger:hover, .btn.gray-destructive:hover, .btn.destructive:hover { background: var(--accent); color: var(--on-accent); }
  .btn--danger:hover .i, .btn.gray-destructive:hover .icon, .btn.destructive:hover .icon { color: var(--on-accent); }
}
/* Small: 32 px to look at, 44 px to hit (the ::after extends the target) */
.btn--sm, .btn.sm { min-height: 32px; padding: 0 var(--s-2); gap: var(--s-1); }
.btn--sm .i, .btn.sm .icon { width: 16px; height: 16px; margin-left: -2px; stroke-width: 1.75; }
.btn--sm::after, .btn.sm::after, .icon-btn--sm::after { content: ""; position: absolute; inset: -7px -2px; }   /* the inset is measured from the padding box (inside the 1 px border), so 32 + 14 = 44 */
.icon-btn--sm::after { inset: -7px; }
.btn--block, .btn.block { width: 100%; }
.btn.md { min-height: 40px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"] .i { animation: spin 900ms linear 3; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toolbar tier */
.tbtn {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 32px; padding: 0 var(--s-2);
  border: 1px solid transparent; border-radius: var(--r-button);
  color: var(--text-2);
  font-size: var(--fs-cell); font-weight: 600; line-height: 1.1; white-space: nowrap;
  transition: background-color var(--t-feedback) var(--ease-out), color var(--t-feedback) var(--ease-out);
}
.tbtn::after { content: ""; position: absolute; inset: -7px -2px; }   /* 44 px hit area on a 32 px look */
.tbtn .i { width: 20px; height: 20px; color: var(--text-3); }
.tbtn:active, .tbtn[aria-expanded="true"], .tbtn[aria-pressed="true"] { background: var(--hover); color: var(--text); }
.tbtn[aria-pressed="true"] { border-color: var(--line-strong); }
@media (hover: hover) { .tbtn:hover { background: var(--hover); color: var(--text); } .tbtn:hover .i { color: var(--text); } }
.tbtn:disabled, .tbtn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.tbtn--outline { border-color: var(--line-strong); }
.tbtn .tbtn-n { font-variant-numeric: tabular-nums; color: var(--text-3); font-weight: 600; }
.tbtn-split { display: inline-flex; align-items: stretch; }
.tbtn-split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tbtn-split > .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 var(--s-2); margin-left: 1px; }
.tbtn-split > .btn:last-child .i { margin: 0; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center; flex: none;
  width: var(--tap); height: var(--tap);
  border-radius: var(--r-button);
  color: var(--text-2);
}
.icon-btn:active, .icon-btn[aria-expanded="true"] { background: var(--hover); color: var(--text); }
@media (hover: hover) { .icon-btn:hover { background: var(--hover); color: var(--text); } }
.icon-btn--sm { width: 32px; height: 32px; min-height: 32px; }
.icon-btn--sm .i { width: 20px; height: 20px; }
.icon-btn--count { display: inline-flex; gap: 6px; width: auto; padding: 0 10px 0 8px; }
.icon-btn--count .num { font-size: var(--fs-body); font-weight: 700; color: var(--accent-text); }
.icon-btn--count[data-n="0"] .num { color: var(--text-3); }
.icon-btn.more svg { stroke-width: 3; }
.avatar-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: var(--r-button); }
.avatar-btn:active, .avatar-btn[aria-expanded="true"] { background: var(--hover); }
@media (hover: hover) { .avatar-btn:hover { background: var(--hover); } }
/* A text link that is a button (Retry, Expand, "See all") */
.link-btn { color: var(--link); text-decoration: underline; text-decoration-color: var(--link-line); text-decoration-thickness: 1px; text-underline-offset: 0.2em; font-weight: 600; cursor: pointer; }
@media (hover: hover) { .link-btn:hover { text-decoration-thickness: 2px; } }

/* ── 3 · Inputs, check button, options ────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.label { font-size: var(--fs-caption); font-weight: 600; letter-spacing: var(--caption-ls); color: var(--text-2); }
.hint { font-size: var(--fs-caption); line-height: 1.45; color: var(--text-3); }
.input, .textarea, .select {
  width: 100%; min-height: var(--tap);
  padding: 0 var(--s-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-field); border-radius: var(--r-button);
  font-size: 1rem; font-weight: var(--fw-body); line-height: var(--lh-body);   /* 16 px+ so iOS never zooms */
  transition: border-color var(--t-feedback) var(--ease-out);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
@media (hover: hover) { .input:hover, .textarea:hover, .select:hover { border-color: var(--text-3); } }
.input:focus, .textarea:focus, .select:focus { border-color: var(--text-3); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.textarea { padding-top: calc((var(--tap) - 1.5em - 2px) / 2); padding-bottom: calc((var(--tap) - 1.5em - 2px) / 2); min-height: 112px; resize: vertical; }
.input--lg { min-height: 56px; font-size: var(--fs-h3); font-weight: 600; }
.input--sm, .select--sm { min-height: 32px; padding: 0 var(--s-2); font-size: var(--fs-cell); }
.input[type="date"], .input[type="time"], .input[type="number"], .input[type="datetime-local"] { font-variant-numeric: tabular-nums; }
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { min-width: 0; }
.input::-webkit-date-and-time-value { text-align: left; }
.input::-webkit-calendar-picker-indicator { opacity: 0.7; cursor: pointer; }
.input[type="search"]::-webkit-search-decoration, .input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.select-wrap, .search { position: relative; display: block; min-width: 0; }
.select { padding-right: 40px; cursor: pointer; }
.select-wrap > .i { position: absolute; right: 12px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--text-3); pointer-events: none; }
.search > .i { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--text-3); pointer-events: none; }
.search > .input { padding-left: 40px; }
.field.is-invalid .input, .field.is-invalid .textarea, .field.is-invalid .select, .input[aria-invalid="true"] { border-color: var(--accent); }
.field-err, .err-line { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--fs-caption); font-weight: 600; line-height: 1.45; color: var(--danger-text); }
.field-err .i, .err-line .icon { width: 16px; height: 16px; margin-top: 1px; color: var(--accent-mark); stroke-width: 1.75; }
.fields { display: grid; gap: var(--s-4); }
.fields--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.input-row { display: flex; gap: var(--s-2); align-items: center; }

/* Check button for tasks: role="checkbox", 24 px box inside a 44 px target. Done = Gilt (complete). */
.check { position: relative; display: inline-grid; place-items: center; flex: none; width: var(--tap); height: var(--tap); border-radius: var(--r-button); color: var(--on-gilt); }
.check::before { content: ""; grid-area: 1 / 1; width: 24px; height: 24px; border-radius: var(--r-button); border: 1.5px solid var(--text-3); transition: background-color var(--t-feedback) var(--ease-out), border-color var(--t-feedback) var(--ease-out); }
.check .i, .check .icon { grid-area: 1 / 1; width: 18px; height: 18px; stroke-width: 2.25; opacity: 0; transform: scale(0.6); transition: opacity var(--t-feedback) var(--ease-out), transform var(--t-feedback) var(--ease-out); }
.check[aria-checked="true"]::before, .check[aria-pressed="true"]::before { background: var(--gilt); border-color: var(--gilt); }
.check[aria-checked="true"] .i, .check[aria-checked="true"] .icon, .check[aria-pressed="true"] .icon { opacity: 1; transform: none; }
@media (hover: hover) { .check:hover::before { border-color: var(--text-2); } .check[aria-checked="true"]:hover::before { border-color: var(--gilt); } }

/* Option: a labelled checkbox (Must do, Show tests, Include closed) */
.opt { display: inline-flex; align-items: center; gap: var(--s-3); min-height: var(--tap); cursor: pointer; color: var(--text); font-weight: 600; }
.opt-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt-box { position: relative; display: grid; place-items: center; width: 24px; height: 24px; flex: none; border: 1.5px solid var(--text-3); border-radius: var(--r-button); color: var(--bg); transition: background-color var(--t-feedback) var(--ease-out), border-color var(--t-feedback) var(--ease-out); }
.opt-box .i { width: 18px; height: 18px; stroke-width: 2.25; opacity: 0; transition: opacity var(--t-feedback) var(--ease-out); }
.opt-input:checked + .opt-box { background: var(--text); border-color: var(--text); }   /* the same checked box as a table's: Linen on Dark, Void on Light; crimson stays for the one primary button */
.opt-input:checked + .opt-box .i { opacity: 1; }
.opt-input:focus-visible + .opt-box { outline: 2px solid var(--focus); outline-offset: 2px; }
.opt-hint { display: block; font-size: var(--fs-caption); font-weight: 500; color: var(--text-3); }
.opt--sm { min-height: 32px; gap: var(--s-2); font-weight: 500; font-size: var(--fs-cell); }
.opt--sm .opt-box { width: 22px; height: 22px; }   /* a rounded square at the kit's 8 px radius; at 20 px it read as a circle */
.opt--sm .opt-box .i { width: 16px; height: 16px; }

/* ── 4 · Segmented control and tabs ──────────────────────────────────────────────────── */
.seg {
  display: inline-flex; gap: 2px; max-width: 100%;
  padding: 2px;                                   /* 10 px track radius − 2 px = the 8 px button radius */
  background: var(--hover);
  border: 1px solid var(--line); border-radius: var(--r-card);
  overflow-x: auto; scrollbar-width: none;
}
.seg > button {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 38px; padding: 0 var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-button);
  color: var(--text-2);
  font-size: var(--button-size); font-weight: 700; letter-spacing: var(--button-ls); text-transform: uppercase; white-space: nowrap;
}
.seg > button::after { content: ""; position: absolute; inset: -4px -1px; }   /* 46 px tall target */
.seg > button[aria-pressed="true"], .seg > button[aria-checked="true"] { background: var(--raised); border-color: var(--line-strong); color: var(--text); }
.seg > button:disabled { opacity: 0.45; cursor: not-allowed; }
@media (hover: hover) { .seg > button:not([aria-pressed="true"]):not([aria-checked="true"]):not(:disabled):hover { color: var(--text); } }
.seg--block { display: flex; }
.seg--block > button { flex: 1 1 0; min-width: 0; }
.seg--sm > button { min-height: 28px; padding: 0 var(--s-2); }
.seg--sm > button::after { inset: -8px -1px; }
.seg--plain > button { text-transform: none; letter-spacing: 0; font-size: var(--fs-cell); font-weight: 600; }
/* Labels of unequal length (Dark · Light · Match device): each segment starts from its own label width and shares
   the spare room, never shrinks below its longest word, and a two-word label wraps to two lines on the narrowest
   phones (320 px) rather than being cut. */
.seg--fit > button { flex: 1 1 auto; min-width: min-content; padding: 4px var(--s-2); white-space: normal; text-align: center; line-height: 1.15; }
/* The ring sits inside the button: the track scrolls (overflow-x), so a ring outside it would be cut off */
.seg > button:focus-visible, .tab:focus-visible { outline-offset: -2px; }

.tabs { display: flex; gap: var(--s-4); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; flex: none;
  min-height: var(--tap); padding: 0 2px;
  color: var(--text-3); font-weight: 600; white-space: nowrap;
}
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); opacity: 0; transform: scaleX(0.6); transition: opacity var(--t-feedback) var(--ease-out), transform var(--t-feedback) var(--ease-out); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { opacity: 1; transform: none; }
.tab:disabled { opacity: 0.45; cursor: not-allowed; }
@media (hover: hover) { .tab:hover:not(:disabled) { color: var(--text); } }
.tab .num { margin-left: 6px; color: var(--text-3); font-weight: 600; }
.tab-panel:focus-visible { outline-offset: 4px; }
.tabs--dense { gap: var(--s-3); }
.tabs--dense .tab { min-height: 40px; font-size: var(--fs-cell); }

/* ── 5 · Marks: counts, chips, ages, status, eyebrow, key-value ───────────────────────── */
/* Count: a plain tabular numeral. Chip: 8 px radius at most, never a pill. */
.count { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.chip, .age {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 24px; padding: 0 var(--s-2);
  border-radius: var(--r-button);
  background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-caption); font-weight: 600; line-height: 1.2; letter-spacing: var(--caption-ls);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip .i, .chip .icon { width: 14px; height: 14px; stroke-width: 1.75; }
button.chip { cursor: pointer; position: relative; }
button.chip::after { content: ""; position: absolute; inset: -10px -2px; }
button.chip[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.age { font-weight: 700; color: var(--text); }
.age--bad { background: var(--accent); color: var(--on-accent); }
.chip--line { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.field > .chips { margin-top: 0 !important; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--s-4) * -1); padding: 6px var(--s-4); }
.chips.scroll .chip { flex: none; }

/* Late: lateness on a row is a crimson icon plus the Linen word */
.late { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 700; }
.late .i, .late .icon { width: 16px; height: 16px; color: var(--accent-mark); stroke-width: 1.75; }
.when { font-variant-numeric: tabular-nums; }

/* Status: dot + word. A dot only for a real, current status. Never pulses. */
.status { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-caption); font-weight: 700; letter-spacing: var(--caption-ls); color: var(--text); white-space: nowrap; }
.status::before, .dot { content: ""; display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--text-3); }
.status--live::before, .dot--live { background: var(--live); }
.status--down::before, .dot--down { background: var(--accent-mark); }
.status--stale::before, .dot--stale { background: var(--text-3); }
.status--private::before, .dot--private { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.status-at { font-weight: 500; color: var(--text-3); }
/* HQ's carried-over status helpers: a mark that always travels with a word */
span.dot { vertical-align: 1px; margin-right: 6px; }
.dot.warn { background: var(--text-3); }
.dot.err { background: var(--accent-mark); }
.dot.ok { background: var(--text-3); }
.dot.tint { background: var(--accent-mark); }

/* Honest states: Not connected · Not recorded · None · Couldn't load · Needs Auri's yes */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-caption); font-weight: 700; letter-spacing: var(--caption-ls); color: var(--text-3); white-space: nowrap; }
.state .i { width: 16px; height: 16px; stroke-width: 1.75; }
.state--bad { color: var(--text); }
.state--bad .i { color: var(--accent-mark); }
.state--gate { color: var(--text-2); }
.state .link-btn { font-size: inherit; }
.state-cell { color: var(--text-3); font-weight: 500; }

/* Section label: tracked caps with a short crimson dash */
.eyebrow { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-caption); font-weight: 600; line-height: 1.2; letter-spacing: var(--eyebrow-ls); text-transform: uppercase; color: var(--text-3); }
.eyebrow::before { content: ""; width: 16px; height: 2px; flex: none; background: var(--accent); }
.eyebrow + * { margin-top: var(--s-2); }
.eyebrow--plain::before { display: none; }

/* Key-value list for detail sheets */
.kv { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: var(--s-2) var(--s-4); }
.kv dt { font-size: var(--fs-caption); font-weight: 600; letter-spacing: var(--caption-ls); color: var(--text-3); padding-top: 2px; }
.kv dd { color: var(--text); overflow-wrap: anywhere; }

/* Owner mark: an 8 px-radius square with initials. The only person mark. */
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--r-button); background: var(--surface-2); color: var(--text); font-size: var(--fs-caption); font-weight: 700; line-height: 1; letter-spacing: 0.04em; text-transform: uppercase; }
.avatar--founder { background: var(--text); color: var(--bg); }
.avatar--lg { width: 44px; height: 44px; font-size: var(--fs-body); }
.avatar--sm { width: 24px; height: 24px; font-size: var(--fs-caption); letter-spacing: 0; }
.avatar--xs { width: 20px; height: 20px; font-size: 0.6875rem; letter-spacing: 0; }

/* ── 6 · Rows and lists (04b) ───────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list > li + li { border-top: 1px solid var(--line); }
.row-main { flex: 1 1 10rem; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-t { font-weight: 600; line-height: 1.35; color: var(--text); overflow-wrap: break-word; }
.row-t--clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Meta line: items separated by a middle dot that never starts a wrapped line. */
.row-s { display: flex; flex-wrap: wrap; align-items: center; margin-left: -14px; clip-path: inset(0 0 0 14px); font-size: var(--fs-caption); line-height: 1.45; letter-spacing: var(--caption-ls); color: var(--text-3); }
.row-s > * { position: relative; margin-left: 14px; }
.row-s > *::before { content: "·"; position: absolute; left: -14px; width: 14px; text-align: center; color: var(--text-3); }
.row-end { flex: none; display: flex; align-items: center; gap: var(--s-1); margin-left: auto; margin-right: calc(var(--s-2) * -1); }
.row-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: var(--r-button); background: var(--surface-2); color: var(--text-2); }
.row-icon .i { width: 20px; height: 20px; }
.row-icon--bad { color: var(--accent-mark); }
.row-time { flex: none; width: 56px; display: flex; flex-direction: column; line-height: 1.25; }
.row-time b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.row-time span { font-size: var(--fs-caption); color: var(--text-3); }

/* ── 7 · Cards, stats, states ───────────────────────────────────────────────────────── */
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s-3); }
.card--flush { padding: 0; overflow: hidden; }
.card--link { display: block; color: var(--text); text-decoration: none; }
@media (hover: hover) { .card--link:hover { border-color: var(--line-strong); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr)); gap: var(--s-3); }
.stat { display: flex; flex-direction: column; min-width: 0; padding: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); text-align: left; color: var(--text); }
button.stat, a.stat { text-decoration: none; cursor: pointer; }
@media (hover: hover) { button.stat:hover, a.stat:hover { border-color: var(--line-strong); } }
.stat-l { font-size: var(--fs-caption); font-weight: 600; line-height: 1.45; letter-spacing: var(--caption-ls); color: var(--text-2); }
.stat-v { margin-top: var(--s-2); font-size: var(--fs-stat); font-weight: 900; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-v small { margin-left: 4px; font-size: var(--fs-body); font-weight: 700; letter-spacing: 0; color: var(--text-3); }
.stat-v.is-none { display: flex; align-items: flex-end; min-height: var(--fs-stat); font-size: var(--fs-body); font-weight: 700; line-height: 1.3; letter-spacing: 0; color: var(--text-3); }
.stat-meta { margin-top: var(--s-2); font-size: var(--fs-caption); line-height: 1.45; color: var(--text-3); }
.stat--accent .stat-v { color: var(--accent-mark); }
.stats--dense .stat { padding: var(--s-2) var(--s-3); }
.stats--dense .stat-v { font-size: 1.75rem; margin-top: var(--s-1); }
.stats--dense .stat-v.is-none { min-height: 1.75rem; }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); padding: var(--s-4) var(--s-3); }
.empty-t { font-weight: 700; color: var(--text); }
.empty-s { color: var(--text-2); max-width: var(--measure); }
.empty .btn { margin-top: var(--s-2); }

.notice { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-3); padding: var(--s-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-button); color: var(--text-2); }
.notice > .i { color: var(--text-3); }
.notice--warn > .i { color: var(--accent-mark); }
.notice-body { flex: 1 1 12rem; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notice-body b { color: var(--text); }
.notice .btn { flex: 0 1 auto; align-self: center; margin-left: auto; white-space: normal; text-align: center; max-width: 100%; padding-top: 6px; padding-bottom: 6px; line-height: 1.25; }
@media (max-width: 559px) { .notice .btn { margin-left: 0; width: 100%; } }

.skel { display: block; height: 20px; border-radius: var(--r-button); background: var(--skeleton); }
.skel--t { width: 62%; }
.skel--s { width: 38%; margin-top: var(--s-2); }
.skel--short { width: 48%; }
.skel--sum { width: 9rem; margin-top: 2px; }
.skel-row { padding: var(--s-3); }
.skel-row + .skel-row { border-top: 1px solid var(--line); }

.meter { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s-1); }
.meter > i { height: 24px; border-radius: var(--r-button); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.meter > i.on { background: var(--accent); box-shadow: none; }

/* Bars and funnels: grey steps, Crimson only on the series or stage that needs attention (PLAN 2.8) */
.bar { display: flex; gap: 2px; height: 8px; border-radius: var(--r-button); overflow: hidden; background: var(--chart-track); }
.bar > i { display: block; height: 100%; background: var(--chart-2); }
.bar > i.focal, .bar > i.tint { background: var(--chart-focal); }
.bar > i.c1 { background: var(--chart-1); }
.bar > i.c3, .bar > i.c2 { background: var(--chart-3); }
.bar > i.fill { background: transparent; }
.bar.thin { height: 6px; }

html.has-overlay { overflow: hidden; scrollbar-gutter: stable; }   /* the page behind an open sheet, menu or palette stays where it is */

/* ── 8 · Sheets, menus, toasts ──────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--t-move) var(--ease-out); }
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* Bottom sheet on phones; side sheet from 768 px. Enters and leaves along the same path. */
.sheet {
  position: fixed; z-index: 51;
  left: 0; right: 0; bottom: var(--kb, 0px);   /* --kb is the iOS keyboard's height (main.js), so a field is never under it */
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--safe-top) - var(--s-3) - var(--kb, 0px));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-panel) var(--r-panel) 0 0;
  box-shadow: var(--shadow);
  transform: translateY(100%); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform var(--t-move) var(--spring), opacity var(--t-press) var(--ease-out), visibility 0s linear var(--t-move);
}
.sheet.is-open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; transition: transform var(--t-move) var(--spring), opacity var(--t-press) var(--ease-out), visibility 0s; }
@media (min-width: 768px) {
  .sheet {
    left: auto; top: calc(var(--safe-top) + var(--s-2)); right: var(--s-2); bottom: var(--s-2);
    width: min(480px, calc(100vw - var(--s-3)));
    max-height: none;
    border-bottom: 1px solid var(--line); border-radius: var(--r-panel);
    transform: translateX(calc(100% + var(--s-3)));
  }
  .sheet--wide { width: min(640px, calc(100vw - var(--s-3))); }
  .sheet--fit { bottom: auto; max-height: calc(100dvh - var(--safe-top) - var(--s-4)); }
}
.sheet-form { display: contents; }
@media (max-width: 767px) { .sheet { padding-bottom: env(safe-area-inset-bottom); } .sheet:has(.sheet-f) { padding-bottom: 0; } }
.sheet-h { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-3) var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.sheet-hgroup { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); padding-top: 6px; }
.sheet-t { font-size: var(--fs-h2); font-weight: 700; line-height: 1.28; color: var(--text); }
.sheet-sub { font-size: var(--fs-caption); line-height: 1.45; color: var(--text-3); }
.sheet-h-slot { flex: none; display: flex; align-items: center; gap: var(--s-2); }
@media (hover: none) { .kbd-hint { display: none; } }   /* keyboard shortcuts are not offered on touch screens */
.sheet-h > .icon-btn { margin-top: -2px; }
.sheet-b { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4); }
.sheet-b--flush { padding: 0; gap: 0; }
.sheet-b:empty { display: none; }
.sheet-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.sheet-f .sheet-f-note { margin-right: auto; align-self: center; }
@media (max-width: 767px) { .sheet-f .btn { flex: 1 1 0; } .sheet-f .sheet-f-note { flex-basis: 100%; } }
@media (min-width: 768px) { .sheet-f { padding-bottom: var(--s-3); border-radius: 0 0 var(--r-panel) var(--r-panel); } }
.sheet-center { flex: 1; min-width: 0; display: flex; justify-content: flex-start; padding-top: 4px; }
.sheet-center > h2 { min-width: 0; font-size: var(--fs-h2); font-weight: 700; line-height: 1.28; overflow-wrap: anywhere; }
/* The lead sheet's header name appears once the big name in the body has scrolled away. */
.sheet-center > h2.peek { opacity: 0; transition: opacity var(--t-feedback) var(--ease-out); }
.sheet-center > h2.peek.on { opacity: 1; }
/* Settings sheet: one section per setting (eyebrow, control, one plain line) */
.set-sec { display: flex; flex-direction: column; gap: var(--s-2); }
.set-sec > .eyebrow + * { margin-top: var(--s-1); }

/* Menu: grows from the button that opened it (transform-origin set in code), closes back into it. */
.menu {
  position: fixed; z-index: 60; top: 0; left: 0;
  min-width: 224px; max-width: min(320px, calc(100vw - var(--s-5)));
  max-height: calc(100dvh - var(--s-5)); overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s-1);
  background: var(--raised);
  border: 1px solid var(--line-strong); border-radius: var(--r-card);
  box-shadow: var(--shadow);
  opacity: 0; transform: scale(0.96); visibility: hidden; pointer-events: none;
  transition: opacity var(--t-feedback) var(--ease-out), transform var(--t-feedback) var(--ease-out), visibility 0s linear var(--t-feedback);
}
.menu.is-open { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition: opacity var(--t-feedback) var(--ease-out), transform var(--t-feedback) var(--ease-out), visibility 0s; }
.menu-scrim { position: fixed; inset: 0; z-index: 59; }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 40px; padding: 0 var(--s-3);
  border-radius: var(--r-button);
  color: var(--text); font-size: var(--fs-cell); font-weight: 600; text-align: left; text-decoration: none;
}
@media (pointer: coarse) { .menu-item { min-height: var(--tap); } }
.menu-item > .i { width: 20px; height: 20px; color: var(--text-3); }
.menu-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--hover); }
.menu-item:active { background: var(--hover); }
@media (hover: hover) { .menu-item:hover:not(:disabled) { background: var(--hover); } }
.menu-item:disabled, .menu-item[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.menu-item .menu-tick { margin-left: auto; color: var(--text); visibility: hidden; }
.menu-item[aria-checked="true"] .menu-tick { visibility: visible; }
.menu-item--danger { color: var(--danger-text); }
.menu-item--danger > .i { color: var(--accent-mark); }
.menu-hint { margin-left: auto; padding-left: var(--s-3); font-size: var(--fs-caption); font-weight: 500; color: var(--text-3); text-align: right; }
.menu-sep { height: 1px; margin: var(--s-1) calc(var(--s-1) * -1); background: var(--line); }
.menu-label { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--fs-caption); font-weight: 600; letter-spacing: var(--caption-ls); color: var(--text-3); }
.menu-text { padding: var(--s-2) var(--s-3); font-size: var(--fs-caption); color: var(--text-2); max-width: 280px; }

.toasts {
  position: fixed; z-index: 70; left: 0; right: 0;
  bottom: calc(var(--s-4) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: 0 var(--s-3); pointer-events: none;
}
@media (max-width: 767px) { .toasts { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--fab) + var(--s-4)); } }
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  max-width: min(480px, 100%); min-height: 52px;
  padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3);
  background: var(--raised); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-card);
  box-shadow: var(--shadow);
  font-weight: 600; pointer-events: auto;
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--t-feedback) var(--ease-out), transform var(--t-move) var(--spring);
}
.toast.is-in { opacity: 1; transform: none; }
.toast > .i { color: var(--gilt); }
.toast.is-err > .i { color: var(--accent-mark); }
.toast-t { flex: 1; min-width: 0; padding: var(--s-2) 0; }
.toast .btn:last-child { margin-left: auto; }
.toast--long { align-items: flex-start; max-width: min(560px, 100%); }
.toast--long .toast-t { font-weight: 500; }
.toast--long > .i { margin-top: 14px; }
.toast-acts { display: flex; flex-wrap: wrap; gap: var(--s-1); align-self: center; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet.is-open { transform: none; transition: opacity var(--t-feedback) var(--ease-out), visibility 0s linear var(--t-feedback); }
  .sheet.is-open { transition: opacity var(--t-feedback) var(--ease-out); }
  .menu, .menu.is-open { transform: none; }
  .toast { transform: none; }
}

/* ── 9 · Layout helpers ─────────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); align-items: start; }
.grid > * { min-width: 0; }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid .span-2 { grid-column: span 2; } }
@media (min-width: 1360px) { .grid:not(.grid--2) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1152px) { :root[data-side="rail"] .grid:not(.grid--2) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.grid .span-all { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack--lg { gap: var(--s-5); }
.row-flex { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap8 { height: 8px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.grid + .grid, .stack + .grid, .grid + .stack { margin-top: var(--s-3); }
.right { margin-left: auto; }
