/* ══════════════════════════════════════════════════════════════
   ARALeads — dashboard styles (from Harvey, MIT)

   The rules this sheet follows:

   1. One accent. Brand navy marks the primary action, the current page
      and the main series in a chart. Status hues (good, waiting, bad,
      active, note) appear only on status, so colour always means
      something.
   2. Space groups things; shadows lift surfaces; lines only divide.
      The gap between groups is at least twice the gap inside one.
   3. One typeface on a small scale. Numbers are tabular so columns
      line up and a changing value never shifts the layout.
   4. Motion is for feedback, not decoration: nothing animates on a
      tab switch, buttons press, hovers only on a real pointer.

   Light and dark are the same design re-tokenised: only :root and
   [data-theme] change between them.
   ══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Geist'; font-style: normal; font-weight: 400 600;
  font-display: swap; src: url('/dashboard/fonts/geist.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono'; font-style: normal; font-weight: 400 500;
  font-display: swap; src: url('/dashboard/fonts/geist-mono.woff2') format('woff2');
}

/* ── Tokens ──────────────────────────────────────────────────── */

:root {
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Type scale: size / line-height pairs, by role. */
  --fs-caption: 0.75rem;     /* 12 */
  --fs-ui:      0.8125rem;   /* 13 */
  --fs-body:    0.875rem;    /* 14 */
  --fs-lead:    0.9375rem;   /* 15 */
  --fs-h3:      1rem;        /* 16 */
  --fs-h2:      1.375rem;    /* 22 */
  --fs-kpi:     1.75rem;     /* 28 */

  /* Spacing: one step per nesting level. */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* Radii: controls sit inside cards with 6px padding+, so cards are
     concentric with the controls they hold. */
  --r-xs: 4px;   /* tags, kbd */
  --r-sm: 6px;   /* buttons, inputs */
  --r-md: 10px;  /* inner panels */
  --r-lg: 14px;  /* cards */

  --sidebar-w: 236px;
  --content-w: 1180px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  /* ARA brand. Navy #030A8C leads (primary action, current page, main
     series); Indigo #30348C supports it; Amber #F28D35 highlights (counts,
     the active marker); Vermilion #F25D27 is reserved for warnings;
     Black #0D0D0D is the ink. Light is the default. */
  --navy:        #030A8C;
  --navy-15:     #292F9D;
  --navy-30:     #4F54AE;
  --navy-d15:    #030877;
  --navy-d30:    #020762;
  --indigo:      #30348C;
  --indigo-30:   #6E71AE;
  --amber:       #F28D35;
  --amber-15:    #F49E53;
  --amber-d15:   #CE782D;
  --vermilion:   #F25D27;
  --vermilion-d15:#CE4F21;
  --ink:         #0D0D0D;

  --bg:          #F4F5FB;
  --surface:     #FFFFFF;
  --surface-2:   #F1F2FA;   /* hover, inset panels */
  --surface-3:   #E6E8F4;   /* pressed, tracks */
  --line:        #E4E6F2;
  --line-strong: #CDD0E6;
  --text:        #0D0D0D;
  --text-2:      #4A4D66;
  --text-3:      #8A8DA6;
  /* Primary: ARA orange. Secondary: navy. */
  --accent:      #E2681F;
  --accent-hover:#CE4F21;
  --accent-text: #FFFFFF;
  --accent-ink:  #B9501A;   /* orange text on white, 4.6:1 */
  --accent-soft: #FEF0E4;
  --accent-line: #F9D3B3;
  --accent-grad: linear-gradient(135deg, #F28D35 0%, #F25D27 100%);
  --accent-grad-hover: linear-gradient(135deg, #CE782D 0%, #CE4F21 100%);
  --chart-muted: #F9D3B3;
  --secondary:      #030A8C;
  --secondary-soft: #ECEDFB;
  --secondary-line: #C9CBEE;
  --highlight:   #030A8C;
  --highlight-soft: #ECEDFB;

  --good:   #157347; --good-bg:   #E6F6EE; --good-line:   #BFE6D1;
  --wait:   #8A6300; --wait-bg:   #FFF6DA; --wait-line:   #F3E0A6;
  --bad:    #C0262D; --bad-bg:    #FDECEC; --bad-line:    #F6C9CB;
  --active: #292F9D; --active-bg: #ECEDFB; --active-line: #C9CBEE;
  --note:   #6A3FB0; --note-bg:   #F2ECFC; --note-line:   #DFD1F6;

  /* Sidebar: a clean surface so the logo shows as designed. */
  --side-bg:     var(--surface);
  --side-text:   var(--text);
  --side-text-2: var(--text-2);
  --side-text-3: #6E71AE;
  --side-hover:  var(--surface-2);
  --side-active: var(--accent-soft);
  --side-line:   var(--line);

  --shadow-border:
    0 0 0 1px rgb(3 10 140 / 0.06),
    0 1px 2px -1px rgb(3 10 140 / 0.08),
    0 4px 12px -2px rgb(3 10 140 / 0.05);
  --shadow-border-hover:
    0 0 0 1px rgb(3 10 140 / 0.10),
    0 2px 4px -1px rgb(3 10 140 / 0.10),
    0 8px 20px -4px rgb(3 10 140 / 0.10);
  --shadow-pop: 0 0 0 1px rgb(3 10 140 / 0.08), 0 16px 40px -10px rgb(3 10 140 / 0.28);
  --btn-shadow: 0 0 0 1px rgb(3 10 140 / 0.12), 0 1px 2px rgb(3 10 140 / 0.06);
  --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 0 0 1px #CE4F21, 0 4px 12px -4px rgb(242 93 39 / 0.55);
  color-scheme: light;
}

/* Dark — deep navy, not grey. Declared twice on purpose: once for an
   explicit choice, once for "auto" when the system is dark. */
:root[data-theme='dark'] {
  --bg:#070A24; --surface:#0E1236; --surface-2:#151A45; --surface-3:#1D2356;
  --line:#1F2557; --line-strong:#2C336E;
  --text:#F4F5FB; --text-2:#B3B6D6; --text-3:#7C80A8;
  --accent:#F28D35; --accent-hover:#F49E53; --accent-text:#FFFFFF; --accent-ink:#F6AF72;
  --accent-soft:#3A2614; --accent-line:#5A3B1A; --chart-muted:#5A3B1A;
  --secondary:#9EA1E0; --secondary-soft:#1A1F55; --secondary-line:#2C336E;
  --highlight:#9EA1E0; --highlight-soft:#1A1F55;
  --good:#5CCB8F; --good-bg:#0F2A20; --good-line:#1C4A36;
  --wait:#F0C44F; --wait-bg:#2E2610; --wait-line:#524417;
  --bad:#FF7A80; --bad-bg:#3A1416; --bad-line:#621F24;
  --active:#9EA1E0; --active-bg:#1A1F55; --active-line:#2C336E;
  --note:#B79BF5; --note-bg:#1E1730; --note-line:#352857;
  --side-bg: #0B0F2E; --side-text-3: #8A8DC4;
  --shadow-border: 0 0 0 1px rgb(255 255 255 / 0.06);
  --shadow-border-hover: 0 0 0 1px rgb(255 255 255 / 0.12);
  --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.09), 0 16px 40px -8px rgb(0 0 0 / 0.6);
  --btn-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 0 0 1px rgb(255 255 255 / 0.10);
  --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.20), 0 0 0 1px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    --bg:#070A24; --surface:#0E1236; --surface-2:#151A45; --surface-3:#1D2356;
    --line:#1F2557; --line-strong:#2C336E;
    --text:#F4F5FB; --text-2:#B3B6D6; --text-3:#7C80A8;
    --accent:#F28D35; --accent-hover:#F49E53; --accent-text:#FFFFFF; --accent-ink:#F6AF72;
    --accent-soft:#3A2614; --accent-line:#5A3B1A; --chart-muted:#5A3B1A;
    --secondary:#9EA1E0; --secondary-soft:#1A1F55; --secondary-line:#2C336E;
    --highlight:#9EA1E0; --highlight-soft:#1A1F55;
    --good:#5CCB8F; --good-bg:#0F2A20; --good-line:#1C4A36;
    --wait:#F0C44F; --wait-bg:#2E2610; --wait-line:#524417;
    --bad:#FF7A80; --bad-bg:#3A1416; --bad-line:#621F24;
    --active:#9EA1E0; --active-bg:#1A1F55; --active-line:#2C336E;
    --note:#B79BF5; --note-bg:#1E1730; --note-line:#352857;
    --side-bg: #0B0F2E; --side-text-3: #8A8DC4;
    --shadow-border: 0 0 0 1px rgb(255 255 255 / 0.06);
    --shadow-border-hover: 0 0 0 1px rgb(255 255 255 / 0.12);
    --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.09), 0 16px 40px -8px rgb(0 0 0 / 0.6);
    --btn-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 0 0 1px rgb(255 255 255 / 0.10);
    --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.20), 0 0 0 1px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

/* ── Base ────────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }
::selection { background: var(--accent-soft); color: var(--text); }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
a {
  color: inherit; text-decoration: underline;
  text-underline-offset: 2px; text-decoration-thickness: from-font;
  text-decoration-color: var(--line-strong);
}
@media (hover: hover) { a:hover { text-decoration-color: currentColor; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
code, kbd, .mono { font-family: var(--mono); }
code {
  font-size: 0.85em; padding: 1px 5px; border-radius: var(--r-xs);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
kbd {
  font-family: var(--mono); font-size: 10.5px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--r-xs);
  color: inherit; opacity: 0.75;
  box-shadow: inset 0 0 0 1px currentColor;
}
.muted { color: var(--text-3); }
.num { text-align: right; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none;
           stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ── App shell: sidebar + content ────────────────────────────── */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-3);
  background: var(--side-bg); color: var(--side-text);
  border-right: 1px solid var(--line); box-shadow: 4px 0 24px -12px rgb(3 10 140 / 0.12);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 4px; }
.brand-mark {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--amber) 0%, var(--vermilion) 100%); color: #fff;
  font: 700 15px/1 var(--sans); letter-spacing: -0.03em; box-shadow: 0 6px 16px -6px rgb(242 93 39 / 0.7);
}
.brand-logo { max-width: 100%; max-height: 92px; object-fit: contain; object-position: left center; display: block; }
.brand-logo-wrap { display: flex; align-items: center; width: 100%; padding: 2px 0 6px; }
:root[data-theme='dark'] .brand-logo-wrap { background: #fff; border-radius: 10px; padding: 8px 10px; }
.brand-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; color: var(--side-text); }
.brand .tagline { font-size: var(--fs-caption); color: var(--side-text-3); line-height: 1.2; }

nav { display: flex; flex-direction: column; gap: var(--sp-4); }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 11px; font-weight: 600; color: var(--side-text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 10px 6px;
}
nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 32px; padding: 0 10px; border: none; border-radius: var(--r-sm);
  background: none; color: var(--side-text-2); position: relative;
  font: 500 var(--fs-ui)/1 var(--sans); text-align: left; cursor: pointer;
  transition-property: background-color, color; transition-duration: 120ms; transition-timing-function: ease;
}
nav button .icon { color: var(--side-text-3); transition: color 120ms ease; }
nav button .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) {
  nav button:hover { background: var(--side-hover); color: var(--side-text); }
  nav button:hover .icon { color: var(--side-text-2); }
}
nav button.active { background: var(--side-active); color: var(--accent-ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent-line); }
nav button.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent-grad);
}
nav button.active .icon { color: var(--accent); }
.nav-count {
  display: none; min-width: 20px; height: 18px; padding: 0 6px;
  align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; border-radius: 99px;
  background: var(--secondary); color: #fff;
}
.nav-count.on { display: inline-flex; }

.sidebar-foot {
  margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3) 6px 0; border-top: 1px solid var(--side-line);
}
.agent-status { display: flex; align-items: center; gap: 8px; font-size: var(--fs-ui); color: var(--side-text-2); }
.sidebar .icon-btn, .sidebar .refresh-btn { background: var(--side-hover); color: var(--side-text-2); box-shadow: inset 0 0 0 1px var(--side-line); }
@media (hover: hover) { .sidebar .icon-btn:hover, .sidebar .refresh-btn:hover { background: var(--side-active); color: var(--side-text); } }
.sidebar .status-dot.stopped { background: var(--text-3); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--text-3); }
.status-dot.running { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.status-dot.offline { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.foot-actions { display: flex; gap: 6px; }

main.content { min-width: 0; padding: var(--sp-6) var(--sp-6) 96px; }
.content-inner { max-width: var(--content-w); margin: 0 auto; }

.section { display: none; }
.section.active { display: block; }

/* ── Page heads, section heads ───────────────────────────────── */

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4);
  flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.section-head h2 {
  font-size: var(--fs-h2); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2;
}
.section-head p {
  font-size: var(--fs-body); color: var(--text-2); margin-top: 4px;
  max-width: 68ch; text-wrap: pretty;
}
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; flex-shrink: 0; }

.subhead {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  font-size: var(--fs-ui); font-weight: 600; color: var(--text);
  margin: var(--sp-6) 0 var(--sp-3);
}
.subhead .hint { font-weight: 400; color: var(--text-3); }
.subhead:first-child { margin-top: 0; }

/* ── Cards ───────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); padding: var(--sp-5); margin-bottom: var(--sp-4);
}
.card > h2, .card-title {
  font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--sp-3);
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.card .lede { font-size: var(--fs-ui); color: var(--text-2); margin: -4px 0 var(--sp-4); max-width: 68ch; text-wrap: pretty; }
.card.flush { padding: 0; overflow: auto hidden; overscroll-behavior-x: contain; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.01em; }
.card-head .meta { font-size: var(--fs-caption); color: var(--text-3); }
.inset {
  background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-4);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-5); align-items: start; }
@media (max-width: 1180px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ── KPI cards with sparklines ───────────────────────────────── */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); padding: var(--sp-4) var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.kpi-label { font-size: var(--fs-ui); color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: var(--fs-kpi); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.kpi-value.zero { color: var(--text-3); }
.kpi-main { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); min-height: 32px; }
.kpi-note { font-size: var(--fs-caption); color: var(--text-3); }
.kpi-note b { color: var(--text-2); font-weight: 500; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 28px; flex: 1; max-width: 140px; justify-content: flex-end; }
.spark i { display: block; width: 5px; min-height: 2px; border-radius: 1.5px; background: var(--chart-muted); }
.spark i.on { background: var(--accent); }
.spark i.today { background: var(--accent); }

/* ── Funnel: one segmented bar, one legend ───────────────────── */

.funnel-bar {
  display: flex; height: 10px; gap: 2px; border-radius: 99px; overflow: hidden;
  background: var(--surface-3);
}
.funnel-bar .seg { min-width: 3px; }
.funnel-legend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-3) var(--sp-4);
  margin-top: var(--sp-4);
}
.legend-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.legend-key { display: flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-2); }
.legend-key i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.legend-val { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; }
.legend-val small { font-size: var(--fs-caption); font-weight: 400; color: var(--text-3); margin-left: 4px; }

.c-accent { background: var(--accent); } .c-accent-soft { background: var(--chart-muted); }
.c-good { background: var(--good); } .c-wait { background: var(--wait); }
.c-bad { background: var(--bad); } .c-active { background: var(--active); }
.c-note { background: var(--note); } .c-idle { background: var(--line-strong); }

.legend-rows { display: flex; flex-direction: column; margin-top: var(--sp-3); }
.legend-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 3.5ch; gap: var(--sp-3); align-items: center; padding: 7px 0; }
.legend-row + .legend-row { border-top: 1px solid var(--line); }
.legend-row .legend-key { font-size: var(--fs-ui); color: var(--text); gap: 8px; }
.legend-row .legend-val { font-size: var(--fs-ui); font-weight: 600; }
.legend-pct { font-size: var(--fs-caption); color: var(--text-3); text-align: right; }

/* Quiet status: a dot and a word, for secondary state inside a cell */
.mini { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-caption); white-space: nowrap; }
.mini::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.mini.t-good { color: var(--good); } .mini.t-waiting { color: var(--wait); } .mini.t-bad { color: var(--bad); }
.mini.t-active { color: var(--active); } .mini.t-note { color: var(--note); } .mini.t-idle { color: var(--text-3); }

/* ── Meters (score, quota, progress) ─────────────────────────── */

.meter { display: inline-flex; align-items: center; gap: 2px; height: 12px; }
.meter i { width: 4px; height: 10px; border-radius: 1px; background: var(--surface-3); }
.meter i.on { background: var(--accent); }
.meter.good i.on { background: var(--good); }
.meter.wait i.on { background: var(--wait); }
.meter.bad i.on { background: var(--bad); }
.meter-row { display: inline-flex; align-items: center; gap: 8px; }
.meter-row .v { font-size: var(--fs-ui); color: var(--text-2); min-width: 2.5ch; text-align: right; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; transition: width 400ms var(--ease-out); }
.bar.thick { height: 8px; }

/* Kept for quota gauges (quotaCardHtml) */
.progress-wrap { margin-bottom: var(--sp-4); }
.progress-wrap:last-child { margin-bottom: 0; }
.progress-label { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-ui); margin-bottom: 6px; }
.progress-label .pct { font-weight: 600; }
.progress-label .text { color: var(--text-2); }
.progress-bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 400ms var(--ease-out); }
.progress-fill.green { background: var(--accent); }
.progress-fill.yellow { background: var(--wait); }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: none; border-radius: var(--r-sm);
  font: 500 var(--fs-ui)/1 var(--sans); white-space: nowrap; cursor: pointer;
  background: var(--surface); color: var(--text); box-shadow: var(--btn-shadow);
  -webkit-tap-highlight-color: transparent;
  transition-property: background-color, color, box-shadow, scale;
  transition-duration: 150ms; transition-timing-function: ease-out;
}
.btn:not(:disabled):active { scale: 0.96; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--accent-grad); color: var(--accent-text); box-shadow: var(--btn-primary-shadow); font-weight: 600; }
.btn-secondary { background: var(--surface); color: var(--secondary); }
.btn-ghost { background: none; box-shadow: none; color: var(--text-2); }
.btn-danger { background: var(--surface); color: var(--bad); }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--accent-grad-hover); }
  .btn-secondary:hover:not(:disabled), .btn-danger:hover:not(:disabled) { background: var(--surface-2); }
  .btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
}
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-caption); }
.btn-icon { width: 32px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn-group { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; }
.icon-btn, .refresh-btn {
  height: 28px; padding: 0 10px; border: none; border-radius: var(--r-sm); cursor: pointer;
  font: 500 var(--fs-caption)/1 var(--sans); color: var(--text-2);
  background: var(--surface); box-shadow: var(--btn-shadow);
  transition-property: background-color, color, scale; transition-duration: 150ms; transition-timing-function: ease-out;
  display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize;
}
.icon-btn:active, .refresh-btn:active { scale: 0.96; }
@media (hover: hover) { .icon-btn:hover, .refresh-btn:hover { color: var(--text); background: var(--surface-2); } }

/* ── Tags & badges: the only coloured text ───────────────────── */

.badge, .tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  font-size: var(--fs-caption); font-weight: 500; line-height: 1; white-space: nowrap;
  border-radius: 99px; border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.t-waiting { background: var(--wait-bg);   color: var(--wait);   border-color: var(--wait-line); }
.badge.t-active  { background: var(--active-bg); color: var(--active); border-color: var(--active-line); }
.badge.t-good    { background: var(--good-bg);   color: var(--good);   border-color: var(--good-line); }
.badge.t-bad     { background: var(--bad-bg);    color: var(--bad);    border-color: var(--bad-line); }
.badge.t-note    { background: var(--note-bg);   color: var(--note);   border-color: var(--note-line); }
.badge.t-idle    { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }
.badge.t-idle::before { background: var(--text-3); }
.tag { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.cost-chip {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 11px;
  font-size: var(--fs-caption); font-weight: 500; line-height: 1.35;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.cost-chip.free { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.cost-chip.paid { background: var(--wait-bg); color: var(--wait); border-color: var(--wait-line); }
.optional-tag { font-size: var(--fs-caption); font-weight: 400; color: var(--text-3); margin-left: 6px; }

/* Settings key status chips */
.email-tag { font-size: var(--fs-caption); font-weight: 500; padding: 2px 8px; border-radius: 99px; margin-left: 6px; }
.email-tag:empty { display: none; }
.email-tag.verified { background: var(--good-bg); color: var(--good); }
.email-tag.risky { background: var(--wait-bg); color: var(--wait); }
.email-tag.guess { background: var(--surface-2); color: var(--text-3); }

/* ── Tables ──────────────────────────────────────────────────── */

.table-card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); overflow: auto; overscroll-behavior-x: contain;
}
.card .table-card { box-shadow: none; border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-ui); }
th {
  text-align: left; font-size: var(--fs-caption); font-weight: 500; color: var(--text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1;
}
th.num { text-align: right; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 100ms ease; }
@media (hover: hover) { tbody tr:hover td { background: var(--surface-2); } }
tr.clickable { cursor: pointer; }
table.nowrap td { white-space: nowrap; }
td a { text-decoration: none; }
@media (hover: hover) { td a:hover { text-decoration: underline; } }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { font-size: var(--fs-caption); color: var(--text-3); margin-top: 1px; }
.cell-stack { display: flex; flex-direction: column; min-width: 0; }
.cell-row { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--surface-3); color: var(--text-2);
}
.row-action { opacity: 0; transition: opacity 120ms ease; }
tr:focus-within .row-action { opacity: 1; }
@media (hover: hover) { tr:hover .row-action { opacity: 1; } }
@media (hover: none) { .row-action { opacity: 1; } }

/* Table toolbar: search + filters */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.search {
  position: relative; flex: 1; min-width: 200px; max-width: 320px;
}
.search .icon { position: absolute; left: 10px; top: 50%; translate: 0 -50%; color: var(--text-3); width: 15px; height: 15px; }
.search input { padding-left: 32px; }
.segmented {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--surface-3);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented button { flex: none; }
.segmented button {
  height: 28px; padding: 0 10px; border: none; border-radius: var(--r-sm); background: none; cursor: pointer;
  font: 500 var(--fs-caption)/1 var(--sans); color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.segmented button .n { color: var(--text-3); font-weight: 500; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-border); }
@media (hover: hover) { .segmented button:not(.on):hover { color: var(--text); } }
.table-foot { font-size: var(--fs-caption); color: var(--text-3); padding: var(--sp-3) 2px 0; }

/* ── Today: the queue, the steps, the timeline ───────────────── */

.queue { display: flex; flex-direction: column; gap: var(--sp-2); }
.queue-item {
  display: flex; align-items: center; gap: var(--sp-4);
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); padding: var(--sp-4);
}
.queue-icon {
  width: 32px; height: 32px; flex: none; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2);
}
.queue-item.warn .queue-icon { background: var(--wait-bg); color: var(--wait); }
.queue-item.bad .queue-icon { background: var(--bad-bg); color: var(--bad); }
.queue-item.good .queue-icon { background: var(--good-bg); color: var(--good); }
.queue-item .qtext { flex: 1; min-width: 0; }
.queue-item .qtitle { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.005em; }
.queue-item .qdetail { font-size: var(--fs-ui); color: var(--text-2); margin-top: 2px; max-width: 72ch; text-wrap: pretty; }
.queue-item .btn { flex: none; }
.queue-clear {
  display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-5);
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg); box-shadow: var(--shadow-border);
}
.queue-clear .queue-icon { background: var(--good-bg); color: var(--good); }
.queue-clear .qtitle { font-weight: 600; }
.queue-clear .qdetail { font-size: var(--fs-ui); color: var(--text-2); margin-top: 2px; max-width: 64ch; }

.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; }
.step + .step { border-top: 1px solid var(--line); }
.step-icon { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.step-icon .icon { width: 12px; height: 12px; stroke-width: 2.5; }
.step-icon.done { background: var(--good-bg); color: var(--good); }
.step-icon.running { background: var(--accent-soft); color: var(--accent); }
.step-icon.partial { background: var(--surface-3); color: var(--text-2); }
.step-icon.waiting { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.step-label { font-size: var(--fs-ui); font-weight: 500; }
.step-detail { font-size: var(--fs-caption); color: var(--text-3); text-align: right; }
.step .bar { grid-column: 2 / 4; }
.live-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.live-now { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-ui); color: var(--text-2); }
.live-next {
  display: flex; gap: 10px; align-items: flex-start; margin-top: var(--sp-3);
  padding: 10px 12px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text);
  font-size: var(--fs-ui);
}
.live-next .icon { color: var(--accent); margin-top: 1px; }
.live-flag { font-size: var(--fs-caption); color: var(--text-3); margin-top: var(--sp-2); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.35; } }
}

.figures { display: flex; flex-direction: column; }
.figure { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); padding: 8px 0; }
.figure + .figure { border-top: 1px solid var(--line); }
.figure .k { font-size: var(--fs-ui); color: var(--text-2); }
.figure .v { font-size: var(--fs-body); font-weight: 600; }
.figure .v.zero { color: var(--text-3); font-weight: 400; }
.figure-note { font-size: var(--fs-caption); color: var(--text-3); margin-top: 8px; }

.runs { display: flex; flex-direction: column; }
.run { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; align-items: center; }
.run + .run { border-top: 1px solid var(--line); }
.run .name { font-size: var(--fs-ui); font-weight: 500; text-transform: capitalize; }
.run .when, .run .stats { font-size: var(--fs-caption); color: var(--text-3); }
.run .stats { text-align: right; }

/* Activity timeline, grouped by day */
.timeline { display: flex; flex-direction: column; }
.tl-day {
  font-size: var(--fs-caption); font-weight: 600; color: var(--text-3);
  padding: var(--sp-4) 0 var(--sp-2);
}
.tl-day:first-child { padding-top: 0; }
.tl-item { display: grid; grid-template-columns: 64px 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; }
.tl-time { font-size: var(--fs-caption); color: var(--text-3); }
.tl-icon {
  width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2);
}
.tl-icon .icon { width: 13px; height: 13px; }
.tl-text { font-size: var(--fs-ui); color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.tl-text::first-letter { text-transform: uppercase; }
.tl-agent { font-size: var(--fs-caption); color: var(--text-3); }
.tl-item.quiet .tl-text { color: var(--text-3); }

/* Setup progress, check list */
.check-item { display: flex; gap: 10px; padding: 10px 0; }
.check-item + .check-item { border-top: 1px solid var(--line); }
.check-icon {
  width: 18px; height: 18px; flex: none; margin-top: 1px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 10px;
}
.check-icon.done { background: var(--good-bg); color: var(--good); }
.check-icon.pending { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.check-info { flex: 1; min-width: 0; }
.check-label { font-size: var(--fs-ui); font-weight: 500; }
.check-label.done { color: var(--text-3); font-weight: 400; }
.check-item.current {
  margin: 0 calc(-1 * var(--sp-3)); padding: var(--sp-3);
  background: var(--accent-soft); border-radius: var(--r-md);
}
.check-item.current + .check-item, .check-item + .check-item.current { border-top-color: transparent; }
.setup-card { margin-bottom: var(--sp-4); }
.setup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.setup-head h3 { font-size: var(--fs-h3); margin: 0; }
.setup-head p { margin: 2px 0 0; font-size: var(--fs-caption); }
.check-help { font-size: var(--fs-caption); color: var(--text-3); margin-top: 2px; text-wrap: pretty; overflow-wrap: anywhere; }
.setup-pct { font-size: var(--fs-caption); color: var(--text-3); font-weight: 500; }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 8px; translate: 0 -2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: -45deg;
  transition: rotate 150ms ease-out;
}
details[open] > summary::before { rotate: 45deg; }

/* ── Signals ─────────────────────────────────────────────────── */

.sig-summary .funnel-bar { margin-bottom: 0; }
.sig-group { margin-bottom: var(--sp-6); }
.sig-group-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.sig-group-head h3 { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; }
.sig-group-head p { font-size: var(--fs-ui); color: var(--text-2); margin-top: 2px; max-width: 68ch; text-wrap: pretty; }
.sig-row { display: flex; gap: var(--sp-4); align-items: flex-start; padding: var(--sp-4) var(--sp-5); }
.sig-row + .sig-row { border-top: 1px solid var(--line); }
.sig-row.rejected .sig-main { opacity: 0.55; }
.sig-row .sig-main { flex: 1; min-width: 0; }
.sig-row .sig-label { font-size: var(--fs-body); font-weight: 500; }
.sig-row .sig-code { font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-left: 8px; }
.sig-row .sig-desc { font-size: var(--fs-ui); color: var(--text-2); margin-top: 2px; max-width: 72ch; text-wrap: pretty; }
.sig-row .sig-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--sp-2); align-items: center; }
.sig-row .sig-decide { display: flex; gap: 6px; flex: none; }

.cohort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.cohort-pick {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px;
  border-radius: var(--r-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px transparent;
  font-size: var(--fs-ui); cursor: pointer; transition: box-shadow 120ms ease, background-color 120ms ease;
}
@media (hover: hover) { .cohort-pick:hover { box-shadow: inset 0 0 0 1px var(--line-strong); } }
.cohort-pick:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
/* In range: a label and two number boxes need more room than a checkbox. */
.cohort-range-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.cohort-range { cursor: default; height: auto; min-height: 40px; padding: 6px 12px; gap: 10px; }
.cohort-range-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cohort-range-inputs { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; }
.cohort-bound {
  width: 72px; height: 28px; padding: 3px 8px; font: inherit; font-size: 12px; box-sizing: border-box;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text);
}
.cohort-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.cohort-range:has(.cohort-bound:not(:placeholder-shown)) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.cohort-pick input { accent-color: var(--accent); }
.cohort-pick .n { margin-left: auto; font-size: var(--fs-caption); color: var(--text-3); }
.cohort-size { font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }

/* ── Outbox: the decisions desk ──────────────────────────────── */

.desk { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.desk-list {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-border);
  border: 1px solid transparent; padding: 6px; overflow: hidden auto; max-height: 680px; overscroll-behavior: contain;
}
.desk-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-md); cursor: pointer; }
.desk-item + .desk-item { margin-top: 2px; }
@media (hover: hover) { .desk-item:hover { background: var(--surface-2); } }
.desk-item.active { background: var(--accent-soft); }
.desk-item .di-text { min-width: 0; flex: 1; }
.desk-item .to { font-size: var(--fs-ui); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-item .sub { font-size: var(--fs-caption); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-item.active .avatar { background: var(--accent); color: var(--accent-text); }

.desk-pane {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-border);
  border: 1px solid transparent; padding: var(--sp-5) var(--sp-6);
}
.desk-pane .to-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-ui); color: var(--text-2); overflow-wrap: anywhere; min-width: 0; }
.desk-pane .to-line b { color: var(--text); font-weight: 500; }
.desk-pane .subject { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; margin: var(--sp-5) 0 var(--sp-3); }
.desk-pane .body { font-size: var(--fs-lead); line-height: 1.65; white-space: pre-wrap; max-width: 66ch; color: var(--text); }
.desk-footer {
  font-size: var(--fs-ui); line-height: 1.6; white-space: pre-wrap; max-width: 66ch;
  color: var(--text-3); margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px dashed var(--line-strong);
}
.desk-actions {
  display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); flex-wrap: wrap;
  padding-top: var(--sp-4); border-top: 1px solid var(--line);
}
.desk-context {
  display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 6px 14px;
  margin-top: var(--sp-4); padding: var(--sp-4); font-size: var(--fs-ui); line-height: 1.5;
  background: var(--surface-2); border-radius: var(--r-md);
}
.desk-context .k { color: var(--text-3); }
.desk-context .v { overflow-wrap: anywhere; }
.desk-edit-subject, .desk-edit-body {
  display: block; width: 100%; margin-top: var(--sp-4);
  padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.desk-edit-subject { font-size: var(--fs-h3); font-weight: 500; }
.desk-edit-body { font-size: var(--fs-body); line-height: 1.65; resize: vertical; max-width: 66ch; }
.desk-edit-subject:focus, .desk-edit-body:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 900px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .desk-list { max-height: 240px; }
  .desk-context { grid-template-columns: minmax(0, 1fr); }
  .desk-pane { padding: var(--sp-4); }
}

.banner {
  display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4); margin-bottom: var(--sp-4);
  border-radius: var(--r-lg); border: 1px solid transparent; font-size: var(--fs-ui);
}
.banner .icon { margin-top: 2px; }
.banner b { display: block; font-size: var(--fs-body); margin-bottom: 2px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.banner.wait { background: var(--wait-bg); color: var(--wait); border-color: var(--wait-line); }
.banner p { color: var(--text-2); }

/* ── Discover ────────────────────────────────────────────────── */

.prov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.prov-card {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); cursor: pointer;
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); transition: box-shadow 150ms ease-out;
}
@media (hover: hover) { .prov-card:hover { box-shadow: var(--shadow-border-hover); } }
.prov-card.selected { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft); }
.prov-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prov-card h3 { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.01em; }
.prov-card .blurb { font-size: var(--fs-ui); color: var(--text-2); text-wrap: pretty; }
.prov-card .row { display: flex; gap: 8px; font-size: var(--fs-caption); }
.prov-card .row .k { color: var(--text-3); min-width: 44px; flex: none; }
.prov-card .row .v { color: var(--text-2); }
.prov-card .caveat {
  font-size: var(--fs-caption); color: var(--wait); background: var(--wait-bg);
  padding: 8px 10px; border-radius: var(--r-sm); text-wrap: pretty;
}
.estimate-box { border-radius: var(--r-md); padding: var(--sp-4); margin-bottom: var(--sp-3); background: var(--surface-2); }
.estimate-box .amount { font-size: var(--fs-kpi); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.estimate-box .amount.free { color: var(--good); }
.estimate-box .amount.paid { color: var(--wait); }
.query-list { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-top: var(--sp-3); line-height: 1.7; max-height: 150px; overflow-y: auto; overscroll-behavior: contain; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.stat-card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); padding: var(--sp-4);
}
.stat-card .label { font-size: var(--fs-ui); color: var(--text-2); margin-bottom: 6px; }
.stat-card .value { font-size: var(--fs-kpi); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.stat-card .breakdown { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chip { font-size: var(--fs-caption); color: var(--text-3); }
.chip b { color: var(--text-2); font-weight: 500; }

/* Column chart (usage per day) */
.chart-cols { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin-top: var(--sp-2); }
.chart-cols .col { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 3px; }
.chart-cols .col i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: 0.85; }
@media (hover: hover) { .chart-cols .col:hover i { opacity: 1; } .chart-cols .col:hover { background: var(--surface-2); } }
.chart-axis { display: flex; justify-content: space-between; font-size: var(--fs-caption); color: var(--text-3); margin-top: 6px; }

/* ── Forms ───────────────────────────────────────────────────── */

.form-group { margin-bottom: var(--sp-4); }
.form-label { display: block; font-size: var(--fs-ui); font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-input {
  width: 100%; height: 36px; padding: 0 12px; font: 400 var(--fs-body) var(--sans);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition-property: border-color, box-shadow; transition-duration: 120ms; transition-timing-function: ease;
}
textarea.form-input { height: auto; padding: 8px 12px; }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-input::placeholder { color: var(--text-3); }
.form-row { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
@media (max-width: 640px) { .form-input { font-size: 16px; } }

.test-result { font-size: var(--fs-ui); margin-top: var(--sp-3); padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid transparent; }
.test-result.success { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.test-result.error   { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.test-result.pending { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }

/* Settings: label column + fields column */
.settings-row { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--sp-5); padding: var(--sp-5) 0; }
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row:first-of-type { padding-top: 0; }
.settings-row:last-child { padding-bottom: 0; }
.settings-row h3 { font-size: var(--fs-body); font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.settings-row .desc { font-size: var(--fs-ui); color: var(--text-2); margin-top: 4px; text-wrap: pretty; }
.settings-row .fields { max-width: 560px; }
.settings-row .fields .form-group:last-child { margin-bottom: 0; }
.settings-row .fields .form-row { margin-bottom: var(--sp-4); }
.settings-row .fields .form-row .form-group { margin-bottom: 0; }
.with-btn { display: flex; gap: var(--sp-2); }
.with-btn .form-input { flex: 1; min-width: 0; }
@media (max-width: 860px) { .settings-row { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); } }

/* ── Campaigns ───────────────────────────────────────────────── */

.campaign-card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); margin-bottom: var(--sp-4); overflow: hidden;
}
.campaign-top { padding: var(--sp-5); }
.campaign-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.campaign-title h3 { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; }
.campaign-card .meta { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; font-size: var(--fs-caption); color: var(--text-3); margin-top: 6px; }
.campaign-progress { margin-top: var(--sp-4); }
.campaign-progress .bar { height: 8px; gap: 2px; background: var(--surface-3); }
.campaign-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.campaign-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-2); }
.campaign-legend i { width: 8px; height: 8px; border-radius: 2px; }
.campaign-legend b { color: var(--text); font-weight: 600; }

.sequence { border-top: 1px solid var(--line); padding: var(--sp-2) var(--sp-5) var(--sp-5); }
.email-step { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 0 var(--sp-3); padding-top: var(--sp-4); }
.email-step::before {
  content: ''; position: absolute; left: 13.5px; top: calc(var(--sp-4) + 30px); bottom: -16px; width: 1px; background: var(--line);
}
.email-step:last-child::before { display: none; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-caption); font-weight: 600; background: var(--surface-2); color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.email-step .step-num { font-size: var(--fs-caption); color: var(--text-3); margin-top: 5px; }
.email-step .subject { font-size: var(--fs-body); font-weight: 600; margin: 2px 0 6px; }
.email-step .body {
  font-size: var(--fs-ui); color: var(--text-2); line-height: 1.6; white-space: pre-wrap;
  background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); max-width: 72ch;
}
.step-actions {
  margin-top: var(--sp-3); display: flex; flex-direction: column; max-width: 72ch;
  border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line);
}
.rcpt { display: flex; align-items: center; gap: var(--sp-3); padding: 8px 12px; flex-wrap: wrap; }
.rcpt + .rcpt { border-top: 1px solid var(--line); }
.rcpt-who { flex: 1 1 200px; min-width: 0; font-size: var(--fs-ui); display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.step-actions label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-2); cursor: pointer; }
.step-actions input { accent-color: var(--accent); }

/* ── Conversations ───────────────────────────────────────────── */

.convo-card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  box-shadow: var(--shadow-border); padding: var(--sp-5); margin-bottom: var(--sp-4);
}
.convo-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.convo-head h3 { font-size: var(--fs-body); font-weight: 600; }
.convo-head > div:nth-child(2) { min-width: 0; flex: 1 1 200px; }
.convo-head h3, .convo-head .sub { overflow-wrap: anywhere; }
.convo-head .sub { font-size: var(--fs-caption); color: var(--text-3); }
.convo-head .tags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.thread { display: flex; flex-direction: column; gap: var(--sp-2); }
.thread-msg { max-width: min(78%, 62ch); padding: 10px 14px; border-radius: 14px; font-size: var(--fs-ui); line-height: 1.55; white-space: pre-wrap; }
.thread-msg.sent { align-self: flex-end; background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-line); border-bottom-right-radius: 4px; }
.thread-msg.received { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.thread-msg .sender { font-size: 11px; opacity: 0.7; margin-bottom: 2px; }
.thread-email {
  align-self: flex-end; width: min(78%, 64ch); border-radius: 14px; border-bottom-right-radius: 4px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden;
}
.te-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: var(--fs-caption);
  color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.te-head .icon { width: 13px; height: 13px; color: var(--accent); }
.te-head b { color: var(--text); font-weight: 600; }
.te-head span:not(.te-when) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.te-when { margin-left: auto; color: var(--text-3); white-space: nowrap; }
.te-body { padding: 10px 14px; font-size: var(--fs-ui); line-height: 1.55; white-space: pre-wrap; color: var(--text-2); }
.thread-draft {
  align-self: flex-end; width: min(78%, 64ch); padding: 10px 14px 12px; border-radius: 14px;
  border: 1.5px dashed var(--accent-line); background: var(--accent-soft);
}
.thread-draft .sender { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--accent-ink); margin-bottom: 4px; }
.thread-draft .sender .icon { width: 12px; height: 12px; }
.td-body { font-size: var(--fs-ui); line-height: 1.55; white-space: pre-wrap; margin-bottom: 10px; }
@media (max-width: 640px) { .thread-email, .thread-draft, .thread-msg { width: auto; max-width: 92%; } }

/* ── Controls, help, misc ────────────────────────────────────── */

.control-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: var(--sp-4); align-items: start; }
@media (max-width: 900px) { .control-panel { grid-template-columns: minmax(0, 1fr); } }
.status-big { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.status-big .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.status-big .dot.running { background: var(--good); box-shadow: 0 0 0 4px var(--good-bg); }
.status-big .label { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.015em; }
.status-big .label.running { color: var(--good); }
.status-meta { font-size: var(--fs-ui); color: var(--text-3); min-height: 20px; }
.log-viewer {
  background: #0B0B0D; color: #C9C9D1; border-radius: var(--r-md);
  padding: var(--sp-4); font-family: var(--mono); font-size: 12px; line-height: 1.7;
  height: 380px; overflow-y: auto; overscroll-behavior: contain; white-space: pre-wrap;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
}

.help-section { margin-bottom: var(--sp-6); max-width: 76ch; }
.help-section h2 { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--sp-2); }
.help-section p { font-size: var(--fs-body); color: var(--text-2); line-height: 1.65; margin-bottom: var(--sp-2); text-wrap: pretty; }
.help-section pre {
  background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-4);
  overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; margin: var(--sp-2) 0;
}
.help-section details { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-border); margin-bottom: var(--sp-2); }
.help-section details summary { padding: 12px var(--sp-4); font-size: var(--fs-body); font-weight: 500; }
.help-section .faq-body { padding: 0 var(--sp-4) var(--sp-4) 34px; font-size: var(--fs-ui); color: var(--text-2); line-height: 1.65; }
.help-section .faq-body p { font-size: var(--fs-ui); margin-bottom: 6px; }
.file-table { width: 100%; font-size: var(--fs-ui); border-collapse: collapse; }
.file-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.file-table td:first-child { font-family: var(--mono); font-size: 12px; white-space: nowrap; width: 230px; color: var(--text); }
.file-table td:last-child { color: var(--text-2); }
.file-table tr:last-child td { border-bottom: none; }

.empty { text-align: center; padding: var(--sp-7) var(--sp-5); }
.empty .glyph {
  width: 40px; height: 40px; margin: 0 auto var(--sp-3); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--surface-2); color: var(--text-2);
}
.empty .title { font-size: var(--fs-h3); font-weight: 600; margin-bottom: 4px; }
.empty .copy { font-size: var(--fs-ui); color: var(--text-2); line-height: 1.6; max-width: 48ch; margin: 0 auto; text-wrap: pretty; }
.empty .copy b { color: var(--text); font-weight: 500; }
.section > .empty, .content-inner > .empty, #companies-list > .empty, #prospects-table > .empty,
#campaigns-list > .empty, #conversations-list > .empty, #activity-list > .empty {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-border);
}

.toast {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 60; max-width: 420px;
  padding: 10px 14px; border-radius: var(--r-md); font-size: var(--fs-ui); font-weight: 500;
  box-shadow: var(--shadow-pop);
  transition-property: opacity, translate; transition-duration: 250ms; transition-timing-function: var(--ease-out);
  @starting-style { opacity: 0; translate: 0 8px; }
}
.toast.success { background: var(--text); color: var(--bg); }
.toast.error { background: var(--bad); color: #fff; }

/* Lock screen */
#lock-screen { background: var(--bg); }
#lock-screen .card { box-shadow: var(--shadow-pop); }

/* ── Small screens: the sidebar becomes a top bar ────────────── */

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) var(--sp-4);
    border-right: none; border-bottom: 1px solid var(--line); overflow: visible;
  }
  .brand .tagline { display: none; }
  nav { order: 3; width: 100%; flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--sp-4)); padding: 0 var(--sp-4) 2px; width: calc(100% + 2 * var(--sp-4)); }
  nav::-webkit-scrollbar { display: none; }
  .nav-group { flex-direction: row; gap: 2px; }
  .nav-label { display: none; }
  nav button { width: auto; height: 30px; flex: none; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; border-top: none; padding: 0; }
  main.content { padding: var(--sp-5) var(--sp-4) 80px; }
  .tl-item { grid-template-columns: 52px 24px minmax(0, 1fr); }
  .queue-item { flex-wrap: wrap; }
  .queue-item .qtext { flex-basis: calc(100% - 48px); }
  .queue-item .btn { margin-left: 48px; }
  .step-detail { grid-column: 2 / 4; text-align: left; }
  .tl-agent { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Replies and scraped text are written by outsiders: a 3,000-character URL
   must wrap inside its box, never push the page sideways. */
.desk-pane .body, .thread-msg, .te-body, .td-body, .te-head span, .cell-main, .cell-sub { overflow-wrap: anywhere; }

.convo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.convo-actions .muted { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-caption); margin-right: auto; }
.convo-actions .btn-ghost { margin-left: auto; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 10px 4px 0; margin-bottom: var(--sp-5); font-size: var(--fs-caption); color: var(--text-3); }
.facts b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-sub .verified { color: var(--good); font-weight: 600; }
/* Long subjects end in an ellipsis; the card scrolls sideways if it must. */
table.clip td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.live-next .btn { margin-left: auto; }
.more-fields { margin-bottom: var(--sp-3); }
.more-fields summary { cursor: pointer; font-size: var(--fs-ui); color: var(--text-2); margin-bottom: var(--sp-3); }
.check-line { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-ui); color: var(--text-2); cursor: pointer; }

/* Contacts: why someone is opted out, under their row. */
.detail-row > td { white-space: normal; background: var(--surface-2); }
.optout-panel { display: flex; flex-direction: column; gap: var(--sp-2); max-width: 72ch; padding: var(--sp-2) 0; }
.optout-panel h4 { margin: 0; font-size: var(--fs-ui); }
.optout-panel p { margin: 0; font-size: var(--fs-ui); line-height: 1.55; }
.optout-panel .optout-meta { font-size: var(--fs-caption); color: var(--text-2); }
.optout-panel .thread-msg.received { background: var(--surface); }
.optout-panel .convo-actions { margin-top: var(--sp-2); }
.optout-panel .convo-actions .muted { white-space: normal; }
.optout-panel .convo-actions .btn-ghost { margin-left: 0; }

/* Outbox: an email autopilot held for you (#66). */
.desk-held { margin-bottom: var(--sp-3); }

/* Approval or autopilot: the Outbox notice and the Settings card. */
.mode-banner { align-items: center; }
.mode-banner > div { flex: 1; }
.mode-card h3 { margin: 0 0 var(--sp-2); }
.mode-card p { margin: 0 0 var(--sp-2); font-size: var(--fs-ui); line-height: 1.55; max-width: 72ch; }
.mode-card .convo-actions .muted { white-space: normal; flex-basis: 100%; }
.mode-confirm .form-input { width: 12rem; }
.mode-card .convo-actions .btn-ghost { margin-left: 0; }
.mode-banner:not(.wait) { background: var(--surface); border-color: var(--line); }

/* Setup checklist: the warmup step's actions */
.warmup-actions { margin-top: var(--sp-2); align-items: center; }
a.btn, a.btn:hover { text-decoration: none; }
.warmup-actions .form-input { flex: 1 1 200px; height: 28px; min-width: 0; }

/* ── Places: chips in a box ──────────────────────────────────── */

.place-picker {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 5px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); cursor: text;
}
.place-picker:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.place-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 26px; padding: 0 4px 0 10px;
  border-radius: 999px; background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line);
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.place-chip button {
  width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2);
  font-size: 15px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.place-chip button:hover { background: var(--surface-2); color: var(--text); }
.place-picker input {
  flex: 1 1 160px; min-width: 120px; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 14px; padding: 4px 2px;
}

/* ── Processes ───────────────────────────────────────────────── */

.proc-bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 4px 0 2px; }
.proc-bar i { display: block; height: 100%; border-radius: 99px; background: var(--text-3); transition: width 400ms ease; }
.proc-bar.run i { background: var(--accent); }
.proc-bar.ok i { background: var(--good); }
.proc-bar.bad i { background: var(--bad); }

.proc-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.proc-filters select { width: auto; height: 32px; padding: 0 8px; }
.filter-chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer;
}
.filter-chip b { color: var(--text); margin-left: 4px; font-weight: 600; }
.filter-chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

.proc-table td { vertical-align: top; }
tr.clickable { cursor: pointer; }
@media (hover: hover) { tr.clickable:hover td { background: var(--surface-2); } }

.proc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; margin-bottom: 4px; }
.proc-card {
  display: block; padding: 12px 14px; border-radius: var(--r-md, 10px); background: var(--surface);
  box-shadow: var(--shadow-border, 0 0 0 1px var(--line)); color: inherit; text-decoration: none;
}
@media (hover: hover) { .proc-card:hover { box-shadow: 0 0 0 1px var(--accent-line); } }
.proc-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.proc-card-top b { font-size: 14px; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.proc-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; font-size: 13px;
}
.proc-line:last-of-type { border-bottom: 0; }
.proc-line span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.proc-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.proc-head-actions { display: flex; align-items: center; gap: 10px; }
.proc-related { margin-top: 10px; font-size: 13px; }

.proc-steps { display: flex; flex-direction: column; gap: 12px; }
.proc-step { display: flex; gap: 12px; align-items: flex-start; }
.proc-step .dot {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; background: var(--surface-2); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line);
}
.proc-step.done .dot { background: var(--good-bg, var(--surface-2)); color: var(--good); }
.proc-step.running .dot { background: var(--accent-soft); color: var(--accent); }
.proc-step.failed .dot { background: var(--bad-bg, var(--surface-2)); color: var(--bad); }
.proc-step-body { flex: 1; min-width: 0; }
.proc-step-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.proc-step-head .muted { font-size: 12px; }
#proc-log { max-height: 560px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Discover: several sources, and the estimate per source */
.prov-check {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: 8px;
  border-radius: 4px; border: 1px solid var(--line-strong); font-size: 12px; vertical-align: -3px; color: var(--accent);
}
.prov-card.selected .prov-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.est-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.est-src { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.est-src.not-ready { box-shadow: inset 0 0 0 1px var(--bad); color: var(--bad); }

/* Autopilot page */
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 8px 16px; }
.auto-grid .check-line { margin: 0; }

.auto-src { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer; }
.auto-src input { margin-top: 3px; accent-color: var(--accent); flex: 0 0 auto; }
.auto-src span { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.auto-src b { font-weight: 500; font-size: 14px; }
.auto-src small { font-size: 12px; color: var(--text-3); line-height: 1.4; overflow-wrap: anywhere; }
.auto-src:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }

/* Jobs */
.id-link { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; color: var(--secondary); text-decoration: none; }
.id-link:hover { text-decoration: underline; }
.id-link.sub { display: block; color: var(--text-3); font-size: 11px; }
.job-procs { display: flex; flex-direction: column; gap: 8px; }
.job-proc {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow-border); color: inherit; text-decoration: none;
}
@media (hover: hover) { .job-proc:hover { box-shadow: 0 0 0 1px var(--accent-line); } }
.job-proc-n {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
}
.job-proc-body { flex: 1; min-width: 0; }

/* ── Training: config form, raw YAML, knowledge files ── */
.tr-toolbar { margin-bottom: var(--sp-4); }
.tr-note { font-size: var(--fs-caption); margin: 0 0 var(--sp-3); }
.tr-pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }
.tr-section { margin-bottom: var(--sp-3); }
.tr-section > summary { display: flex; align-items: center; gap: var(--sp-3); cursor: pointer; list-style: none; flex-wrap: wrap; }
.tr-section > summary > span:first-child b { font-size: var(--fs-body); }
.tr-section > summary .muted { font-size: var(--fs-caption); flex: 1; min-width: 160px; }
.tr-section[open] > summary { margin-bottom: var(--sp-4); }
.tr-map { display: flex; flex-direction: column; gap: var(--sp-3); }
.tr-field { min-width: 0; }
.tr-field.tr-nested { border-left: 2px solid var(--line); padding-left: var(--sp-3); }
.tr-key { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.tr-key label { font-size: var(--fs-ui); font-weight: 500; }
.tr-key code { font-size: 10.5px; color: var(--text-3); }
.tr-del { color: var(--text-3); margin-left: auto; flex: none; }
.tr-key .tr-del { margin-left: 4px; height: 22px; padding: 0 6px; }
@media (hover: hover) { .tr-del:hover { color: var(--bad); } }
.tr-list { display: flex; flex-direction: column; gap: 6px; }
.tr-item { display: flex; gap: 6px; align-items: flex-start; }
.tr-item > .tr-input, .tr-item > .tr-nested { flex: 1; min-width: 0; }
.tr-item > .tr-nested { border-left: 2px solid var(--line); padding-left: var(--sp-3); }
.tr-add { align-self: flex-start; color: var(--accent-ink); }
.tr-pair { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: 6px; align-items: start; }
.tr-pair-key { font-weight: 500; }
.tr-pair-val { min-width: 0; }
.tr-pair-val > textarea { width: 100%; }
@media (max-width: 700px) { .tr-pair { grid-template-columns: minmax(0, 1fr) auto; } .tr-pair-val { grid-column: 1; } }
.tr-input { width: 100%; }
textarea.tr-input, .tr-pair textarea { resize: vertical; line-height: 1.5; }
.tr-add-sections { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--fs-caption); color: var(--text-3); margin: var(--sp-3) 0; }
.tr-savebar { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center;
  padding: var(--sp-3) 0; margin-top: var(--sp-3); background: var(--bg); border-top: 1px solid var(--line); }
.tr-savebar .muted { font-size: var(--fs-caption); }
.tr-code { width: 100%; min-height: 60vh; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; resize: vertical; tab-size: 2; white-space: pre; }
.tr-history { margin-top: var(--sp-3); }
.tr-version { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); padding: 6px 0; border-top: 1px solid var(--line); font-size: var(--fs-ui); flex-wrap: wrap; }
.tr-version-view { min-height: 0; max-height: 50vh; overflow: auto; background: var(--surface-2); padding: var(--sp-3); border-radius: var(--r-sm); margin-top: var(--sp-3); }
.tr-files { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
@media (max-width: 860px) { .tr-files { grid-template-columns: minmax(0, 1fr); } }
.tr-file-list { position: sticky; top: var(--sp-4); max-height: calc(100vh - 120px); overflow-y: auto; }
.tr-group + .tr-group { margin-top: var(--sp-4); }
.tr-group-title { font-size: var(--fs-caption); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.tr-file { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; border: none; background: none;
  padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--text); font: 500 var(--fs-ui)/1.3 var(--mono); }
.tr-file small { font: 400 var(--fs-caption)/1.3 var(--sans); color: var(--text-3); }
.tr-file.on { background: var(--accent-soft); color: var(--accent-ink); }
@media (hover: hover) { .tr-file:not(.on):hover { background: var(--surface-2); } }
.tr-none { font-size: var(--fs-caption); padding: 2px 8px; }
.tr-agents { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.tr-editor .tr-code { min-height: 55vh; white-space: pre-wrap; }
/* Grow with their text where the browser can. */
textarea.tr-input, .tr-pair textarea { field-sizing: content; min-height: 34px; max-height: 360px; }


/* ── Top bar: who is signed in ─────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  height: 60px; padding: 0 var(--sp-6); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { margin-right: auto; font-size: var(--fs-ui); color: var(--text-3); }
.topbar-title b { color: var(--text); font-weight: 600; }
main.content { padding-top: 0; }
.content-inner { padding-top: var(--sp-6); }
.theme-switch { display: inline-flex; padding: 2px; border-radius: 99px; background: var(--surface-3); gap: 2px; }
.theme-switch button { width: 30px; height: 26px; border: none; border-radius: 99px; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.theme-switch button.on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-border); }
.user-chip { position: relative; }
.user-chip > button {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 4px 12px 4px 4px; border: none; cursor: pointer;
  border-radius: 99px; background: var(--surface); box-shadow: var(--shadow-border); color: var(--text); font: 500 var(--fs-ui)/1.2 var(--sans); text-align: left;
}
@media (hover: hover) { .user-chip > button:hover { box-shadow: var(--shadow-border-hover); } }
.user-chip small { display: block; color: var(--text-3); font-size: 11px; font-weight: 400; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; padding: 6px; border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-pop); display: none; z-index: 30;
}
.user-menu.open { display: block; }
.user-menu .who { display: flex; gap: 10px; align-items: center; padding: 8px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu .who small { display: block; color: var(--text-3); font-size: 11.5px; overflow-wrap: anywhere; }
.user-menu a, .user-menu button.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border: none; background: none; border-radius: var(--r-sm);
  font: 500 var(--fs-ui)/1.2 var(--sans); color: var(--text-2); text-decoration: none; cursor: pointer; text-align: left;
}
@media (hover: hover) { .user-menu a:hover, .user-menu button.menu-item:hover { background: var(--surface-2); color: var(--text); } }
.avatar {
  --size: 34px; width: var(--size); height: var(--size); flex: none; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--indigo-30) 100%); color: #fff; font: 600 calc(var(--size) * 0.38)/1 var(--sans);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--secondary-line);
}
.avatar.lg { --size: 96px; }
.avatar.sm { --size: 28px; }
.role-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--secondary-soft); color: var(--secondary); }
.role-tag.admin { background: var(--accent-soft); color: var(--accent-ink); }
@media (max-width: 860px) { .topbar { padding: 0 var(--sp-4); } .topbar-title { display: none; } .user-chip > button span.who-text { display: none; } .user-chip > button { padding-right: 4px; } }

/* ── Users, profile, branding ──────────────────────────────────── */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.user-card { display: flex; flex-direction: column; gap: var(--sp-3); }
.user-card .top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.user-card .top div { min-width: 0; }
.user-card .top b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .top small { color: var(--text-3); font-size: var(--fs-caption); overflow-wrap: anywhere; }
.user-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.profile-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
@media (max-width: 860px) { .profile-grid { grid-template-columns: minmax(0, 1fr); } }
.profile-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.profile-hero .banner-strip { align-self: stretch; height: 72px; margin: calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)) -52px; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(120deg, var(--amber) 0%, var(--vermilion) 60%, var(--navy) 140%); }
.upload-row { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }
.brand-preview { width: 220px; height: 96px; border-radius: var(--r-md); display: grid; place-items: center; padding: 12px;
  background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px; box-shadow: inset 0 0 0 1px var(--line); }
.brand-preview.fav { width: 96px; }
.brand-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgb(2 7 98 / 0.35); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: var(--sp-5); }
.modal h3 { font-size: var(--fs-h3); margin-bottom: var(--sp-4); }

/* ── Brand touches ─────────────────────────────────────────────── */
.section-head h2 { color: var(--text); }
.section-head h2::after { content: ''; display: block; width: 36px; height: 3px; border-radius: 3px; margin-top: 8px;
  background: linear-gradient(90deg, var(--amber), var(--vermilion)); }
.card { border-radius: var(--r-lg); }
