/* ============================================================================================================
   The components' skin (teams/crm/design/system/components.md, layout.md): tokens only. No color literal here:
   every color is a var() from tokens.css or /ui/brand.css. Sizes that differ per component follow the same layers
   as the tokens (touch, sun, compact), declared just below.
   Drafting: a well-kept job file on drafting vellum. Ink marks what you can act on, pencil-grey hairlines hold the
   page, no shadows on cards; a 3 px ink bar means "the active one"; dashed means "not yet".
   ============================================================================================================ */

/* ---- Component sizes, per mode (components.md's size tables) ---------------------------------------------- */
:root {
  --btn-fs: 14px; --btn-px: 16px;
  --input-fs: 14px; --chip-fs: 14px;
  --pill-h: 24px; --pill-fs: 13px;
  --tag-h: 24px;
  --sync-h: 28px; --sync-fs: 13px; --sync-hit: 0px;
  --hit-extra: 0px;                 /* how far a small control's invisible hit area reaches above and below it */
  --iconbtn: 34px;
  --avatar: 28px;
  --tabs-h: 44px;
  --nav-item-h: 36px;
  --th-h: 40px; --cell-py: 8px; --cell-px: 12px;
  --sel-w: 44px;
  --board-card-w: 248px;
  --plus: 60px; --tile-h: 96px;
  --record-title: 40px;
}
@media (max-width: 767px), (pointer: coarse) {
  :root {
    --btn-fs: 16px; --input-fs: 16px;
    --pill-h: 28px; --pill-fs: 14px;
    --tag-h: 28px;
    --sync-h: 36px; --sync-fs: 14px; --sync-hit: 5px;
    --hit-extra: 2px;               /* 40 px chips reach 44 */
    --iconbtn: 44px;
    --avatar: 32px;
    --tabs-h: 48px;
    --record-title: 28px;
  }
}
@media (max-width: 767px), (pointer: coarse) {
  :root[data-sun="1"] {
    --btn-fs: 18px; --btn-px: 20px; --input-fs: 18px; --chip-fs: 16px;
    --pill-h: 36px; --pill-fs: 15px;
    --tag-h: 36px;
    --sync-h: 52px; --sync-fs: 16px; --sync-hit: 6px;
    --hit-extra: 6px;               /* 52 px chips and small buttons reach 64 */
    --iconbtn: 56px;
    --avatar: 40px;
    --tabs-h: 64px;
    --plus: 64px; --tile-h: 112px;
    --record-title: 30px;
  }
}
@media (min-width: 1024px) and (pointer: fine) {
  :root[data-density="compact"] {
    --btn-px: 12px;
    --pill-h: 22px;
    --iconbtn: 28px;
    --avatar: 26px;
    --tabs-h: 36px;
    --nav-item-h: 32px;
    --th-h: 32px; --cell-py: 4px; --cell-px: 8px;
    --board-card-w: 224px;
  }
}

/* ---- Base ---------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: fine) { html { overscroll-behavior: none; } }
@media (max-width: 767px) {
  html { scroll-padding-bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); }
}
body.ui-body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  text-rendering: optimizeLegibility;
}
/* The resets weigh nothing (:where), so any component's class wins over them. The spacing ones skip an old page body
   in the new shell (.ui-bridged, spec 02), whose paragraphs and lists keep the spacing app.css gives them. */
:where(.ui-body) :where(h1, h2, h3, h4) { margin: 0; line-height: var(--lh-tight); text-wrap: balance; }
:where(.ui-body) :where(p):where(:not(.ui-bridged *)) { margin: 0; text-wrap: pretty; }
:where(.ui-body) :where(ul, ol):where(:not(.ui-bridged *)) { margin: 0; padding: 0; }
:where(.ui-body) :where(dl, dd, figure, blockquote):where(:not(.ui-bridged *)) { margin: 0; }
:where(.ui-body) :where(img):where(:not(.ui-bridged *)) { max-width: 100%; }
:where(.ui-body) :where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(.ui-body) :where(a, button, label, summary, select) { touch-action: manipulation; }

/* The guard (G1, spec 02 section 1), on a bridged page only (ui/bridged.html adds .ui-body--bridged). There
   static/crm/app.css loads first and styles bare elements (a, a:hover, h1-h3, label, main, details summary, code,
   input:focus), and those rules would reach the shell too. Each rule here weighs what app.css's does (one element, or
   one element and a pseudo-class) and comes later, so the shell's elements get back what they have with no app.css
   (/ui/components/: the browser's own value, `revert`, or the reset above) and any ui- class still wins over it.
   Two app.css rules weigh more than a ui- class:
   - `input[type=…]`: the shell's search field is written `input.ui-search__input` (one element more), and a field
     class the shell uses later needs the same (with its modifiers); app.css's phone rule `label:has(> input[type=
     checkbox])` (44 px tall) likewise outweighs .ui-check;
   - `a:hover`: links with a ui- class lose its underline here; .ui-link keeps it, and .ui-btn--quiet says its own
     underline again in its :hover rule. */
:where(.ui-body--bridged) :is(h1, h2, h3, h4):where(:not(.ui-bridged *)) {
  margin: 0; font-family: revert; font-size: revert; font-weight: revert; color: revert;
  text-transform: revert; letter-spacing: revert;
}
:where(.ui-body--bridged) a:where(:not(.ui-bridged *)) { color: revert; text-decoration: revert; }
:where(.ui-body--bridged) a:hover:where([class*="ui-"]):where(:not(.ui-bridged *, .ui-link)) { text-decoration: none; }
:where(.ui-body--bridged) label:where(:not(.ui-bridged *)) {
  display: revert; font-weight: revert; font-size: revert; margin-bottom: revert;
}
:where(.ui-body--bridged) main:where(:not(.ui-bridged *)) { margin: revert; }
:where(.ui-body--bridged) details summary:where(:not(.ui-bridged *)) { cursor: revert; color: revert; font-weight: revert; }
:where(.ui-body--bridged) code:where(:not(.ui-bridged *)) { overflow-wrap: revert; }
:where(.ui-body--bridged) :is(input, select, textarea):focus:not(:focus-visible):where(:not(.ui-bridged *)) {
  outline: revert; outline-offset: revert;
}
.ui-body [hidden] { display: none !important; }

/* Focus: always visible, never removed (components.md 1) */
.ui-body :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.ui-body .is-focus {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: var(--focus-offset);
}
.ui-body :where(input, select, textarea):focus-visible { outline-offset: 1px; }

.ui-vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.ui-skip {
  position: absolute; left: var(--sp-3); top: var(--sp-3); z-index: var(--z-cmd);
  padding: var(--sp-2) var(--sp-4); background: var(--raised); color: var(--accent-ink);
  border: var(--bw) solid var(--accent-ink); border-radius: var(--r-md); transform: translateY(-200%);
}
.ui-skip:focus-visible { transform: none; }

.ui-num { font-variant-numeric: tabular-nums lining-nums; }
.ui-meta { color: var(--muted); font-size: var(--fs-xs); }
.ui-code { font-family: inherit; font-size: var(--fs-sm); color: var(--muted); }
.ui-link {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.ui-link:hover { text-decoration-thickness: 2px; }
.ui-kbd {
  display: inline-flex; align-items: center; min-height: 20px; padding: 0 var(--sp-1);
  border: var(--bw) solid var(--border); border-radius: var(--r-sm);
  color: var(--muted); background: var(--surface);
  font: var(--fw-medium) var(--fs-xs)/1 var(--font-ui);
}
@media (pointer: coarse) { .ui-kbd { display: none; } }
.ui-icon {
  width: var(--icon-size); height: var(--icon-size); flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--icon-stroke);
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}

/* Type roles (tokens.md 7) */
.ui-t-page, .ui-page__title {
  font: var(--fw-display) var(--fs-3xl)/var(--lh-tight) var(--font-display);
  letter-spacing: var(--track-display);
}
.ui-t-record {
  font: var(--fw-display) var(--record-title)/var(--lh-tight) var(--font-display);
  letter-spacing: var(--track-display);
}
.ui-t-money {
  font: var(--fw-display) var(--fs-2xl)/var(--lh-tight) var(--font-display);
  font-variant-numeric: tabular-nums lining-nums; white-space: nowrap;
}
/* An amount never splits (design-system 4.6): "-$99,999.00" stays whole, and a label stays with its amount */
.ui-money { white-space: nowrap; font-variant-numeric: tabular-nums lining-nums; }
.ui-stats {
  display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
}
@media (min-width: 768px) { .ui-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); } }
.ui-stat { min-width: 0; padding: var(--sp-3) var(--sp-4); border: var(--bw) solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.ui-stat--danger { border-left: var(--bar) solid var(--danger); }
.ui-stat--warn { border-left: var(--bar) solid var(--warn); }
.ui-stat--ok { border-left: var(--bar) solid var(--ok); }
.ui-stat__n { display: block; font: var(--fw-display) var(--fs-xl)/var(--lh-tight) var(--font-display); color: var(--text); }
@media (min-width: 768px) { .ui-stat__n { font-size: var(--fs-2xl); } }
.ui-stat__l { display: block; font-size: var(--fs-sm); color: var(--muted); }
.ui-t-section, .ui-h3 { font: var(--fw-strong) var(--fs-lg)/var(--lh-tight) var(--font-ui); }
.ui-t-action { font: var(--fw-strong) var(--fs-md)/var(--lh-tight) var(--font-ui); }
.ui-t-body { font: var(--fw-body) var(--fs-md)/var(--lh-body) var(--font-ui); max-width: 72ch; }
.ui-t-second { font-size: var(--fs-sm); color: var(--muted); }
.ui-t-label { font: var(--fw-medium) var(--fs-sm)/1.3 var(--font-ui); color: var(--text); }
.ui-t-fact { font-size: var(--fs-sm); color: var(--muted); }
.ui-t-meta { font-size: var(--fs-xs); color: var(--muted); }
.ui-t-quote, .ui-now__quote blockquote {
  font: italic var(--fw-display) var(--fs-lg)/1.4 var(--font-display);
}
@media (max-width: 767px), (pointer: coarse) {
  :root[data-sun="1"] .ui-t-quote, :root[data-sun="1"] .ui-now__quote blockquote {
    font: normal var(--fw-medium) var(--fs-lg)/1.4 var(--font-ui);   /* upright in the sun */
  }
}

/* ---- Button (components.md 4) ------------------------------------------------------------------------- */
.ui-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--ctl-h); padding: 0 var(--btn-px);
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--accent-ink);
  font: var(--fw-strong) var(--btn-fs)/1.2 var(--font-ui);
  text-align: center; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.ui-btn__label { min-width: 0; }             /* wraps between words only, never inside one (components.md 4) */
.ui-btn:hover, .ui-btn.is-hover { background: var(--accent-soft); border-color: var(--accent-ink); }
.ui-btn:active, .ui-btn.is-pressed { background: var(--accent-soft); transform: translateY(1px); }
.ui-btn--primary {
  background: var(--accent); color: var(--on-accent);
  border: var(--bw-strong) solid var(--accent-edge);
}
.ui-btn--primary:hover, .ui-btn--primary.is-hover,
.ui-btn--primary:active, .ui-btn--primary.is-pressed { background: var(--accent-hover); border-color: var(--accent-edge); }
.ui-btn--quiet {
  min-height: var(--ctl-h-sm); padding: 0 var(--sp-1);
  border-color: transparent; background: transparent;
  text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px;
}
.ui-btn--quiet:hover, .ui-btn--quiet.is-hover {
  background: var(--hover); border-color: transparent;
  text-decoration: underline; text-decoration-color: var(--border-strong);   /* again: the guard above drops a:hover's */
}
.ui-btn--danger { color: var(--danger); border-color: var(--danger); }
.ui-btn--danger:hover, .ui-btn--danger.is-hover { background: var(--danger-soft); border-color: var(--danger); }
.ui-btn--danger-fill { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.ui-btn--danger-fill:hover { background: var(--danger); color: var(--surface); border-color: var(--text); }
.ui-btn--on-text { background: transparent; color: var(--on-text); border-color: var(--on-text); }
.ui-btn--on-text:hover { background: transparent; color: var(--on-text); border-color: var(--on-text); text-decoration: underline; }
.ui-btn--sm { min-height: var(--ctl-h-sm); padding: 0 var(--sp-3); }
.ui-btn--sm::after, .ui-chip::after, .ui-iconbtn--sm::after {
  content: ""; position: absolute; left: 0; right: 0; top: calc(-1 * var(--hit-extra)); bottom: calc(-1 * var(--hit-extra));
}
.ui-btn--wide { width: 100%; }
.ui-btn__count {
  min-width: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--sunken); color: var(--text); font-size: var(--fs-xs); font-variant-numeric: tabular-nums;
}
.ui-btn--primary .ui-btn__count { background: var(--on-accent); color: var(--accent); }
.ui-btn[aria-disabled="true"]:not([aria-busy="true"]) {
  border-style: dashed; border-color: var(--border-strong);
  background: var(--sunken); color: var(--muted); cursor: not-allowed; transform: none;
}
.ui-btn[aria-busy="true"] { cursor: progress; }
.ui-reason { display: inline-block; margin-left: var(--sp-2); color: var(--muted); font-size: var(--fs-sm); }
.ui-spinner {
  width: var(--icon-size); height: var(--icon-size); flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: var(--r-pill);
  animation: ui-spin 0.8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  .ui-spinner { animation: none; border-right-color: currentColor; border-style: dotted; }
}

/* Icon button */
.ui-iconbtn {
  position: relative;
  display: inline-grid; place-items: center; flex: none;
  width: var(--iconbtn); height: var(--iconbtn); padding: 0;
  border: var(--bw) solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ui-iconbtn:hover, .ui-iconbtn.is-hover { color: var(--text); background: var(--hover); }
.ui-iconbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-ink); }
.ui-iconbtn--sm { width: var(--ctl-h-sm); height: var(--ctl-h-sm); }
@media (max-width: 767px), (pointer: coarse) {
  :root[data-sun="1"] .ui-iconbtn::after { content: ""; position: absolute; inset: -4px; }
}
.ui-tip {
  position: fixed; z-index: var(--z-cmd); pointer-events: none;
  max-width: 240px; padding: var(--sp-1) var(--sp-2);
  background: var(--text); color: var(--on-text); border-radius: var(--r-sm);
  font: var(--fw-medium) var(--fs-xs)/1.3 var(--font-ui);
}

/* Action row: wraps on a 360 px phone instead of squeezing. A button grows to share the row but never shrinks below
   72 px or below its own label and padding (no min-width set, so the automatic minimum is the content's), so a
   button that doesn't fit drops to the next line. */
.ui-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ui-actions__btn { flex: 1 0 72px; }
.ui-actions__note {
  flex: 1 0 72px; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  min-height: var(--ctl-h); padding: 0 var(--sp-2); color: var(--muted); font-size: var(--fs-sm);
}
@media (min-width: 768px) and (pointer: fine) { .ui-actions__btn, .ui-actions__note { flex: 0 1 auto; } }
@media (max-width: 767px), (pointer: coarse) {
  .ui-actions__btn, .ui-actions__note {
    flex-direction: column; gap: var(--sp-1); min-height: 64px; padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-xs); font-weight: var(--fw-medium);
  }
}

/* Menu: a popover on a computer, a bottom sheet list on a phone */
.ui-menu-wrap { position: relative; display: inline-block; }
.ui-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: var(--z-sheet);
  min-width: 220px; max-width: min(320px, calc(100vw - 32px)); padding: var(--sp-1) 0;
  background: var(--raised); color: var(--text);
  border: var(--bw) solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-float);
}
.ui-menu--up { top: auto; bottom: calc(100% + 4px); left: 0; right: auto; }
.ui-menu__item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  min-height: var(--ctl-h); padding: 0 var(--sp-4);
  border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer;
  font-size: var(--fs-md);
}
.ui-menu__item:hover, .ui-menu__item:focus-visible { background: var(--hover); }
.ui-menu__item .ui-kbd { margin-left: auto; }
.ui-menu__item--danger { color: var(--danger); }
.ui-menu__sep { height: var(--bw); margin: var(--sp-1) 0; background: var(--border); }
.ui-menu__cancel { display: none; justify-content: center; font-weight: var(--fw-strong); color: var(--accent-ink); }
.ui-menu__col { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 0 var(--sp-3) 0 var(--sp-4); }
.ui-menu__moves { display: inline-flex; }
@media (max-width: 767px) {
  .ui-menu, .ui-menu--up {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; max-width: none;
    max-height: 80dvh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom));
  }
  .ui-menu__cancel { display: flex; border-top: var(--bw) solid var(--border); margin-top: var(--sp-1); }
  html.ui-menu-open::after {
    content: ""; position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--scrim);
  }
}

/* ---- Chips, pills, badges (components.md 5) ----------------------------------------------------------- */
.ui-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 100%;
  min-height: var(--chip-h); padding: 0 var(--sp-3);
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: var(--fw-medium) var(--chip-fs)/1.2 var(--font-ui); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.ui-chip__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24ch; }
.ui-chip__count { font-variant-numeric: tabular-nums; color: var(--muted); }
.ui-chip__check { display: none; }
.ui-chip:hover, .ui-chip.is-hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.ui-chip[aria-pressed="true"], .ui-chip--choice:has(.ui-chip__input:checked) {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent-edge);
  font-weight: var(--fw-strong);
}
.ui-chip[aria-pressed="true"] .ui-chip__count, .ui-chip--choice:has(.ui-chip__input:checked) .ui-chip__count { color: inherit; }
.ui-chip[aria-pressed="true"]:hover, .ui-chip--choice:has(.ui-chip__input:checked):hover { background: var(--accent-hover); color: var(--on-accent); }
.ui-chip[aria-pressed="true"] .ui-chip__check, .ui-chip--choice:has(.ui-chip__input:checked) .ui-chip__check { display: block; }
.ui-chip__input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.ui-chip--choice:has(.ui-chip__input:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }
.ui-chip--choice .ui-chip__label { white-space: normal; max-width: none; }
.ui-chip--active { cursor: default; background: var(--surface); padding-right: 0; }
.ui-chip--active:hover { color: var(--text); border-color: var(--border-strong); }
.ui-chip__x {
  display: inline-grid; place-items: center; width: var(--chip-h); height: calc(var(--chip-h) - 2 * var(--bw));
  border: 0; border-left: var(--bw) solid var(--border); background: transparent; color: var(--muted); cursor: pointer;
}
.ui-chip__x:hover { color: var(--text); background: var(--hover); }
.ui-choices { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: var(--sp-2); }
.ui-choices__row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 767px), (pointer: coarse) {
  .ui-choices__row > .ui-chip--choice { flex: 1 1 auto; justify-content: center; }
}
.ui-choices--big .ui-chip { min-height: 64px; flex: 1 1 calc(33% - var(--sp-2)); justify-content: center; font-size: var(--fs-md); }
@media (max-width: 767px), (pointer: coarse) { .ui-choices--big .ui-chip { flex-basis: calc(50% - var(--sp-2)); } }

.ui-tag {
  display: inline-flex; align-items: center; min-height: var(--tag-h); max-width: 100%;
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  background: var(--sunken); color: var(--text);
  font: var(--fw-strong) var(--fs-sm)/1.2 var(--font-ui);
  white-space: normal; overflow-wrap: anywhere;
}
.ui-tags { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); }

.ui-pill {
  display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 200px;
  min-height: var(--pill-h); padding: 0 var(--sp-2); border-radius: var(--r-pill);
  font: var(--fw-strong) var(--pill-fs)/1.1 var(--font-ui); white-space: nowrap; vertical-align: middle;
}
.ui-pill .ui-icon { width: 1.15em; height: 1.15em; }
.ui-pill__words { overflow: hidden; text-overflow: ellipsis; }
.ui-pill-why { display: block; max-width: 60ch; margin-top: var(--sp-1); color: var(--text); font-size: var(--fs-sm); }
.ui-file .ui-pill-why { flex-basis: 100%; margin-top: 0; }
@media (max-width: 767px), (pointer: coarse) {
  .ui-pill { white-space: normal; max-width: 100%; padding-top: 2px; padding-bottom: 2px; }
  .ui-pill__words { overflow: visible; }
  .ui-sync { white-space: normal; max-width: 100%; text-align: left; }
}
.ui-pill--ok { background: var(--ok-soft); color: var(--ok); }
.ui-pill--warn { background: var(--warn-soft); color: var(--warn); }
.ui-pill--danger { background: var(--danger-soft); color: var(--danger); }
.ui-pill--info { background: var(--info-soft); color: var(--info); }
.ui-pill--neutral { background: var(--sunken); color: var(--text); }

.ui-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: auto;
  border-radius: var(--r-pill); color: var(--muted);
  font: var(--fw-strong) var(--fs-xs)/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.ui-badge--needs { background: var(--danger-soft); color: var(--danger); }

/* ---- Containers (components.md 6) --------------------------------------------------------------------- */
.ui-card {
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--border); border-radius: var(--r-lg);
  padding: var(--pad-card); box-shadow: var(--shadow-card); min-width: 0;
}
.ui-card__head { display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.ui-card__head > .ui-btn, .ui-card__head > .ui-card__chev { margin-left: auto; }
.ui-card__title { font: var(--fw-strong) var(--fs-md)/var(--lh-tight) var(--font-ui); }
.ui-card__head--fold { cursor: pointer; list-style: none; margin-bottom: 0; align-items: center; }
.ui-card__head--fold::-webkit-details-marker { display: none; }
details.ui-card[open] > .ui-card__head--fold { margin-bottom: var(--sp-3); }
details.ui-card:not([open]) .ui-card__chev { transform: rotate(-90deg); }
.ui-card__foot { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: var(--bw) solid var(--border); }
.ui-card__body > * + * { margin-top: var(--sp-3); }

/* Record card */
.ui-rcard {
  position: relative; display: grid; gap: var(--sp-2); min-width: 0;
  padding: var(--sp-3); background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--border); border-radius: var(--r-lg);
}
.ui-rcard--board { width: var(--board-card-w); max-width: 100%; }
.ui-rcard:hover { border-color: var(--border-strong); }
.ui-rcard.is-past { border-left: var(--bar) solid var(--danger); }
.ui-rcard.is-selected { background: var(--accent-soft); border-left: var(--bar) solid var(--accent-ink); }
.ui-rcard__head { display: flex; align-items: flex-start; gap: var(--sp-2); }
.ui-rcard__head .ui-tag { margin-left: auto; flex: none; }
.ui-rcard__title {
  font: var(--fw-display) var(--fs-lg)/var(--lh-tight) var(--font-display); letter-spacing: var(--track-display);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-width: 0;
}
.ui-rcard__link { color: inherit; text-decoration: none; }
.ui-rcard__link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.ui-rcard__link:focus-visible { outline: none; }
.ui-rcard:has(.ui-rcard__link:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }
.ui-rcard__link:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ui-rcard .ui-btn, .ui-rcard .ui-menu-wrap { position: relative; z-index: 1; }
.ui-rcard__people, .ui-rcard__nextwords, .ui-rcard__stepwords {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm);
}
.ui-rcard__people { color: var(--muted); }
.ui-rcard__step { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); }
.ui-rcard__next { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-weight: var(--fw-medium); }
.ui-card__line { font-size: var(--fs-sm); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-card__label { color: var(--muted); }
.ui-rcard__foot { display: flex; justify-content: flex-end; }

/* List row (the queue; components.md 6, the 2026-10-31 anatomy; G2). The record slot first, the action words, one status
   line, the meter's bar and the holder, the owner, one button and "…". Comfortable: two lines (address and people,
   then the words and the context) with the status at the right. Compact (a computer, the office's default): one line,
   the words cut first, the address never. A phone: the lines stack and the button sits at the right, or under the
   words at full width when its label is long. */
.ui-rows { list-style: none; display: grid; }
.ui-row {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center;
  gap: var(--sp-3); min-height: var(--row-h); padding: var(--sp-2) var(--sp-3);
  background: var(--surface); border-bottom: var(--bw) solid var(--border);
}
.ui-rows > .ui-row:first-child { border-top: var(--bw) solid var(--border); }
.ui-row:hover { background: var(--hover); }
.ui-row__icon {
  position: relative; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-pill);
  background: var(--sunken); color: var(--text);
}
.ui-row__icon .ui-icon { width: 16px; height: 16px; }
.ui-row.is-overdue .ui-row__icon { background: var(--danger-soft); color: var(--danger); }
.ui-row__pick { position: absolute; inset: -8px; width: auto; height: auto; margin: 0; opacity: 0; cursor: pointer; accent-color: var(--accent-ink); z-index: 1; }
.ui-row__pick:checked, .ui-row__pick:focus-visible { opacity: 1; inset: 4px; }
.ui-row__pick:checked ~ .ui-row__glyph, .ui-row__pick:focus-visible ~ .ui-row__glyph { visibility: hidden; }
@media (hover: hover) and (pointer: fine) {
  .ui-row:hover .ui-row__pick { opacity: 1; inset: 4px; }
  .ui-row:hover .ui-row__pick ~ .ui-row__glyph { visibility: hidden; }
}
.is-picking .ui-row__pick { opacity: 1; inset: 4px; }
.is-picking .ui-row__pick ~ .ui-row__glyph { visibility: hidden; }
.ui-row__main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--sp-3); min-width: 0; align-items: baseline; }
.ui-row__rec { grid-column: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-2); min-width: 0; font: var(--fw-strong) var(--fs-md)/var(--lh-tight) var(--font-ui); }
.ui-row__addr { color: var(--text); text-decoration: none; overflow-wrap: break-word; min-width: 0; }
.ui-row__addr:hover { text-decoration: underline; text-underline-offset: 3px; }
.ui-row__city { font-weight: var(--fw-body); }
.ui-row__people { font-weight: var(--fw-body); color: var(--muted); font-size: var(--fs-sm); overflow-wrap: break-word; min-width: 0; }
.ui-row__what { grid-column: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-2); min-width: 0; font-size: var(--fs-sm); }
.ui-row__title {
  font: var(--fw-medium) var(--fs-sm)/var(--lh-tight) var(--font-ui); min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ui-row__context {
  color: var(--muted); min-width: 0; max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.ui-row:not(:has(.ui-row__rec)) .ui-row__title { font-weight: var(--fw-strong); font-size: var(--fs-md); }
.ui-row__state { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: var(--fs-sm); text-align: right; }
.ui-row__status { display: inline-flex; align-items: center; gap: var(--sp-1); white-space: nowrap; color: var(--muted); font-weight: var(--fw-medium); }
.ui-row__status .ui-icon { width: 14px; height: 14px; }
.ui-row__status.is-danger { color: var(--danger); font-weight: var(--fw-strong); }
.ui-row__status.is-warn { color: var(--warn); font-weight: var(--fw-strong); }
.ui-row__meter { width: 72px; }
.ui-row__holder { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 var(--sp-1); max-width: 22ch; font-size: var(--fs-xs); color: var(--muted); }
.ui-row__owner { display: flex; }
.ui-row__act { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-1); }
.ui-row__desk { display: none; font-variant-numeric: tabular-nums; }
.ui-row__act { min-width: 0; max-width: 100%; }
.ui-row__act .ui-btn { white-space: nowrap; max-width: 100%; }
.ui-row.is-busy { opacity: .6; }
.ui-grouphead {
  display: flex; align-items: baseline; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-2);
  font: var(--fw-strong) var(--fs-lg)/var(--lh-tight) var(--font-ui);
}
@media (min-width: 1024px) and (pointer: fine) {
  .ui-row__desk { display: inline; }
  .ui-row__act .ui-btn__label { display: block; max-width: 24ch; overflow: hidden; text-overflow: ellipsis; }   /* a long step's words are in the title */
  .ui-row__lbl { display: none; }
  :root[data-density="compact"] .ui-row { padding-top: 0; padding-bottom: 0; gap: var(--sp-2); }
  :root[data-density="compact"] .ui-row__main { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: nowrap; }
  :root[data-density="compact"] .ui-row__rec { flex: 0 1 auto; min-width: 0; max-width: 55%; font-size: var(--fs-sm); }
  :root[data-density="compact"] .ui-row__what { flex: 1 1 0; flex-wrap: nowrap; min-width: 0; }
  :root[data-density="compact"] .ui-row__title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
  :root[data-density="compact"] .ui-row__context, :root[data-density="compact"] .ui-row__meter { display: none; }
  :root[data-density="compact"] .ui-row__state { flex: none; flex-direction: row; align-items: center; gap: var(--sp-3); }
  :root[data-density="compact"] .ui-row__holder { max-width: 16ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  :root[data-density="compact"] .ui-row__icon { width: 22px; height: 22px; }
}
@media (max-width: 767px), (pointer: coarse) {
  .ui-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ui-row__owner { display: none; }
  .ui-row__people, .ui-row__addr { flex: 1 1 100%; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }   /* a long name or address takes two lines at most; the whole text is in its title */
  .ui-row__main { grid-template-columns: minmax(0, 1fr); }
  .ui-row__state { grid-column: 1; grid-row: auto; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: left; gap: var(--sp-1) var(--sp-3); margin-top: var(--sp-1); }
  .ui-row__holder { justify-content: flex-start; max-width: none; }
  .ui-row__what { flex-direction: column; gap: 2px; }
  .ui-row__context { -webkit-line-clamp: 2; }
  .ui-row__title { font-size: var(--fs-md); }
  .ui-row:has(.ui-row__wide) .ui-row__act { grid-column: 2 / -1; }
  .ui-row:has(.ui-row__wide) .ui-row__act .ui-btn { flex: 1; }
  .ui-row__act .ui-btn { min-height: var(--tap); white-space: normal; height: auto; text-align: center; }
}

/* Table */
.ui-tablebox { position: relative; display: grid; gap: var(--sp-2); min-width: 0; }
.ui-tablebox__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.ui-tablebox__count { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.ui-tablebox__scroll {
  overflow: auto; max-height: min(70dvh, 720px); overscroll-behavior-x: contain;
  background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg);
}
.ui-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.ui-table th, .ui-table td {
  padding: var(--cell-py) var(--cell-px); text-align: left; vertical-align: middle;
  border-bottom: var(--bw) solid var(--border); white-space: nowrap; height: var(--row-h);
  max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.ui-table thead th {
  position: sticky; top: 0; z-index: 2; height: var(--th-h);
  background: var(--surface); color: var(--muted); font-weight: var(--fw-medium);
  border-bottom: var(--bw) solid var(--border-strong);
}
.ui-table tbody tr:hover > * { background: var(--hover); }
.ui-table tbody tr.is-selected > * { background: var(--accent-soft); }
.ui-table tbody tr.is-selected > :first-child { box-shadow: inset var(--bar) 0 0 var(--accent-ink); }
.ui-table .ui-table__sel { position: sticky; left: 0; z-index: 1; width: var(--sel-w); min-width: var(--sel-w); background: var(--surface); }
.ui-table .ui-table__rec {
  position: sticky; left: var(--sel-w); z-index: 1; background: var(--surface); min-width: 220px;
  font: var(--fw-strong) var(--fs-md)/1.3 var(--font-ui); color: var(--text);
}
.ui-table:not(:has(.ui-table__sel)) .ui-table__rec { left: 0; }
.ui-table thead .ui-table__sel, .ui-table thead .ui-table__rec { z-index: 3; }
.ui-table thead .ui-table__rec { font: inherit; font-weight: var(--fw-medium); color: var(--muted); }
.ui-table__link { color: var(--text); text-decoration: none; }
.ui-table__link:hover { text-decoration: underline; text-underline-offset: 3px; color: var(--accent-ink); }
.ui-table__sub { display: block; font: var(--fw-body) var(--fs-sm)/1.3 var(--font-ui); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ui-table__th--end, .ui-table__td--end { text-align: right !important; font-variant-numeric: tabular-nums; }
.ui-table__sort {
  display: inline-flex; align-items: center; gap: var(--sp-1); min-height: var(--ctl-h-sm); padding: 0;
  border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.ui-table__sort:hover { color: var(--text); }
.ui-table__sorticon { width: 14px; height: 14px; opacity: .7; }
.ui-table [aria-sort="ascending"] .ui-table__sort, .ui-table [aria-sort="descending"] .ui-table__sort { color: var(--accent-ink); font-weight: var(--fw-strong); }
.ui-table tfoot th, .ui-table tfoot td { border-bottom: 0; border-top: var(--bw) solid var(--border-strong); font-weight: var(--fw-strong); }
.ui-table__empty { white-space: normal; height: auto; }
.ui-table .ui-col-hidden { display: none; }
.ui-trunc { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ui-table td[data-ui-cell="_holder"] { white-space: normal; overflow: visible; max-width: none; }
/* The holder cell asks for a real width (a grid of nowrap words alone asks for none and the table squeezes it):
   the badge's words end in "…" (the full words in title), the overdue line sits under it and may wrap. */
.ui-table__holder {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 2px;
  width: max-content; min-width: 13rem; max-width: 20rem;
}
.ui-table__holder .ui-holder { max-width: 100%; min-width: 0; }
.ui-table__holder .ui-holder__words { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-table__holder .ui-holder__overdue { max-width: 100%; white-space: normal; }
.ui-check { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); cursor: pointer; }
.ui-check input { width: var(--icon-size); height: var(--icon-size); margin: 0; accent-color: var(--accent); cursor: pointer; }
.ui-check--bare { min-height: 0; padding: var(--sp-1); }
.ui-check--field .ui-label { font-weight: var(--fw-medium); }
.ui-tablecards { display: none; list-style: none; gap: var(--sp-2); }
@media (min-width: 1024px) and (pointer: fine) {
  :root[data-density="compact"] .ui-table .ui-meter__words,
  :root[data-density="compact"] .ui-table .ui-meter__bar { display: none; }
  :root[data-density="compact"] .ui-table .ui-meter__short { display: inline; }
  :root[data-density="compact"] .ui-table .ui-table__sub { display: none; }
  :root[data-density="compact"] .ui-table .ui-table__rec { font-size: var(--fs-sm); }
  :root[data-density="compact"] .ui-table__holder { display: flex; align-items: center; gap: var(--sp-2); max-width: 340px; }
  :root[data-density="compact"] .ui-table__holder .ui-holder { flex: 0 1 auto; min-width: 0; }
  :root[data-density="compact"] .ui-table__holder .ui-holder__overdue { flex: none; white-space: nowrap; }
}
@media (max-width: 767px) {
  .ui-tablebox__scroll, .ui-tablebox__columns { display: none; }
  .ui-tablecards { display: grid; }
}

/* ---- Fields and forms (components.md 7) --------------------------------------------------------------- */
.ui-field { display: grid; gap: var(--sp-1); min-width: 0; align-content: start; }
.ui-field__group { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--sp-2); }
.ui-field__group:focus { outline: none; }
.ui-label { font: var(--fw-medium) var(--fs-sm)/1.3 var(--font-ui); color: var(--text); padding: 0; }
.ui-help { font-size: var(--fs-sm); color: var(--muted); max-width: 72ch; }
.ui-needed {
  display: inline-flex; align-items: center; gap: var(--sp-1); margin-left: var(--sp-1); padding: 0 var(--sp-2);
  border-radius: var(--r-sm); background: var(--info-soft); color: var(--info);
  font: var(--fw-medium) var(--fs-xs)/1.6 var(--font-ui); vertical-align: middle;
}
.ui-needed .ui-icon { width: 14px; height: 14px; }
.ui-input {
  width: 100%; max-width: 100%; min-height: var(--ctl-h); padding: 0 var(--sp-3);
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-sm);
  background-color: var(--surface); color: var(--text);
  font: var(--fw-body) var(--input-fs)/1.3 var(--font-ui);
}
.ui-input::placeholder { color: var(--muted); opacity: 1; }
.ui-input:hover { border-color: var(--text); }
.ui-input--area { padding: var(--sp-2) var(--sp-3); min-height: calc(var(--ctl-h) * 2); resize: vertical; field-sizing: content; line-height: var(--lh-body); }
.ui-input--num { font-variant-numeric: tabular-nums; }
.ui-input--date { width: auto; min-width: 0; max-width: 100%; }
.ui-select { appearance: auto; padding-right: var(--sp-2); }
.ui-affix { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.ui-affix > .ui-input { flex: 1 1 auto; min-width: 0; }
.ui-affix__before, .ui-affix__after { color: var(--muted); font-size: var(--input-fs); }
.has-error .ui-input, .ui-input[aria-invalid="true"] { border-color: var(--danger); border-width: max(var(--bw), 2px); }
.ui-error { display: flex; align-items: flex-start; gap: var(--sp-1); color: var(--danger); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.ui-error .ui-icon { width: 16px; height: 16px; margin-top: 2px; }
.ui-datebox { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.ui-filepick { position: relative; align-self: start; justify-self: start; overflow: hidden; }
.ui-filepick__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ui-filepick:has(.ui-filepick__input:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }
.ui-files { list-style: none; display: grid; gap: var(--sp-1); }
.ui-file { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); min-width: 0; }
.ui-file__name { min-width: 0; overflow-wrap: anywhere; }

.ui-facts { display: grid; gap: var(--sp-3); }
.ui-fact { display: grid; grid-template-columns: minmax(9rem, 34%) minmax(0, 1fr); gap: var(--sp-1) var(--sp-3); align-items: baseline; }
.ui-fact__label { font: var(--fw-medium) var(--fs-sm)/1.3 var(--font-ui); color: var(--text); }
.ui-fact__value { min-width: 0; overflow-wrap: anywhere; }
.ui-fact__empty { color: var(--muted); }
.ui-fact__note { display: flex; align-items: center; gap: var(--sp-1); margin-top: var(--sp-1); color: var(--muted); font-size: var(--fs-sm); }
.ui-fact.is-archived .ui-fact__value { color: var(--muted); user-select: text; }
@media (max-width: 767px) { .ui-fact { grid-template-columns: minmax(0, 1fr); } }
.ui-longtext p + p { margin-top: var(--sp-2); }
.ui-longtext.is-clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.ui-form { display: grid; gap: var(--sp-5); max-width: var(--form-max); }
.ui-formerrors { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.ui-formerrors:focus { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }
.ui-formerrors__list { margin-top: var(--sp-1) !important; padding-left: var(--sp-5) !important; }
.ui-savebar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
@media (max-width: 767px) {
  .ui-sheet .ui-savebar { position: sticky; bottom: 0; padding: var(--sp-3) 0 calc(var(--sp-3) + env(safe-area-inset-bottom)); background: var(--raised); }
}

.ui-inline { min-width: 0; }
.ui-inline__value {
  display: inline-flex; align-items: center; gap: var(--sp-2); max-width: 100%; min-height: var(--ctl-h-sm);
  padding: 0 var(--sp-2); margin-left: calc(-1 * var(--sp-2));
  border: var(--bw) solid transparent; border-radius: var(--r-sm); background: transparent; text-align: left; cursor: text;
}
.ui-inline__pencil { opacity: 0; color: var(--muted); }
.ui-inline__value:hover, .ui-inline__value:focus-visible { border-color: var(--border-strong); }
.ui-inline__value:hover .ui-inline__pencil, .ui-inline__value:focus-visible .ui-inline__pencil { opacity: 1; }
@media (pointer: coarse) { .ui-inline__pencil { opacity: 1; } }
.ui-inline__status { margin-left: var(--sp-2); color: var(--ok); font-size: var(--fs-sm); }
.ui-inline__form { display: grid; gap: var(--sp-2); }
.ui-inline__buttons { display: flex; gap: var(--sp-2); }

/* ---- Feedback (components.md 8) ----------------------------------------------------------------------- */
.ui-msg {
  position: relative; display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border: var(--bw) solid; border-radius: var(--r-md); color: var(--text);
}
.ui-msg__icon { margin-top: 2px; }
.ui-msg__body { display: grid; gap: var(--sp-1); justify-items: start; min-width: 0; flex: 1; }
.ui-msg__title { font-weight: var(--fw-strong); }
.ui-msg--ok { background: var(--ok-soft); border-color: var(--ok); }
.ui-msg--ok .ui-msg__icon { color: var(--ok); }
.ui-msg--info { background: var(--info-soft); border-color: var(--info); }
.ui-msg--info .ui-msg__icon { color: var(--info); }
.ui-msg--warn { background: var(--warn-soft); border-color: var(--warn); }
.ui-msg--warn .ui-msg__icon { color: var(--warn); }
.ui-msg--danger { background: var(--danger-soft); border-color: var(--danger); }
.ui-msg--danger .ui-msg__icon { color: var(--danger); }
.ui-msg .ui-btn--quiet { margin-left: calc(-1 * var(--sp-1)); }
.ui-msg__close { margin: calc(-1 * var(--sp-2)) calc(-1 * var(--sp-2)) 0 0; }

.ui-banner {
  display: flex; align-items: center; gap: var(--sp-3); min-width: 0;
  padding: var(--sp-2) var(--pad-page); border-bottom: var(--bw) solid; color: var(--text);
}
.ui-banner__words { flex: 1; min-width: 0; }
.ui-banner--warn { background: var(--warn-soft); border-color: var(--warn); }
.ui-banner--warn > .ui-icon { color: var(--warn); }
.ui-banner--danger { background: var(--danger-soft); border-color: var(--danger); }
.ui-banner--danger > .ui-icon { color: var(--danger); }
.ui-banner--info { background: var(--info-soft); border-color: var(--info); }
.ui-banner--info > .ui-icon { color: var(--info); }
.ui-banner { align-items: flex-start; }
.ui-banner > .ui-icon { margin-top: 2px; }
.ui-banner__link { white-space: nowrap; }
@media (max-width: 767px) {                     /* the words keep the width; the link goes under them when it's tight */
  .ui-banner { flex-wrap: wrap; }
  .ui-banner__words { flex: 1 1 12rem; }
  .ui-banner__link { order: 3; flex-basis: 100%; padding-left: calc(var(--icon-size) + var(--sp-3)); }
}

.ui-empty { display: grid; gap: var(--sp-3); justify-items: start; padding: var(--sp-5); color: var(--text); }
.ui-empty__words { max-width: 60ch; }

.ui-skel { display: grid; gap: var(--sp-3); animation: ui-after-300 1ms linear 300ms both; }
@keyframes ui-after-300 { from { visibility: hidden; } to { visibility: visible; } }
.ui-skel__row { display: flex; align-items: center; gap: var(--sp-3); }
.ui-skel__dot { width: 28px; height: 28px; border-radius: var(--r-pill); background: var(--sunken); flex: none; }
.ui-skel__lines { display: grid; gap: var(--sp-2); flex: 1; }
.ui-skel__line { height: 12px; border-radius: var(--r-sm); background: var(--sunken); }
.ui-skel__line--short { width: 60%; }
.ui-skel__slow { display: flex; align-items: center; gap: var(--sp-3); color: var(--muted); }

.ui-sync {
  position: relative; display: inline-flex; align-items: center; gap: var(--sp-1); flex: none;
  min-height: var(--sync-h); padding: 0 var(--sp-3); border-radius: var(--r-pill);
  border: var(--bw) solid var(--border-strong); background: var(--surface); color: var(--text);
  font: var(--fw-medium) var(--sync-fs)/1 var(--font-ui); cursor: pointer; white-space: nowrap;
}
.ui-sync::after { content: ""; position: absolute; left: 0; right: 0; top: calc(-1 * var(--sync-hit)); bottom: calc(-1 * var(--sync-hit)); }
.ui-sync .ui-icon { width: 1.2em; height: 1.2em; }
.ui-sync--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.ui-sync--warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.ui-sync--info .ui-icon { color: var(--info); }
.ui-sync--ok .ui-icon { color: var(--ok); }
.ui-sync:hover { border-color: var(--text); }

/* ---- Overlays (components.md 9) ----------------------------------------------------------------------- */
.ui-sheet, .ui-dialog {
  padding: 0; border: 0; color: var(--text); background: var(--raised); box-shadow: var(--shadow-float);
  max-width: 100vw; max-height: 100dvh; overscroll-behavior: contain;
}
.ui-sheet::backdrop, .ui-dialog::backdrop { background: var(--scrim); }
.ui-sheet {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(var(--sheet-w), 100vw); height: 100dvh;
  border-left: var(--bw) solid var(--border);
}
.ui-sheet--lg { width: min(var(--sheet-w-lg), 100vw); }
.ui-sheet--xl { width: min(var(--sheet-w-xl), 100vw); }
.ui-sheet[open] { display: block; animation: ui-sheet-side var(--dur-sheet) var(--ease); }
@keyframes ui-sheet-side { from { transform: translateX(24px); opacity: 0; } }
.ui-sheet__frame { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ui-sheet__grip { display: none; }
.ui-sheet__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3) var(--sp-5); border-bottom: var(--bw) solid var(--border);
}
.ui-sheet__title { font: var(--fw-display) var(--fs-xl)/var(--lh-tight) var(--font-display); }
.ui-sheet__meta { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.ui-sheet__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-5); display: grid; gap: var(--sp-4); align-content: start; }
.ui-sheet__bar {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom)); border-top: var(--bw) solid var(--border);
}
.ui-sheet__bar .ui-btn--wide { flex: 1 1 200px; }
@media (max-width: 767px) {
  .ui-sheet, .ui-sheet--lg, .ui-sheet--xl {
    inset: auto 0 0 0; width: 100%; height: auto; max-height: 92dvh;
    border-left: 0; border-top: var(--bw) solid var(--border); border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  .ui-sheet[open] { display: flex; flex-direction: column; animation-name: ui-sheet-up; }
  .ui-sheet--full { max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .ui-sheet__frame { height: auto; max-height: 92dvh; }
  .ui-sheet--full .ui-sheet__frame { max-height: 100dvh; height: 100%; padding-top: env(safe-area-inset-top); }
  .ui-sheet__grip { display: block; width: 40px; height: 4px; margin: var(--sp-2) auto 0; border-radius: var(--r-pill); background: var(--border-strong); }
  .ui-sheet__head { padding: var(--sp-2) var(--sp-3) var(--sp-3) var(--sp-4); }
  .ui-sheet__body { padding: var(--sp-4); }
  .ui-sheet__bar { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .ui-sheet__bar .ui-btn { flex: 1 1 100%; }
}
@keyframes ui-sheet-up { from { transform: translateY(32px); opacity: 0; } }

.ui-dialog { width: min(480px, calc(100vw - 32px)); border-radius: var(--r-lg); border: var(--bw) solid var(--border); }
.ui-dialog[open] { animation: ui-dialog-in var(--dur-sheet) var(--ease); }
@keyframes ui-dialog-in { from { opacity: 0; transform: scale(.98); } }
.ui-dialog__frame { display: grid; gap: var(--sp-4); padding: var(--sp-6); }
.ui-dialog__title { font: var(--fw-strong) var(--fs-xl)/var(--lh-tight) var(--font-ui); }
.ui-dialog__buttons { display: flex; flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; gap: var(--sp-2); }
.ui-keys { display: grid; gap: var(--sp-2); }
.ui-keys > div { display: flex; justify-content: space-between; gap: var(--sp-4); }
.ui-keys dt { display: inline-flex; gap: var(--sp-1); }
@media (max-width: 767px) {
  .ui-dialog { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .ui-dialog__frame { padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)); }
  .ui-dialog__buttons { flex-direction: column; }
  .ui-dialog__buttons .ui-btn { width: 100%; }
}

/* ---- Switching (components.md 10) --------------------------------------------------------------------- */
.ui-tabs {
  display: flex; gap: var(--sp-1); min-width: 0; overflow-x: auto; scrollbar-width: none;
  border-bottom: var(--bw) solid var(--border);
}
.ui-tabs::-webkit-scrollbar { display: none; }
.ui-tabs__tab {
  display: inline-flex; align-items: center; gap: var(--sp-1); flex: none;
  min-height: var(--tabs-h); padding: 0 var(--sp-3); margin-bottom: calc(-1 * var(--bw));
  border-bottom: var(--bar) solid transparent; color: var(--text); text-decoration: none; white-space: nowrap;
}
.ui-tabs__tab:hover { border-bottom-color: var(--border-strong); }
.ui-tabs__tab[aria-selected="true"] { border-bottom-color: var(--accent-ink); font-weight: var(--fw-strong); }
.ui-tabs__tab .ui-badge { margin-left: 0; }
@media (max-width: 767px) {
  .ui-tabs { mask-image: linear-gradient(to right, black calc(100% - 32px), transparent); }
}

.ui-seg {
  display: inline-flex; max-width: 100%; padding: 2px; gap: 2px;
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-md); background: transparent;
}
.ui-seg__opt {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center;
  min-height: calc(var(--ctl-h) - 4px - 2 * var(--bw)); padding: 0 var(--sp-3);
  border: var(--bw) solid transparent; border-radius: var(--r-sm);
  color: var(--text); text-decoration: none; white-space: nowrap; font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.ui-seg__opt:hover { background: var(--hover); }
.ui-seg__opt[aria-checked="true"], .ui-seg__opt[aria-current="true"] {
  background: var(--surface); border-color: var(--accent-ink); color: var(--accent-ink); font-weight: var(--fw-strong);
}
.ui-seg--wrap { flex-wrap: wrap; }
.ui-seg--wrap .ui-seg__opt { flex: 0 1 auto; }

/* ---- The record's spine (components.md 11) ------------------------------------------------------------ */
.ui-track__phases { list-style: none; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--sp-1); }
.ui-track--strip .ui-track__phase {
  display: grid; align-content: center; gap: 2px; min-height: 52px; min-width: 0; padding: var(--sp-2) var(--sp-3);
  border: var(--bw) dashed var(--border-strong); border-radius: var(--r-sm); color: var(--muted);
  font-size: var(--fs-sm);
}
.ui-track__name { display: flex; align-items: center; gap: var(--sp-1); font-weight: var(--fw-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-track__name .ui-icon { width: 14px; height: 14px; }
.ui-track__date { font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-track--strip .ui-track__phase.is-done { border-style: solid; border-color: var(--muted); background: var(--muted); color: var(--on-text); }
.ui-track--strip .ui-track__phase.is-current {
  position: relative; border-style: solid; border-color: var(--accent-edge); background: var(--accent); color: var(--on-accent);
  outline: var(--bw-strong) solid var(--text); outline-offset: 2px;           /* a ring done cells don't have */
}
.ui-track--bar .ui-track__phases { grid-auto-columns: minmax(0, 1fr); gap: 3px; align-items: center; padding-top: 10px; }
.ui-track--bar .ui-track__phase { position: relative; height: var(--meter-h); border: var(--bw) dashed var(--border-strong); border-radius: 1px; }
.ui-track--bar .ui-track__name { display: none; }
.ui-track--bar .ui-track__phase.is-done { border-style: solid; border-color: var(--muted); background: var(--muted); }
.ui-track--bar .ui-track__phase.is-current {                   /* taller than done and not yet: shape, not only color */
  height: calc(var(--meter-h) + 12px); border-style: solid; border-color: var(--accent-edge); background: var(--accent);
  outline: var(--bw) solid var(--text); outline-offset: 1px;
}
.ui-track__marker {                                               /* a notch over the current phase, in the words' color */
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 4px; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom-width: 0; border-top-color: var(--text);
}
.ui-track__words { margin-top: var(--sp-2); font-size: var(--fs-sm); }
.ui-track-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
@media (max-width: 767px) {
  .ui-track--strip .ui-track__phases { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

.ui-now {
  display: grid; gap: var(--sp-3); padding: var(--pad-card); background: var(--surface); color: var(--text);
  border: var(--bw-strong) solid var(--border-strong); border-left: var(--bar) solid var(--accent-ink); border-radius: var(--r-lg);
}
.ui-now__eyebrow { color: var(--accent-ink); font: var(--fw-strong) var(--fs-sm)/1 var(--font-ui); }
.ui-now__title { font: var(--fw-strong) var(--fs-xl)/var(--lh-tight) var(--font-ui); }
@media (min-width: 1600px) { .ui-now__title { font-size: var(--fs-2xl); } }
.ui-now__facts { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); }
.ui-now__fact { display: grid; gap: 2px; min-width: 0; }
.ui-now__fact dt { color: var(--muted); font-size: var(--fs-sm); }
.ui-now__fact dd { font-weight: var(--fw-medium); }
.ui-now__buttons { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ui-now__missing { display: flex; align-items: center; gap: var(--sp-2); color: var(--warn); font-weight: var(--fw-strong); }
.ui-now__also { border-top: var(--bw) solid var(--border); padding-top: var(--sp-3); }
.ui-now__alsohead { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--sp-2) !important; }
.ui-now__also ul { list-style: none; display: grid; gap: var(--sp-2); }
.ui-now__also li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.ui-now__also li > span { min-width: 0; }
.ui-now__also li > .ui-btn { flex: none; }
.ui-now__quote { border-left: var(--bw) solid var(--border-strong); padding-left: var(--sp-3); display: grid; gap: var(--sp-1); }
.ui-now__quote figcaption { display: flex; align-items: center; gap: var(--sp-2); color: var(--muted); font-size: var(--fs-sm); }
@media (max-width: 767px), (pointer: coarse) {
  .ui-now__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ui-now__buttons .ui-btn { flex: 1 1 100%; }
}

.ui-holder {
  display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 100%; min-height: var(--tag-h);
  padding: 2px var(--sp-2); border-radius: var(--r-sm); font: var(--fw-medium) var(--fs-sm)/1.2 var(--font-ui); vertical-align: middle;
}
.ui-holder .ui-icon { width: 1.1em; height: 1.1em; }
.ui-holder__words { min-width: 0; overflow-wrap: break-word; }
.ui-holder--us { background: var(--accent-soft); color: var(--accent-ink); }
.ui-holder--waiting { background: var(--sunken); color: var(--text); }
.ui-holder__overdue { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--danger); font-weight: var(--fw-strong); font-size: var(--fs-sm); }
.ui-holder__overdue .ui-icon { width: 1.1em; height: 1.1em; }

.ui-meter { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); max-width: 100%; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.ui-meter__words { white-space: nowrap; }
.ui-meter__bar {
  position: relative; display: inline-block; width: var(--meter-w, 96px); height: var(--meter-h);
  background: var(--sunken); box-shadow: inset 0 0 0 var(--bw) var(--border-strong);
}
.ui-meter__bar::before, .ui-meter__bar::after {     /* the dimension line's end ticks */
  content: ""; position: absolute; top: -3px; bottom: -3px; width: var(--bw); background: var(--border-strong);
}
.ui-meter__bar::before { left: 0; }
.ui-meter__bar::after { right: 0; }
.ui-meter__fill { position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%); background: var(--muted); }
.ui-meter--warn .ui-meter__fill { background: var(--warn); }
.ui-meter--danger .ui-meter__fill { background: var(--danger); width: 100%; }
.ui-meter--danger .ui-meter__bar { margin-right: 6px; }
.ui-meter--danger .ui-meter__bar::after { right: -6px; width: calc(var(--bw) * 2); background: var(--danger); }
.ui-meter--danger .ui-meter__words { color: var(--danger); font-weight: var(--fw-strong); }
.ui-meter__short { display: none; }
.ui-meter--danger .ui-meter__short { color: var(--danger); font-weight: var(--fw-strong); }

.ui-avatar-wrap { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; max-width: 100%; }
.ui-avatar {
  display: inline-grid; place-items: center; flex: none; width: var(--avatar); height: var(--avatar);
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text); font: var(--fw-strong) var(--fs-xs)/1 var(--font-ui);
}
.ui-avatar__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-avatars { display: inline-flex; gap: var(--sp-1); }

/* ---- The shell (layout.md 2, components.md 12) -------------------------------------------------------- */
.ui-shell { min-height: 100dvh; }
.ui-frame { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.ui-main { flex: 1; min-width: 0; padding: var(--pad-page); }
.ui-main:focus { outline: none; }
@media (max-width: 767px) {
  .ui-main { padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
  .ui-shell > .ui-sidebar { display: none; }
}
@media (min-width: 768px) {
  .ui-shell { display: grid; grid-template-columns: var(--sidebar-w-folded) minmax(0, 1fr); }
  .ui-tabbar { display: none; }
}
@media (min-width: 1200px) {
  .ui-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .ui-shell.is-folded { grid-template-columns: var(--sidebar-w-folded) minmax(0, 1fr); }
}

.ui-sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; min-width: 0;
  display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3);
  background: var(--surface); border-right: var(--bw) solid var(--border);
}
.ui-sidebar__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 40px; }
.ui-logo { display: inline-flex; align-items: center; min-width: 0; color: var(--text); text-decoration: none; }
img.ui-logo__img { height: 32px; width: auto; max-width: 160px; object-fit: contain; }
.ui-topbar__logo img.ui-logo__img { height: 24px; max-width: 120px; }
.ui-topbar__logo .ui-logo__name { font-size: var(--fs-md); max-width: 50vw; }
.ui-logo__img--dark { display: none; }
:root[data-theme="dark"] .ui-logo__img--light { display: none; }
:root[data-theme="dark"] .ui-logo__img--dark { display: block; }
@media (max-width: 767px), (pointer: coarse) {
  :root[data-sun="1"] .ui-logo__img--light { display: block; }
  :root[data-sun="1"] .ui-logo__img--dark { display: none; }
}
.ui-logo__name {
  font: 600 var(--fs-lg)/var(--lh-tight) var(--font-display); letter-spacing: var(--track-display);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ui-logo__mark {
  display: none; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md);
  border: var(--bw) solid var(--border-strong); font: 600 var(--fs-lg)/1 var(--font-display);
}
.ui-sidebar__newbtn { width: 100%; justify-content: flex-start; }
.ui-sidebar__newbtn .ui-kbd { margin-left: auto; }
.ui-sidebar__new { display: block; }
.ui-sidebar__new .ui-menu { left: 0; right: auto; }
.ui-nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); align-content: start; flex: 1; min-width: 0; }
.ui-nav__list { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.ui-nav__item {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); min-height: var(--nav-item-h);
  padding: 0 var(--sp-3); border-radius: var(--r-md); color: var(--text); text-decoration: none;
  font-weight: var(--fw-medium); white-space: nowrap;
}
.ui-nav__item:hover { background: var(--hover); }
.ui-nav__item.is-current { background: var(--accent-soft); font-weight: var(--fw-strong); box-shadow: inset var(--bar) 0 0 var(--accent-ink); }
.ui-nav__item.is-current .ui-icon { color: var(--accent-ink); }
.ui-nav__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* a pinned view's name is never cut short: two lines, the full name in its title (G3's views; the roofer review) */
.ui-nav__label--view { white-space: normal; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ui-nav__item:has(.ui-nav__label--view) { padding-block: var(--sp-1); }
.ui-nav__section { padding: var(--sp-3) var(--sp-3) var(--sp-1); color: var(--muted); font: italic var(--fw-display) var(--fs-md)/1.2 var(--font-display); }
.ui-sidebar__end { display: grid; gap: var(--sp-1); border-top: var(--bw) solid var(--border); padding-top: var(--sp-3); }
.ui-person {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: var(--sp-2);
  border: 0; border-radius: var(--r-md); background: transparent; text-align: left; cursor: pointer;
}
.ui-person:hover { background: var(--hover); }
.ui-person__words { display: grid; min-width: 0; flex: 1; }
.ui-person__name { font-weight: var(--fw-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-person__role { color: var(--muted); font-size: var(--fs-xs); }
.ui-person__chev { color: var(--muted); }
.ui-sidebar .ui-menu-wrap { display: block; }

/* The folded rail: 64 px of icons (under 1200 px, or folded with [ ) */
@media (min-width: 768px) and (max-width: 1199px) {
  .ui-sidebar { padding: var(--sp-3) var(--sp-2); align-items: center; }
  .ui-sidebar .ui-nav__label, .ui-sidebar .ui-person__words, .ui-sidebar .ui-person__chev,
  .ui-sidebar .ui-nav__section, :root .ui-sidebar .ui-logo__img, :root .ui-sidebar .ui-logo__name,
  .ui-sidebar .ui-sidebar__newbtn .ui-btn__label, .ui-sidebar .ui-sidebar__newbtn .ui-kbd, .ui-sidebar__fold { display: none; }
  .ui-sidebar .ui-logo__mark { display: inline-grid; }
  .ui-sidebar .ui-nav__item { justify-content: center; padding: 0; width: 44px; }
  .ui-sidebar .ui-badge { position: absolute; top: 4px; right: 4px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; background: var(--muted); }
  .ui-sidebar .ui-badge--needs { background: var(--danger); }
  .ui-sidebar__newbtn { width: 44px; padding: 0; justify-content: center; }
  .ui-person { justify-content: center; width: 44px; padding: 0; min-height: 44px; }
  .ui-sidebar__top { justify-content: center; }
}
@media (min-width: 1200px) {
  .ui-shell.is-folded .ui-sidebar { padding: var(--sp-3) var(--sp-2); align-items: center; }
  .ui-shell.is-folded .ui-nav__label, .ui-shell.is-folded .ui-person__words, .ui-shell.is-folded .ui-person__chev,
  .ui-shell.is-folded .ui-nav__section, :root .ui-shell.is-folded .ui-sidebar .ui-logo__img, :root .ui-shell.is-folded .ui-sidebar .ui-logo__name,
  .ui-shell.is-folded .ui-sidebar__newbtn .ui-btn__label, .ui-shell.is-folded .ui-sidebar__newbtn .ui-kbd { display: none; }
  .ui-shell.is-folded .ui-sidebar .ui-logo__mark { display: inline-grid; }
  .ui-shell.is-folded .ui-sidebar__top { flex-direction: column; }
  .ui-shell.is-folded .ui-nav__item { justify-content: center; padding: 0; width: 44px; }
  .ui-shell.is-folded .ui-sidebar .ui-badge { position: absolute; top: 4px; right: 4px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; background: var(--muted); }
  .ui-shell.is-folded .ui-sidebar .ui-badge--needs { background: var(--danger); }
  .ui-shell.is-folded .ui-sidebar__newbtn { width: 44px; padding: 0; justify-content: center; }
  .ui-shell.is-folded .ui-person { justify-content: center; width: 44px; padding: 0; min-height: 44px; }
}

.ui-topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--sp-4); min-height: var(--topbar-h);
  padding: env(safe-area-inset-top) var(--pad-page) 0; background: var(--surface); border-bottom: var(--bw) solid var(--border);
}
/* The start (logo or Back and the title) takes the shrink; Back, the status and Search keep their size. */
.ui-topbar__start { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; flex: 0 1 auto; }
.ui-topbar__back {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1); flex: none;
  min-height: var(--tap); min-width: var(--tap); color: var(--accent-ink); text-decoration: none;
  font-weight: var(--fw-medium); white-space: nowrap;
}
.ui-topbar__back:hover { text-decoration: underline; text-underline-offset: 3px; }
.ui-topbar__title { flex: 1 1 auto; font-weight: var(--fw-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ui-topbar__cmd { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.ui-topbar__status { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; flex: none; }
.ui-topbar__status > * { flex: none; }
.ui-queue { list-style: none; display: grid; gap: var(--sp-3); }
.ui-queue__item { display: grid; gap: var(--sp-1); justify-items: start; padding-bottom: var(--sp-3); border-bottom: var(--bw) solid var(--border); }
.ui-queue__words { font-weight: var(--fw-medium); }
.ui-topbar__search { display: none; }
.ui-topbar__logo { display: none; }
@media (max-width: 767px) {
  .ui-topbar { gap: var(--sp-2); }
  .ui-topbar--titled .ui-topbar__start { flex: 1 1 auto; gap: var(--sp-1); }
  .ui-topbar--titled .ui-topbar__backlabel {          /* the arrow alone; its words stay for screen readers */
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .ui-topbar .ui-sync { max-width: 45vw; }            /* long sync words wrap inside the pill instead of pushing Search out */
  /* Sun's bigger sizes leave a child page's title only a few letters beside Back, the pill and Search: it takes a
     line of its own under them instead. */
  :root[data-sun="1"] .ui-topbar--titled { flex-wrap: wrap; }
  :root[data-sun="1"] .ui-topbar--titled .ui-topbar__start { display: contents; }
  :root[data-sun="1"] .ui-topbar--titled .ui-topbar__title { order: 9; flex: 1 1 100%; padding-bottom: var(--sp-2); }
  .ui-topbar__cmd, .ui-topbar__keys { display: none; }
  .ui-topbar__search { display: inline-grid; }
  .ui-topbar__logo { display: inline-flex; }
}
@media (pointer: coarse) { .ui-topbar__keys { display: none; } }

.ui-search { position: relative; display: flex; align-items: center; width: 100%; max-width: 520px; border-radius: var(--r-md); }
.ui-search__icon { position: absolute; left: var(--sp-3); color: var(--muted); pointer-events: none; }
input.ui-search__input {            /* input.: as heavy as app.css's input[type=search] (the guard above) */
  width: 100%; min-height: var(--ctl-h); padding: 0 var(--sp-3) 0 calc(var(--sp-3) + var(--icon-size) + var(--sp-2));
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-md);
  background-color: var(--surface); color: var(--text);
  font-family: inherit; font-weight: inherit; line-height: inherit; font-size: var(--input-fs);
}
.ui-search__input::placeholder { color: var(--muted); opacity: 1; }
.ui-search__input:focus-visible { outline: none; }
.ui-search:focus-within { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }
.ui-search__kbd { position: absolute; right: var(--sp-2); pointer-events: none; }
.ui-search:focus-within .ui-search__kbd { display: none; }

/* ---- The live shell (G1, spec 01): the tab strip, the phone's app switch and sun button, search's drop-down,
   the person menu, the More sheet, banners and panel messages above an old page body ------------------------------ */
.ui-tabs__tab[aria-current="page"] { border-bottom-color: var(--accent-ink); font-weight: var(--fw-strong); }
.ui-strip { padding: 0 var(--pad-page); background: var(--surface); }
.ui-tabs__away { width: 14px; height: 14px; color: var(--muted); }
.ui-seg__opt[aria-current="page"] {
  background: var(--surface); border-color: var(--accent-ink); color: var(--accent-ink); font-weight: var(--fw-strong);
}
.ui-appswitch { display: none; }
.ui-topbar__sun { display: none; }
@media (pointer: coarse) { .ui-topbar__sun { display: inline-grid; } }
@media (max-width: 767px) {
  .ui-appswitch { display: inline-flex; flex: none; }
  .ui-appswitch .ui-seg__opt { min-height: 44px; flex: none; }
  .ui-topbar__logo--wide { display: none; }
  body[data-app] .ui-strip, body[data-app] .ui-tabbar, body[data-app] .ui-banner { display: none; }
}
@media (max-width: 767px), (pointer: coarse) {
  :root[data-sun="1"] .ui-appswitch .ui-seg__opt { min-height: 52px; }
}
html.in-shell .ui-topbar { display: none; }          /* inside the installed app its own top bar shows (spec 01 section 9) */
.ui-search .ui-suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: var(--z-sheet);
  max-height: 70dvh; overflow-y: auto; border-top: var(--bw) solid var(--border); border-radius: var(--r-md); padding: var(--sp-1) 0;
}
.ui-suggest__in.ui-bridged { max-width: none; margin: 0; font-size: var(--fs-sm); }
.ui-search__results { margin-top: var(--sp-3); }
.ui-search__results.ui-bridged { max-width: none; }
.ui-main--bare { padding: var(--pad-page); }
.ui-msgs { display: grid; gap: var(--sp-2); max-width: var(--content-max); margin: 0 auto var(--sp-4); }
.ui-banner--viewas { flex-wrap: wrap; }
.ui-banner--viewas .ui-banner__words { flex: 1 1 16rem; }
select.ui-banner__pick { width: auto; max-width: 100%; min-height: var(--ctl-h-sm); }
/* The tab bar's More and the + as a link */
button.ui-tabbar__item { width: 100%; border: 0; background: transparent; cursor: pointer; }
a.ui-plus { text-decoration: none; }
.ui-plus[aria-current="page"] { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--accent-ink); }
/* The person menu: who, the display settings (each saves on change), the links, Log out */
.ui-menu--person { min-width: 300px; }
@media (min-width: 768px) {
  /* out of the sidebar (it scrolls, so it would clip the menu), up from the person button */
  .ui-sidebar .ui-menu--person {
    position: fixed; left: var(--sp-3); bottom: 76px; top: auto; width: 320px;
    max-height: calc(100dvh - 96px); overflow-y: auto; z-index: var(--z-sheet);
  }
}
.ui-who { display: grid; padding: var(--sp-2) var(--sp-4) var(--sp-3); border-bottom: var(--bw) solid var(--border); margin-bottom: var(--sp-1); }
.ui-who__name { font-weight: var(--fw-strong); overflow-wrap: break-word; }
.ui-who__role { color: var(--muted); font-size: var(--fs-sm); }
.ui-prefs { display: grid; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); }
.ui-pref { display: grid; gap: var(--sp-1); }
.ui-pref__label { font-weight: var(--fw-medium); font-size: var(--fs-sm); }
.ui-pref__help { display: block; color: var(--muted); font-size: var(--fs-xs); }
.ui-pref__seg { display: flex; width: 100%; }
.ui-pref__seg .ui-seg__opt { flex: 1 1 0; min-width: 0; padding: 0 var(--sp-2); white-space: normal; text-align: center; line-height: 1.2; }
.ui-pref__saved { min-height: 1em; color: var(--ok); font-size: var(--fs-xs); }
.ui-pref__saved:empty { display: none; }
.ui-pref--switch {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-1) var(--sp-3);
  width: 100%; min-height: var(--ctl-h); padding: var(--sp-1) 0; border: 0; background: transparent; color: var(--text);
  text-align: left; cursor: pointer;
}
.ui-pref--switch .ui-pref__saved { grid-column: 1 / -1; }
.ui-pref__words { min-width: 0; }
.ui-switch {
  position: relative; width: 40px; height: 24px; flex: none; border-radius: var(--r-pill);
  border: var(--bw) solid var(--border-strong); background: var(--sunken);
}
.ui-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: var(--r-pill);
  background: var(--surface); border: var(--bw) solid var(--border-strong); transition: transform var(--dur-fast) var(--ease);
}
[aria-checked="true"] > .ui-switch { background: var(--accent); border-color: var(--accent-edge); }
[aria-checked="true"] > .ui-switch::after { transform: translateX(16px); border-color: var(--accent-edge); }
.ui-pref--rows, .ui-pref--keys { display: none; }
@media (min-width: 1024px) and (pointer: fine) { .ui-pref--rows { display: grid; } }
@media (pointer: fine) { .ui-pref--keys { display: grid; } }
.ui-pref--sun { display: none; }
@media (pointer: coarse) { .ui-pref--sun { display: grid; } }
.ui-menu__item--two { align-items: center; min-height: calc(var(--ctl-h) + 12px); }
.ui-menu__words { display: grid; text-align: left; }
.ui-menu__help { color: var(--muted); font-size: var(--fs-xs); }
.ui-menu__note { padding: var(--sp-2) var(--sp-4); color: var(--muted); font-size: var(--fs-sm); }
.ui-menu__form { display: block; margin: 0; }
.ui-menu__pick { display: grid; gap: var(--sp-1); padding: var(--sp-2) var(--sp-4); }
.ui-more__you .ui-menu__pick { padding-left: 0; padding-right: 0; }
a.ui-menu__item { text-decoration: none; }
/* The More sheet: the places not on the tab bar, Settings, then You */
.ui-more__grid { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.ui-more__item {
  display: grid; justify-items: center; align-content: center; gap: var(--sp-1); min-height: 72px; padding: var(--sp-2);
  border: var(--bw) solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  text-decoration: none; text-align: center; font-weight: var(--fw-medium);
}
.ui-more__item.is-current { background: var(--accent-soft); border-color: var(--accent-ink); font-weight: var(--fw-strong); }
.ui-more__item.is-current .ui-icon { color: var(--accent-ink); }
.ui-more__label { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1); white-space: nowrap; margin: 0 calc(var(--sp-1) * -1); }
.ui-more__label .ui-badge { margin-left: 0; }
.ui-more__you { margin-top: var(--sp-5); }
.ui-more__head { margin-bottom: var(--sp-2); font: var(--fw-strong) var(--fs-md)/var(--lh-tight) var(--font-ui); }
.ui-more__you .ui-who { padding-left: 0; padding-right: 0; }
.ui-more__you .ui-prefs { padding-left: 0; padding-right: 0; }
.ui-more__you .ui-menu__item { padding-left: 0; padding-right: 0; }
@media (max-width: 359px) { .ui-more__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.ui-cmd { display: grid; gap: 0; max-width: 520px; }
.ui-cmd .ui-search__input { border-radius: var(--r-md) var(--r-md) 0 0; }
.ui-cmd__list, .ui-cmd__note {
  background: var(--raised); border: var(--bw) solid var(--border); border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md); box-shadow: var(--shadow-float); padding: var(--sp-2);
}
.ui-cmd__note { display: flex; gap: var(--sp-2); align-items: center; color: var(--text); font-size: var(--fs-sm); }
.ui-cmd__group { padding: var(--sp-2) var(--sp-2) var(--sp-1); color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.ui-cmd__opt { display: grid; gap: 2px; padding: var(--sp-2); border-radius: var(--r-sm); cursor: pointer; color: var(--text); text-decoration: none; }
.ui-cmd__opt:hover { background: var(--hover); }
.ui-cmd__opt[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset var(--bar) 0 0 var(--accent-ink); }
.ui-cmd__main { font-weight: var(--fw-strong); }
.ui-cmd__sub { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ui-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
  background: var(--surface); border-top: var(--bw) solid var(--border-strong);
  padding-bottom: env(safe-area-inset-bottom);
}
.ui-tabbar__list { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; }
.ui-tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tab-h); padding: var(--sp-1) 2px; color: var(--text); text-decoration: none;
  font: var(--fw-medium) var(--fs-xs)/1.1 var(--font-ui);
}
.ui-tabbar__item.is-current { color: var(--accent-ink); font-weight: var(--fw-strong); box-shadow: inset 0 var(--bar) 0 var(--accent); }
.ui-tabbar__icon { position: relative; display: inline-grid; }
.ui-tabbar__badge { position: absolute; top: -6px; left: calc(100% - 8px); margin: 0; background: var(--surface); border: var(--bw) solid var(--border-strong); color: var(--text); }
.ui-tabbar__badge.ui-badge--needs { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.ui-tabbar__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-tabbar__pluscell { display: grid; place-items: center; }
html.ui-kb-open .ui-tabbar, html.ui-bulk-on .ui-tabbar { display: none; }
.ui-plus {
  display: grid; place-items: center; width: var(--plus); height: var(--plus); margin-top: -12px;
  border: var(--bw) solid var(--accent-edge); border-radius: var(--r-pill);
  background: var(--accent); color: var(--on-accent); cursor: pointer;
  box-shadow: 0 0 0 4px var(--surface), var(--shadow-float);
}
.ui-plus:hover { background: var(--accent-hover); }
.ui-plus .ui-icon { width: 28px; height: 28px; stroke-width: 2.25; }
.ui-tiles { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.ui-tile {
  display: grid; place-items: center; align-content: center; gap: var(--sp-2); width: 100%; min-height: var(--tile-h);
  padding: var(--sp-2); border: var(--bw) solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font-weight: var(--fw-medium); cursor: pointer; text-align: center;
}
.ui-tile .ui-icon { width: 24px; height: 24px; color: var(--accent-ink); }
.ui-tile:hover { background: var(--accent-soft); border-color: var(--accent-ink); }

/* ---- Many at once (components.md 13) ------------------------------------------------------------------ */
.ui-views { display: grid; gap: var(--sp-2); min-width: 0; }
.ui-views__tabs { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; overflow-x: auto; scrollbar-width: none; border-bottom: var(--bw) solid var(--border); }
.ui-views__count { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.ui-views__edited { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.ui-views__phone { display: none; justify-self: start; }
@media (max-width: 767px) {
  .ui-views__tabs, .ui-views__edited { display: none; }
  .ui-views__phone { display: inline-flex; }
}
.ui-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0; }
.ui-filters__quick, .ui-filters__more { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }
.ui-filters__active { list-style: none; display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }
.ui-filters__count { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.ui-filters__phone { display: none; }
@media (max-width: 767px) {
  .ui-filters__more, .ui-filters > .ui-seg, .ui-filters__add, .ui-filters__active, .ui-filters > .ui-btn--quiet { display: none; }
  .ui-filters__phone { display: inline-flex; }
}
.ui-bulk {
  position: sticky; bottom: var(--sp-3); z-index: var(--z-bulk);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) var(--sp-3);
  background: var(--raised); border: var(--bw) solid var(--accent-ink); border-radius: var(--r-lg); box-shadow: var(--shadow-float);
}
.ui-bulk__count { color: var(--accent-ink); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; }
.ui-bulk__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 767px) {
  .ui-bulk[data-ui-bulk]:not([data-ui-bulk="sample"]) {
    position: fixed; left: 0; right: 0; bottom: 0; border-radius: 0; border-width: var(--bw) 0 0;
    padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom));
  }
  .ui-bulk__extra, .ui-bulk__all { display: none; }
}

/* One-column grids never grow past their box for a long unbroken line (an address, a holder's words): the track's
   minimum is 0, so the line truncates or wraps instead of pushing the page sideways. */
.ui-rcard, .ui-now, .ui-now__fact, .ui-tablebox, .ui-views, .ui-field, .ui-field__group, .ui-choices, .ui-empty,
.ui-skel, .ui-sheet__body, .ui-dialog__frame, .ui-facts, .ui-cmd, .ui-page, .ui-page__head, .ui-form, .ui-inline__form,
.ui-home__paper, .ui-option, .ui-card__body, .ui-msg__body { grid-template-columns: minmax(0, 1fr); }

/* ---- Pages ---------------------------------------------------------------------------------------------- */
.ui-page { display: grid; gap: var(--sp-6); min-width: 0; max-width: var(--content-max); }
.ui-page__head { display: grid; gap: var(--sp-2); }
.ui-page__lede { color: var(--muted); max-width: 72ch; }

/* ---- Homeowner pages (homeowner-pages.md; layout.md 5.5): always light, the company's brand only ---------- */
.ui-home { font-size: max(16px, var(--fs-md)); }
.ui-home__head { background: var(--surface); border-bottom: 4px solid var(--brand); }
.ui-home__headin {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  max-width: 1080px; margin: 0 auto; padding: var(--sp-4) var(--sp-5);
}
.ui-home__logo { display: inline-flex; min-width: 0; color: var(--brand-ink); text-decoration: none; }
.ui-home__logo img { height: 56px; width: auto; max-width: 240px; object-fit: contain; }
.ui-home__name { font: 600 var(--fs-xl)/var(--lh-tight) var(--font-display); color: var(--brand-ink); }
.ui-home__contact { display: grid; justify-items: end; gap: 2px; text-align: right; }
.ui-home__main { padding: var(--sp-6) var(--sp-5); }
.ui-home__paper {
  display: grid; gap: var(--sp-4); max-width: 760px; margin: 0 auto; padding: var(--sp-7);
  background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg);
}
.ui-home__title { font: var(--fw-display) var(--fs-3xl)/var(--lh-tight) var(--font-display); letter-spacing: var(--track-display); color: var(--text); }
.ui-home__address { color: var(--muted); font-size: var(--fs-lg); }
.ui-home__foot { max-width: 760px; margin: 0 auto; padding: 0 var(--sp-5) var(--sp-7); color: var(--muted); font-size: var(--fs-sm); text-align: center; }
.ui-home__sticky { display: none; }
.ui-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.ui-option { display: grid; gap: var(--sp-2); align-content: start; padding: var(--sp-4); border: var(--bw) solid var(--border-strong); border-radius: var(--r-lg); }
.ui-option--rec { border: 2px solid var(--brand-edge); background: var(--brand-soft); }
.ui-option__tag { justify-self: start; padding: 0 var(--sp-2); border-radius: var(--r-sm); background: var(--brand-fill); color: var(--on-brand); font-weight: var(--fw-strong); font-size: var(--fs-sm); }
.ui-option__name { font: var(--fw-strong) var(--fs-lg)/var(--lh-tight) var(--font-ui); }
.ui-option__price { font: var(--fw-display) var(--fs-2xl)/var(--lh-tight) var(--font-display); color: var(--text); white-space: nowrap; }
@media (max-width: 767px) {
  .ui-home__headin { padding: var(--sp-3) var(--sp-4); }
  .ui-home__logo img { height: 40px; max-width: 180px; }
  .ui-home__main { padding: 0; }
  .ui-home__paper { padding: var(--sp-5) var(--sp-4); border: 0; border-radius: 0; }
  .ui-home--sticky { padding-bottom: calc(var(--ctl-h) + 2 * var(--sp-3) + var(--bw) + env(safe-area-inset-bottom)); }
  .ui-options { grid-template-columns: minmax(0, 1fr); }
  .ui-home__sticky {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
    background: var(--surface); border-top: var(--bw) solid var(--border-strong);
  }
}

/* ---- Estimate sheet (F1a; components.md 15, ruled 2026-11-17 N1 and N2): the cost and margin box and the rate meter.
   The sheet's own layout is static/ui/estimate/sheet.css. Tokens only. ---------------------------------------- */
.ui-card--costs { border: var(--bw) dashed var(--border-strong); background: var(--surface); }
.ui-card--costs .ui-card__title { font: var(--fw-strong) var(--fs-sm)/1.3 var(--font-ui); color: var(--muted); }
.ui-card--costs .ui-card__body { display: grid; gap: var(--sp-2); }
.ui-card--costs .ui-card__line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--sp-3); white-space: normal; overflow: visible; text-overflow: clip; font-variant-numeric: tabular-nums; }
.ui-card--costs .ui-card__line > .ui-money { margin-left: auto; }
.ui-card--costs .est-warnwords { color: var(--warn); font-weight: var(--fw-medium); }
.ui-card--costs .est-dangerwords { color: var(--danger); font-weight: var(--fw-strong); }
.ui-meter--rate { display: grid; gap: var(--sp-1); width: 100%; }
.ui-meter--rate .ui-meter__words { white-space: normal; }
.ui-meter--rate .ui-meter__bar { position: relative; display: block; width: 100%; height: 8px; margin: 0; background: var(--sunken); border: var(--bw) solid var(--border); border-radius: var(--r-pill); overflow: visible; }
.ui-meter--rate .ui-meter__bar::before, .ui-meter--rate .ui-meter__bar::after { display: none; }
.ui-meter--rate .ui-meter__fill { position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%); border-radius: inherit; background: var(--text); }
.ui-meter--rate.is-ok .ui-meter__fill { background: var(--ok); }
.ui-meter--rate.is-below .ui-meter__fill { background: var(--danger); }
.ui-meter--rate.is-below .ui-meter__words { color: var(--danger); font-weight: var(--fw-strong); }
.ui-meter__tick { position: absolute; top: -3px; bottom: -3px; left: var(--at, 0%); width: 2px; background: var(--text); }
.ui-meter__tick--floor { background: var(--danger); }

/* Ranked list (.ui-order, R3 section 18) and Rights list (.ui-rights): first built for People, and Roles and access. */
.ui-order { display: grid; gap: var(--sp-3); min-width: 0; align-content: start; }
.ui-order__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); }
.ui-order__headline { flex: 1 1 18rem; min-width: 0; color: var(--text); font-size: var(--fs-sm); max-width: 60ch; }
.ui-order__status { min-height: 0; }
.ui-order__status:empty { display: none; }
.ui-order__list { list-style: none; display: grid; margin: 0; padding: 0; border: var(--bw) solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.ui-order__row { position: relative; display: flex; align-items: center; gap: var(--sp-2); min-height: var(--row-h); padding: var(--sp-2) var(--sp-3); border-top: var(--bw) solid var(--border); min-width: 0; background: var(--surface); }
.ui-order__row:first-child { border-top: 0; }
.ui-order__row.is-lastfixed { border-bottom: 2px solid var(--border-strong); }
.ui-order__row.is-selected { background: var(--accent-soft); box-shadow: inset var(--bar) 0 0 var(--accent-ink); }
.ui-order__row.is-moving { opacity: .6; }
.ui-order__row.is-dragging { box-shadow: var(--shadow-float); background: var(--surface); }
.ui-order__row.is-ghost { opacity: .35; }
.ui-order__handle { display: none; flex: none; width: 24px; height: 24px; color: var(--muted); cursor: grab; }
@media (hover: hover) and (pointer: fine) { .ui-order__handle { display: inline-flex; } }
.ui-order__place { flex: none; min-width: 2ch; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.ui-order__main { flex: 1 1 auto; display: grid; min-width: 0; color: inherit; text-decoration: none; padding-block: var(--sp-1); }
.ui-order__title { font-weight: var(--fw-strong); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ui-order__second { overflow-wrap: anywhere; }
.ui-order__menu { flex: none; }
.ui-order__main:focus-visible { outline: 2px solid var(--focus, var(--accent-ink)); outline-offset: 2px; }
.ui-rights { display: grid; gap: var(--sp-3); min-width: 0; }
.ui-rights__note { color: var(--muted); font-size: var(--fs-sm); max-width: 62ch; }
.ui-rights__group { display: grid; gap: 0; min-width: 0; margin: 0; padding: 0; border: 0; }
.ui-rights__legend { padding: 0 0 var(--sp-1); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--muted); text-transform: none; }
.ui-rights__row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-1) var(--sp-3); min-height: var(--tap); padding: var(--sp-2) 0; border-top: var(--bw) solid var(--border); min-width: 0; }
.ui-rights__row.is-fixed { align-items: center; }
.ui-rights__box { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--accent-ink); }
.ui-rights__check { flex: none; width: 24px; height: 24px; color: var(--ok); }
.ui-rights__what { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; display: grid; gap: 2px; }
.ui-rights__help { color: var(--muted); font-size: var(--fs-sm); }
.ui-rights__from { flex: 0 1 auto; color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.ui-rights__tag { flex: 0 1 auto; max-width: 100%; white-space: normal; }
@media (max-width: 767px) { .ui-rights__from, .ui-rights__tag { flex-basis: 100%; padding-left: calc(24px + var(--sp-3)); } .ui-rights__row.is-fixed .ui-rights__from, .ui-rights__row.is-fixed .ui-rights__tag { padding-left: 0; } }
