/* ══════════════════════════════════════════════════════════════
   Harvey — dashboard styles

   The rules this sheet follows:

   1. One accent. Cobalt 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('/static/fonts/geist.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono'; font-style: normal; font-weight: 400 500;
  font-display: swap; src: url('/static/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);

  /* Light — neutral, a touch cool. */
  --bg:          #F6F6F7;
  --surface:     #FFFFFF;
  --surface-2:   #F3F3F4;   /* hover, inset panels */
  --surface-3:   #EBEBED;   /* pressed, tracks */
  --line:        #E7E7EA;
  --line-strong: #D6D6DB;
  --text:        #111113;
  --text-2:      #5B5B63;
  --text-3:      #8B8B93;
  --accent:      #1D4ED8;
  --accent-hover:#1E40AF;
  --accent-text: #FFFFFF;
  --accent-soft: #EBF1FE;
  --accent-line: #CCDBFC;
  --chart-muted: #BCD0FA;

  --good:   #1F7A4D; --good-bg:   #E8F6EE; --good-line:   #C6EAD5;
  --wait:   #8A5A00; --wait-bg:   #FFF4DE; --wait-line:   #F6DFAE;
  --bad:    #B4232F; --bad-bg:    #FDECEE; --bad-line:    #F7CDD2;
  --active: #0E7490; --active-bg: #E5F6F9; --active-line: #BDE5EE;
  --note:   #6A3FB0; --note-bg:   #F2ECFC; --note-line:   #DFD1F6;

  --shadow-border:
    0 0 0 1px rgb(17 17 19 / 0.06),
    0 1px 2px -1px rgb(17 17 19 / 0.06),
    0 2px 4px 0 rgb(17 17 19 / 0.04);
  --shadow-border-hover:
    0 0 0 1px rgb(17 17 19 / 0.09),
    0 1px 2px -1px rgb(17 17 19 / 0.08),
    0 2px 6px 0 rgb(17 17 19 / 0.06);
  --shadow-pop: 0 0 0 1px rgb(17 17 19 / 0.08), 0 12px 32px -8px rgb(17 17 19 / 0.18);
  --btn-shadow: 0 0 0 1px rgb(17 17 19 / 0.10), 0 1px 2px rgb(17 17 19 / 0.06);
  --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 0 0 1px #1A44C2, 0 1px 2px rgb(17 17 19 / 0.12);
  color-scheme: light;
}

/* Dark — near-black, neutral. Declared twice on purpose: once for an
   explicit choice, once for the system preference when none is chosen. */
:root[data-theme='dark'] {
  --bg:          #0E0E10;
  --surface:     #161618;
  --surface-2:   #1D1D20;
  --surface-3:   #26262A;
  --line:        #26262A;
  --line-strong: #34343A;
  --text:        #F3F3F5;
  --text-2:      #A3A3AC;
  --text-3:      #6E6E77;
  --accent:      #3D6FF5;
  --accent-hover:#5A85FF;
  --accent-text: #FFFFFF;
  --accent-soft: #111C36;
  --accent-line: #1E3366;
  --chart-muted: #22365F;

  --good:   #5CCB8F; --good-bg:   #10261B; --good-line:   #1C4130;
  --wait:   #F0B84F; --wait-bg:   #2A2010; --wait-line:   #4A3817;
  --bad:    #FF7A85; --bad-bg:    #2C1316; --bad-line:    #4C1F25;
  --active: #4CC3D9; --active-bg: #0C2328; --active-line: #164049;
  --note:   #B79BF5; --note-bg:   #1E1730; --note-line:   #352857;

  --shadow-border: 0 0 0 1px rgb(255 255 255 / 0.07);
  --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:not([data-theme='light']) {
    --bg:#0E0E10; --surface:#161618; --surface-2:#1D1D20; --surface-3:#26262A;
    --line:#26262A; --line-strong:#34343A;
    --text:#F3F3F5; --text-2:#A3A3AC; --text-3:#6E6E77;
    --accent:#3D6FF5; --accent-hover:#5A85FF; --accent-text:#FFFFFF;
    --accent-soft:#111C36; --accent-line:#1E3366; --chart-muted:#22365F;
    --good:#5CCB8F; --good-bg:#10261B; --good-line:#1C4130;
    --wait:#F0B84F; --wait-bg:#2A2010; --wait-line:#4A3817;
    --bad:#FF7A85; --bad-bg:#2C1316; --bad-line:#4C1F25;
    --active:#4CC3D9; --active-bg:#0C2328; --active-line:#164049;
    --note:#B79BF5; --note-bg:#1E1730; --note-line:#352857;
    --shadow-border: 0 0 0 1px rgb(255 255 255 / 0.07);
    --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);
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto; overscroll-behavior: contain;
}
.brand { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; }
.brand .tagline { font-size: var(--fs-caption); color: var(--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: 500; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  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(--text-2);
  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(--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(--surface-2); color: var(--text); }
  nav button:hover .icon { color: var(--text-2); }
}
nav button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-border); }
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(--accent-soft); color: var(--accent);
}
.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(--line);
}
.harvey-status { display: flex; align-items: center; gap: 8px; font-size: var(--fs-ui); color: var(--text-2); }
.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); color: var(--accent-text); box-shadow: var(--btn-primary-shadow); }
.btn-secondary { background: var(--surface); color: var(--text); }
.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-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); 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-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); }
.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); 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; }
