/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio, geometry.
   Put this @layer first; product CSS outside the layer always wins. */
@layer od-layout {
  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* functional inline SVG icons opt into bounded geometry; content SVGs keep their own */
  .od-icon { display: inline-block; inline-size: var(--od-icon-size, 1em); block-size: var(--od-icon-size, 1em); flex: none; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
  .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
/* /OD-LAYOUT-PRIMITIVES v1 */

/* =====================================================================
   Waste Defense design tokens — byte-identical to frontend/app/globals.css
   (light mode only; no dark tokens by design)
   ===================================================================== */
:root {
  color-scheme: light;
  --radius: 0.625rem;                 /* 10px base */
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);   /* 8px controls */
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);   /* 14px cards */

  --background: oklch(0.985 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.45 0.19 295);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.45 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --warning: oklch(0.769 0.188 70.08);
  --warning-foreground: oklch(0.279 0.077 45.635);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.55 0 0);
  --ring: oklch(0.45 0.19 295);

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* type scale (Tailwind steps) */
  --text-xs: 12px; --lh-xs: 16px;
  --text-sm: 14px; --lh-sm: 20px;
  --text-base: 16px; --lh-base: 24px;
  --text-lg: 18px; --lh-lg: 28px;
  --text-2xl: 24px; --lh-2xl: 32px;

  /* spacing (4px scale) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* shell geometry */
  --header-h: 56px;
  --sidebar-w: 232px;
  --inspector-w: 360px;

  /* motion */
  --dur-fast: 150ms; --dur-base: 200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* focus ring: solid 3px ring with 2px background offset */
  --ring-shadow: 0 0 0 2px var(--background), 0 0 0 5px var(--ring);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--lh-sm);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p, dl, dd, dt, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

h1, .h1 { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
h2, .h2 { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: 600; }
h3, .h3 { font-size: var(--text-base); line-height: 1; font-weight: 600; }
h4, .h4 { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 600; }
.text-xs { font-size: var(--text-xs); line-height: var(--lh-xs); }
.text-sm { font-size: var(--text-sm); line-height: var(--lh-sm); }
.text-base { font-size: var(--text-base); line-height: var(--lh-base); }
.muted { color: var(--muted-foreground); }
.medium { font-weight: 500; }
.semibold { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 0.875em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: var(--text-xs); line-height: var(--lh-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); }
.unavail, .projected { font-style: italic; color: var(--muted-foreground); }
.link { color: var(--primary); text-underline-offset: 4px; border-radius: var(--radius-sm); }
.link:hover { text-decoration: underline; }
.prose { max-width: 65ch; }

/* one focus treatment for every interactive control */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
  border-color: var(--ring);
}
.on-primary :where(a, button):focus-visible { box-shadow: none; outline: 2px solid currentColor; outline-offset: 2px; }

/* =====================================================================
   Components — recipes mirror frontend/components/ui/*
   ===================================================================== */

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4);
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; white-space: nowrap;
  transition: background-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
  cursor: pointer; flex-shrink: 0;
}
.btn .od-icon { --od-icon-size: 16px; }
.btn-default { background: var(--primary); color: var(--primary-foreground); }
.btn-default:hover { background: color-mix(in oklab, var(--primary) 90%, black); }
.btn-destructive { background: var(--destructive); color: #fff; }
.btn-destructive:hover { background: color-mix(in oklab, var(--destructive) 90%, black); }
.btn-destructive:focus-visible { box-shadow: 0 0 0 2px var(--background), 0 0 0 5px var(--destructive); }
.btn-outline { background: var(--background); border-color: var(--border); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 80%, transparent); }
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-link { color: var(--primary); height: auto; padding: 0; text-underline-offset: 4px; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { height: 32px; padding: 0 var(--s-3); gap: 6px; }
.btn-xs { height: 24px; padding: 0 var(--s-2); font-size: var(--text-xs); line-height: var(--lh-xs); gap: var(--s-1); border-radius: var(--radius-md); }
.btn-xs .od-icon { --od-icon-size: 12px; }
.btn-lg { height: 40px; padding: 0 var(--s-6); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon-sm { width: 32px; height: 32px; padding: 0; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-default[aria-disabled="true"]:hover { background: var(--primary); }
.btn-outline[aria-disabled="true"]:hover { background: var(--background); color: inherit; }
.btn-ghost[aria-disabled="true"]:hover { background: transparent; color: inherit; }
.btn-secondary[aria-disabled="true"]:hover { background: var(--secondary); }
.on-primary .btn-ghost { color: var(--primary-foreground); }
.on-primary .btn-ghost:hover { background: color-mix(in oklab, var(--primary) 80%, white); color: var(--primary-foreground); }

/* Badge / StatusBadge */
.badge {
  display: inline-flex; width: fit-content; flex-shrink: 0; align-items: center; justify-content: center; gap: var(--s-1);
  overflow: hidden; border-radius: 9999px; border: 1px solid transparent;
  padding: 2px var(--s-2); font-size: var(--text-xs); line-height: var(--lh-xs); font-weight: 500; white-space: nowrap;
}
.badge .od-icon { --od-icon-size: 12px; }
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-warning { background: var(--warning); color: var(--warning-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-destructive { background: var(--destructive); color: #fff; }
.badge-outline { border-color: var(--border); color: var(--foreground); }
.badge-internal { background: var(--foreground); color: var(--background); }
.badge-projected { border-color: var(--border); color: var(--muted-foreground); font-style: italic; }
.badge-proposed { position: relative; }

/* Card */
.card {
  display: flex; flex-direction: column; gap: var(--s-6);
  border-radius: var(--radius-xl); border: 1px solid var(--border);
  background: var(--card); color: var(--card-foreground);
  padding: var(--s-6) 0; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.card-dense { gap: var(--s-4); padding: var(--s-4) 0; }
.card-header { display: grid; grid-template-rows: auto auto; align-items: start; gap: var(--s-2); padding: 0 var(--s-6); }
.card-header.has-action { grid-template-columns: 1fr auto; }
.card-dense .card-header, .card-dense .card-content, .card-dense .card-footer { padding-inline: var(--s-4); }
.card-title { font-size: var(--text-base); line-height: 1; font-weight: 600; }
.card-title .count { color: var(--muted-foreground); font-weight: 500; margin-left: var(--s-2); font-variant-numeric: tabular-nums; }
.card-desc { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--muted-foreground); }
.card-action { grid-column: 2; grid-row: 1 / span 2; align-self: start; justify-self: end; }
.card-content { padding: 0 var(--s-6); }
.card-content.flush { padding: 0; }
.card-footer { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-6); }
.card-footer.border-t { border-top: 1px solid var(--border); padding-top: var(--s-4); }

/* Table */
.table-wrap { position: relative; width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; caption-side: bottom; font-size: var(--text-sm); line-height: var(--lh-sm); }
.table thead tr { border-bottom: 1px solid var(--border); }
.table tbody tr { border-bottom: 1px solid var(--border); transition: background-color var(--dur-fast); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); }
.table th { height: 40px; padding: 0 var(--s-2); text-align: left; vertical-align: middle; font-weight: 500; white-space: nowrap; color: var(--foreground); }
/* Text cells wrap at word boundaries (break-word, never anywhere: anywhere lets auto table layout squeeze a column to one letter per line); identifiers, amounts, dates and badges never break */
.table td { padding: var(--s-2); vertical-align: middle; white-space: normal; overflow-wrap: break-word; }
.table td.num, .table td .mono, .table td .tnum, .table td .badge, .table td .btn { white-space: nowrap; }
/* "— Unavailable" is held together by a non-breaking space in the copy, so a longer reason after it may wrap */
.table td .unavail { white-space: normal; }
.table td .row-link.mono { white-space: nowrap; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-link { color: var(--foreground); font-weight: 500; border-radius: var(--radius-sm); }
.table .row-link:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }
.table.compact th { height: 36px; }
.table caption { margin-top: var(--s-4); font-size: var(--text-sm); color: var(--muted-foreground); text-align: left; }
.table .group-row td { padding-top: var(--s-3); padding-bottom: var(--s-1); }
.table tbody tr.disabled-row .row-link { color: var(--muted-foreground); pointer-events: none; }

/* Alert */
.alert {
  display: grid; width: 100%; gap: var(--s-1);
  border-radius: var(--radius-md); border: 1px solid var(--border); padding: var(--s-3);
  font-size: var(--text-sm); line-height: var(--lh-sm);
  background: var(--card); color: var(--card-foreground);
}
.alert-info { border-color: var(--primary); background: color-mix(in oklab, var(--primary) 8%, var(--card)); color: var(--foreground); }
.alert-warning { border-color: var(--warning); background: color-mix(in oklab, var(--warning) 18%, var(--card)); color: var(--foreground); }
.alert-destructive { border-color: var(--destructive); background: color-mix(in oklab, var(--destructive) 8%, var(--card)); color: var(--foreground); }
.alert-title { font-weight: 500; }
.alert-body { display: grid; gap: var(--s-2); }
.alert-actions { margin-top: var(--s-1); display: flex; flex-wrap: wrap; gap: var(--s-2); }
.alert-page { font-size: var(--text-base); line-height: var(--lh-base); padding: var(--s-4); }

/* EmptyState */
.empty {
  display: flex; width: 100%; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--s-4); padding: var(--s-12) var(--s-6);
  border-radius: var(--radius-lg); border: 1px dashed var(--border); background: var(--muted);
}
.empty.sm { gap: var(--s-3); padding: var(--s-8) var(--s-4); }
.empty.plain { background: transparent; border: 0; }
.empty-icon { display: flex; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 9999px; width: 48px; height: 48px; }
.empty.sm .empty-icon { width: 40px; height: 40px; }
.empty-icon .od-icon { --od-icon-size: 24px; }
.empty.sm .empty-icon .od-icon { --od-icon-size: 20px; }
.empty[data-kind="empty"] .empty-icon { background: color-mix(in oklab, var(--primary) 10%, var(--card)); color: var(--primary); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary) 20%, var(--card)); }
.empty[data-kind="unavailable"] .empty-icon { background: color-mix(in oklab, var(--warning) 25%, var(--card)); color: var(--warning-foreground); box-shadow: inset 0 0 0 1px var(--warning); }
.empty-text { display: flex; max-width: 24rem; flex-direction: column; gap: 6px; }
.empty-title { font-weight: 600; letter-spacing: -0.01em; color: var(--foreground); font-size: var(--text-base); line-height: var(--lh-base); }
.empty.sm .empty-title { font-size: var(--text-sm); line-height: var(--lh-sm); }
.empty-desc { color: var(--muted-foreground); font-size: var(--text-sm); line-height: var(--lh-sm); }
.empty.sm .empty-desc { font-size: var(--text-xs); line-height: var(--lh-xs); }
.empty-actions { margin-top: var(--s-1); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }

/* KeyValueList */
.kv { display: grid; gap: var(--s-2) var(--s-4); font-size: var(--text-sm); line-height: var(--lh-sm); }
.kv.row { grid-template-columns: minmax(0, 10rem) minmax(0, 1fr); }
.kv.row > dt, .kv.row > dd { display: block; }
.kv.stack { gap: var(--s-3); }
.kv.stack > div { display: grid; gap: 2px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { min-width: 0; overflow-wrap: break-word; }
.kv dd.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ChangeHistory */
.history { display: grid; gap: var(--s-3); font-size: var(--text-sm); line-height: var(--lh-sm); }
.history-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
.history-caveat { color: var(--muted-foreground); }
.history-list { display: grid; gap: var(--s-3); overflow-wrap: break-word; }
.history-entry { display: grid; gap: 6px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--card); padding: var(--s-3); }
.history-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-2); }
.history-line .op { font-weight: 500; }
.history-line .actor { color: var(--muted-foreground); }
.history-line .time { margin-left: auto; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.history-fields { display: grid; gap: var(--s-1); }
.history-field { display: grid; grid-template-columns: minmax(0, 10rem) minmax(0, 1fr); gap: 0 var(--s-3); }
.history-field .f { color: var(--muted-foreground); }
.history-field .before { color: var(--muted-foreground); text-decoration: line-through; }
.history-field .arrow { padding: 0 6px; color: var(--muted-foreground); }
.history-field .after { font-weight: 500; }

/* Field / Input / Switch / Checkbox / Radio */
.field { display: grid; gap: 6px; }
.field > label, .field-label { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; }
.field .req { color: var(--destructive); margin-left: 2px; }
.field-hint { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--muted-foreground); }
.field-error { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--destructive); }
.input {
  display: flex; height: 36px; width: 100%; min-width: 0; align-items: center;
  border-radius: var(--radius-md); border: 1px solid var(--input); background: var(--card);
  padding: 0 var(--s-3); font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--foreground);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.input::placeholder { color: var(--muted-foreground); }
.input[readonly] { background: var(--muted); color: var(--muted-foreground); }
.input[aria-invalid="true"] { border-color: var(--destructive); }
.input-sm { height: 32px; }
.input-xs { width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.input-search { padding-left: 32px; }
.input-wrap { position: relative; }
.input-wrap .od-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); --od-icon-size: 16px; pointer-events: none; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea.input { height: auto; min-height: 72px; padding: var(--s-2) var(--s-3); resize: vertical; }

.switch { display: inline-flex; align-items: center; width: 32px; height: 18px; border-radius: 9999px; background: var(--input); padding: 2px; flex-shrink: 0; transition: background-color var(--dur-fast); cursor: pointer; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch .thumb { width: 14px; height: 14px; border-radius: 9999px; background: #fff; transition: transform var(--dur-fast) var(--ease-out); }
.switch[aria-checked="true"] .thumb { transform: translateX(14px); }
.switch[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.switch-row { display: flex; align-items: flex-start; gap: var(--s-3); }
.switch-row .switch { margin-top: 1px; }
.switch-text { display: grid; gap: 2px; }
.switch-text label { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; }
.switch-text .desc { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--muted-foreground); }

.check { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--input); background: var(--card); flex-shrink: 0; }
.check[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.check .od-icon { --od-icon-size: 12px; }
.check-row { display: flex; align-items: center; gap: var(--s-2); }
.radio { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 9999px; border: 1px solid var(--input); background: var(--card); flex-shrink: 0; }
.radio[aria-checked="true"] { border-color: var(--primary); }
.radio[aria-checked="true"]::after { content: ""; width: 8px; height: 8px; border-radius: 9999px; background: var(--primary); }
.radio-row { display: flex; align-items: flex-start; gap: var(--s-2); }
.radio-row .radio { margin-top: 2px; }
.radio-row[aria-disabled="true"] { opacity: 0.5; }
.radio-text { display: grid; gap: 2px; }
.radio-text .lbl { font-weight: 500; }

/* Tooltip (shown on hover, focus and when forced open with .tip-open) */
.tip { position: relative; display: inline-flex; }
.tip-bubble {
  position: absolute; z-index: 30; left: 0; top: calc(100% + 6px);
  background: var(--foreground); color: var(--background);
  font-size: var(--text-xs); line-height: var(--lh-xs); padding: 6px var(--s-2);
  border-radius: var(--radius-md); max-width: 280px; width: max-content; white-space: normal;
  display: none; pointer-events: none;
}
.tip-bubble.right { left: auto; right: 0; }
.tip-bubble.up { top: auto; bottom: calc(100% + 6px); }
/* Hidden bubbles are removed from layout so they never add scrollable overflow inside a pane */
.tip:hover .tip-bubble, .tip:focus-within .tip-bubble, .tip.tip-open .tip-bubble { display: block; animation: tip-in var(--dur-fast) var(--ease-out); }
@keyframes tip-in { from { opacity: 0; } to { opacity: 1; } }

/* Skeleton */
.skel { display: block; border-radius: var(--radius-sm); background: color-mix(in oklab, var(--muted) 85%, var(--border)); height: 14px; position: relative; overflow: hidden; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.6), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel.h-20 { height: 20px; } .skel.h-28 { height: 28px; } .skel.h-36 { height: 36px; } .skel.w-40 { width: 40%; } .skel.w-60 { width: 60%; } .skel.w-80 { width: 80%; } .skel.w-24px { width: 24px; }
.skel-rows { display: grid; gap: var(--s-3); }
.skel-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 0.8fr; gap: var(--s-4); align-items: center; height: 36px; border-bottom: 1px solid var(--border); }
.skel-row:last-child { border-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } .tip-bubble { animation: none !important; } * { transition-duration: 0.01ms !important; } }

/* Metric tile */
.tile {
  display: grid; grid-template-rows: auto auto auto; gap: 2px;
  min-height: 108px; padding: var(--s-4); border-radius: var(--radius-xl);
  border: 1px solid var(--border); background: var(--card); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  color: var(--foreground); text-align: left; transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
a.tile:hover { border-color: var(--primary); }
.tile-count { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile-label { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; }
.tile-qual { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--muted-foreground); }
.tile[data-state="unavailable"] { background: color-mix(in oklab, var(--warning) 10%, var(--card)); border-color: var(--warning); }
.tile[data-state="unavailable"] .tile-count { color: var(--muted-foreground); font-weight: 500; }
.tile[data-state="unavailable"] .tile-qual { color: var(--warning-foreground); font-weight: 500; }
.tile[data-state="zero"] .tile-count { color: var(--muted-foreground); }
.tile[data-state="empty"] { border-style: dashed; background: var(--muted); box-shadow: none; }
.tile[data-state="empty"] .tile-count { display: flex; align-items: center; }
.tile[data-state="empty"] .tile-empty-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 9999px; color: var(--primary); background: color-mix(in oklab, var(--primary) 10%, var(--card)); }
.tile[data-state="empty"] .tile-empty-mark .od-icon { --od-icon-size: 16px; }
.tile[data-state="empty"] .tile-label { color: var(--muted-foreground); }
.tile[data-state="loading"] { pointer-events: none; }
.tile .tile-badge { margin-top: var(--s-1); }
.tile-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-3); }

/* KPI strip: headline figures, distinct from the needs-attention tiles (which are work queues with deep links) */
.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
.kpi {
  display: grid; grid-template-rows: auto auto auto; align-content: start; gap: var(--s-1);
  min-height: 96px; padding: var(--s-4) var(--s-4) var(--s-3); border-radius: var(--radius-xl);
  border: 1px solid var(--border); background: var(--card); box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  color: var(--foreground); text-align: left; min-width: 0;
}
a.kpi { transition: border-color var(--dur-fast); }
a.kpi:hover { border-color: var(--primary); }
.kpi-label { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; color: var(--muted-foreground); }
.kpi-value { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: proportional-nums; overflow-wrap: break-word; }
.kpi-value .unit { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; color: var(--muted-foreground); margin-left: 4px; letter-spacing: 0; }
.kpi-qual { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--muted-foreground); overflow-wrap: break-word; }
.kpi[data-state="zero"] .kpi-value { color: var(--muted-foreground); }
.kpi[data-state="unavailable"] { background: color-mix(in oklab, var(--warning) 10%, var(--card)); border-color: var(--warning); }
.kpi[data-state="unavailable"] .kpi-value { color: var(--muted-foreground); font-weight: 500; }
.kpi[data-state="unavailable"] .kpi-qual { color: var(--warning-foreground); font-weight: 500; }
.kpi[data-state="loading"] .kpi-value { display: flex; align-items: center; min-height: var(--lh-2xl); }

/* Chips (filters) */
.chip { display: inline-flex; align-items: center; gap: var(--s-1); height: 28px; padding: 0 var(--s-2) 0 var(--s-3); border-radius: 9999px; border: 1px solid var(--border); background: var(--card); font-size: var(--text-xs); line-height: var(--lh-xs); font-weight: 500; white-space: nowrap; }
.chip .k { color: var(--muted-foreground); font-weight: 400; }
.chip .x { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 9999px; color: var(--muted-foreground); }
.chip .x:hover { background: var(--accent); color: var(--foreground); }
.chip .x .od-icon { --od-icon-size: 12px; }
.chip-scope { border-color: var(--primary); background: color-mix(in oklab, var(--primary) 8%, var(--card)); color: var(--foreground); height: 28px; }
.chip-scope .k { color: var(--muted-foreground); }

/* Dialog + Sheet */
.overlay { position: absolute; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 120px var(--s-4) var(--s-4); }
.dialog { width: 100%; max-width: 480px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 20px 48px rgb(0 0 0 / 0.2); display: grid; gap: var(--s-4); padding: var(--s-6); position: relative; }
.dialog-title { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: 600; }
.dialog-desc { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--muted-foreground); }
.dialog-close { position: absolute; right: var(--s-3); top: var(--s-3); }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
.sheet-overlay { position: absolute; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 40; }
.sheet { position: absolute; top: 0; bottom: 0; right: 0; width: min(100%, 320px); background: var(--card); border-left: 1px solid var(--border); z-index: 41; display: grid; grid-template-rows: auto minmax(0,1fr) auto; box-shadow: -8px 0 32px rgb(0 0 0 / 0.15); }
.sheet.bottom { top: auto; left: 0; right: 0; width: 100%; max-height: 70%; border-left: 0; border-top: 1px solid var(--border); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: 0 -8px 32px rgb(0 0 0 / 0.15); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-4); border-bottom: 1px solid var(--border); }
.sheet-body { overflow-y: auto; padding: var(--s-2) 0; }
.sheet-foot { border-top: 1px solid var(--border); padding: var(--s-3) var(--s-4); display: grid; gap: var(--s-2); }

/* Toast */
.toast { position: absolute; right: var(--s-6); bottom: var(--s-6); z-index: 35; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s-3) var(--s-4); box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); display: grid; gap: 2px; min-width: 200px; }
.toast .t { font-weight: 500; }
.toast .d { color: var(--muted-foreground); }

/* =====================================================================
   Application shell
   ===================================================================== */
.app { position: relative; display: grid; grid-template-rows: auto auto 1fr; min-height: 900px; background: var(--background); color: var(--foreground); font-size: var(--text-sm); line-height: var(--lh-sm); }
.app.phone { min-height: 812px; width: 375px; }
.app.auth { grid-template-rows: 1fr; }

.header { display: flex; align-items: center; gap: var(--s-4); height: var(--header-h); padding: 0 var(--s-6); background: var(--primary); border-bottom: 1px solid var(--primary); color: var(--primary-foreground); }
.app.phone .header { padding: 0 var(--s-4); gap: var(--s-2); }
.wordmark { font-weight: 600; font-size: var(--text-base); line-height: var(--lh-base); border-radius: var(--radius-sm); padding: 2px 4px; margin-left: -4px; white-space: nowrap; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.header .username { font-size: var(--text-sm); line-height: var(--lh-sm); padding: 0 var(--s-2); }

.scope { position: relative; }
.scope-btn { display: inline-flex; align-items: center; gap: var(--s-2); height: 36px; min-width: 260px; max-width: 360px; padding: 0 var(--s-3); border-radius: var(--radius-md); background: color-mix(in oklab, var(--primary) 80%, white); color: var(--primary-foreground); border: 1px solid color-mix(in oklab, var(--primary) 65%, white); text-align: left; }
.scope-btn:hover { background: color-mix(in oklab, var(--primary) 72%, white); }
.scope-btn .k { font-size: var(--text-xs); line-height: var(--lh-xs); opacity: 0.85; white-space: nowrap; }
.scope-btn .v { font-weight: 500; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-btn .od-icon { --od-icon-size: 16px; }
.scope-btn.failed { border-color: var(--warning); }
.scope-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 45; width: 360px; background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 12px 32px rgb(0 0 0 / 0.14); padding: var(--s-2); display: grid; gap: var(--s-1); }
.scope-pop .group { padding: var(--s-2) var(--s-2) var(--s-1); }
.scope-pop .opt { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: var(--s-2); border-radius: var(--radius-sm); text-align: left; }
.scope-pop .opt:hover { background: var(--accent); }
.scope-pop .opt[aria-selected="true"] { background: color-mix(in oklab, var(--primary) 8%, var(--card)); font-weight: 500; }
.scope-pop .opt .od-icon { --od-icon-size: 16px; color: var(--primary); margin-left: auto; }
.scope-pop .opt .meta { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); }
.scope-inline-err { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--primary-foreground); }

.notif { position: relative; }
.notif .count { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9999px; background: var(--card); color: var(--primary); font-size: 11px; line-height: 16px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.notif-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 45; width: 360px; background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 12px 32px rgb(0 0 0 / 0.14); display: grid; }
.notif-pop .head { display: flex; justify-content: space-between; align-items: center; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); font-weight: 500; }
.notif-pop .item { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.notif-pop .item:last-child { border-bottom: 0; }

/* Guard banner */
.guard { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-6); border-bottom: 1px solid var(--border); font-size: var(--text-sm); line-height: var(--lh-sm); }
.guard .od-icon { --od-icon-size: 16px; flex: none; }
.guard-pending { background: color-mix(in oklab, var(--primary) 8%, var(--card)); border-color: var(--primary); }
.guard-unknown { background: color-mix(in oklab, var(--destructive) 8%, var(--card)); border-color: var(--destructive); }
.guard-unsaved { background: color-mix(in oklab, var(--warning) 18%, var(--card)); border-color: var(--warning); }
.guard-fail { background: color-mix(in oklab, var(--destructive) 8%, var(--card)); border-color: var(--destructive); }
.guard-empty { display: none; }

/* Body: sidebar + main */
.body { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 0; }
.app.phone .body { grid-template-columns: minmax(0, 1fr); }
.sidebar { background: var(--card); border-right: 1px solid var(--border); padding: var(--s-4) var(--s-3); display: grid; align-content: start; gap: var(--s-5); }
.nav-group { display: grid; gap: 2px; }
.nav-group .eyebrow { padding: 0 var(--s-3) var(--s-1); }
.nav-item { display: flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3); border-radius: var(--radius-md); color: var(--foreground); font-weight: 500; }
.nav-item:hover { background: var(--accent); }
.nav-item .od-icon { color: var(--muted-foreground); }
.nav-item[aria-current="page"] { background: color-mix(in oklab, var(--primary) 10%, var(--card)); color: var(--primary); }
.nav-item[aria-current="page"] .od-icon { color: var(--primary); }
.nav-item[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.nav-item .badge { margin-left: auto; }
.sidebar.locked .nav-item { opacity: 0.5; pointer-events: none; }
.header.locked .btn-signout { opacity: 0.5; pointer-events: none; }
.header.locked .scope-btn { opacity: 0.5; pointer-events: none; }

/* The content column never grows past its track: wide tables scroll inside their card instead of pushing the page past the frame */
.main { padding: var(--s-6); display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--s-5); min-width: 0; }
.main > * { min-width: 0; }
.card { min-width: 0; }
.app.phone .main { padding: var(--s-4); gap: var(--s-4); }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--muted-foreground); }
.breadcrumb a { border-radius: var(--radius-sm); }
.breadcrumb a:hover { color: var(--foreground); text-decoration: underline; text-underline-offset: 4px; }
.breadcrumb .sep { color: var(--border); padding: 0 2px; }
.breadcrumb .cur { color: var(--foreground); font-weight: 500; }
.page-head { display: grid; gap: var(--s-2); }
.page-head .title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); }
.page-head .title-row .lhs { display: grid; gap: var(--s-1); min-width: 0; }
.page-head .title-row .rhs { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.page-head .title-line { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.page-head .scope-line { display: flex; align-items: center; gap: var(--s-2); color: var(--muted-foreground); }
.app.phone .page-head .title-row { flex-direction: column; align-items: stretch; }

/* Filter bar */
.filterbar { display: grid; gap: var(--s-3); }
.filterbar .controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.filterbar .controls .input-wrap { width: 260px; }
.filterbar .controls .select { width: 200px; }
.filterbar .controls .select.sm { width: 160px; }
.filterbar .toggle { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; white-space: nowrap; }
.filterbar .chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); color: var(--muted-foreground); }
.pager { display: flex; align-items: center; gap: var(--s-1); }
.pager .pg { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 var(--s-2); border-radius: var(--radius-md); border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.pager .pg:hover { background: var(--accent); }
.pager .pg[aria-current="page"] { border-color: var(--border); background: var(--card); font-weight: 500; }
.pager .pg[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* Record layout */
.record { display: grid; grid-template-columns: minmax(0, 1fr) var(--inspector-w); gap: var(--s-5); align-items: start; }
.record .col { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); min-width: 0; }
.app.phone .record { grid-template-columns: minmax(0, 1fr); }
.actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* Review layout */
/* Review workspace: a fixed-height split. The document pane and the review panel each scroll inside their own pane;
   the blockers summary and footer stay pinned under the review panel. */
.review { display: grid; grid-template-columns: minmax(0, 55fr) minmax(0, 45fr); grid-template-rows: minmax(0, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); overflow: hidden; height: 720px; }
.doc-pane { border-right: 1px solid var(--border); display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--muted); min-height: 0; }
.doc-toolbar { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); background: var(--card); }
.doc-toolbar .pages { margin: 0 var(--s-2); font-variant-numeric: tabular-nums; color: var(--muted-foreground); }
.doc-canvas { padding: var(--s-6); display: grid; place-items: start center; overflow: hidden auto; overscroll-behavior: contain; min-height: 0; min-width: 0; }
.doc-page { width: 100%; max-width: 520px; aspect-ratio: 8.5 / 11; background: var(--card); border: 1px solid var(--border); box-shadow: 0 2px 8px rgb(0 0 0 / 0.08); padding: 36px 32px; display: grid; gap: var(--s-3); align-content: start; font-size: 11px; line-height: 15px; color: var(--muted-foreground); position: relative; }
.doc-page .doc-h { display: flex; justify-content: space-between; font-weight: 600; color: var(--foreground); font-size: 12px; }
.doc-page .doc-line { display: grid; grid-template-columns: 1fr auto; gap: var(--s-4); padding: 3px 4px; border-radius: 2px; }
.doc-page .doc-line.hl { background: color-mix(in oklab, var(--primary) 14%, var(--card)); outline: 2px solid var(--primary); color: var(--foreground); }
.doc-page .doc-rule { border-top: 1px solid var(--border); margin: var(--s-2) 0; }
.review-pane { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; min-height: 0; min-width: 0; }
.review-tabs { display: flex; gap: var(--s-4); padding: 0 var(--s-5); border-bottom: 1px solid var(--border); }
.review-tabs .tab { height: 40px; display: inline-flex; align-items: center; color: var(--muted-foreground); font-weight: 500; position: relative; border-radius: var(--radius-sm); }
.review-tabs .tab[aria-selected="true"] { color: var(--primary); }
.review-tabs .tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.review-body { padding: var(--s-5); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); align-content: start; overflow: hidden auto; overscroll-behavior: contain; min-height: 0; min-width: 0; }
.review-body > * { min-width: 0; }
.review-body .row-item .r .od-row { flex-wrap: wrap; justify-content: flex-end; }
.review-body .kv.row { grid-template-columns: minmax(0, 8rem) minmax(0, 1fr); }
.review-body .kv dd, .review-body .kv dt { min-width: 0; overflow-wrap: break-word; }
.review-body .row-item { grid-template-columns: minmax(0, 1fr) fit-content(55%); }
.review-foot { flex-wrap: wrap; }
.review-foot .od-row { flex-wrap: wrap; justify-content: flex-end; }
.blockers { border-top: 1px solid var(--warning); background: color-mix(in oklab, var(--warning) 18%, var(--card)); padding: var(--s-3) var(--s-5); display: grid; gap: var(--s-1); }
.blockers .t { font-weight: 500; }
.blockers li { display: flex; align-items: flex-start; gap: var(--s-2); min-width: 0; }
.blockers li a, .blockers li span { min-width: 0; overflow-wrap: break-word; }
.blockers li .od-icon { flex: none; margin-top: 3px; }
.blockers li .od-icon { --od-icon-size: 14px; color: var(--warning-foreground); }
.review-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); background: var(--card); }
.flag-card { display: grid; gap: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s-3); }
.flag-card .head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.evidence { display: grid; gap: 2px; padding: var(--s-2) var(--s-3); background: var(--muted); border-radius: var(--radius-sm); font-size: var(--text-xs); line-height: var(--lh-xs); }
.evidence .cmp { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--foreground); font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.evidence { min-width: 0; }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-5); align-items: start; }
.dash-grid .col { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); min-width: 0; }
.rows { display: grid; }
.row-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2) var(--s-4); align-items: center; padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-item .l1 { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s-2); min-width: 0; }
.row-item .l1 .name { font-weight: 500; }
.row-item .l2 { display: flex; flex-wrap: wrap; gap: 2px var(--s-2); color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); }
.row-item .r { display: grid; justify-items: end; gap: 2px; text-align: right; }
.row-item .r .amt { font-variant-numeric: tabular-nums; font-weight: 500; }
.row-item .dot { color: var(--border); }
.sub-group { display: grid; gap: var(--s-1); padding-top: var(--s-3); }
.sub-group .eyebrow { padding-bottom: 2px; }
.amounts3 { display: grid; grid-template-columns: repeat(3, auto); gap: var(--s-4); font-variant-numeric: tabular-nums; font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--muted-foreground); }
.amounts3 .v { color: var(--foreground); font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; }
.asof { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--muted-foreground); font-variant-numeric: tabular-nums; font-size: var(--text-sm); line-height: var(--lh-sm); }
.bbs { display: grid; gap: var(--s-2); }
.bbs .bbs-row { display: grid; grid-template-columns: minmax(0, 8rem) minmax(0,1fr); gap: var(--s-3); font-size: var(--text-sm); line-height: var(--lh-sm); }
.bbs .bbs-row .k { color: var(--muted-foreground); }
.bbs .bbs-row .v { font-variant-numeric: tabular-nums; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); }
.bbs .bbs-row .rev { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); }
/* Phone record: stacked rows instead of five-column tables, which cannot fit 375px without a horizontal scroll */
.prow { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.prow:last-child { border-bottom: 0; }
.prow .pname { font-weight: 500; }
.prow .pmeta { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); display: flex; flex-wrap: wrap; gap: 2px var(--s-2); }
.prow .pright { display: grid; justify-items: end; gap: 2px; text-align: right; }

/* Phone-specific */
.app.phone .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.app.phone .kpi { min-height: 84px; padding: var(--s-3); border-radius: var(--radius-lg); }
.app.phone .kpi-value { font-size: 20px; line-height: 28px; }
.app.phone .tile-strip { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); overflow: hidden; }
.app.phone .tile { min-height: 56px; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto; align-items: center; gap: var(--s-3); border: 0; border-radius: 0; border-bottom: 1px solid var(--border); box-shadow: none; padding: var(--s-3) var(--s-4); }
.app.phone .tile:last-child { border-bottom: 0; }
.app.phone .tile-count { font-size: var(--text-lg); line-height: var(--lh-lg); min-width: 2.5ch; text-align: right; }
.app.phone .tile .texts { display: grid; gap: 0; min-width: 0; }
.app.phone .tile .chev { color: var(--muted-foreground); --od-icon-size: 16px; }
.app.phone .tile[data-state="unavailable"] { background: color-mix(in oklab, var(--warning) 10%, var(--card)); }
.acc { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); overflow: hidden; }
.acc summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-4); min-height: 48px; font-weight: 600; font-size: var(--text-base); line-height: var(--lh-base); cursor: pointer; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary .od-icon { --od-icon-size: 16px; color: var(--muted-foreground); transition: transform var(--dur-fast); }
.acc[open] summary .od-icon { transform: rotate(180deg); }
.acc summary .count { color: var(--muted-foreground); font-weight: 500; font-size: var(--text-sm); margin-left: var(--s-2); }
.acc .acc-body { border-top: 1px solid var(--border); padding: var(--s-2) var(--s-4) var(--s-4); display: grid; gap: var(--s-2); }
.pcard { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--s-1) var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); min-height: 56px; }
.pcard .pname { font-weight: 500; }
.pcard .pmeta { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); display: flex; flex-wrap: wrap; gap: 2px var(--s-2); }
.pcard .pright { display: grid; justify-items: end; gap: 2px; }
.pcard .chev { color: var(--muted-foreground); --od-icon-size: 16px; }
.pcard-list { display: grid; gap: var(--s-2); }
.phone-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.menu-item { display: flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4); font-weight: 500; }
.menu-item:hover { background: var(--accent); }
.menu-item .od-icon { color: var(--muted-foreground); }
.menu-item[aria-current="page"] { color: var(--primary); background: color-mix(in oklab, var(--primary) 8%, var(--card)); }
.menu-item[aria-current="page"] .od-icon { color: var(--primary); }
.menu-item .badge { margin-left: auto; }
.menu-item.desktop-only { color: var(--muted-foreground); }

/* Sign-in */
.auth-wrap { display: grid; place-items: center; padding: var(--s-12) var(--s-4); min-height: 100%; align-content: center; }
.auth-stack { display: grid; gap: var(--s-6); width: 100%; max-width: 400px; justify-items: center; }
.auth-wordmark { font-weight: 600; font-size: var(--text-lg); line-height: var(--lh-lg); color: var(--foreground); }
.auth-stack .card { width: 100%; }
.app.phone .auth-wrap { padding: var(--s-8) var(--s-4); align-content: start; }
.app.phone .auth-stack { max-width: none; }

/* Denied / desktop-only full-page */
.center-card { display: grid; place-items: center; padding: var(--s-12) var(--s-4); }
.center-card .card { max-width: 480px; width: 100%; }

/* =====================================================================
   Design board chrome (review surface for the frames, not product UI)
   ===================================================================== */
.board { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.board-index { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--card); border-right: 1px solid var(--border); padding: var(--s-5) var(--s-4); display: grid; gap: var(--s-5); align-content: start; }
.board-index h1 { font-size: var(--text-base); line-height: var(--lh-base); }
.board-index .sub { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); }
.idx-group { display: grid; gap: 2px; }
.idx-group .eyebrow { padding: 0 var(--s-2) var(--s-1); }
.idx-link { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 28px; padding: 4px var(--s-2); border-radius: var(--radius-md); font-size: var(--text-sm); line-height: var(--lh-sm); }
.idx-link:hover { background: var(--accent); }
.idx-link.active { background: color-mix(in oklab, var(--primary) 10%, var(--card)); color: var(--primary); font-weight: 500; }
.idx-link .w { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); font-variant-numeric: tabular-nums; }
.board-main { padding: var(--s-6); display: grid; gap: var(--s-10); align-content: start; min-width: 0; }
.board-intro { display: grid; gap: var(--s-2); max-width: 72ch; }
.board-intro h1 { font-size: var(--text-2xl); line-height: var(--lh-2xl); }
.frame { display: grid; gap: var(--s-3); scroll-margin-top: var(--s-6); }
.frame-head { display: grid; gap: var(--s-2); }
.frame-name { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.frame-name h2 { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: 600; }
.frame-name .w { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); font-variant-numeric: tabular-nums; }
.annot { display: flex; flex-wrap: wrap; gap: var(--s-2); font-size: var(--text-xs); line-height: var(--lh-xs); }
.annot .a { display: inline-flex; align-items: flex-start; gap: var(--s-1); padding: 3px var(--s-2); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); color: var(--foreground); max-width: 100%; }
.annot .a.refs { color: var(--muted-foreground); }
.annot .a.open { border-color: var(--warning); background: color-mix(in oklab, var(--warning) 18%, var(--card)); }
.annot .a.req { border-color: var(--primary); background: color-mix(in oklab, var(--primary) 8%, var(--card)); }
.annot .a .k { font-weight: 600; flex: none; }
.frame-canvas-wrap { width: 100%; overflow: hidden; }
.frame-canvas { width: var(--fw, 1440px); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); overflow: hidden; box-shadow: 0 8px 24px rgb(0 0 0 / 0.06); zoom: var(--fit, 1); }
.frame-canvas > .app { width: var(--fw, 1440px); }
.board-foot { color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); }
.play-btn { margin-left: var(--s-2); }
.idx-link .od-icon { color: var(--muted-foreground); }
.flows { display: grid; gap: var(--s-2); }
.flow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-1) var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.flow .steps { grid-column: 2; color: var(--muted-foreground); font-size: var(--text-xs); line-height: var(--lh-xs); }

/* Prototype mode: one frame at a time, every control swaps the frame in place */
.play-bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: var(--s-4); height: 48px; padding: 0 var(--s-4); background: var(--foreground); color: var(--background); }
.play-bar[hidden] { display: none; }
.play-bar .btn-ghost { color: var(--background); }
.play-bar .btn-ghost:hover { background: color-mix(in oklab, var(--foreground) 80%, white); color: var(--background); }
.play-bar .play-title { font-weight: 600; }
.play-bar .play-hint { margin-left: auto; font-size: var(--text-xs); line-height: var(--lh-xs); color: color-mix(in oklab, var(--background) 70%, transparent); }
body[data-mode="play"] .board { grid-template-columns: minmax(0, 1fr); }
body[data-mode="play"] .board-index, body[data-mode="play"] .board-intro, body[data-mode="play"] .frame-head { display: none; }
body[data-mode="play"] .frame:not(.playing) { display: none; }
body[data-mode="play"] .board-main { padding: var(--s-6) var(--s-6) var(--s-12); min-height: calc(100vh - 48px); background: color-mix(in oklab, var(--foreground) 6%, var(--background)); }
body[data-mode="play"] .frame-canvas-wrap { display: flex; justify-content: center; }
body[data-mode="play"] .frame-canvas { box-shadow: 0 16px 48px rgb(0 0 0 / 0.12); }
