/* ==========================================================================
   Omega Planners — internal tool
   Palette is taken from the Omega Planners brand: warm near-black chrome,
   brand gold #EABD23, warm paper content surfaces.
   Category hues are a validated categorical set (see --cat-* below) — they
   are the data marks and must not be re-picked casually.
   ========================================================================== */

:root {
  /* --- brand ink ------------------------------------------------------- */
  --ink-950: #12120e;
  --ink-900: #1a1913;
  --ink-800: #26251c;
  --ink-700: #38362a;
  --ink-600: #4d4a3a;
  --ink-500: #5d5a4d;   /* muted body text — 6.6:1 on paper */
  --ink-400: #85826f;
  --ink-300: #b3b0a0;

  /* --- brand gold ------------------------------------------------------ */
  --gold-300: #f2d867;
  --gold-500: #eabd23;  /* the mark's gold — 10.6:1 on ink */
  --gold-600: #c79e12;
  --gold-700: #8a6d08;  /* gold that is legible on paper — 4.7:1 */

  /* --- surfaces -------------------------------------------------------- */
  --paper: #fbfaf6;
  --card: #ffffff;
  --card-sunk: #f6f5ef;
  --line: #e7e4da;
  --line-soft: #f0eee6;

  /* --- category hues (validated categorical palette, fixed order) -------
     Two categories, validated all-pairs on this surface:
     CVD dE 24.7, normal-vision dE 33.6, both >= 3:1 contrast. */
  --cat-trust: #2a78d6;  --cat-trust-tint: #f1f4fb;  --cat-trust-ink: #2770c7;
  --cat-will: #eb6834;   --cat-will-tint: #fdf3f2;   --cat-will-ink: #b95129;

  /* --- status (reserved — never reused as a series colour) -------------- */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(18, 18, 14, .06), 0 1px 3px rgba(18, 18, 14, .04);
  --shadow-md: 0 4px 12px rgba(18, 18, 14, .06), 0 12px 32px rgba(18, 18, 14, .05);
  --shadow-lg: 0 24px 70px rgba(18, 18, 14, .22);
  --header-h: 72px;

  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
/* any class that sets `display` outranks the UA rule for [hidden]; .btn did,
   so hidden buttons were still painted */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
/* the closed drawer is parked past the right edge — clip it so it cannot
   widen the page. `clip` (unlike `hidden`) keeps position:sticky working. */
html, body { overflow-x: clip; }
@supports not (overflow: clip) { html, body { overflow-x: hidden; } }

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink-800);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); color: var(--ink-950); letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 .3rem; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }

a { color: var(--ink-950); text-decoration-color: color-mix(in srgb, var(--gold-600) 60%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold-600); }
a.plain, .card a.plain { text-decoration: none; }

.muted { color: var(--ink-500); }
.tiny { font-size: .74rem; color: var(--ink-500); line-height: 1.4; }
.small { font-size: .86rem; }
.mono { font-family: var(--font-mono); font-size: .78rem; letter-spacing: -.01em; }
.center { text-align: center; padding: 1.75rem; }
.stack > * + * { margin-top: .6rem; }

/* --- skip link ---------------------------------------------------------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--gold-500); color: var(--ink-950); padding: .6rem 1rem;
  font-weight: 700; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  background: var(--ink-950);
  color: #fff;
  position: sticky; top: 0; z-index: 30;
}
.site-header::after {
  /* One even gold rule, full width — no left-to-right fade.
     It sits on the header's bottom edge (spaced off the nav with margin-top,
     not padding underneath) so the glow spills onto the page below instead of
     onto 7px of dark, which is what made the boundary read as a hard cut. */
  content: ""; display: block; height: 2px; margin-top: 7px;
  background: var(--gold-500);
  box-shadow:
    0 0 7px rgba(234, 189, 35, .75),
    0 0 18px rgba(234, 189, 35, .45),
    0 0 38px rgba(234, 189, 35, .22);
}
.header-top {
  max-width: none; width: 100%; margin: 0; padding: .7rem 1.75rem;
  display: flex; align-items: center; gap: 1.5rem;
  box-sizing: border-box;
}
/* nav sits on the same row, between the mark and the menu button */
.header-nav { display: flex; align-items: center; gap: .15rem; flex: 1 1 auto; flex-wrap: wrap; min-width: 0; }

.brand { display: flex; align-items: center; gap: .7rem; color: #fff; flex: 0 0 auto; text-decoration: none; }
.brand:hover { text-decoration: none; }
/* the tree mark is a CSS mask, so one cached SVG inherits whatever colour
   its context sets — gold on the ink chrome, gold-700 on paper. */
.brand-mark {
  width: 38px; height: 38px; flex: none; color: var(--gold-500);
  background: currentColor;
  -webkit-mask: url(/static/omega-tree-glyph.svg) center / contain no-repeat;
          mask: url(/static/omega-tree-glyph.svg) center / contain no-repeat;
}
.brand-mark.is-detailed {
  -webkit-mask-image: url(/static/omega-tree-mark.svg);
          mask-image: url(/static/omega-tree-mark.svg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); color: #fff; font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.brand-text span { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-500); font-weight: 600; }

.header-nav a {
  color: rgba(255,255,255,.68); padding: .42rem .8rem; border-radius: 7px;
  font-size: .86rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.header-nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.header-nav a[aria-current="page"] { color: var(--ink-950); background: var(--gold-500); }
.header-nav-end { margin-left: auto; }

/* the drawer trigger sits after the nav, at the far right of the header */
.menu-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: .55rem;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16);
  color: #fff; border-radius: 999px; padding: .42rem .5rem .42rem .95rem;
  font: 600 .84rem var(--font-ui); cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.menu-btn:hover { background: rgba(255,255,255,.14); border-color: var(--gold-600); }
.menu-btn kbd {
  font: 600 .68rem var(--font-mono); background: rgba(255,255,255,.12);
  border-radius: 5px; padding: .15rem .4rem; color: var(--gold-300);
}
.menu-btn .bars { display: grid; gap: 3px; }
.menu-btn .bars i { display: block; width: 15px; height: 2px; background: var(--gold-500); border-radius: 2px; }

.header-who {
  flex: 0 1 auto; min-width: 0; max-width: 18rem;
  display: flex; flex-direction: row; align-items: center; gap: .5rem;
  justify-content: flex-end;
}
.header-who strong {
  font-size: .84rem; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.header-role {
  flex: none;
  display: inline-flex; align-items: center;
  padding: .18rem .5rem;
  border-radius: 999px;
  background: var(--gold-500); color: var(--ink-950);
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; line-height: 1.2;
}
.header-logout { flex: 0 0 auto; margin: 0; }
.header-logout-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.16);
  color: rgba(255,255,255,.86); border-radius: 999px;
  padding: .42rem .95rem; font: 600 .84rem var(--font-ui); cursor: pointer;
}
.header-logout-btn:hover {
  background: rgba(255,255,255,.1); border-color: var(--gold-600); color: #fff;
}

@media (max-width: 900px) {
  .header-top { flex-wrap: wrap; gap: .5rem 1rem; }
  .header-nav { order: 3; width: 100%; }
  .header-nav-end { margin-left: auto; }
}

/* ==========================================================================
   Slide-in command drawer (right)
   ========================================================================== */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(18, 18, 14, .45);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(420px, 92vw);
  background: var(--ink-950);
  color: #fff;
  transform: translateX(101%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column;
  box-shadow: -20px 0 60px rgba(0,0,0,.4);
  border-left: 1px solid var(--ink-800);
}
body.drawer-open .drawer { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-backdrop { transition: none; }
}

.drawer-head {
  padding: 1rem 1.1rem .85rem; border-bottom: 1px solid var(--ink-800);
  display: flex; align-items: center; gap: .7rem;
}
.drawer-head .brand-mark { width: 30px; height: 30px; }
.drawer-head strong { font-family: var(--font-display); font-size: .98rem; }
.drawer-head .tiny { color: var(--ink-300); }
.drawer-close {
  margin-left: auto; background: transparent; border: 1px solid rgba(255,255,255,.18);
  color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  font-size: 1rem; line-height: 1; display: grid; place-items: center;
}
.drawer-close:hover { background: rgba(255,255,255,.1); border-color: var(--gold-600); }

.drawer-body { overflow-y: auto; padding: 1rem 1.1rem 2rem; flex: 1; scrollbar-width: thin; }
.drawer-section + .drawer-section { margin-top: 1.5rem; padding-top: 1.3rem; border-top: 1px solid var(--ink-800); }
.drawer-section > h3 {
  font-family: var(--font-ui); font-size: .66rem; font-weight: 700; letter-spacing: .17em;
  text-transform: uppercase; color: var(--gold-500); margin: 0 0 .7rem;
}

.drawer-search { position: relative; }
.drawer-search input {
  width: 100%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.16);
  color: #fff; border-radius: 10px; padding: .6rem .8rem; font: inherit;
}
.drawer-search input::placeholder { color: var(--ink-400); }
.drawer-search input:focus { outline: 2px solid color-mix(in srgb, var(--gold-500) 55%, transparent); border-color: var(--gold-600); }
.drawer-results { margin-top: .5rem; display: grid; gap: 2px; }
.drawer-results a {
  display: grid; grid-template-columns: 4.4rem 1fr; gap: 0 .6rem; align-items: center;
  padding: .5rem .6rem; border-radius: 9px; color: #fff; text-decoration: none;
}
.drawer-results a:hover, .drawer-results a.is-active { background: rgba(255,255,255,.09); }
.drawer-results .k { font-size: .6rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-500); }
.drawer-results .l { font-weight: 600; font-size: .87rem; }
.drawer-results .m { grid-column: 2; font-size: .72rem; color: var(--ink-300); }
.drawer-hint { font-size: .74rem; color: var(--ink-400); margin: .5rem 0 0; }

/* verbose nav rows: label + what the page is actually for + a live count */
.nav-rows { display: grid; gap: 3px; }
.nav-row {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: .5rem .7rem;
  padding: .6rem .7rem; border-radius: 10px; color: #fff; text-decoration: none;
  border: 1px solid transparent;
}
.nav-row:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); text-decoration: none; }
.nav-row[aria-current="page"] { background: rgba(234,189,35,.12); border-color: rgba(234,189,35,.35); }
.nav-row b { font-size: .9rem; font-weight: 600; }
.nav-row .count {
  font: 600 .72rem var(--font-mono); color: var(--gold-500);
  background: rgba(234,189,35,.12); border-radius: 999px; padding: .1rem .5rem;
}
.nav-row small { grid-column: 1 / -1; font-size: .74rem; color: var(--ink-300); line-height: 1.4; }

.cat-rows { display: grid; gap: 2px; }
.cat-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem;
  padding: .45rem .7rem; border-radius: 9px; color: #fff; text-decoration: none; font-size: .86rem;
}
.cat-row:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.cat-row .swatch { width: 10px; height: 10px; border-radius: 3px; }
.cat-row .code { font: 600 .7rem var(--font-mono); color: var(--ink-300); }
.cat-row .count { font: 600 .74rem var(--font-mono); color: var(--gold-500); }

.drawer-actions { display: grid; gap: .4rem; }
.drawer-action {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 9px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12);
  color: #fff; text-decoration: none; font-size: .86rem; font-weight: 600;
}
.drawer-action:hover { background: rgba(234,189,35,.14); border-color: rgba(234,189,35,.4); text-decoration: none; }
.drawer-action .sym { color: var(--gold-500); font-size: 1rem; width: 1.1rem; text-align: center; }

.keys { display: grid; gap: .3rem; }
.keys div { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; color: var(--ink-300); }
.keys kbd {
  font: 600 .7rem var(--font-mono); background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.14); border-radius: 5px; padding: .1rem .4rem; color: #fff;
}

/* ==========================================================================
   Page shell
   ========================================================================== */
.wrap { max-width: 1240px; margin: 0 auto; padding: 1.9rem 1.5rem 4rem; }
.page-head {
  display: flex; justify-content: space-between; gap: 1.2rem; align-items: flex-start;
  flex-wrap: wrap; margin-bottom: 1.6rem;
}
.page-head h1 { margin-bottom: .25rem; }
.page-head .meta-line, .page-head p { margin: 0; max-width: 46rem; color: var(--ink-500); }
.page-head.client-head .meta-line, .page-head.client-head p { max-width: none; }
.page-head-wide { display: block; }
.page-head-wide > div { max-width: none; width: 100%; }
.page-head-wide p { max-width: none; }
.page-head-title {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem 1.5rem; width: 100%;
}
.page-head-title h1 { margin: 0; }
.page-head-wide .meta-line {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem 1.5rem; flex-wrap: wrap; max-width: none; width: 100%;
}
.portal-head.page-head-wide .meta-line {
  max-width: none !important; width: 100%;
}
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.id-tag {
  display: inline-block; padding: .12rem .5rem; font: 600 .74rem var(--font-mono);
  color: var(--ink-700); background: var(--card-sunk); border: 1px solid var(--line);
  border-radius: 6px; vertical-align: middle;
}
.block { margin-bottom: 1.75rem; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 1.25rem 1.35rem;
}
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.card-head h2 { margin: 0; }

a.card { display: block; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
a.card:hover { border-color: var(--gold-600); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }

/* stat strip — five numbers in one bar, not five cards */
.statbar {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 1.5rem;
}
.statbar-cell {
  position: relative; display: flex; flex-direction: column; gap: .1rem;
  padding: .75rem 1.1rem; text-decoration: none;
  border-left: 1px solid var(--line-soft);
  transition: background .15s ease;
}
.statbar-cell:first-child { border-left: 0; }
.statbar-cell:hover { background: var(--card-sunk); text-decoration: none; }
.statbar-cell::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--gold-500)); opacity: 0; transition: opacity .15s ease;
}
.statbar-cell:first-child::before, .statbar-cell:hover::before { opacity: 1; }
.statbar-cell .v {
  display: flex; align-items: baseline; gap: .4rem;
  font-family: var(--font-display); font-size: 1.55rem; line-height: 1.1;
  color: var(--ink-950); font-weight: 600; font-variant-numeric: tabular-nums;
}
.statbar-cell .v small { font-family: var(--font-ui); font-size: .74rem; font-weight: 600; color: var(--ink-400); }
.statbar-cell .k {
  display: flex; align-items: center; gap: .35rem;
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-500); font-weight: 700;
}
.statbar-cell .k::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent, var(--gold-500)); flex: none;
}
@media (max-width: 780px) {
  .statbar { grid-auto-flow: row; grid-template-columns: 1fr 1fr; grid-auto-columns: auto; }
  .statbar-cell { border-left: 0; border-top: 1px solid var(--line-soft); }
  .statbar-cell:nth-child(-n+2) { border-top: 0; }
  .statbar-cell:nth-child(odd) { border-right: 1px solid var(--line-soft); }
}

.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.15rem; align-items: start; }
.split-even { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.15rem; align-items: start; }
@media (max-width: 950px) { .split { grid-template-columns: 1fr; } }

/* ==========================================================================
   Charts — plain SVG/CSS, no libraries
   ========================================================================== */
.chart-note { font-size: .76rem; color: var(--ink-500); margin: 0 0 .9rem; }

/* horizontal category bars */
.barlist { display: grid; gap: .55rem; }
.barlist-row { display: grid; grid-template-columns: 8.5rem 1fr 3.2rem; gap: .7rem; align-items: center; }
.barlist-row .lbl { display: flex; align-items: center; gap: .45rem; font-size: .82rem; font-weight: 600; color: var(--ink-800); min-width: 0; }
.barlist-row .lbl .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.barlist-track { background: var(--card-sunk); border-radius: 5px; height: 20px; overflow: hidden; }
.barlist-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 3px; transition: width .4s ease; }
.barlist-row .num { font: 600 .82rem var(--font-mono); color: var(--ink-700); text-align: right; font-variant-numeric: tabular-nums; }
/* split fill: complete portion solid, open portion hatched — a 2px surface gap between */
.barlist-fill.is-split { display: flex; gap: 2px; background: transparent; }
.barlist-fill .seg-done { border-radius: 0; }
.barlist-fill .seg-open { border-radius: 0 4px 4px 0; opacity: .32; }

/* column chart (monthly trend) */
.colchart { display: block; width: 100%; height: auto; overflow: visible; }
.colchart .grid { stroke: var(--line); stroke-width: 1; }
.colchart .axis { fill: var(--ink-500); font: 500 10px var(--font-ui); }
.colchart .col rect { transition: opacity .15s ease; }
.colchart .col:hover rect { opacity: .78; }
.colchart .val { fill: var(--ink-700); font: 600 10px var(--font-mono); text-anchor: middle; }

.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line-soft); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--ink-600); font-weight: 600; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: block; }

/* agent workload table-in-card */
.mini-rows { display: grid; gap: .1rem; }
.mini-row { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: center; padding: .42rem 0; border-bottom: 1px solid var(--line-soft); font-size: .85rem; }
.mini-row:last-child { border-bottom: 0; }
.mini-row .n { font-weight: 600; color: var(--ink-800); text-decoration: none; }
.mini-row .bar { height: 6px; border-radius: 3px; background: var(--cat-trust); }
.mini-row .rt { display: flex; align-items: center; gap: .5rem; }
.mini-row .rt b { font: 600 .78rem var(--font-mono); color: var(--ink-600); min-width: 1.6rem; text-align: right; }

/* ==========================================================================
   Tables
   ========================================================================== */
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th {
  text-align: left; font-size: .67rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-500); font-weight: 700; padding: .7rem .6rem; border-bottom: 1px solid var(--line);
  background: var(--card-sunk); white-space: nowrap;
}
td { padding: .7rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: var(--card-sunk); }
tbody tr.has-incomplete td {
  background: color-mix(in srgb, var(--gold-500) 12%, var(--card));
}
tbody tr.has-incomplete td:first-child {
  box-shadow: inset 3px 0 0 var(--gold-600);
}
tbody tr.has-incomplete:hover td {
  background: color-mix(in srgb, var(--gold-500) 20%, var(--card));
}
tbody tr:last-child td { border-bottom: 0; }
.table-wrap { padding: 0; overflow-x: auto; }
.table-wrap th:first-child, .table-wrap td:first-child { padding-left: 1.2rem; }
.table-wrap th:last-child, .table-wrap td:last-child { padding-right: 1.2rem; }
.table-wrap th:first-child { border-top-left-radius: var(--radius); }
.table-wrap th:last-child { border-top-right-radius: var(--radius); }
th.num, td.num { text-align: right; }
td.num .warn-tag { margin-left: 0; }
table.is-nowrap th, table.is-nowrap td { white-space: nowrap; }
.cell-client { white-space: nowrap; }
.cell-client .cell-name { display: block; }
.cell-client .warn-tag,
.cell-client .quiet-tag { display: block; margin: .22rem 0 0; width: fit-content; }
.quiet-tag {
  font-size: .62rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-500); background: var(--card-sunk); border: 1px solid var(--line);
  border-radius: 999px; padding: .05rem .45rem;
}
.var-list { margin: .4rem 0 0; padding: 0; list-style: none; display: grid; gap: .28rem; }
.var-list code { font: 600 .76rem var(--font-mono); color: var(--gold-700); }

/* .NET-style column sort: dual chevron idle, gold on the active direction */
.sort-link {
  display: inline-flex; align-items: center; gap: .4rem;
  color: inherit; text-decoration: none; letter-spacing: inherit;
  text-transform: inherit; font: inherit; cursor: pointer;
}
.sort-link:hover { color: var(--ink-950); text-decoration: none; }
.sort-arrows {
  display: inline-flex; flex-direction: column; gap: 1px; flex: none;
}
.sort-arrows i {
  display: block; width: 0; height: 0;
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
}
.sort-arrows i:first-child { border-bottom: 4px solid var(--ink-300); }
.sort-arrows i:last-child { border-top: 4px solid var(--ink-300); }
.sort-link.is-asc .sort-arrows i:first-child { border-bottom-color: var(--gold-600); }
.sort-link.is-asc .sort-arrows i:last-child { opacity: .28; }
.sort-link.is-desc .sort-arrows i:last-child { border-top-color: var(--gold-600); }
.sort-link.is-desc .sort-arrows i:first-child { opacity: .28; }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--ink-800); }
.cell-name { font-weight: 600; color: var(--ink-950); text-decoration: none; }
.cell-name:hover { text-decoration: underline; text-decoration-color: var(--gold-600); }

/* ==========================================================================
   Product identity: category mark + English label
   ========================================================================== */
.ptype { display: inline-flex; flex-direction: column; gap: .15rem; min-width: 0; }
.ptype-main { display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.ptype-label { font-weight: 600; color: var(--ink-950); text-decoration: none; }
a.ptype-label:hover { text-decoration: underline; text-decoration-color: var(--gold-600); }
.cat-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.55rem; height: 1.55rem; flex: none;
  border-radius: 7px; font-size: .95rem; line-height: 1;
  background: var(--cat-tint);
  border: 1px solid color-mix(in srgb, var(--cat) 22%, transparent);
}
.ptype-code {
  font: 600 .68rem var(--font-mono); letter-spacing: -.02em;
  color: var(--ink-500); background: var(--card-sunk);
  border: 1px solid var(--line); border-radius: 5px; padding: .05rem .35rem;
  white-space: nowrap;
}
.ptype-code.is-unknown { border-style: dashed; color: var(--serious); }

/* category pill: tinted ground, saturated ink, colour dot — always carries text */
.cat-pill {
  display: inline-flex; align-items: center; gap: .38rem;
  padding: .12rem .5rem .12rem .42rem; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  background: var(--cat-tint); color: var(--cat-ink); border: 1px solid color-mix(in srgb, var(--cat) 22%, transparent);
  white-space: nowrap;
}
.cat-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat); flex: none; }
.cat-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .45rem; vertical-align: middle; background: var(--cat); }

/* the category custom-props, set once per category class */
.cat-trust { --cat: var(--cat-trust); --cat-tint: var(--cat-trust-tint); --cat-ink: var(--cat-trust-ink); }
.cat-will  { --cat: var(--cat-will);  --cat-tint: var(--cat-will-tint);  --cat-ink: var(--cat-will-ink); }

/* letter chips keep the category colour but now show code + label */
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-row-lg { margin: 0 0 1.25rem; }
.letter-chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .3rem .7rem .3rem .55rem; border-radius: 999px;
  background: var(--cat-tint); border: 1px solid color-mix(in srgb, var(--cat) 26%, transparent);
  color: var(--cat-ink); text-decoration: none; max-width: 100%;
}
.letter-chip:hover { text-decoration: none; border-color: var(--cat); background: color-mix(in srgb, var(--cat) 12%, var(--card)); }
.letter-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat); flex: none; }
.letter-chip-name { font-weight: 600; font-size: .82rem; color: var(--ink-950); }
.letter-chip-code { font: 600 .66rem var(--font-mono); color: var(--cat-ink); opacity: .85; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: 9px; padding: .5rem 1rem; font: 600 .84rem var(--font-ui);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .12s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--gold-600); outline-offset: 2px; }

.btn.primary { background: var(--ink-950); color: #fff; border-color: var(--ink-950); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--ink-800); box-shadow: var(--shadow-md); }
.btn.gold { background: var(--gold-500); color: var(--ink-950); border-color: var(--gold-500); box-shadow: var(--shadow-sm); }
.btn.gold:hover { background: var(--gold-600); }
.btn.ghost { background: transparent; color: var(--ink-800); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink-400); background: var(--card-sunk); }
/* ghost buttons on the dark drawer/header: the light hover ground would make
   the white label unreadable, so they get a dark hover instead */
.btn.on-dark {
  background: transparent; color: #fff;
  border-color: rgba(255, 255, 255, .3); box-shadow: none;
}
.btn.on-dark:hover {
  background: rgba(255, 255, 255, .14);
  border-color: var(--gold-500); color: #fff;
}
.btn.secondary { background: var(--card); color: var(--ink-800); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { border-color: var(--ink-400); }
.btn.danger { background: var(--critical); color: #fff; border-color: var(--critical); }
.btn.danger:hover { background: #b62f2f; }
.btn.success { background: var(--good); color: #fff; border-color: var(--good); }
.btn.success:hover { background: #0a8c0a; }
.btn.warning { background: var(--warning); color: var(--ink-950); border-color: var(--warning); }
.btn.warning:hover { background: #e5a00f; }
.btn.info { background: var(--cat-trust); color: #fff; border-color: var(--cat-trust); }
.btn.info:hover { background: #2268bd; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; border-radius: 7px; }

/* segmented filter control */
.segmented { display: inline-flex; background: var(--card-sunk); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented a {
  padding: .32rem .8rem; border-radius: 7px; font-size: .81rem; font-weight: 600;
  color: var(--ink-600); text-decoration: none;
}
.segmented a:hover { background: var(--card); text-decoration: none; }
.segmented a[aria-current="true"] { background: var(--ink-950); color: #fff; box-shadow: var(--shadow-sm); }

/* ==========================================================================
   Badges / banners
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px;
  padding: .16rem .6rem; font-size: .73rem; font-weight: 700; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.open { background: #fff8e8; color: #8a5a00; border-color: #f3ddab; }
.badge.done { background: #eefbee; color: #16640f; border-color: #b9e5b5; }

.banner {
  border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1.2rem; font-size: .88rem;
  border: 1px solid transparent; display: flex; align-items: flex-start; gap: .6rem;
}
.banner::before { font-weight: 700; }
.banner.ok { background: #eefbee; color: #16640f; border-color: #b9e5b5; }
.banner.ok::before { content: "✓"; }
.banner.err { background: #fdf1f1; color: #97231f; border-color: #f2c4c2; }
.banner.err::before { content: "!"; }

/* ==========================================================================
   Forms
   ========================================================================== */
.omega-input, select.omega-input, textarea.omega-input {
  width: 100%; border: 1px solid color-mix(in srgb, var(--ink-950) 10%, var(--line));
  border-radius: 9px;
  padding: .55rem .75rem; font: inherit; font-size: .9rem;
  color: var(--ink-900); background: var(--card-sunk);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.omega-input:hover { border-color: var(--ink-300); }
.omega-input:focus {
  outline: none; border-color: var(--gold-600); background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-500) 24%, transparent);
}
.omega-input[type="date"]::-webkit-datetime-edit,
.omega-input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  background: transparent;
}
.locked { background: color-mix(in srgb, var(--ink-950) 5%, var(--card-sunk)); color: var(--ink-500); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 860px; }
.form-grid label { display: block; font-size: .78rem; font-weight: 700; color: var(--ink-600); letter-spacing: .04em; text-transform: uppercase; }
.form-grid label .omega-input, .form-grid label .wysiwyg { margin-top: .35rem; text-transform: none; letter-spacing: normal; }
.form-grid .span-2 { grid-column: 1 / -1; }

.product-pick {
  border: 0; margin: 0; padding: 0; min-width: 0;
}
.product-pick legend {
  font-size: .78rem; font-weight: 700; color: var(--ink-600);
  letter-spacing: .04em; text-transform: uppercase; padding: 0;
}
.product-pick .muted { margin: .35rem 0 .55rem; text-transform: none; letter-spacing: normal; }
.product-radios { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .75rem; }
.format-json {
  margin: 0; padding: 1rem 1.1rem; overflow: auto; max-height: 32rem;
  font: 500 .78rem/1.45 var(--font-mono); color: var(--ink-800);
  background: var(--card-sunk); border-radius: 8px; white-space: pre-wrap;
}
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.plain-list li { padding-bottom: .65rem; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.form-grid label.product-radio {
  display: block; margin: 0; cursor: pointer;
  font-size: inherit; font-weight: 500; letter-spacing: normal; text-transform: none; color: inherit;
}
.product-radio input {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.product-radio-card {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .85rem 1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.product-radio-card .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--cat);
  margin-top: .35rem; flex: none;
}
.product-radio-copy { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.product-radio-copy strong {
  font-size: .95rem; font-weight: 650; color: var(--ink-900);
}
.product-radio-copy .code {
  font: 600 .72rem var(--font-mono); color: var(--ink-500);
}
.product-radio:hover .product-radio-card { border-color: var(--cat); }
.product-radio input:checked + .product-radio-card {
  border-color: var(--cat);
  background: var(--cat-tint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat) 22%, transparent);
}
.product-radio input:focus-visible + .product-radio-card {
  outline: 2px solid var(--gold-600); outline-offset: 2px;
}
@media (max-width: 720px) { .product-radios { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid label.check-row {
  display: flex; align-items: flex-start; gap: .7rem;
  font-size: .9rem; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--ink-800); cursor: pointer; padding: .15rem 0 .1rem;
}
.form-grid label.check-row input[type="checkbox"] {
  width: 1.1rem; height: 1.1rem; margin: .2rem 0 0; flex: none;
  accent-color: var(--gold-600); cursor: pointer;
}
.form-grid label.check-row > span { display: block; line-height: 1.4; }
.form-grid label.check-row strong {
  display: block; font-size: .9rem; font-weight: 700; color: var(--ink-900);
}
.form-grid label.check-row > span > span {
  display: block; color: var(--ink-500); font-size: .84rem; font-weight: 500;
}
.form-grid .joint-fields { display: none; }
.form-grid:has(input[name="is_joint"]:checked) .joint-fields { display: block; }
.form-grid .spouse-scope {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-top: .15rem; padding: 1rem 1.15rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--gold-500) 38%, var(--line));
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fbf6e4 0%, var(--card) 5.5rem);
}
.form-grid .spouse-scope .span-2 { grid-column: 1 / -1; }
.form-grid label.check-row.spouse-toggle strong {
  font-size: 1.05rem; font-weight: 700; color: var(--ink-950); letter-spacing: -.01em;
  text-transform: none;
}
.form-grid .spouse-fields { display: none; }
.form-grid:has(input[name="has_spouse"]:checked) .spouse-fields { display: block; }
.form-layout [data-spouse-scan] { display: none; }
.form-layout:has(input[name="has_spouse"]:checked) [data-spouse-scan] { display: block; }
@media (max-width: 720px) { .form-grid .spouse-scope { grid-template-columns: 1fr; } }
.inline-search { margin-bottom: 1.1rem; max-width: 30rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 1.2rem 0 .6rem; }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; margin: 0; }
.danger-zone { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.meta { display: grid; grid-template-columns: 9rem 1fr; gap: .45rem .9rem; margin: 0; }
.meta dt { color: var(--ink-500); font-size: .78rem; font-weight: 600; }
.meta dd { margin: 0; font-size: .88rem; }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1.1rem; background: #fff; box-shadow: var(--shadow-sm); }

/* ==========================================================================
   Login
   ========================================================================== */
.login-body {
  min-height: 100vh; margin: 0;
  display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--ink-950); color: #fff;
}
@media (max-width: 880px) { .login-body { grid-template-columns: 1fr; } .login-aside { display: none; } }

.login-aside {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  padding: 2.6rem 3rem;
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(234,189,35,.14), transparent 55%),
    radial-gradient(90% 80% at 100% 100%, rgba(234,189,35,.08), transparent 60%),
    var(--ink-950);
  border-right: 1px solid var(--ink-800);
}
/* the tree, very large and low-contrast, as the ground of the panel */
.login-tree {
  position: absolute; right: -4%; bottom: -6%; width: 62%; max-width: 460px;
  aspect-ratio: 1; color: var(--gold-500); opacity: .16; pointer-events: none;
  background: currentColor;
  -webkit-mask: url(/static/omega-tree-mark.svg) center / contain no-repeat;
          mask: url(/static/omega-tree-mark.svg) center / contain no-repeat;
}

.login-aside > *:not(.login-tree) { position: relative; z-index: 1; }
.login-placeholder {
  flex: 1 1 auto;
  width: 100%;
  min-height: clamp(8rem, 36vh, 100%);
  border: 1.5px dashed color-mix(in srgb, var(--gold-500) 55%, var(--ink-700));
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(234, 189, 35, .045) 0 14px,
      rgba(234, 189, 35, .09) 14px 28px
    );
  display: grid;
  place-items: center;
  color: var(--ink-400);
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 600;
}
.login-lockup { display: flex; align-items: center; gap: .9rem; }
.login-lockup .brand-mark { width: 56px; height: 56px; color: var(--gold-500); }
.login-lockup strong { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; display: block; line-height: 1.1; }
.login-lockup span { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-500); font-weight: 600; }

.login-pitch { max-width: 30rem; }
.login-pitch h2 {
  font-family: var(--font-display); color: #fff;
  font-size: clamp(1.4rem, 2.1vw, 1.85rem); line-height: 1.25;
  font-weight: 400; margin: 0 0 .9rem;
}
.login-pitch h2 em { font-style: normal; color: var(--gold-500); }
.login-pitch p { color: var(--ink-300); font-size: .92rem; margin: 0; }
.login-facts { display: flex; gap: 1.6rem 2rem; margin-top: 1.5rem; flex-wrap: wrap; }
.login-facts div b { display: block; font-family: var(--font-display); font-size: 1.15rem; color: var(--gold-500); line-height: 1.15; }
.login-facts div span { font-size: .7rem; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-400); font-weight: 600; }
.login-foot { font-size: .74rem; color: var(--ink-400); }

.login-main { display: grid; place-items: center; padding: 2.5rem 1.5rem; background: var(--paper); }
.login-card { width: min(400px, 100%); }
.login-card.is-wide { width: min(560px, 100%); }
.login-card.is-wide .form-grid { margin-top: .4rem; }
.login-card > .brand-mark { width: 46px; height: 46px; color: var(--gold-700); margin-bottom: 1.1rem; display: none; }
@media (max-width: 880px) { .login-card > .brand-mark { display: block; } }
.login-card h1 { color: var(--ink-950); font-size: 1.6rem; margin-bottom: .35rem; }
.login-card > p { color: var(--ink-500); font-size: .89rem; margin: 0 0 1.6rem; }
.login-card form { display: grid; gap: .95rem; }
.login-card label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-600); }
.login-card label .omega-input { margin-top: .35rem; letter-spacing: normal; text-transform: none; }
.login-card label.login-forgot {
  display: flex; align-items: flex-start; gap: .65rem;
  font-size: .84rem; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--ink-700); cursor: pointer;
}
.login-card label.login-forgot input[type="checkbox"] {
  width: 1.1rem; height: 1.1rem; margin: .15rem 0 0; flex: none;
  accent-color: var(--gold-600); cursor: pointer;
}
.login-card .btn { width: 100%; padding: .65rem 1rem; font-size: .9rem; }
.login-note { margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--line); font-size: .76rem; color: var(--ink-500); }
.login-note a { color: var(--gold-700); font-weight: 600; }

.portal-signout { margin-left: auto; display: flex; align-items: center; }
.letter-body { padding: 1.2rem 1.4rem; }

/* ==========================================================================
   Rich-text note pad
   ========================================================================== */
.wysiwyg { border: 1px solid color-mix(in srgb, var(--ink-950) 10%, var(--line)); border-radius: 10px; background: var(--card-sunk); overflow: hidden; }
.wysiwyg:focus-within { border-color: var(--gold-600); background: var(--card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-500) 24%, transparent); }
.wysiwyg-bar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: .35rem .4rem; background: var(--card-sunk); border-bottom: 1px solid var(--line);
}
.wysiwyg-btn {
  min-width: 28px; height: 28px; padding: 0 .4rem; border-radius: 6px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font: 600 .82rem var(--font-ui); color: var(--ink-700); line-height: 1;
}
.wysiwyg-btn:hover { background: var(--card); border-color: var(--line); color: var(--ink-950); }
.wysiwyg-btn:active { background: var(--gold-500); border-color: var(--gold-600); }
.wysiwyg-sep { width: 1px; height: 18px; background: var(--line); margin: 0 .25rem; }
.wysiwyg-surface {
  border: 0; border-radius: 0; min-height: 8.5rem; padding: .7rem .85rem;
  font-size: .9rem; line-height: 1.6; overflow-y: auto; max-height: 26rem;
}
.wysiwyg-surface:focus { outline: none; box-shadow: none; }
.wysiwyg-surface:empty::before {
  content: attr(data-placeholder); color: var(--ink-400); pointer-events: none;
}
.wysiwyg-surface > :first-child { margin-top: 0; }
.wysiwyg-surface > :last-child { margin-bottom: 0; }
.wysiwyg-surface p { margin: 0 0 .65rem; }
.wysiwyg-surface h3 { font-size: .95rem; margin: 0 0 .5rem; }
.wysiwyg-surface ul, .wysiwyg-surface ol { margin: 0 0 .65rem; padding-left: 1.3rem; }
.wysiwyg-surface li { margin-bottom: .2rem; }
.wysiwyg-surface blockquote {
  margin: 0 0 .65rem; padding: .2rem 0 .2rem .8rem;
  border-left: 3px solid var(--gold-500); color: var(--ink-600);
}
textarea.wysiwyg-source { display: none; }

/* read-only rendering of the same content */
.richtext { font-size: .9rem; line-height: 1.6; color: var(--ink-800); }
.richtext > :first-child { margin-top: 0; }
.richtext > :last-child { margin-bottom: 0; }
.richtext p { margin: 0 0 .65rem; }
.richtext ul, .richtext ol { margin: 0 0 .65rem; padding-left: 1.2rem; }
.richtext blockquote {
  margin: 0 0 .65rem; padding: .2rem 0 .2rem .8rem;
  border-left: 3px solid var(--gold-500); color: var(--ink-600);
}
.richtext.is-empty { color: var(--ink-400); font-style: italic; }

/* ==========================================================================
   Driver's-licence scanner
   ========================================================================== */
.scan-panel {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow-sm); padding: 1.1rem 1.2rem; margin-bottom: 1.15rem;
}
.scan-head { display: flex; align-items: flex-start; gap: .9rem; flex-wrap: wrap; }
.scan-head h2 { margin: 0 0 .2rem; }
.scan-head .grow { flex: 1 1 16rem; min-width: 0; }
.scan-head p { margin: 0; }
.scan-actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }

.scan-stage { margin-top: 1rem; display: none; }
[data-stage="live"] .scan-stage.for-live,
[data-stage="shot"] .scan-stage.for-shot,
[data-stage="done"] .scan-stage.for-shot { display: block; }
[data-stage="live"] [data-scan-start],
[data-stage="live"] [data-scan-file-label] { display: none; }
[data-stage="idle"] [data-scan-shoot], [data-stage="idle"] [data-scan-stop],
[data-stage="shot"] [data-scan-shoot], [data-stage="shot"] [data-scan-stop],
[data-stage="done"] [data-scan-shoot], [data-stage="done"] [data-scan-stop] { display: none; }
[data-stage="idle"] [data-scan-retry], [data-stage="live"] [data-scan-retry] { display: none; }

.scan-video {
  /* `contain` with the stream's own ratio (set from JS) so the preview shows
     exactly what gets captured. `cover` cropped the sides, which meant aiming
     against a view that did not match the frame being sent. */
  width: 100%; max-width: 560px; aspect-ratio: 16 / 9;
  background: var(--ink-900); border-radius: 10px; object-fit: contain; display: block;
}
.scan-frame {
  position: relative; width: 100%; max-width: 560px;
  /* the guide dims its surround with a huge box-shadow — clip it, or it
     spills out and greys the whole page */
  overflow: hidden; border-radius: 10px;
}
/* Card-shaped guide. Advisory only — the whole frame is captured either way. */
.scan-guide {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 86%; aspect-ratio: 1.586;              /* ID-1 card */
  border: 2px dashed rgba(234, 189, 35, .9); border-radius: 10px;
  pointer-events: none; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .3);
}
/* anchored to the frame, not the guide, so clipping cannot eat it */
.scan-guide-hint {
  position: absolute; left: 0; right: 0; bottom: .5rem; margin: 0;
  text-align: center; font-size: .72rem; font-weight: 600;
  color: rgba(255, 255, 255, .8); text-shadow: 0 1px 3px rgba(0, 0, 0, .85);
  pointer-events: none;
}
.scan-quality {
  margin: .5rem 0 0; font-size: .8rem; font-weight: 600; color: var(--ink-500);
  display: flex; align-items: center; gap: .4rem; min-height: 1.2rem;
}
.scan-quality::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-300); flex: none;
}
.scan-quality:empty { display: none; }
.scan-quality.is-ready { color: #16640f; }
.scan-quality.is-ready::before { background: var(--good); }
.scan-status { margin: .7rem 0 0; font-size: .84rem; color: var(--ink-600); }
.scan-status.is-ok { color: #16640f; font-weight: 600; }
.scan-status.is-warn { color: #8a5a00; font-weight: 600; }
.scan-status.is-err { color: #97231f; font-weight: 600; }
.scan-status.is-busy { color: var(--ink-600); }
.scan-status.is-busy::after {
  content: ""; display: inline-block; width: .5rem; height: .5rem; margin-left: .4rem;
  border-radius: 50%; background: var(--gold-500); animation: scan-pulse 1s infinite ease-in-out;
}
@keyframes scan-pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .scan-status.is-busy::after { animation: none; opacity: .7 } }

.scan-readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .4rem .9rem; margin-top: .8rem; }
.scan-field { display: flex; justify-content: space-between; gap: .6rem; font-size: .8rem; padding: .3rem .5rem; background: var(--card-sunk); border-radius: 7px; }
.scan-field span { color: var(--ink-500); }
.scan-field b { color: var(--ink-950); text-align: right; }
.omega-input.is-scanned { border-color: var(--gold-600); background: color-mix(in srgb, var(--gold-500) 7%, #fff); }
.scan-privacy { font-size: .74rem; color: var(--ink-500); margin: .8rem 0 0; padding-top: .7rem; border-top: 1px solid var(--line-soft); }
.scan-preview {
  display: block; width: 100%; max-width: 560px; padding: 0; border: 0;
  background: var(--ink-900); border-radius: 10px; overflow: hidden; cursor: zoom-in;
}
.scan-preview img {
  display: block; width: 100%; max-height: 280px; object-fit: contain;
  background: var(--ink-900);
}
.scan-shot-actions { margin-top: .75rem; display: flex; gap: .45rem; flex-wrap: wrap; }
.lightbox {
  width: min(1200px, 96vw); max-height: 96vh; padding: 0; border: 0;
  border-radius: 12px; background: #111; overflow: hidden; position: relative;
}
.lightbox::backdrop { background: rgba(18, 18, 14, .78); backdrop-filter: blur(4px); }
.lightbox img {
  display: block; margin: 0 auto; max-width: 96vw; max-height: 92vh;
  width: auto; height: auto; object-fit: contain;
}
.lightbox-x {
  position: absolute; top: .7rem; right: .7rem; z-index: 2;
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer;
  background: rgba(18, 18, 14, .55); border: 1px solid rgba(255,255,255,.28);
  color: #fff; font-size: 1.3rem; line-height: 1; display: grid; place-items: center;
}
.lightbox-x:hover { background: rgba(18, 18, 14, .8); border-color: var(--gold-500); }

/* ==========================================================================
   Letter composer
   ========================================================================== */
.composer { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.15rem; align-items: start; margin-bottom: 1.75rem; }
@media (max-width: 1000px) { .composer { grid-template-columns: 1fr; } }
.composer-main .field { margin-bottom: 1rem; }
.composer-main .field > label {
  display: block; margin-bottom: .35rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-600);
}
.composer-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding-top: .4rem; }
.composer-side { position: sticky; top: calc(var(--header-h) + 1rem); }
.composer-main { position: relative; }
.ai-wait {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .85rem;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: blur(2px); border-radius: inherit;
  color: var(--ink-900); font-weight: 600;
}
.ai-wait[hidden] { display: none; }
.ai-wait-spin {
  width: 2rem; height: 2rem; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--gold-500) 28%, var(--line));
  border-top-color: var(--gold-500);
  animation: ai-spin .8s linear infinite;
}
.ai-wait p { margin: 0; font-size: .95rem; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ai-wait-spin { animation: none; border-top-color: var(--gold-500); }
}

.opt-group { margin-bottom: 1.1rem; }
.opt-group > h3 {
  font-family: var(--font-ui); font-size: .66rem; font-weight: 700; letter-spacing: .15em;
  text-transform: uppercase; color: var(--ink-500); margin: 0 0 .5rem;
}
.opt-list { display: grid; gap: .35rem; }
.opt {
  display: grid; grid-template-columns: 1fr; gap: .1rem;
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer; background: var(--card); transition: border-color .15s ease, background .15s ease;
}
.opt:hover { border-color: var(--ink-300); }
.opt.is-on { border-color: var(--gold-600); background: color-mix(in srgb, var(--gold-500) 9%, #fff); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt b { font-size: .84rem; font-weight: 600; color: var(--ink-950); }
.opt small { font-size: .74rem; color: var(--ink-500); line-height: 1.35; }

/* ==========================================================================
   Note ledger
   ========================================================================== */
.ledger { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.ledger-row {
  display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem;
  padding: .85rem 0; border-bottom: 1px solid var(--line-soft); position: relative;
}
.ledger-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ledger-row:first-child { padding-top: 0; }
.ledger-when { text-align: right; line-height: 1.3; }
.ledger-when b { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-800); }
.ledger-when span { font-size: .72rem; color: var(--ink-400); font-family: var(--font-mono); }
.ledger-head { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-bottom: .35rem; }
.ledger-action {
  font-size: .64rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  border-radius: 999px; padding: .1rem .5rem; border: 1px solid transparent;
}
.ledger-action.is-create { background: #eefbee; color: #16640f; border-color: #b9e5b5; }
.ledger-action.is-edit { background: var(--card-sunk); color: var(--ink-600); border-color: var(--line); }
.ledger-who { font-size: .82rem; font-weight: 600; color: var(--ink-950); }
.ledger-delta { font: 600 .72rem var(--font-mono); color: var(--ink-400); }
.ledger-delta.is-up { color: #16640f; }
.ledger-delta.is-down { color: #97231f; }
.ledger-detail summary {
  cursor: pointer; font-size: .82rem; color: var(--ink-600); list-style: none;
  padding: .3rem .5rem; border-radius: 7px; background: var(--card-sunk);
}
.ledger-detail summary::-webkit-details-marker { display: none; }
.ledger-detail summary::before { content: "▸ "; color: var(--gold-600); font-weight: 700; }
.ledger-detail[open] summary::before { content: "▾ "; }
.ledger-detail summary:hover { color: var(--ink-950); }
.ledger-detail .richtext { margin-top: .55rem; padding-left: .5rem; border-left: 2px solid var(--line); }

/* ==========================================================================
   Client attachments
   ========================================================================== */
.file-add { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.file-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .8rem; margin-top: 1.1rem;
}
.file-card {
  display: grid; grid-template-columns: 76px 1fr; gap: .75rem;
  border: 1px solid var(--line); border-radius: 11px; padding: .65rem; background: var(--card);
}
.file-card.is-licence { border-color: color-mix(in srgb, var(--gold-500) 55%, var(--line)); background: color-mix(in srgb, var(--gold-500) 5%, #fff); }
.file-thumb {
  display: grid; place-items: center; width: 76px; height: 76px; overflow: hidden;
  border-radius: 8px; background: var(--card-sunk); border: 1px solid var(--line); text-decoration: none;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-ext { font: 700 .72rem var(--font-mono); color: var(--ink-500); letter-spacing: .06em; }
.file-meta { min-width: 0; }
.file-name {
  display: block; font-size: .85rem; font-weight: 600; color: var(--ink-950);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none;
}
.file-name:hover { text-decoration: underline; text-decoration-color: var(--gold-600); }
.file-tag {
  display: inline-block; margin-top: .2rem; font-size: .62rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--gold-700);
  background: color-mix(in srgb, var(--gold-500) 18%, #fff);
  border: 1px solid color-mix(in srgb, var(--gold-500) 45%, transparent);
  border-radius: 999px; padding: .05rem .45rem;
}
.file-actions { display: flex; gap: .35rem; margin-top: .45rem; flex-wrap: wrap; }
.file-actions form { margin: 0; }
.file-card.is-archived { opacity: .78; }
.file-archived-list { margin-top: 1rem; }

/* who is signed in, now that it lives in the drawer */
.drawer-user { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.drawer-user b { display: block; font-size: .88rem; font-weight: 600; color: #fff; }
.drawer-user span { font-size: .74rem; color: var(--ink-300); }

/* administrator / disabled agent states */
.admin-tag {
  display: inline-block; vertical-align: middle; margin-left: .4rem;
  font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold-700); background: color-mix(in srgb, var(--gold-500) 18%, #fff);
  border: 1px solid color-mix(in srgb, var(--gold-500) 45%, transparent);
  border-radius: 999px; padding: .1rem .5rem;
}
.badge.off { background: var(--card-sunk); color: var(--ink-500); border-color: var(--line); }
tbody tr.is-off td { opacity: .58; }
tbody tr.is-off td:first-child, tbody tr.is-off td:last-child, tbody tr.is-off td:nth-last-child(2) { opacity: 1; }

/* ==========================================================================
   Modal dialog
   ========================================================================== */
.modal {
  width: min(480px, calc(100vw - 2rem)); padding: 0; border: 0;
  border-radius: 16px; background: var(--card); color: var(--ink-800);
  box-shadow: 0 32px 90px rgba(18, 18, 14, .32);
  overflow: hidden;
}
.modal::backdrop { background: rgba(18, 18, 14, .55); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .18s cubic-bezier(.32, .72, 0, 1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

.modal-head {
  display: flex; align-items: center; gap: .7rem;
  padding: .9rem 1.1rem; background: var(--ink-950); color: #fff;
}
.modal-head .brand-mark { width: 30px; height: 30px; }
.modal-title { min-width: 0; }
.modal-title strong { display: block; font-family: var(--font-display); font-size: 1rem; }
.modal-title span {
  display: block; font-size: .74rem; color: var(--ink-300);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-x {
  margin-left: auto; flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,.22); color: #fff;
  font-size: 1.1rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.modal-x:hover { background: rgba(255,255,255,.14); border-color: var(--gold-500); }

.modal-body { padding: 1.4rem 1.35rem; display: grid; justify-items: center; gap: 1.1rem; }
.modal-foot {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .8rem 1.35rem; border-top: 1px solid var(--line); background: var(--card-sunk);
}
.modal-foot .btn { margin-left: auto; }

.modal-confirm { width: min(440px, calc(100vw - 2rem)); }
.modal-confirm .modal-body {
  display: block; justify-items: stretch; text-align: left; padding: 1.25rem 1.35rem 1.15rem;
}
.modal-confirm .modal-body p {
  margin: 0; font-size: .95rem; color: var(--ink-700); line-height: 1.5;
}
.modal-confirm .confirm-field { display: block; margin-top: .85rem; }
.modal-confirm .confirm-field[hidden] { display: none !important; }
.modal-confirm .modal-foot { justify-content: flex-end; gap: .5rem; }
.modal-confirm .modal-foot .btn { margin-left: 0; }
.modal-confirm.is-danger .modal-head { background: #2a1614; }

.modal-artifacts { width: min(780px, calc(100vw - 2rem)); }
.modal-artifacts .modal-body {
  padding: 0; max-height: min(62vh, 540px); overflow: auto;
}

.modal-portal { width: min(480px, calc(100vw - 2rem)); }
.modal-portal .modal-body { display: block; text-align: left; }
.modal-portal .omega-input { font-size: 1.05rem; letter-spacing: .02em; }
.modal-portal [data-portal-status] { margin: .65rem 0 0; min-height: 1.2em; }
.record button.linkish {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--gold-600) 60%, transparent);
  text-underline-offset: 3px;
}
.record button.linkish:hover { text-decoration-color: var(--gold-600); }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 16rem; overflow: auto; margin: 0; padding: .3rem;
  list-style: none; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(22, 30, 42, .14);
}
.combo-list[hidden] { display: none; }
.combo-option {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: .5rem .7rem; border-radius: 8px; cursor: pointer; font: inherit;
  color: var(--ink-950);
}
.combo-option:hover, .combo-option.is-active {
  background: color-mix(in srgb, var(--gold-500) 16%, #fff);
}
.combo-option small { display: block; color: var(--ink-500); font-size: .74rem; margin-top: .12rem; }
.combo-empty { padding: .65rem .7rem; color: var(--ink-500); font-size: .84rem; }
.modal-artifacts .modal-body p { padding: 1.15rem 1.25rem; }
.modal-artifacts table { margin: 0; }
.modal-artifacts th:first-child,
.modal-artifacts td:first-child { padding-left: 1.2rem; }
.modal-artifacts th:last-child,
.modal-artifacts td:last-child { padding-right: 1.2rem; }
.modal-artifacts .modal-foot { justify-content: flex-end; }

/* the QR itself */
.pair-qr {
  line-height: 0; background: #fff; padding: 16px; border-radius: 14px;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  width: 300px; height: 300px; margin: 0 auto;
  display: grid; place-items: center;
}
.pair-qr svg { display: block; width: 100%; height: 100%; }
.pair-qr:empty::after {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold-500);
  animation: pair-spin .8s linear infinite;
}
@keyframes pair-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pair-qr:empty::after { animation: none; } }
[data-state="done"] .pair-qr { opacity: .35; }

.pair-steps {
  margin: 0; padding-left: 1.1rem; display: grid; gap: .3rem;
  font-size: .84rem; color: var(--ink-600); justify-self: stretch;
}
.pair-steps li::marker { color: var(--gold-700); font-weight: 700; }
.pair-code { margin: 0; font-size: .76rem; color: var(--ink-500); text-align: center; }
.pair-expiry {
  margin: 0; font-size: .74rem; font-weight: 600; text-align: center;
  color: var(--ink-500); font-variant-numeric: tabular-nums;
}
.pair-expiry b { font-family: var(--font-mono); color: var(--ink-800); }
.pair-expiry.is-low b { color: #97231f; }
.pair-code b, .pair-code span { font-family: var(--font-mono); color: var(--ink-900); }
.pair-state { margin: 0; font-size: .82rem; font-weight: 600; color: var(--ink-600); }
.pair-state.is-ok { color: #16640f; }
.pair-state.is-err { color: #97231f; }

/* ==========================================================================
   Phone capture screen — full-bleed camera, fixed chrome, no page scroll
   ========================================================================== */
.phone-body {
  margin: 0; height: 100dvh; overflow: hidden;
  background: #000; color: #fff;
  font-size: 15px; -webkit-text-size-adjust: 100%;
}
.phone-shell {
  height: 100dvh; display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--ink-950);
}

/* --- top bar --- */
.phone-bar {
  display: flex; align-items: center; gap: .65rem;
  padding: .7rem .95rem; background: var(--ink-950);
}
.phone-bar .brand-mark { width: 26px; height: 26px; }
.phone-bar-text { min-width: 0; line-height: 1.2; }
.phone-bar-text strong { display: block; font-size: .84rem; font-weight: 600; color: #fff; }
.phone-bar-text span {
  display: block; font-size: .72rem; color: var(--gold-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- camera fills everything between bar and dock --- */
.phone-stage {
  position: relative; overflow: hidden; background: var(--ink-950);
  display: grid; place-items: center;
}
/* Sized in JS to the stream's exact ratio, so the video fills it with no
   letterboxing. A CSS aspect-ratio cannot do this: it is ignored once both
   width and height are constrained, which left portrait streams pillarboxed
   and the guide overhanging the picture — a card lined up in the box ran off
   the edge of the actual frame. */
.phone-camera {
  position: relative; width: 100%; height: 100%;
  background: #000; overflow: hidden; border-radius: 10px;
}
.phone-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  /* `contain`, never `cover`: what is on screen is exactly what gets sent */
  object-fit: contain; display: block;
}
/* ID-1 card shape. Sized in JS against the camera box so it fits whichever
   way the stream is oriented and never spills onto a black margin. */
.phone-guide {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 88%; aspect-ratio: 1.586;
  border: 2px dashed rgba(234, 189, 35, .95); border-radius: 12px;
  pointer-events: none; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .42);
}
.phone-guide-hint {
  position: absolute; left: 0; right: 0; bottom: .8rem; margin: 0;
  text-align: center; font-size: .76rem; font-weight: 600; color: rgba(255,255,255,.72);
  text-shadow: 0 1px 3px rgba(0,0,0,.8); pointer-events: none;
}
.phone-pill {
  position: absolute; top: .7rem; left: 50%; transform: translateX(-50%);
  margin: 0; padding: .28rem .8rem; border-radius: 999px;
  background: rgba(18, 18, 14, .72); backdrop-filter: blur(6px);
  font-size: .74rem; font-weight: 600; color: rgba(255,255,255,.85);
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.phone-pill:empty { display: none; }
.phone-pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-400); flex: none;
}
.phone-pill.is-ready { color: #fff; }
.phone-pill.is-ready::before { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* --- success state replaces the camera --- */
.phone-done { display: none; }
[data-stage="sent"] .phone-camera,
[data-stage="sent"] .phone-video,
[data-stage="sent"] .phone-guide,
[data-stage="sent"] .phone-guide-hint,
[data-stage="sent"] .phone-pill { display: none; }
[data-stage="sent"] .phone-done {
  position: absolute; inset: 0; display: grid; place-content: center;
  justify-items: center; gap: .45rem; text-align: center; padding: 1.5rem;
}
.phone-tick {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(12, 163, 12, .16); border: 2px solid var(--good);
  color: var(--good); font-size: 1.9rem; line-height: 1; margin-bottom: .4rem;
}
.phone-done strong { font-family: var(--font-display); font-size: 1.1rem; color: #fff; }
.phone-done span { font-size: .84rem; color: var(--ink-300); }

/* --- bottom dock --- */
.phone-dock {
  display: grid; justify-items: center; gap: .55rem;
  padding: .85rem .95rem 1.1rem; background: var(--ink-950);
}
.phone-status {
  margin: 0; font-size: .84rem; text-align: center; color: var(--ink-300);
  min-height: 1.15rem; line-height: 1.3;
}
.phone-status.is-ok { color: var(--gold-300); font-weight: 600; }
.phone-status.is-err { color: #ff9b96; font-weight: 600; }
.phone-status.is-busy { color: #fff; }

.phone-shutter {
  width: 72px; height: 72px; border-radius: 50%; padding: 0; cursor: pointer;
  background: transparent; border: 3px solid rgba(255, 255, 255, .9);
  display: grid; place-items: center;
  transition: transform .12s ease, border-color .12s ease;
}
.phone-shutter span {
  width: 56px; height: 56px; border-radius: 50%; background: var(--gold-500);
  transition: background .12s ease, transform .12s ease;
}
.phone-shutter:active span { transform: scale(.9); background: var(--gold-600); }
.phone-shutter:disabled { border-color: rgba(255,255,255,.3); cursor: default; }
.phone-shutter:disabled span { background: var(--ink-600); }
[data-stage="sent"] .phone-shutter { display: none; }
.phone-again { min-width: 12rem; }
.phone-hint { margin: 0; font-size: .7rem; color: var(--ink-400); text-align: center; }
[data-stage="sent"] .phone-hint { display: none; }

/* --- message states (expired / claimed / unknown) --- */
.phone-shell.is-message { grid-template-rows: 1fr; place-items: center; padding: 1.5rem; }
.phone-message { text-align: center; max-width: 22rem; display: grid; justify-items: center; gap: .5rem; }
.phone-message .brand-mark { width: 46px; height: 46px; margin-bottom: .4rem; }
.phone-message h1 { font-family: var(--font-display); font-size: 1.25rem; color: #fff; margin: 0; }
.phone-message p { font-size: .88rem; color: var(--ink-300); margin: 0; }

/* Portrait is the working orientation; in landscape the camera area collapses
   and the shutter goes off screen, so ask for a turn instead. */
.phone-rotate { display: none; }
@media (orientation: landscape) and (max-height: 560px) {
  .phone-rotate {
    position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
    background: var(--ink-950); text-align: center; padding: 1.5rem;
  }
  .phone-rotate .rotate-icon { font-size: 2.4rem; color: var(--gold-500); display: block; line-height: 1; }
  .phone-rotate strong { display: block; margin-top: .7rem; font-family: var(--font-display); font-size: 1.15rem; color: #fff; }
  .phone-rotate p { margin: .3rem 0 0; font-size: .85rem; color: var(--ink-300); }
  .phone-shell { display: none; }
}

/* ==========================================================================
   Pager — one row: count on the left, controls on the right
   ========================================================================== */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: nowrap;
  margin-top: .9rem; padding: .5rem .55rem .5rem .9rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.pager-count {
  margin: 0; font-size: .82rem; color: var(--ink-500); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.pager-count b { color: var(--ink-900); font-variant-numeric: tabular-nums; font-weight: 600; }
.pager-right { display: flex; align-items: center; gap: .5rem; flex: none; }

.pager-rows { display: flex; align-items: center; gap: .4rem; }
.pager-rows label {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-400);
}
.pager-rows select {
  font: 600 .8rem var(--font-ui); color: var(--ink-800);
  background: var(--card-sunk); border: 1px solid var(--line);
  border-radius: 8px; padding: .32rem 1.5rem .32rem .55rem; cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-500) 50%),
                    linear-gradient(135deg, var(--ink-500) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.pager-rows select:hover { border-color: var(--ink-300); }
.pager-rows select:focus-visible { outline: 2px solid var(--gold-600); outline-offset: 1px; }

/* prev / page / next as one joined control */
.pager-nav {
  display: flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--card-sunk);
}
.pager-step {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .32rem .7rem; font: 600 .8rem var(--font-ui);
  color: var(--ink-800); text-decoration: none; background: var(--card);
  transition: background .13s ease, color .13s ease;
}
.pager-step span { font-size: 1.05em; line-height: 1; }
.pager-step:hover { background: var(--gold-500); color: var(--ink-950); text-decoration: none; }
.pager-step.is-off { color: var(--ink-300); background: var(--card-sunk); cursor: default; }
.pager-page {
  display: inline-flex; align-items: center; gap: .28rem;
  padding: .32rem .7rem; font: 600 .8rem var(--font-mono);
  color: var(--ink-700); background: var(--card-sunk);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pager-page i { font-style: normal; color: var(--ink-300); }

@media (max-width: 720px) {
  .pager { flex-wrap: wrap; justify-content: flex-end; }
  .pager-count { width: 100%; }
}

/* ==========================================================================
   Record list (client detail sidebar)
   ========================================================================== */
.record { display: grid; grid-template-columns: 7.5rem 1fr; gap: .5rem .8rem; margin: 0; }
.record dt { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-400); padding-top: .1rem; }
.record dd { margin: 0; font-size: .87rem; color: var(--ink-900); overflow-wrap: anywhere; }
.record .tiny.is-expired { color: #97231f; font-weight: 700; }

body:has(.client-file) .wrap { max-width: 1680px; }
.client-file.stack > * + * { margin-top: 1.15rem; }
.client-file .form-grid { max-width: none; }
.client-profile {
  border-top: 3px solid var(--gold-500);
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem 1.6rem;
}
.profile-grid > div { min-width: 0; display: flex; flex-direction: column; gap: .22rem; }
.profile-span-2 { grid-column: span 2; }
.profile-k {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-400);
}
.profile-v { font-size: .9rem; color: var(--ink-900); overflow-wrap: anywhere; }
.profile-v .tiny.is-expired { color: #97231f; font-weight: 700; }
.profile-v button.linkish {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--gold-600) 60%, transparent);
  text-underline-offset: 3px;
}
.profile-v button.linkish:hover { text-decoration-color: var(--gold-600); }
.profile-ids { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .55rem; align-items: flex-start; }
.profile-id-thumb {
  display: block; width: 220px; max-width: 100%; height: 140px; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card-sunk);
  text-decoration: none; box-shadow: var(--shadow-sm);
}
.profile-id-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-id-thumb:hover { border-color: var(--gold-600); }
@media (max-width: 1100px) {
  .profile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .profile-span-2 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-span-2 { grid-column: auto; }
}
.sent-dot {
  display: inline-block; margin-left: .35rem; font-size: .62rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: #16640f;
}

/* ==========================================================================
   Form + sidebar layout (client add / edit)
   ========================================================================== */
.form-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 26rem);
  gap: 1.15rem; align-items: start;
}
/* only stack once the sidebar genuinely cannot fit */
@media (max-width: 820px) {
  .form-layout { grid-template-columns: 1fr; }
  /* Client add/edit: scan and password first on a phone, then name/address. */
  .form-layout:has(.portal-pass-card) {
    display: flex; flex-direction: column;
  }
  .form-layout:has(.portal-pass-card) .form-side { display: contents; }
  .form-layout:has(.portal-pass-card) .form-side .scan-panel,
  .form-layout:has(.portal-pass-card) .form-side [data-spouse-scan] { order: -2; }
  .form-layout:has(.portal-pass-card) .form-side .portal-pass-card { order: -1; }
}
.form-main .form-grid { max-width: none; }

.trust-scope {
  border: 1px solid color-mix(in srgb, var(--cat-trust) 42%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--cat-trust-tint) 0%, var(--card) 7.25rem);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.25rem 1.2rem;
}
.form-main > .trust-scope { margin-top: .75rem; }
.trust-scope-head { margin: 0 0 1rem; padding-left: .35rem; width: 100%; }
.trust-scope-head h2 {
  margin: 0 0 .3rem; width: 100%;
  color: var(--cat-trust-ink);
}
.trust-scope-head p { margin: 0; max-width: none; }
.trust-scope .form-grid { max-width: none; }
.trust-scope-spacer { display: none; }
@media (min-width: 721px) {
  .trust-scope-spacer { display: block; }
}
.form-side {
  display: flex; flex-direction: column; gap: 1.15rem;
}
.portal-pass-card { padding: 1.1rem 1.2rem 1.15rem; }
.portal-pass-card label {
  display: block; font-size: .78rem; font-weight: 700; color: var(--ink-600);
  letter-spacing: .04em; text-transform: uppercase;
}
.portal-pass-card label .omega-input {
  margin-top: .35rem; text-transform: none; letter-spacing: normal; width: 100%;
}
.form-side .scan-panel { margin: 0; position: static; }
.form-side .scan-head { flex-direction: column; align-items: stretch; gap: .7rem; }
/* the head's flex-basis is a width in the row layout; once it stacks, that
   16rem becomes a height and reserves 256px of empty panel */
.form-side .scan-head .grow { flex: 0 0 auto; }
.form-side .scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.form-side .scan-actions .btn { width: 100%; }
.form-side .scan-video, .form-side .scan-frame { max-width: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.portal-video { padding: 0; margin: 0; overflow: hidden; }
.portal-video-frame {
  width: 100%; min-height: 12rem; aspect-ratio: 16 / 9;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(234, 189, 35, .18), transparent 55%),
    var(--ink-950);
  color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 1.15rem;
  padding: 1.5rem 1.75rem;
}
.portal-video-play {
  flex: none; width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--gold-500); position: relative;
}
.portal-video-play::after {
  content: ""; position: absolute; left: 24px; top: 18px;
  border-style: solid; border-width: 14px 0 14px 22px;
  border-color: transparent transparent transparent var(--gold-500);
}
.portal-video-frame strong {
  display: block; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600;
}
.portal-video-frame p { margin: .35rem 0 0; color: rgba(255,255,255,.72); max-width: 28rem; line-height: 1.45; }
@media (max-width: 640px) {
  .portal-video-frame { flex-direction: column; text-align: center; aspect-ratio: auto; min-height: 14rem; }
}

.form-layout.portal-lock { grid-template-columns: 1fr; }
.portal-lock .form-main {
  display: flex; flex-direction: column; gap: .85rem;
}
.portal-lock .form-main > * { margin-top: 0; margin-bottom: 0; }
.portal-lock .form-main > .trust-scope { margin-top: 0; }
.portal-lock fieldset.form-grid {
  min-width: 0;
  margin: 0;
}
.form-save { display: flex; gap: .5rem; align-items: center; padding-top: .3rem; }

/* ==========================================================================
   Client activity
   ========================================================================== */
.cell-contact a { display: block; font-size: .84rem; color: var(--ink-800); text-decoration: none; }
.cell-contact a:hover { text-decoration: underline; text-decoration-color: var(--gold-600); }
.cell-contact .tiny { display: block; font-variant-numeric: tabular-nums; }

/* How long a file has been quiet. Only recent activity is worth calling out —
   an old file is not a problem, so the older it gets the more it recedes
   rather than escalating through warning colours. */
.active-tag {
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
  font-size: .78rem; font-weight: 600; color: var(--ink-700);
}
.active-tag::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--dot, var(--ink-300));
}
.active-tag.is-fresh   { --dot: var(--good);    color: #16640f; }
.active-tag.is-recent  { --dot: var(--ink-400); color: var(--ink-700); }
.active-tag.is-cooling { --dot: var(--ink-300); color: var(--ink-500); font-weight: 500; }
/* the recede lives in the dot and the weight — the text stays readable
   (ink-400 measured only 3.87:1 against the card, short of 4.5:1) */
.active-tag.is-stale   { --dot: var(--line);    color: var(--ink-500); font-weight: 500; }
.active-tag.is-never   { --dot: var(--line);    color: var(--ink-500); font-weight: 500; font-style: italic; }

.warn-tag {
  display: inline-block; margin-left: .4rem; font-size: .62rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: #97231f;
  background: #fdf1f1; border: 1px solid #f2c4c2; border-radius: 999px; padding: .05rem .45rem;
  text-decoration: none; vertical-align: middle;
}
.warn-tag:hover { text-decoration: none; border-color: #e08b88; background: #fce8e8; }
.letter-chip.is-pending {
  background: #fdf1f1; border-color: #f2c4c2; color: #97231f;
}
.letter-chip.is-pending .letter-chip-name { color: #7a1f1c; }
.letter-chip.is-pending .letter-chip-code { color: #97231f; }
#letters, #messages { scroll-margin-top: calc(var(--header-h) + 12px); }

.thread {
  display: flex; flex-direction: column; gap: .65rem;
  height: 22rem; max-height: 22rem; min-height: 0;
  overflow-x: hidden; overflow-y: scroll;
  overscroll-behavior: contain;
  padding: .15rem .35rem .15rem 0; margin: 0 0 .2rem;
  scrollbar-width: thin;
}
.bubble {
  max-width: min(42rem, 92%); padding: .7rem .9rem;
  border-radius: 12px; border: 1px solid var(--line);
}
.bubble.is-mine {
  margin-left: auto;
  background: color-mix(in srgb, var(--gold-500) 14%, #fff);
  border-color: color-mix(in srgb, var(--gold-500) 35%, var(--line));
}
.bubble.is-theirs { background: var(--card-sunk); }
.bubble-who { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-500); margin-bottom: .25rem; }
.bubble-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; color: var(--ink-900); line-height: 1.45; }
.bubble-meta { margin-top: .35rem; font-size: .72rem; color: var(--ink-500); }
.thread-form { display: grid; gap: .65rem; }
.thread-form textarea.omega-input { resize: none; min-height: 0; height: 4.8rem; }
.thread-form .form-save { padding-top: 0; }

.msg-stats {
  display: flex; gap: 1.6rem 2.2rem; flex-wrap: wrap;
  margin: 0 0 1.2rem;
}
.msg-stats div b {
  display: block; font-family: var(--font-display); font-size: 1.45rem;
  color: var(--ink-950); line-height: 1.1;
}
.msg-stats div span {
  font-size: .7rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-500); font-weight: 600;
}
.msg-inbox {
  display: grid; grid-template-columns: minmax(240px, 22rem) minmax(0, 1fr);
  gap: 1rem; align-items: start;
}
@media (max-width: 820px) { .msg-inbox { grid-template-columns: 1fr; } }
.msg-list { padding: .35rem; display: flex; flex-direction: column; gap: .2rem; }
.msg-row {
  display: block; padding: .75rem .85rem; border-radius: 10px;
  text-decoration: none; color: inherit; border: 1px solid transparent;
}
.msg-row:hover { background: var(--card-sunk); text-decoration: none; }
.msg-row.is-active {
  background: color-mix(in srgb, var(--gold-500) 12%, #fff);
  border-color: color-mix(in srgb, var(--gold-500) 40%, var(--line));
}
.msg-row.has-unread strong { color: var(--ink-950); }
.msg-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.msg-row-top strong { font-size: .95rem; }
.msg-counts { display: flex; flex-wrap: wrap; gap: .25rem; justify-content: flex-end; }
.msg-count {
  display: inline-block; font-size: .62rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; border-radius: 999px; padding: .08rem .45rem;
  background: var(--card-sunk); color: var(--ink-600); border: 1px solid var(--line);
}
.msg-count.is-client { background: #f1f4fb; color: var(--cat-trust-ink); border-color: #d5e2f6; }
.msg-count.is-unread { background: #fdf1f1; color: #97231f; border-color: #f2c4c2; }
.msg-row-meta { margin-top: .25rem; font-size: .74rem; color: var(--ink-500); }
.msg-thread .thread { height: 26rem; max-height: 26rem; }

/* choosing which package a new letter is for */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .9rem; max-width: 40rem; }
.pick-card {
  display: grid; justify-items: start; gap: .2rem;
  padding: 1.1rem 1.2rem; border-radius: var(--radius); text-decoration: none;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pick-card:hover { border-color: var(--cat); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.pick-card .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat); margin-bottom: .3rem; }
.pick-card strong { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink-950); }
.pick-card .code { font: 600 .7rem var(--font-mono); color: var(--cat-ink); }

/* search result emphasis */
.drawer-results mark {
  background: rgba(234, 189, 35, .28); color: #fff;
  border-radius: 3px; padding: 0 1px;
}
.drawer-results .w {
  margin-left: .4rem; font-size: .62rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-400);
}
.drawer-similar {
  margin: 0 0 .4rem; font-size: .74rem; font-weight: 600; color: var(--gold-500);
}

/* ==========================================================================
   Forms board (administrator drag order)
   ========================================================================== */
.form-board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .7rem;
}
.form-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: .85rem 1rem;
  align-items: center;
  padding: 1rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-board[data-form-sort] .form-tile {
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}
.form-board[data-form-sort] .form-tile:hover {
  border-color: color-mix(in srgb, var(--gold-500) 42%, var(--line));
  box-shadow: var(--shadow-md);
}
.form-tile-grip {
  width: 14px;
  height: 22px;
  flex: none;
  background-image: radial-gradient(circle, var(--ink-400) 1.15px, transparent 1.3px);
  background-size: 6px 6px;
  background-position: 1px 1px;
  opacity: .42;
  touch-action: none;
}
.form-board[data-form-sort] .form-tile:hover .form-tile-grip { opacity: .7; }
.form-tile-main { min-width: 0; }
.form-tile-main .cell-name { display: block; }
.form-tile-main .tiny { margin-top: .18rem; }
.form-tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .5rem;
  justify-content: flex-end;
}
.form-tile .row-actions { justify-content: flex-end; }
.form-tile.is-dragging {
  position: fixed;
  z-index: 80;
  margin: 0;
  cursor: grabbing;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  border-color: var(--gold-500);
  background: #fff;
  transform: scale(1.015) rotate(.35deg);
}
.form-tile-placeholder {
  border: 1.5px dashed color-mix(in srgb, var(--gold-500) 60%, var(--line));
  background:
    repeating-linear-gradient(
      -55deg,
      color-mix(in srgb, var(--gold-500) 9%, var(--card-sunk)),
      color-mix(in srgb, var(--gold-500) 9%, var(--card-sunk)) 8px,
      color-mix(in srgb, var(--gold-500) 16%, var(--card-sunk)) 8px,
      color-mix(in srgb, var(--gold-500) 16%, var(--card-sunk)) 16px
    );
  box-shadow: none;
  cursor: default;
}
.form-board.is-sorting .form-tile:not(.is-dragging):not(.form-tile-placeholder) {
  transition: transform .14s ease;
}
body.is-form-sorting { cursor: grabbing; user-select: none; }
body.is-form-sorting * { cursor: grabbing !important; }
.form-board.is-sort-error .form-tile {
  border-color: color-mix(in srgb, var(--critical) 40%, var(--line));
}
.form-sort-status {
  margin: .7rem 0 0;
  min-height: 1.1em;
  color: var(--ink-500);
}
.form-board.is-saving + .form-sort-status { color: var(--gold-700); }
@media (max-width: 820px) {
  .form-tile {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .form-tile-meta,
  .form-tile .row-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}
