/* ==========================================================================
   LaunchList — visual system
   One stylesheet for both shells:
     - the operator app (index.html, #app) — dark by default, light via [data-theme]
     - the client portal (portal.html, #portal) — html[data-surface="portal"], paper

   Principle: emphasis from contrast, colour only for meaning.
     accent (verdigris) = positive / your numbers
     attn   (brass)     = needs attention
     neg    (clay)      = negative
   No gradients in UI chrome. No web fonts. Icons are inline SVG, currentColor.

   Contents
     01  Tokens — colour sets (dark / paper) and theming selectors
     02  Tokens — type, space, radius, motion, controls, layers
     04  Base and reset
     05  Typography and numbers
     06  Layout: screen, stack, grids
     07  Surfaces and ruled headers
     08  Chips, status dots, deltas
     09  Buttons
     10  Inputs, fields, checks, segmented control, swatches, spinner
     11  Top navigation, switcher chip, monograms, tabs
     12  Phone bottom bar
     13  Stats and hero numbers
     14  Sheets
     15  Business switcher
     16  Hub
     17  Pipeline: filter chips, board, cards
     18  Empty states
     19  Lists, rows, replies
     20  Lead detail: stage rail, client strip
     21  Clients roster
     22  Client detail: thread, compose, access, log, key-value
     23  Handoff code plate
     24  Lock screen
     25  Overlays: busy, toast
     26  Charts (window.charts)
     27  Client portal
     28  Legacy screens restyled onto tokens (money, advisor, settings, work, send)
     29  Motion: entrance stagger, keyframes, reduced motion
     30  Utilities
     31  Responsive: phone (<=640px), sheets and hub (>=720px), wide (>=1080px)
   ========================================================================== */


/* ==========================================================================
   01  TOKENS — COLOUR SETS AND THEMING
   Dark is the operator default. Paper is used by the portal, by
   [data-theme="light"], and by the system light preference when the operator
   has not forced dark. Every set defines the same token names.
   ========================================================================== */

/* DARK SET (operator default, and [data-theme="dark"]) */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0B0C0E;
  --surface-1: #121317;
  --surface-2: #191B20;
  --surface-3: #22252C;
  --hairline: #262A32;
  --hairline-soft: rgba(255, 255, 255, .06);
  --text: #ECEDEF;
  --text-2: #A9AEB8;
  --text-3: #7A808C;
  --accent: #3FBFAE;
  --accent-deep: #2A9C8D;
  --accent-wash: rgba(63, 191, 174, .12);
  --attn: #E0A33E;
  --attn-wash: rgba(224, 163, 62, .12);
  --neg: #E0655B;
  --neg-wash: rgba(224, 101, 91, .12);
  --emph-bg: #EDEAE4;
  --emph-fg: #0B0C0E;
  --focus: #3FBFAE;
  --scrim: rgba(8, 9, 11, .56);
  --e1-shadow: 0 1px 2px rgba(0, 0, 0, .28), 0 4px 12px -4px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .04);
  --e2-shadow: 0 2px 6px rgba(0, 0, 0, .30), 0 18px 40px -12px rgba(0, 0, 0, .50), inset 0 1px 0 rgba(255, 255, 255, .05);
  --tint-0: #8A97FF;
  --tint-1: #E0894F;
  --tint-2: #C08BE0;
  --tint-3: #86C05E;
  --tint-4: #8FAFC6;
  --tint-5: #D4B483;
}

/* PAPER SET via system preference (operator only, when not forced dark) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-surface="portal"]) {
    color-scheme: light;
    --ground: #FBFAF7;
    --surface-1: #FFFFFF;
    --surface-2: #F4F2ED;
    --surface-3: #EDEAE3;
    --hairline: #E3DFD6;
    --hairline-soft: rgba(22, 24, 28, .06);
    --text: #16181C;
    --text-2: #4F555F;
    --text-3: #6B717B;
    --accent: #0F6E64;
    --accent-deep: #0A544C;
    --accent-wash: rgba(15, 110, 100, .08);
    --attn: #8A5A00;
    --attn-wash: rgba(138, 90, 0, .08);
    --neg: #B03A2E;
    --neg-wash: rgba(176, 58, 46, .08);
    --emph-bg: #16181C;
    --emph-fg: #FBFAF7;
    --focus: #0F6E64;
    --scrim: rgba(22, 24, 28, .32);
    --e1-shadow: 0 1px 2px rgba(0, 0, 0, .056), 0 4px 12px -4px rgba(0, 0, 0, .07);
    --e2-shadow: 0 2px 6px rgba(0, 0, 0, .06), 0 18px 40px -12px rgba(0, 0, 0, .10);
    --tint-0: #4C5BD4;
    --tint-1: #A8552A;
    --tint-2: #7A3E9D;
    --tint-3: #3F6B2B;
    --tint-4: #3E5567;
    --tint-5: #7A5C2E;
  }
}

/* PAPER SET (portal always; operator when [data-theme="light"]) */
:root[data-theme="light"],
:root[data-surface="portal"] {
  color-scheme: light;
  --ground: #FBFAF7;
  --surface-1: #FFFFFF;
  --surface-2: #F4F2ED;
  --surface-3: #EDEAE3;
  --hairline: #E3DFD6;
  --hairline-soft: rgba(22, 24, 28, .06);
  --text: #16181C;
  --text-2: #4F555F;
  --text-3: #6B717B;
  --accent: #0F6E64;
  --accent-deep: #0A544C;
  --accent-wash: rgba(15, 110, 100, .08);
  --attn: #8A5A00;
  --attn-wash: rgba(138, 90, 0, .08);
  --neg: #B03A2E;
  --neg-wash: rgba(176, 58, 46, .08);
  --emph-bg: #16181C;
  --emph-fg: #FBFAF7;
  --focus: #0F6E64;
  --scrim: rgba(22, 24, 28, .32);
  --e1-shadow: 0 1px 2px rgba(0, 0, 0, .056), 0 4px 12px -4px rgba(0, 0, 0, .07);
  --e2-shadow: 0 2px 6px rgba(0, 0, 0, .06), 0 18px 40px -12px rgba(0, 0, 0, .10);
  --tint-0: #4C5BD4;
  --tint-1: #A8552A;
  --tint-2: #7A3E9D;
  --tint-3: #3F6B2B;
  --tint-4: #3E5567;
  --tint-5: #7A5C2E;
}


/* ==========================================================================
   02  TOKENS — TYPE, SPACE, RADIUS, MOTION, CONTROLS, LAYERS
   Type tokens are sizes only (safe in inline styles); line-heights are --lh-*.
   ========================================================================== */
:root {
  --font: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --t-micro: 11px;     --lh-micro: 1.3;
  --t-small: 12.5px;   --lh-small: 1.45;
  --t-body: 14.5px;    --lh-body: 1.55;
  --t-lead: 16.5px;    --lh-lead: 1.5;
  --t-h3: 18px;        --lh-h3: 1.35;
  --t-h2: 21px;        --lh-h2: 1.3;
  --t-h1: 27px;        --lh-h1: 1.2;
  --t-display: 40px;   --lh-display: 1.05;
  --t-mega: 56px;      --lh-mega: 1;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 72px;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --h-compact: 32px;
  --h-std: 40px;

  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 360ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.16, 1, .3, 1);

  --gutter: var(--s5);
  --pad: var(--s5);
  --max-operator: 1120px;
  --max-portal: 880px;

  --z-nav: 20;
  --z-bar: 30;
  --z-sheet: 50;
  --z-busy: 60;
  --z-toast: 70;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}


/* ==========================================================================
   04  BASE AND RESET
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

img, svg, video { max-width: 100%; }
svg { flex-shrink: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[data-action] { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

p { margin: 0 0 var(--s3); }

hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--s5) 0; }

code, kbd, pre, samp { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--hairline-soft); padding: 1px 5px; border-radius: var(--r-xs); }
pre {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: var(--s3) var(--s4);
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; }

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* Focus: visible for keyboard users only, never removed */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: inherit;
}

/* Quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-pill); border: 2px solid var(--ground); }

table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--hairline-soft); }
th { font-size: var(--t-small); font-weight: 600; color: var(--text-3); }


/* ==========================================================================
   05  TYPOGRAPHY AND NUMBERS
   ========================================================================== */
h1, h2, h3 { margin: 0; color: var(--text); text-wrap: balance; font-weight: 600; }
h1 { font-size: var(--t-h1); line-height: var(--lh-h1); letter-spacing: -0.012em; margin: 0 0 var(--s2); }
h2 { font-size: var(--t-h3); line-height: var(--lh-h3); margin: 0 0 var(--s3); text-transform: none; letter-spacing: 0; }
h3 { font-size: 15.5px; line-height: 1.4; margin: 0 0 var(--s2); }

.eyebrow {
  display: block;
  font-size: var(--t-micro);
  line-height: var(--lh-micro);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 var(--s2);
}

.lead-line {
  font-size: var(--t-lead);
  line-height: var(--lh-lead);
  color: var(--text-2);
  max-width: 62ch;
  margin: 0 0 var(--s5);
  text-wrap: pretty;
}
.lead-line strong, .lead-line b { color: var(--text); font-weight: 600; }

.num,
.money,
.stat-val,
.hero-num { font-variant-numeric: tabular-nums; }

.num { font-feature-settings: "tnum" 1; }

.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cur {
  font-size: .62em;
  vertical-align: .32em;
  color: var(--text-3);
  margin-right: .06em;
  font-weight: 500;
  letter-spacing: 0;
}

.mono { font-family: var(--mono); font-size: 13px; }

.hint {
  display: block;
  color: var(--text-3);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  margin: var(--s1) 0 0;
}
.hint code { font-size: 12px; }

.muted { color: var(--text-2); font-size: 13px; }
.next-action { color: var(--text-2); margin-top: 0; }
.next-action strong { color: var(--text); font-weight: 600; }


/* ==========================================================================
   06  LAYOUT: SCREEN, STACK, GRIDS
   ========================================================================== */
#app { min-height: 100vh; min-height: 100dvh; }

.screen {
  max-width: calc(var(--max-operator) + var(--gutter) * 2);
  margin: 0 auto;
  padding: var(--s6) var(--gutter) var(--s8);
}

.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
  margin-bottom: var(--s5);
}
.screen-head h1 { margin: 0; }
.screen-head .eyebrow { margin-bottom: var(--s1); }
.screen-head > div:first-child { min-width: 0; }

.screen-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack > * { margin-top: 0; margin-bottom: 0; }

.grid-2,
.grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
}
.grid-2 > *, .grid-3 > * { min-width: 0; margin-top: 0; }

.row-btns { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); align-items: center; }
.mt { margin-top: var(--s5); }


/* ==========================================================================
   07  SURFACES AND RULED HEADERS
   ========================================================================== */
.surface {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--pad);
  min-width: 0;
}
.surface.e1 { box-shadow: var(--e1-shadow); }
.surface.e2 { box-shadow: var(--e2-shadow); border-radius: var(--r-lg); }
.surface.inset { background: var(--surface-2); box-shadow: none; }

/* Ruled header outside a surface: a simple hairline-underlined row */
.rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding-bottom: var(--s3);
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--hairline);
}
/* Inside a surface it bleeds to the edges */
.surface > .rule-head {
  margin: calc(var(--pad) * -1) calc(var(--pad) * -1) var(--s4);
  padding: var(--s3) var(--pad);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 52px;
}
.rule-head h2, .rule-head h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.rule-head .eyebrow { margin: 0; }


/* Interactive card: hover lift */
.surface.link,
.biz-card,
.card {
  cursor: pointer;
  transition:
    transform var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    background-color var(--dur-1) var(--ease-out);
}
@media (hover: hover) {
  .surface.link:hover,
  .biz-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--e2-shadow);
    border-color: color-mix(in srgb, var(--text-3) 45%, var(--hairline));
  }
}
.surface.link:active, .biz-card:active { transform: translateY(0) scale(.995); }

/* Quiet text link (not a card) */
a.link,
button.link:not(.surface) {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-2);
  font-size: var(--t-small);
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
  cursor: pointer;
}
a.link:hover, button.link:not(.surface):hover { color: var(--text); text-decoration-color: currentColor; }


/* ==========================================================================
   08  CHIPS, STATUS DOTS, DELTAS
   ========================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font: 600 var(--t-micro)/1 var(--font);
  letter-spacing: .04em;
  text-transform: none;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  border: 0;
}
.chip svg { width: 12px; height: 12px; }
.chip.pos { background: var(--accent-wash); color: var(--accent); }
.chip.attn { background: var(--attn-wash); color: var(--attn); }
.chip.neg { background: var(--neg-wash); color: var(--neg); }
.chip.ink { background: var(--emph-bg); color: var(--emph-fg); }
.chip .sdot { width: 6px; height: 6px; margin: 0; }

/* Chip as a control (filters) */
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--h-compact);
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--text-2);
  font: 600 13px/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.chip-btn:hover { color: var(--text); background: var(--surface-2); }
.chip-btn.active,
.chip-btn[aria-pressed="true"] {
  background: var(--emph-bg);
  color: var(--emph-fg);
  border-color: transparent;
}
.chip-btn .chip,
.chip-btn .tab-count { height: 18px; padding: 0 6px; font-size: 10.5px; }
.chip-btn.active .chip,
.chip-btn.active .tab-count { background: color-mix(in srgb, var(--emph-fg) 14%, transparent); color: inherit; }

/* Status dot */
.sdot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  vertical-align: middle;
}
.sdot.pos { background: var(--accent); }
.sdot.attn { background: var(--attn); }
.sdot.neg { background: var(--neg); }
.sdot.mute { background: var(--text-3); opacity: .55; }

/* Delta chip: up = pos, down = neutral (never clay) */
.delta { gap: 4px; }
.delta:not(.chip) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  min-width: 0;
}
.delta:not(.chip) .stat-sub { margin: 0; }
.delta svg { width: 12px; height: 12px; }
.delta:not(.pos):not(.neg):not(.attn) { color: var(--text-2); }


/* ==========================================================================
   09  BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: var(--h-std);
  padding: 0 var(--s4);
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text);
  font: 600 14px/1 var(--font);
  letter-spacing: -0.003em;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out),
    filter var(--dur-1) var(--ease-out);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.985); }

.btn.primary {
  background: var(--emph-bg);
  color: var(--emph-fg);
  border-color: transparent;
}
.btn.primary:hover { background: var(--emph-bg); filter: brightness(.94); }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

.btn.danger {
  color: var(--neg);
  background: transparent;
  border-color: color-mix(in srgb, var(--neg) 40%, var(--hairline));
}
.btn.danger:hover { background: var(--neg-wash); }
.btn.primary.danger { background: var(--neg); color: #fff; border-color: transparent; }

.btn.sm { height: var(--h-compact); padding: 0 var(--s3); font-size: 13px; gap: 6px; }
.btn.sm svg { width: 14px; height: 14px; }

.btn.icon { position: relative; width: var(--h-std); padding: 0; }
.btn.icon.sm { width: var(--h-compact); }

.btn:disabled,
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn .spin { width: 14px; height: 14px; }


/* ==========================================================================
   10  INPUTS, FIELDS, CHECKS, SEGMENTED CONTROL, SWATCHES, SPINNER
   ========================================================================== */
.inp {
  display: block;
  width: 100%;
  height: var(--h-std);
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text);
  font: 400 14.5px/1.4 var(--font);
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}
.inp::placeholder { color: var(--text-3); opacity: 1; }
.inp:hover { border-color: color-mix(in srgb, var(--text-3) 40%, var(--hairline)); }
.inp:focus { border-color: var(--accent); background: var(--surface-1); }
.inp:disabled, .inp[readonly] { color: var(--text-2); }

textarea.inp {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
  line-height: 1.55;
  resize: vertical;
}

select.inp {
  padding-right: 34px;
  cursor: pointer;
  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='%237A808C' stroke-width='1.8' 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;
  background-size: 16px 16px;
}

.fld { margin: 0 0 var(--s4); min-width: 0; }
.fld:last-child { margin-bottom: 0; }

.lbl {
  display: block;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  margin: 0 0 6px;
}

.inline-error {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: 10px 12px;
  margin: var(--s3) 0;
  border-radius: var(--r-sm);
  background: var(--neg-wash);
  color: var(--neg);
  font-size: 13.5px;
  line-height: 1.45;
}
.inline-error svg { width: 16px; height: 16px; margin-top: 1px; }
.inline-error:empty { display: none; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  margin: var(--s2) 0;
  cursor: pointer;
}
.check input[type="checkbox"],
.check input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.check .hint { margin-top: 2px; }

.form-row,
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--s3);
}
.form-row > .fld, .two-col > .fld { margin-bottom: var(--s4); }

/* Segmented control (and portal range control) */
.seg,
.range-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  height: var(--h-std);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}
.seg-btn,
.range-seg > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  min-width: 44px;
  padding: 0 var(--s3);
  border: 1px solid transparent;
  border-radius: calc(var(--r-sm) - 3px);
  background: transparent;
  color: var(--text-2);
  font: 600 13px/1 var(--font);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.seg-btn:hover,
.range-seg > button:hover { color: var(--text); }
.seg-btn.active,
.seg-btn[aria-pressed="true"],
.seg-btn[aria-selected="true"],
.range-seg > button.active,
.range-seg > button[aria-pressed="true"],
.range-seg > button[aria-selected="true"] {
  background: var(--surface-1);
  color: var(--text);
  border-color: var(--hairline);
  box-shadow: var(--e1-shadow);
}

/* Tint swatches (inline --t on each) */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--t, var(--tint-0));
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--hairline-soft) inset;
  transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.swatch:hover { transform: scale(1.06); }
.swatch.active,
.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--t, var(--tint-0));
}

/* Spinner (animation is covered by the reduced-motion guard) */
.spin {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}


/* ==========================================================================
   11  TOP NAVIGATION, SWITCHER CHIP, MONOGRAMS, TABS
   --t on .topnav is the active business tint (2px hairline at the very top).
   ========================================================================== */
.topnav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--hairline);
  box-shadow: inset 0 2px 0 var(--t, transparent);
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 56px;
  max-width: calc(var(--max-operator) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 calc(var(--gutter) - 8px);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}
.topbar-right .btn.icon,
.topbar .btn.icon { background: transparent; border-color: transparent; color: var(--text-2); position: relative; }
.topbar-right .btn.icon:hover,
.topbar .btn.icon:hover { background: var(--surface-2); color: var(--text); }
.topbar .btn.icon .tab-count { position: absolute; top: 4px; right: 4px; }

.seal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--h-std);
  height: var(--h-std);
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--dur-1) var(--ease-out);
}
.seal-btn:hover { background: var(--surface-2); }
.seal-btn svg { width: 22px; height: 22px; }
.seal { display: inline-block; color: var(--text); }

.switcher-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 36px;
  min-width: 0;
  max-width: 100%;
  padding: 0 var(--s2) 0 7px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: 600 14.5px/1 var(--font);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.switcher-chip:hover { background: var(--surface-2); border-color: var(--hairline); }
.switcher-chip > svg:last-child { width: 14px; height: 14px; color: var(--text-3); }
.switcher-chip .seal,
.switcher-chip > svg:first-child:not(:last-child) { width: 22px; height: 22px; }
.switcher-name {
  min-width: 0;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Monogram: tint from inline --t */
.monogram {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--t, var(--tint-0)) 16%, transparent);
  color: var(--t, var(--tint-0));
  font: 650 10px/1 var(--font);
  letter-spacing: .02em;
  text-transform: uppercase;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}
.monogram-lg {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
}

/* Section tabs */
.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font: 550 14px/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active,
.tab[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }

/* In the top nav the tab row sits under the bar with an ink underline */
.topnav .tabs:not(.bottom-bar) {
  max-width: calc(var(--max-operator) + var(--gutter) * 2);
  margin: 0 auto;
  height: 44px;
  padding: 0 calc(var(--gutter) - 12px);
  align-items: stretch;
  gap: var(--s1);
}
.topnav .tabs:not(.bottom-bar) .tab { height: 44px; border-radius: 0; background: transparent; }
.topnav .tabs:not(.bottom-bar) .tab:hover { background: transparent; }
.topnav .tabs:not(.bottom-bar) .tab.active,
.topnav .tabs:not(.bottom-bar) .tab[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--text); }
.subtabs { border-top: 1px solid var(--hairline-soft); }

.tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font: 700 10.5px/1 var(--font);
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-count,
.tab-count.attn { background: var(--emph-bg); color: var(--emph-fg); }


/* ==========================================================================
   12  PHONE BOTTOM BAR (shown at <=640px only)
   ========================================================================== */
.bottom-bar { display: none; }

.bottom-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: 60px;
  padding: 0 var(--s1);
  border: 0;
  background: transparent;
  color: var(--text-3);
  font: 600 11px/1 var(--font);
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--dur-1) var(--ease-out);
}
.bottom-item svg { width: 20px; height: 20px; }
.bottom-item.active,
.bottom-item[aria-current="page"] { color: var(--text); }
.bottom-item .tab-count {
  position: absolute;
  top: 7px;
  left: calc(50% + 6px);
  height: 16px;
  min-width: 16px;
  padding: 0 4px;
  font-size: 10px;
  background: var(--emph-bg);
  color: var(--emph-fg);
}


/* ==========================================================================
   13  STATS AND HERO NUMBERS
   ========================================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
  gap: var(--s3);
  margin: 0 0 var(--s5);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.surface .stat { background: var(--surface-2); border-color: transparent; }

.stat-label {
  order: -1;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  font-weight: 550;
  color: var(--text-3);
  margin-bottom: var(--s1);
}
.stat-val {
  font-size: 26px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.014em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-sub {
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-2);
  margin-top: var(--s1);
}
.stat-sub.attn { color: var(--attn); }
.stat-sub.neg { color: var(--neg); }
.stat-sub.pos { color: var(--accent); }

.hero-num {
  font-size: var(--t-mega);
  line-height: var(--lh-mega);
  font-weight: 600;
  letter-spacing: -0.024em;
  color: var(--text);
}


/* ==========================================================================
   14  SHEETS
   Phone: bottom sheet. >=720px: centred dialog. .sheet-enter is applied only on
   the render where the sheet opens, so background renders never re-animate.
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--z-sheet) + 1);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 88vh;
  max-height: 88dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--s2) var(--s5) calc(var(--s5) + var(--safe-bottom));
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--e2-shadow);
}

.sheet-grab {
  flex-shrink: 0;
  width: 36px;
  height: 4px;
  margin: 0 auto var(--s3);
  border-radius: var(--r-pill);
  background: var(--surface-3);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) 0 var(--s4);
}
.sheet-head .eyebrow { margin-bottom: var(--s1); }
.sheet-head .btn.icon { margin: -6px -10px 0 0; background: transparent; border-color: transparent; color: var(--text-2); }
.sheet-head .btn.icon:hover { background: var(--surface-2); color: var(--text); }

.sheet-title {
  margin: 0;
  font-size: var(--t-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
  letter-spacing: -0.006em;
}

.sheet-body { flex: 1 1 auto; min-height: 0; }
.sheet-body > p { color: var(--text-2); }

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--hairline-soft);
}
.sheet-foot > .push { margin-right: auto; }

/* Entrance: works whether .sheet-enter sits on the backdrop, the sheet, or a wrapper */
.sheet-backdrop.sheet-enter,
.sheet-enter .sheet-backdrop,
.sheet-backdrop:has(.sheet-enter),
.sheet-backdrop:has(+ .sheet-enter) {
  animation: sheet-fade var(--dur-2) var(--ease-out) both;
}
.sheet.sheet-enter,
.sheet-enter .sheet {
  animation: sheet-rise var(--dur-2) var(--ease-spring) both;
}


/* ==========================================================================
   15  BUSINESS SWITCHER
   ========================================================================== */
.switcher { display: flex; flex-direction: column; min-width: 0; }

.switcher-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 calc(var(--s2) * -1);
}

.switcher-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 52px;
  padding: var(--s2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  font: 550 14.5px/1.3 var(--font);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
.switcher-row:hover { background: var(--surface-2); }
.switcher-row.active,
.switcher-row[aria-current="true"] { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--t, var(--text)); }
.switcher-row > svg { width: 16px; height: 16px; color: var(--text-3); }
.switcher-row .row-main { flex: 1; min-width: 0; }
.switcher-row .row-title { font-weight: 600; }
.switcher-row .row-sub { font-size: var(--t-small); color: var(--text-3); }
.switcher-row + .switcher-row { margin-top: 0; }
.switcher-list > hr { margin: var(--s1) var(--s2); border: 0; border-top: 1px solid var(--hairline-soft); }

.switcher-meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-3);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}

.switcher-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--hairline-soft);
}
.switcher-foot .btn { color: var(--text-2); }
.switcher-foot .btn:hover { color: var(--text); }


/* ==========================================================================
   16  HUB
   ========================================================================== */
.hub-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  margin: 0 0 var(--s6);
}

.biz-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
  min-height: 212px;
  padding: var(--s5);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--e1-shadow);
  text-align: left;
  color: var(--text);
}

.biz-card-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}
.biz-card-head > div { min-width: 0; }
.biz-card-head h3,
.biz-card-head .row-title {
  margin: 0;
  font-size: var(--t-h3);
  line-height: var(--lh-h3);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.biz-card-head .eyebrow { margin: 0 0 2px; }
.biz-card .spark { margin-top: auto; }

.biz-card-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 212px;
  padding: var(--s5);
  border: 1px dashed color-mix(in srgb, var(--text-3) 45%, var(--hairline));
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font: 600 14.5px/1.3 var(--font);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.biz-card-new svg { width: 20px; height: 20px; }
.biz-card-new:hover { color: var(--text); border-color: var(--text-3); background: color-mix(in srgb, var(--surface-1) 50%, transparent); }

.micro-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
  padding: var(--s3) 0;
  border-top: 1px solid var(--hairline-soft);
  border-bottom: 1px solid var(--hairline-soft);
}
.micro-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-3);
}
.micro-stat .num,
.micro-stat .money,
.micro-stat .stat-val,
.micro-stat strong,
.micro-stat b {
  font-size: 16.5px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.008em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.micro-stat .stat-label { order: -1; margin: 0; font-size: var(--t-small); }

.attn-line {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.attn-line > span:not(.sdot):not(.chip) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attn-line.mute { color: var(--text-3); }

.attn-list {
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  overflow: hidden;
}
.attn-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 52px;
  padding: var(--s3) var(--s4);
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
.attn-row + .attn-row { border-top: 1px solid var(--hairline-soft); }
.attn-row:hover { background: var(--surface-2); }
.attn-row > :not(.monogram):not(.sdot):not(.chip):not(svg) { flex: 1; min-width: 0; }
.attn-row > svg { width: 16px; height: 16px; color: var(--text-3); }


/* ==========================================================================
   17  PIPELINE: FILTER CHIPS, BOARD, CARDS
   ========================================================================== */
.filter-chips {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0 0 var(--s5);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.filter-chips::-webkit-scrollbar { display: none; }

.board {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  overflow-x: auto;
  padding-bottom: var(--s3);
  margin: 0 calc(var(--gutter) * -1);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  scroll-padding: 0 var(--gutter);
}

.col {
  display: flex;
  flex-direction: column;
  flex: 1 0 232px;
  min-width: 232px;
  max-width: 320px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}

.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  height: 44px;
  padding: 0 var(--s3) 0 var(--s4);
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.col-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font: 600 11px/1 var(--font);
  font-variant-numeric: tabular-nums;
}

.col-body {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s2);
  min-height: 56px;
}
.col-body .empty-state { padding: var(--s4) var(--s2); gap: var(--s1); }
.col-body .empty-state .empty-title { font-size: 14px; }
.col-body .empty-state .empty-text { font-size: var(--t-small); }
.col-body .empty-state .empty-icon { width: 32px; height: 32px; }

.card {
  display: block;
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text);
  text-align: left;
}
@media (hover: hover) {
  .card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--text-3) 45%, var(--hairline));
    box-shadow: var(--e1-shadow);
  }
}
.card-title {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--s3);
  margin: var(--s1) 0 var(--s2);
  color: var(--text-3);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}
.card-meta:last-child { margin-bottom: 0; }

details.lost { margin-top: var(--s5); }
details.lost > summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
  padding: var(--s2) 0;
  list-style-position: inside;
}
details.lost > summary:hover { color: var(--text); }
details.lost .board { margin-top: var(--s2); }


/* ==========================================================================
   18  EMPTY STATES
   ========================================================================== */
.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  padding: var(--s6) var(--s4);
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--s1);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hairline-soft);
  color: var(--text-3);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty-title {
  margin: 0;
  font-size: var(--t-h3);
  line-height: var(--lh-h3);
  font-weight: 600;
  color: var(--text);
  text-wrap: balance;
}
.empty-text {
  margin: 0;
  max-width: 42ch;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}
.empty-state .btn { margin-top: var(--s2); }
.empty-state pre { text-align: left; max-width: 100%; margin: var(--s2) 0 0; font-size: 12px; }


/* ==========================================================================
   19  LISTS, ROWS, REPLIES
   ========================================================================== */
.list {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.surface > .list { margin: calc(var(--s2) * -1) calc(var(--s3) * -1); }

.row-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  min-height: 52px;
  padding: var(--s3);
  border-radius: var(--r-sm);
  color: var(--text);
  text-align: left;
  transition: background-color var(--dur-1) var(--ease-out);
}
.list > .row-item + .row-item { box-shadow: 0 -1px 0 var(--hairline-soft); }
.row-item[data-action],
.row-item.link { cursor: pointer; }
.row-item[data-action]:hover,
.row-item.link:hover { background: var(--surface-2); }
button.row-item { width: 100%; border: 0; background: transparent; font: inherit; }

.row-main { flex: 1 1 auto; min-width: 0; }
.row-title {
  font-size: 14.5px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  margin-top: 2px;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-side {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-shrink: 0;
  margin-left: auto;
  color: var(--text-3);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-side > svg { width: 16px; height: 16px; }

/* Work rows (legacy list rows, restyled) */
.worklist, .sendlist, .notiflist { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }
.work-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
@media (hover: hover) {
  .work-row:not(.static):hover {
    border-color: color-mix(in srgb, var(--text-3) 45%, var(--hairline));
    transform: translateY(-1px);
    box-shadow: var(--e1-shadow);
  }
}
.work-row.static { cursor: default; }
.work-row.static:hover { transform: none; box-shadow: none; border-color: var(--hairline); }
.w-main { flex: 1; min-width: 0; }
.w-title { font-weight: 600; font-size: 14.5px; line-height: 1.4; }
.w-action { color: var(--text-2); font-size: 13px; line-height: 1.45; }
.w-go { color: var(--text-3); }

.reply-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s3);
}

.converted-line {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  min-height: 44px;
  padding: var(--s2) var(--s4);
  border: 1px dashed var(--hairline);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: 13.5px;
}
.converted-line strong, .converted-line b { color: var(--text-2); font-weight: 600; }
.converted-line .btn, .converted-line a.link, .converted-line button.link { margin-left: auto; }

.reply-dot { min-width: 18px; display: flex; align-items: center; justify-content: center; }
.reply-dot .sdot { margin: 0; }
.reply-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s3); }
.reply blockquote {
  margin: 0;
  padding: var(--s3) var(--s4);
  border-left: 2px solid var(--hairline);
  background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text);
  white-space: pre-wrap;
}
.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 6px 0;
  color: var(--text-2);
}

/* Notifications (legacy) */
.notif {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.notif.clickable { cursor: pointer; }
.notif.clickable:hover { border-color: color-mix(in srgb, var(--text-3) 45%, var(--hairline)); }
.notif-text { flex: 1; min-width: 0; }


/* ==========================================================================
   20  LEAD DETAIL: STAGE RAIL, CLIENT STRIP
   ========================================================================== */
.stage-rail {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 360px;
  height: 16px;
  margin: var(--s2) 0 var(--s4);
}
.stage-rail::before {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  top: 50%;
  height: 1px;
  background: var(--hairline);
}
.rail-dot {
  position: relative;
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ground);
  border: 1.5px solid var(--hairline);
  flex-shrink: 0;
}
.rail-dot.done { background: var(--text-2); border-color: var(--text-2); }
.rail-dot.current {
  width: 11px;
  height: 11px;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ground), 0 0 0 4.5px var(--accent);
}
.rail-dot.lost { background: var(--neg); border-color: var(--neg); }
.rail-dot.current.lost { box-shadow: 0 0 0 3px var(--ground), 0 0 0 4.5px var(--neg); }

.client-strip {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  margin: 0 0 var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.client-strip .row-main,
.client-strip > strong,
.client-strip > span:not(.monogram):not(.chip) { min-width: 0; font-weight: 600; }
.client-strip .btn { margin-left: auto; }

.lead-grid,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  margin-top: var(--s4);
  align-items: start;
}
.lead-grid > *, .detail-grid > * { min-width: 0; margin-top: 0; }
.detail-grid > .stack { min-width: 0; }

.danger-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--hairline);
}
.danger-row .inp { width: auto; flex: 1 1 200px; }


/* ==========================================================================
   21  CLIENTS ROSTER
   ========================================================================== */
.roster {
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  overflow: hidden;
}

.roster-row {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 64px;
  padding: var(--s3) var(--s4);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
.roster-row + .roster-row { border-top: 1px solid var(--hairline-soft); }
.roster-row:hover { background: var(--surface-2); }
.roster-row > .row-main { flex: 1 1 200px; }
.roster-row .spark { width: 64px; height: 18px; }
.roster-row .num { min-width: 3ch; text-align: right; font-size: 13.5px; color: var(--text-2); }

.unclaimed-strip {
  display: flex;
  align-items: center;
  gap: var(--s2) var(--s3);
  flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  margin: 0 0 var(--s4);
  background: var(--attn-wash);
  border: 1px solid color-mix(in srgb, var(--attn) 28%, var(--hairline));
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13.5px;
}
.unclaimed-strip code { background: var(--surface-1); }
.unclaimed-strip .inp { width: auto; min-width: 160px; height: var(--h-compact); font-size: 13.5px; }
.unclaimed-strip form { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-left: auto; }
.unclaimed-strip + .unclaimed-strip { margin-top: calc(var(--s2) * -1); }

.access-line {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.access-line .mono { font-size: 12px; letter-spacing: .06em; }


/* ==========================================================================
   22  CLIENT DETAIL: THREAD, COMPOSE, ACCESS, LOG, KEY-VALUE
   ========================================================================== */
.thread {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  max-height: 520px;
  overflow-y: auto;
  padding: var(--s1) 2px;
  overscroll-behavior: contain;
}
.thread:empty { display: none; }
ol.thread, ul.thread { list-style: none; margin: 0; }
.msg > p { margin: 0; }
.msg > .msg-meta:first-child { margin: 0 0 4px; }
.msg-out > .msg-meta:first-child { text-align: left; }


.msg {
  max-width: min(84%, 560px);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-in {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: var(--r-xs);
  color: var(--text);
}
.msg-out {
  align-self: flex-end;
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-bottom-right-radius: var(--r-xs);
  color: var(--text);
}
.msg-meta {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text-3);
  white-space: normal;
  font-variant-numeric: tabular-nums;
}
.msg-out .msg-meta { text-align: right; }
.thread > .msg-meta { margin-top: calc(var(--s2) * -1); }
.thread > .msg-meta.out, .thread > .msg-out + .msg-meta { align-self: flex-end; }

.compose {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--hairline-soft);
}
.compose textarea.inp { min-height: 88px; }
.compose .row-btns,
.compose > div:last-child:not(.fld) {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s2);
  margin-top: 0;
}
.compose .hint { margin: 0 auto 0 0; }
.compose > .btn { align-self: flex-end; }

.access-panel .kv { margin-bottom: var(--s4); }
.access-panel .btn + .hint,
.access-panel .hint { margin-top: 6px; }
.access-panel .row-btns { margin-top: var(--s4); }

.log-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}
.log-row {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s2) 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.log-row + .log-row { border-top: 1px solid var(--hairline-soft); }
.log-row > :first-child { color: var(--text); min-width: 0; flex: 1; }
.log-row > :last-child:not(:first-child) { color: var(--text-3); white-space: nowrap; font-size: 12px; }

.kv {
  display: flex;
  flex-direction: column;
  margin: 0;
}
.kv-row {
  display: grid;
  grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
  gap: var(--s3);
  align-items: baseline;
  padding: var(--s2) 0;
  font-size: 14px;
  line-height: 1.45;
}
.kv-row + .kv-row { border-top: 1px solid var(--hairline-soft); }
.kv-row > :first-child { color: var(--text-3); font-size: 13px; margin: 0; }
.kv-row > :last-child { color: var(--text); margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv-row > .chip, .kv-row > .btn, .kv-row > a { justify-self: start; }
.kv-row > a { display: inline-flex; align-items: center; gap: 6px; }
.kv-row > a svg { width: 14px; height: 14px; flex-shrink: 0; }


/* ==========================================================================
   23  HANDOFF CODE PLATE
   ========================================================================== */
.code-plate {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 10px;
  padding: var(--s5) var(--s3);
  margin: var(--s2) 0 var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 30px;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  user-select: all;
  -webkit-user-select: all;
}
.code-plate::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left center;
}

.code-group {
  display: inline-block;
  padding: 0 0 6px;
  letter-spacing: .14em;
  margin-right: -.14em;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

.code-sep {
  display: inline-grid;
  place-items: center;
  color: var(--text-3);
  font-size: .6em;
  padding-bottom: 6px;
  user-select: none;
  -webkit-user-select: none;
}
.code-sep:empty::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
}

.code-url {
  display: block;
  margin: 0 0 var(--s1);
  font-family: var(--mono);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-2);
  overflow-wrap: anywhere;
  text-align: center;
}
.code-note {
  margin: 0 auto var(--s2);
  max-width: 46ch;
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-3);
  text-align: center;
  text-wrap: pretty;
}

.sheet-enter .code-plate,
.code-plate.sheet-enter { animation: plate-in var(--dur-3) var(--ease-spring) both; }
.sheet-enter .code-plate::after,
.code-plate.sheet-enter::after { animation: sweep var(--dur-3) var(--ease-out) 120ms both; }


/* ==========================================================================
   24  LOCK SCREEN
   ========================================================================== */
.lock-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--s5) + var(--safe-top)) var(--s4) calc(var(--s5) + var(--safe-bottom));
  background: var(--ground);
}

.lock-card {
  width: 100%;
  max-width: 380px;
  padding: var(--s6);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--e2-shadow);
}
.lock-card > svg:first-child,
.lock-card .seal { width: 32px; height: 32px; margin-bottom: var(--s5); color: var(--text); }
.lock-card h1 { font-size: var(--t-h2); line-height: var(--lh-h2); letter-spacing: -0.006em; margin: 0 0 var(--s5); }
.lock-card form { display: flex; flex-direction: column; gap: var(--s3); }
.lock-card .btn.primary { width: 100%; }
.lock-card .inline-error { margin: 0; }
.lock-card .link,
.lock-card a:not(.btn) { display: inline-block; margin-top: var(--s5); }


/* ==========================================================================
   25  OVERLAYS: BUSY, TOAST
   ========================================================================== */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-busy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.busy-card {
  display: flex;
  align-items: center;
  gap: var(--s3);
  max-width: 420px;
  padding: var(--s4) var(--s5);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--e2-shadow);
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s5) + var(--safe-bottom));
  z-index: var(--z-toast);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: max-content;
  max-width: min(92vw, 520px);
  min-height: 44px;
  padding: 10px var(--s4);
  background: var(--emph-bg);
  color: var(--emph-fg);
  border-radius: var(--r-md);
  box-shadow: var(--e2-shadow);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.4;
}
.toast svg { width: 16px; height: 16px; }
.toast .btn { height: var(--h-compact); color: inherit; background: transparent; border-color: color-mix(in srgb, var(--emph-fg) 25%, transparent); }
.toast.neg { background: var(--neg); color: #fff; }


/* ==========================================================================
   26  CHARTS (src/charts.js)
   Colours only via these classes; gradients live inside the SVG.
   ========================================================================== */
.chart {
  position: relative;
  display: block;
  min-width: 0;
  margin: var(--s2) 0 0;
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s2);
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--text-3);
}
.chart-ymax {
  font-size: var(--t-small);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  fill: var(--text-3);
}
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.chart-fill { stroke: none; }
.chart-mean {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
}
.chart-dot { fill: var(--accent); stroke: var(--surface-1); stroke-width: 1.5; }
.chart-dot-label {
  fill: var(--text);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chart-bar { fill: var(--accent); fill-opacity: .85; }
.chart-bar-zero { fill: var(--hairline); stroke: none; }
.chart-x {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  fill: var(--text-3);
  font-variant-numeric: tabular-nums;
}
svg .chart-x, svg.chart-x { font-family: var(--font); font-size: 11px; }

/* Funnel: one grid on the container, rows are display:contents */
.funnel {
  display: grid;
  grid-template-columns: minmax(96px, 140px) minmax(0, 1fr) 72px;
  align-items: center;
  column-gap: var(--s3);
  row-gap: var(--s2);
}
.funnel-row { display: contents; }
.funnel-label {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.funnel-track {
  position: relative;
  height: 10px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  overflow: hidden;
}
.funnel-fill {
  display: block;
  height: 100%;
  max-width: 100%;
  background: var(--accent);
  border-radius: var(--r-xs);
}
.funnel-val {
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Sources: same grid pattern, 4-stop accent ramp */
.sources {
  display: grid;
  grid-template-columns: minmax(96px, 160px) minmax(0, 1fr) 52px;
  align-items: center;
  column-gap: var(--s3);
  row-gap: var(--s2);
}
.source-row { display: contents; }
.source-label {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-track {
  position: relative;
  height: 10px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  overflow: hidden;
}
.source-fill {
  display: block;
  height: 100%;
  max-width: 100%;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--accent) 25%, var(--surface-1));
}
.source-row:nth-of-type(1) .source-fill { background: var(--accent); }
.source-row:nth-of-type(2) .source-fill { background: color-mix(in srgb, var(--accent) 70%, var(--surface-1)); }
.source-row:nth-of-type(3) .source-fill { background: color-mix(in srgb, var(--accent) 45%, var(--surface-1)); }
.source-val {
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Sparkline */
.spark {
  display: inline-block;
  vertical-align: middle;
  overflow: visible;
  flex-shrink: 0;
}
.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.spark-dot { fill: var(--accent); stroke: none; }


/* ==========================================================================
   27  CLIENT PORTAL  (html[data-surface="portal"], paper)
   ========================================================================== */
#portal { min-height: 100vh; min-height: 100dvh; }

.p-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ground);
}

.p-top {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: calc(60px + var(--safe-top));
  padding-left: max(var(--gutter), calc((100% - var(--max-portal)) / 2));
  padding-right: max(var(--gutter), calc((100% - var(--max-portal)) / 2));
}

.p-brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}
.p-brand > span:not(.monogram),
.p-brand > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-brand svg { width: 22px; height: 22px; }

.p-body {
  flex: 1 0 auto;
  width: 100%;
  max-width: calc(var(--max-portal) + var(--gutter) * 2);
  margin: 0 auto;
  padding: var(--s6) var(--gutter) var(--s7);
}
.p-body > .eyebrow + h1,
.p-body > .eyebrow + h2 { margin-top: 0; }

.p-signin {
  display: grid;
  place-items: center;
  flex: 1 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--s5) + var(--safe-top)) var(--s4) calc(var(--s5) + var(--safe-bottom));
}
.p-shell .p-signin { min-height: 0; padding-top: var(--s7); padding-bottom: var(--s7); }

.p-card {
  width: 100%;
  max-width: 400px;
  padding: var(--s6);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--e2-shadow);
}
.p-card > svg:first-child,
.p-card .seal { width: 32px; height: 32px; margin-bottom: var(--s5); color: var(--text); }
.p-card h1 { font-size: var(--t-h1); line-height: var(--lh-h1); letter-spacing: -0.012em; margin: 0 0 var(--s5); }
.p-card form { display: flex; flex-direction: column; gap: var(--s3); }
.p-card .btn.primary { width: 100%; height: 48px; font-size: 15px; }
.p-card .inline-error { margin: 0; }
.p-card .fld { margin: 0; }
.p-card .eyebrow { margin: 0 0 var(--s2); }
.p-card h1 + .lead-line { margin-top: calc(var(--s3) * -1); font-size: 15px; }
.p-card .lead-line + .p-note { margin: 0 0 var(--s4); }
.p-card .hint, .p-card .p-note { margin-top: var(--s4); }

/* Segmented code field: one real input, three visual groups via hyphens */
input.code-field,
.code-field input {
  display: block;
  width: 100%;
  height: 56px;
  padding: 0 var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
input.code-field::placeholder,
.code-field input::placeholder { color: var(--text-3); opacity: .55; letter-spacing: .14em; }
input.code-field:focus,
.code-field input:focus { border-color: var(--accent); background: var(--surface-1); }
.code-field:not(input) { display: block; }

.hero {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s6);
  margin: 0 0 var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--e1-shadow);
  min-width: 0;
}
.hero .hero-num { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; margin: 0; }
.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3) var(--s5);
  flex-wrap: wrap;
  min-width: 0;
}
.hero-row > div:first-child { min-width: 0; }
.hero-row .hero-label { margin: 0 0 var(--s1); }
.hero-row > .delta { padding-bottom: 10px; }
.hero .chart { margin-top: var(--s4); }
.hero-label {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 550;
  color: var(--text-2);
}
.hero > .delta, .hero .chip { align-self: flex-start; }
.hero-num + .chip, .hero-num + .delta { margin-top: var(--s1); }

.p-section { margin: var(--s6) 0 0; min-width: 0; }
.p-section:first-child { margin-top: 0; }
.p-section > h2,
.p-section > .rule-head h2 { font-size: var(--t-h3); line-height: var(--lh-h3); margin: 0 0 var(--s3); }
.p-section > .eyebrow { margin-bottom: var(--s2); }
.p-section > .surface + .surface { margin-top: var(--s3); }

.p-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s6) var(--gutter) calc(var(--s6) + var(--safe-bottom));
  border-top: 1px solid var(--hairline-soft);
  color: var(--text-3);
  font-size: var(--t-small);
  text-align: center;
}
.p-footer svg { width: 20px; height: 20px; color: var(--text-2); }

.p-note {
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
}

.hero > h2 { font-size: var(--t-h2); line-height: var(--lh-h2); letter-spacing: -0.006em; margin: 0; }

/* Refetching a new range: keep the old numbers, quietly dimmed */
.stack[aria-busy="true"] { opacity: .55; transition: opacity var(--dur-2) var(--ease-out); pointer-events: none; }
.hero > .eyebrow { margin: 0; }
.hero > .lead-line { margin: 0 0 var(--s3); }

/* Awaiting-data skeleton: static hairline ghosts at 30%, no shimmer */
.skeleton {
  display: grid;
  gap: var(--s3);
  opacity: .3;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.skeleton:empty {
  min-height: 140px;
  border: 1px solid var(--text-3);
  border-radius: var(--r-md);
}
.skeleton > :not(svg) {
  display: block;
  min-height: 10px;
  border: 1px solid var(--text-3);
  border-radius: var(--r-xs);
  background: transparent;
  color: transparent;
}
.skeleton > :nth-child(2n) { width: 72%; }
.skeleton > :nth-child(3n) { width: 48%; }
.skeleton > svg { display: block; width: 100%; height: auto; }
.skeleton > svg + svg { margin-top: var(--s3); }
/* Ghost strokes: inline hairline strokes are too faint at 30%, lift them to --text-3 */
.skeleton svg path,
.skeleton svg rect,
.skeleton .chart-line,
.skeleton .spark-line { stroke: var(--text-3) !important; }
.skeleton > svg[viewBox$=" 180"] { aspect-ratio: 600 / 180; }


/* ==========================================================================
   28  LEGACY SCREENS RESTYLED ONTO TOKENS
   Money ledger, advisor, settings, send queue, QA, old top bar, old portal.
   ========================================================================== */

/* Legacy badge look, still used by the Auto screen's QA line */
.qa-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-pill);
  font: 600 var(--t-micro)/1 var(--font);
  letter-spacing: .04em;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
  text-transform: none;
  vertical-align: middle;
  margin: 6px 0;
  height: auto;
  min-height: 22px;
  padding: 4px 8px;
  white-space: normal;
  line-height: 1.35;
}

.qa-line.ok { background: var(--accent-wash); color: var(--accent); }
.qa-line.bad { background: var(--neg-wash); color: var(--neg); }

/* Send queue */
.send-card {
  padding: var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.send-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); flex-wrap: wrap; }
.send-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.send-subject { font-weight: 600; margin: var(--s3) 0 6px; }
.send-body { color: var(--text-2); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }

/* Advisor */
.advisor-summary { font-size: var(--t-lead); line-height: var(--lh-lead); color: var(--text); margin: 6px 0 var(--s4); max-width: 68ch; }
.advisor-list { display: flex; flex-direction: column; gap: var(--s2); }
.adv-item {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.adv-item.clickable { cursor: pointer; transition: border-color var(--dur-1) var(--ease-out); }
.adv-item.clickable:hover { border-color: color-mix(in srgb, var(--text-3) 45%, var(--hairline)); }
.adv-dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; flex-shrink: 0; background: var(--text-3); }
.adv-item.p0 .adv-dot { background: var(--neg); }
.adv-item.p1 .adv-dot { background: var(--attn); }
.adv-item.p2 .adv-dot { background: var(--text-3); }
.adv-item.p0 { border-color: color-mix(in srgb, var(--neg) 35%, var(--hairline)); }
.adv-text { flex: 1; min-width: 0; }
.ai-brief { border-color: color-mix(in srgb, var(--accent) 30%, var(--hairline)); }

/* Backend connection */
.conn-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin: 4px 0 var(--s3); }

/* Transactions */
.tx-list { display: flex; flex-direction: column; margin-bottom: var(--s3); }
.tx-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; flex-wrap: wrap; }
.tx-row + .tx-row { border-top: 1px solid var(--hairline-soft); }
.tx-amount { min-width: 84px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amount.paid { color: var(--accent); }
.tx-amount.overdue { color: var(--neg); }
.tx-amount.due { color: var(--attn); }
.tx-amount .cur { color: inherit; opacity: .7; }
.tx-main { flex: 1; min-width: 0; }
.tx-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.tx-form { border-top: 1px solid var(--hairline); padding-top: var(--s3); margin-top: var(--s2); }
.tx-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--s3); }


/* ==========================================================================
   29  MOTION
   Entrance stagger fires only when render() sets #app[data-enter] (a real
   view change). Rows may set style="--i:N".
   ========================================================================== */
#app[data-enter] .stagger > *,
#portal[data-enter] .stagger > * {
  animation: rise var(--dur-2) var(--ease-out) both;
  animation-delay: calc(min(var(--i, 0), 12) * 28ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
}
@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheet-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-scale {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes plate-in {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes sweep {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ==========================================================================
   30  UTILITIES
   ========================================================================== */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mute { color: var(--text-3); }


/* ==========================================================================
   31  RESPONSIVE
   Breakpoints: 640px (phone), 720px (sheets and hub grid only), 1080px (wide).
   ========================================================================== */

/* ---- >= 720px: centred dialog sheets, two-up hub, two-up grids ---- */
@media (min-width: 720px) {
  .sheet {
    inset: 0;
    margin: auto;
    width: min(560px, 92vw);
    height: fit-content;
    max-height: 88vh;
    max-height: 88dvh;
    padding: var(--s5) var(--s6) var(--s6);
    border-bottom: 1px solid var(--hairline);
    border-radius: var(--r-lg);
  }
  .sheet.switcher,
  .sheet:has(> .switcher) { width: min(440px, 92vw); }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 0; }
  .sheet.sheet-enter,
  .sheet-enter .sheet { animation-name: sheet-scale; }

  .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .code-plate { font-size: 36px; gap: 14px; padding: var(--s6) var(--s4); }
}

/* ---- >= 1080px: three-up hub, two-column detail layouts ---- */
@media (min-width: 1080px) {
  .hub-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lead-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--s5); }
}

/* ---- <= 640px: phone ---- */
@media (max-width: 640px) {
  :root {
    --h-std: 44px;
    --gutter: 16px;
    --pad: var(--s4);
    --t-mega: 44px;
  }

  body { font-size: 15px; }
  h1 { font-size: 24px; }

  .screen {
    padding: var(--s5) var(--gutter) calc(96px + var(--safe-bottom));
  }
  .screen-head { flex-direction: column; align-items: stretch; gap: var(--s3); margin-bottom: var(--s4); }
  .screen-head h1 { font-size: 24px; }
  .screen-head > div:not(:first-child),
  .screen-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .screen-head .screen-actions .btn,
  .screen-head > .row-btns .btn { flex: 1 1 auto; }

  /* 16px inputs stop iOS zooming on focus */
  .inp, input, select, textarea { font-size: 16px; }
  .btn { min-height: var(--h-std); }
  .btn.sm { min-height: var(--h-compact); }

  .form-row, .two-col, .tx-form-grid { grid-template-columns: minmax(0, 1fr); }

  /* Top bar */
  .topbar { height: 56px; padding: 0 var(--s2); gap: var(--s1); }
  .switcher-name { max-width: 44vw; }
  .topbar-right { gap: 0; }

  /* Bottom bar replaces the tab row */
  .bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-bar);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: stretch;
    height: calc(60px + var(--safe-bottom));
    padding: 0 var(--s2) var(--safe-bottom);
    background: color-mix(in srgb, var(--ground) 90%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--hairline);
  }
  .bottom-bar .tab {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    height: 60px;
    padding: 0 var(--s1);
    border-radius: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    box-shadow: none;
  }
  .bottom-bar .tab svg { width: 20px; height: 20px; }
  .bottom-bar .tab.active,
  .bottom-bar .tab[aria-current="page"] { color: var(--text); background: transparent; box-shadow: none; }
  .topnav:has(.bottom-bar) .tabs:not(.bottom-bar),
  body:has(.bottom-bar) .topnav .tabs:not(.bottom-bar) { display: none; }
  /* position:fixed inside a backdrop-filtered ancestor is trapped by it, so a
     nav that contains the bottom bar drops its blur on phones */
  .topnav:has(.bottom-bar) {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--ground);
  }
  .subtabs { padding: 0 var(--s2); }

  /* Pipeline: one column per swipe */
  .board { scroll-snap-type: x mandatory; gap: var(--s2); }
  .col { flex: 0 0 84vw; min-width: 84vw; max-width: none; scroll-snap-align: start; }
  .col-body { min-height: 96px; }
  .filter-chips { margin: 0 calc(var(--gutter) * -1) var(--s4); padding: 2px var(--gutter); }

  /* Hub */
  .biz-card, .biz-card-new { min-height: 0; padding: var(--s4); }
  .biz-card-new { min-height: 120px; }

  /* Stats */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .stat { padding: var(--s3); }
  .stat-val { font-size: 21px; }

  /* Rows wrap instead of squeezing */
  .roster-row { flex-wrap: wrap; gap: var(--s2) var(--s3); padding: var(--s3); }
  .roster-row > .row-main { flex: 1 1 100%; }
  .roster-row .row-side { margin-left: auto; }
  .work-row { padding: var(--s3); gap: var(--s2); }
  .client-strip .btn { margin-left: 0; flex: 1 1 100%; }
  .converted-line .btn { margin-left: 0; }
  .unclaimed-strip form { margin-left: 0; width: 100%; }
  .unclaimed-strip .inp { flex: 1 1 auto; }

  .kv-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }

  .msg { max-width: 90%; }
  .thread { max-height: none; }

  /* Charts */
  .funnel { grid-template-columns: minmax(84px, 108px) minmax(0, 1fr) 56px; column-gap: var(--s2); }
  .sources { grid-template-columns: minmax(84px, 116px) minmax(0, 1fr) 44px; column-gap: var(--s2); }
  .funnel-label, .source-label, .funnel-val, .source-val { font-size: 13px; }

  /* Code plate */
  .code-plate { font-size: 26px; gap: 6px; padding: var(--s5) var(--s2); }
  .code-group { letter-spacing: .1em; margin-right: -.1em; }

  /* Sheets on phone: bigger tap targets in the footer */
  .sheet { padding-left: var(--s4); padding-right: var(--s4); }
  .sheet-foot { flex-direction: column-reverse; align-items: stretch; }
  .sheet-foot .btn { width: 100%; }
  .sheet-foot > .push { margin-right: 0; }

  /* Overlays sit above the bottom bar */
  .toast { bottom: calc(60px + var(--s3) + var(--safe-bottom)); }

  /* Lock and portal cards */
  .lock-card, .p-card { padding: var(--s5); }
  .hero { padding: var(--s5) var(--s4); }
  .p-body { padding: var(--s5) var(--gutter) var(--s7); }
  .p-top { min-height: calc(56px + var(--safe-top)); }
  .p-section { margin-top: var(--s5); }
  .range-seg, .seg { height: 40px; }
}

/* ---- tiny phones ---- */
@media (max-width: 374px) {
  .code-plate { font-size: 22px; }
  .micro-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
  .micro-stat .num, .micro-stat .money, .micro-stat strong { font-size: 15px; }
}
