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

   A registry browser, not a marketing page. The rules:

   1. Data first. Phones, CUIs and CAEN codes are set in Geist Mono and
      are the darkest, most legible thing in a row; labels step back.
   2. One accent. Petrol marks the primary action, the current page,
      links you can act on (call, write) and the main series in a chart.
      Status hues appear only on status, so colour always means something.
   3. Dense but calm: 13px UI text, 40px rows, hairline dividers, paper
      background with white sheets on it. Space groups; lines divide.
   4. Motion is feedback only: the drawer slides, buttons press. Nothing
      animates on a tab switch.

   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;
  /* Counts and amounts: the text face with tabular figures. In the mono face
     the ro-RO thousands dot takes a full cell, so 2.421 read as "2. 421". */
  --num: var(--sans);

  --fs-micro:   0.6875rem;   /* 11 */
  --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.25rem;     /* 20 */
  --fs-kpi:     1.625rem;    /* 26 */

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 10px;

  --topbar-h: 52px;
  --sidebar-w: 212px;
  --content-w: 1320px;
  --drawer-w: 520px;

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

  /* Light — warm paper, ink, petrol. */
  --bg:          #F4F3EF;
  --surface:     #FFFFFF;
  --surface-2:   #F6F5F1;   /* hover, inset panels */
  --surface-3:   #ECEAE4;   /* pressed, tracks */
  --line:        #E5E2DA;
  --line-strong: #D2CEC4;
  --text:        #17181A;
  --text-2:      #55565A;
  --text-3:      #8A8A86;
  --accent:      #0B6B64;
  --accent-hover:#08564F;
  --accent-text: #FFFFFF;
  --accent-soft: #E4F1EF;
  --accent-line: #B9DAD5;
  --chart-muted: #A9D2CC;
  --select:      #EEF6F4;

  --good:   #1E7A46; --good-bg:   #E7F5EC; --good-line:   #C3E6CF;
  --wait:   #8A5300; --wait-bg:   #FDF1DC; --wait-line:   #F1D9AA;
  --bad:    #B3261E; --bad-bg:    #FCEBE9; --bad-line:    #F4CBC6;
  --active: #1E5FA8; --active-bg: #E8F0FA; --active-line: #C6D9F1;
  --note:   #6B47A8; --note-bg:   #F1ECFA; --note-line:   #DCD0F2;

  --shadow-sheet: 0 0 0 1px var(--line), 0 1px 2px rgb(23 24 26 / 0.04);
  --shadow-pop: 0 0 0 1px rgb(23 24 26 / 0.08), 0 16px 40px -12px rgb(23 24 26 / 0.22);
  --btn-shadow: 0 0 0 1px var(--line-strong), 0 1px 1px rgb(23 24 26 / 0.04);
  --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.14), 0 0 0 1px #075952;
  color-scheme: light;
}

/* Dark — graphite with the same petrol, lifted. Declared twice on
   purpose: once for an explicit choice, once for the system preference. */
:root[data-theme='dark'] {
  --bg:#0F1111; --surface:#161918; --surface-2:#1B1F1E; --surface-3:#242928;
  --line:#262B2A; --line-strong:#353B39;
  --text:#ECEDEA; --text-2:#A7ABA7; --text-3:#727874;
  --accent:#4DC3B5; --accent-hover:#6FD4C8; --accent-text:#062320;
  --accent-soft:#11292A; --accent-line:#1E4A46; --chart-muted:#1F4A45; --select:#14262A;
  --good:#5FCB8C; --good-bg:#0F2619; --good-line:#1C412B;
  --wait:#EDB65A; --wait-bg:#2A2010; --wait-line:#4A3817;
  --bad:#FF8A80; --bad-bg:#2C1514; --bad-line:#4C2220;
  --active:#7DB2F0; --active-bg:#0F1E30; --active-line:#1E3756;
  --note:#B9A0F2; --note-bg:#1E1730; --note-line:#352857;
  --shadow-sheet: 0 0 0 1px var(--line);
  --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.08), 0 18px 48px -10px rgb(0 0 0 / 0.7);
  --btn-shadow: 0 0 0 1px var(--line-strong);
  --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg:#0F1111; --surface:#161918; --surface-2:#1B1F1E; --surface-3:#242928;
    --line:#262B2A; --line-strong:#353B39;
    --text:#ECEDEA; --text-2:#A7ABA7; --text-3:#727874;
    --accent:#4DC3B5; --accent-hover:#6FD4C8; --accent-text:#062320;
    --accent-soft:#11292A; --accent-line:#1E4A46; --chart-muted:#1F4A45; --select:#14262A;
    --good:#5FCB8C; --good-bg:#0F2619; --good-line:#1C412B;
    --wait:#EDB65A; --wait-bg:#2A2010; --wait-line:#4A3817;
    --bad:#FF8A80; --bad-bg:#2C1514; --bad-line:#4C2220;
    --active:#7DB2F0; --active-bg:#0F1E30; --active-line:#1E3756;
    --note:#B9A0F2; --note-bg:#1E1730; --note-line:#352857;
    --shadow-sheet: 0 0 0 1px var(--line);
    --shadow-pop: 0 0 0 1px rgb(255 255 255 / 0.08), 0 18px 48px -10px rgb(0 0 0 / 0.7);
    --btn-shadow: 0 0 0 1px var(--line-strong);
    --btn-primary-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18);
    color-scheme: dark;
  }
}

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

* { margin: 0; padding: 0; box-sizing: border-box; }
::selection { background: var(--accent-soft); color: var(--text); }
[hidden] { display: none !important; }
/* A page whose data failed to load hides its forms and builders (markLoadFailed). */
.section.load-failed .needs-data { display: none !important; }

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;
  overflow-x: hidden;
}
body.drawer-open { overflow: hidden; }
/* Geist's space is narrow (0.236em at weight 600). Under the headings'
   negative tracking, rounded to whole pixels on a 1x screen, it shrank to
   under 3px and words ran together ("Cota abonamentului" read as one). */
h1, h2, h3, h4, .status-big .label, .brand-name, .qtitle, .cell-main, .empty .title { word-spacing: 0.14em; }
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); }
.mono { font-size: 0.95em; letter-spacing: -0.01em; }
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); }
.small { font-size: var(--fs-ui); }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.pad { padding: var(--sp-4) var(--sp-5); font-size: var(--fs-ui); }
.spacer { height: 18px; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none;
           stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ── Top bar ─────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: 0 var(--sp-5) 0 var(--sp-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  position: relative; width: 30px; height: 30px; flex: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text); color: var(--bg);
  font: 600 15px/1 var(--sans); letter-spacing: -0.04em;
}
.mark i {
  position: absolute; right: -5px; bottom: -4px; padding: 1px 3px; border-radius: 4px;
  font: 600 8px/1.1 var(--mono); font-style: normal; letter-spacing: 0.02em;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 2px var(--bg);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.tagline { font-size: var(--fs-caption); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); }

.harvey-status { display: flex; align-items: center; gap: 8px; font-size: var(--fs-caption); color: var(--text-2); white-space: nowrap; }
.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); }

.lang-switch {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: 7px;
  background: var(--surface-3);
}
.lang-switch button {
  height: 24px; min-width: 32px; padding: 0 8px; border: none; border-radius: 5px; cursor: pointer;
  font: 600 var(--fs-micro)/1 var(--mono); letter-spacing: 0.04em; color: var(--text-3); background: none;
}
.lang-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sheet); }
@media (hover: hover) { .lang-switch button:not(.on):hover { color: var(--text); } }

.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);
  display: inline-flex; align-items: center; gap: 6px;
  transition-property: background-color, color, scale; transition-duration: 150ms; transition-timing-function: ease-out;
}
.icon-btn .icon, .refresh-btn .icon { width: 14px; height: 14px; }
.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); } }

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

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

.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
}
nav { display: flex; flex-direction: column; gap: var(--sp-4); }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: var(--fs-micro); font-weight: 500; color: var(--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(--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-3); color: var(--text); }
  nav button:hover .icon { color: var(--text-2); }
}
nav button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sheet); }
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: 600 var(--fs-micro)/1 var(--num); border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
.nav-count.soft { background: none; color: var(--text-3); font-weight: 500; padding: 0; }
.nav-count.on { display: inline-flex; }

.sidebar-foot { margin-top: auto; padding: var(--sp-3) 2px 0; border-top: 1px solid var(--line); }

main.content { min-width: 0; padding: var(--sp-5) 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-4);
}
.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-ui); color: var(--text-2); margin-top: 4px; max-width: 72ch; 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-caption); font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: var(--sp-6) 0 var(--sp-2);
}
.subhead .hint { font-weight: 400; color: var(--text-3); text-transform: none; letter-spacing: 0; }
.subhead:first-child { margin-top: 0; }

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

.card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sheet); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3);
}
.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: 0 0 var(--sp-4); max-width: 72ch; 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-3) var(--sp-4); border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: var(--fs-ui); font-weight: 600; }
.card-head .meta { font-size: var(--fs-caption); color: var(--text-3); }
.card.tip p { font-size: var(--fs-ui); color: var(--text-2); text-wrap: pretty; }
.card.tip code { white-space: nowrap; }
.card.tip p + p, .card.tip pre + p { margin-top: var(--sp-2); }
pre.cmd {
  margin: var(--sp-3) 0 0; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
pre.cmd .nb { white-space: nowrap; }

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

/* ── Overview ────────────────────────────────────────────────── */

.hero-search {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2) var(--sp-3);
  align-items: center; margin-bottom: var(--sp-4);
}
.hero-hints { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--fs-caption); }
.hero-search .btn { height: 44px; padding: 0 18px; font-size: var(--fs-body); }
.chip-btn {
  height: 24px; padding: 0 9px; border: none; border-radius: 99px; cursor: pointer; white-space: nowrap;
  font: 500 var(--fs-caption)/1 var(--sans); color: var(--text-2);
  background: var(--surface); box-shadow: var(--btn-shadow);
}
@media (hover: hover) { .chip-btn:hover { color: var(--accent); box-shadow: 0 0 0 1px var(--accent-line); } }

.stat-strip {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px; background: var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet);
  margin-bottom: var(--sp-2); overflow: hidden;
}
.stat { padding: var(--sp-4) var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: 4px; min-width: 0; background: var(--surface); }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--text-2); font-weight: 500; }
.stat-label .icon { width: 14px; height: 14px; color: var(--text-3); }
.stat-value { font: 500 var(--fs-kpi)/1.1 var(--num); letter-spacing: -0.04em; }
.stat-value.zero { color: var(--text-3); }
.stat-note { font-size: var(--fs-caption); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.share span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
@media (max-width: 1100px) {
  .stat-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .stat { grid-column: span 2; }
  .stat:nth-child(n+4) { grid-column: span 3; }
}

/* ── KPI cards with sparklines (Today) ───────────────────────── */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet);
  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-caption); color: var(--text-2); font-weight: 500; }
.kpi-value { font: 500 var(--fs-kpi)/1.1 var(--num); letter-spacing: -0.04em; }
.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); }

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

.funnel-bar { display: flex; height: 8px; 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-3); }
.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: 500 var(--fs-h3) var(--num); letter-spacing: -0.02em; }
.legend-val small { font: 400 var(--fs-caption) var(--sans); 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); }
.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, .mini-dot.t-good { color: var(--good); } .mini.t-waiting, .mini-dot.t-waiting { color: var(--wait); }
.mini.t-bad, .mini-dot.t-bad { color: var(--bad); } .mini.t-active, .mini-dot.t-active { color: var(--active); }
.mini.t-note, .mini-dot.t-note { color: var(--note); } .mini.t-idle, .mini-dot.t-idle { color: var(--text-3); }
.mini-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.mini-dot.t-idle { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }

/* ── Meters ──────────────────────────────────────────────────── */

.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-row { display: inline-flex; align-items: center; gap: 8px; }
.meter-row .v { font: var(--fs-caption) var(--num); 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; }

.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-family: var(--mono); font-weight: 500; }
.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.97; }
.btn:disabled { opacity: 0.45; 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-3); 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; }
.btn-row { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
a.btn, a.btn:hover { text-decoration: none; }

/* ── Tags & badges ───────────────────────────────────────────── */

.badge, .tag {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px;
  font-size: var(--fs-micro); 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); }
.tag.t-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.tag.t-good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.tag.t-warn { background: var(--wait-bg); color: var(--wait); border-color: var(--wait-line); }
button.tag { cursor: pointer; font: inherit; font-size: var(--fs-micro); }
/* The Registry page: a firm no longer operating is dimmed, not hidden. */
.rg-table tr.rg-closed td:not(.sel) { color: var(--text-2); }
.fin-table.across th:first-child, .fin-table.across td:first-child { text-align: left; white-space: nowrap; }
.fin-table.across td, .fin-table.across th { text-align: right; }
.cost-chip {
  display: inline-flex; align-items: center; min-height: 20px; padding: 2px 8px; border-radius: 10px;
  font-size: var(--fs-micro); 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; }

.email-tag { font-size: var(--fs-micro); font-weight: 500; padding: 2px 8px; border-radius: 99px; margin-left: 6px; text-transform: none; letter-spacing: 0; }
.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-3); color: var(--text-2); }

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

.table-card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sheet); overflow: auto; overscroll-behavior-x: contain;
}
.card .table-card { box-shadow: 0 0 0 1px var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-ui); }
th {
  text-align: left; font-size: var(--fs-micro); font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 9px 12px; 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: 9px 12px; 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; }
tr.selected td { background: var(--select); }
@media (hover: hover) { tr.selected:hover td { background: var(--select); } }
table.nowrap td { white-space: nowrap; }
table.compact td, table.compact th { padding-top: 7px; padding-bottom: 7px; }
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-sub.verified { color: var(--good); }
.cell-stack { display: flex; flex-direction: column; min-width: 0; }
.cell-row { display: flex; align-items: center; gap: 8px; }
.dot-sep { margin: 0 6px; color: var(--line-strong); }
.none { font-size: var(--fs-caption); color: var(--text-3); }
.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; } }

/* Data tables: Companies and Contacts */
th.sel, td.sel { width: 36px; padding-right: 0; }
td.sel input, th.sel input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.data td { vertical-align: top; }
.data td.sel { padding-top: 12px; }
.co-name { min-width: 220px; max-width: 360px; }
.co-name .cell-main { font-size: var(--fs-ui); line-height: 1.35; }
.co-name .cell-sub { margin-top: 3px; }
.co-phone, .co-email { min-width: 170px; }
.co-acts { min-width: 200px; max-width: 340px; }
.co-src { font-size: var(--fs-caption); min-width: 90px; white-space: nowrap; }
.ct-name { min-width: 210px; }
.ct-table td:nth-child(3) { min-width: 200px; max-width: 300px; }
.ct-table td:nth-child(4), .ct-table td:nth-child(5) { min-width: 170px; }
.contact-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contact-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
a.tel {
  color: var(--accent); font-weight: 500; text-decoration: none; white-space: nowrap;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
a.email { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (hover: hover) { a.tel:hover, a.email:hover { text-decoration: underline; } }
.co-link { color: var(--text); text-decoration: none; }
.link-btn {
  display: inline; padding: 0; margin: 0; border: none; background: none; cursor: pointer;
  font: inherit; color: var(--text); text-align: left; overflow-wrap: anywhere;
}
.link-btn.cell-main { font-weight: 500; }
@media (hover: hover) { .link-btn:hover { text-decoration: underline; text-underline-offset: 2px; } }
.sel-page-mobile { display: none; }
.copy {
  width: 22px; height: 22px; flex: none; border: none; border-radius: 5px; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-3);
  opacity: 0; transition: opacity 120ms ease, color 120ms ease, background-color 120ms ease;
}
.copy .icon { width: 13px; height: 13px; }
tr:hover .copy, .copy:focus-visible, .drow .copy, .copy.done { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }
@media (hover: hover) { .copy:hover { color: var(--text); background: var(--surface-3); } }
.copy.done { color: var(--good); }

.acts { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.act { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.act .code {
  flex: none; font: 500 11px/1.4 var(--mono); padding: 0 5px; border-radius: 4px;
  color: var(--text-2); background: var(--surface-3);
}
.act.matched .code { color: var(--accent); background: var(--accent-soft); }
.act .aname {
  font-size: var(--fs-caption); color: var(--text-2); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.act.matched .aname { color: var(--text); }

/* Toolbar: search, filters, actions */
.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: 360px; display: block; }
.search.grow { max-width: 560px; }
.search.big { max-width: none; }
.search .icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--text-3); width: 15px; height: 15px; pointer-events: none; }
.search input { padding-left: 34px; }
.search.big input { height: 44px; font-size: var(--fs-lead); padding-left: 40px; border-radius: var(--r-md); box-shadow: 0 1px 2px rgb(23 24 26 / 0.04); }
.search.big .icon { left: 14px; width: 17px; height: 17px; }
.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; 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-family: var(--num); font-size: var(--fs-micro); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sheet); }
@media (hover: hover) { .segmented button:not(.on):hover { color: var(--text); } }
#company-actions, #contact-actions { margin-left: auto; }

/* Possible duplicates: two records side by side, decided by a person */
.chip-btn.on { color: var(--accent); box-shadow: 0 0 0 1px var(--accent-line); }
.dup-panel { padding: var(--sp-4); margin-bottom: var(--sp-3); }
.dup-head { display: flex; gap: var(--sp-3); align-items: flex-start; justify-content: space-between; }
.dup-head h3 { margin: 0 0 var(--sp-1); }
.dup-head p { margin: 0 0 var(--sp-3); max-width: 70ch; }
.dup-tabs { margin-bottom: var(--sp-3); }
.dup-pair { padding: var(--sp-3) 0; border-top: 1px solid var(--line); display: grid; gap: var(--sp-2); }
.dup-why { font-size: var(--fs-caption); color: var(--text-2); }
.dup-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.dup-side { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .dup-sides { grid-template-columns: minmax(0, 1fr); } }
.dup-head .btn-row { flex-wrap: nowrap; }
.dup-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-2); }
.dup-member { min-width: 0; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); display: grid; gap: var(--sp-1); align-content: start; }
.dup-member.keeper { border-color: var(--accent-line); background: var(--select); }
.dup-member.other { background: var(--surface-2); }
.dup-member.other .dup-side { color: var(--text-3); }
.dup-choice { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-caption); color: var(--text-2); }
.dup-pick { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-height: 24px; }
.dup-pick:has(input:disabled) { cursor: not-allowed; opacity: .6; }
.cell-sub.warn { color: var(--wait); }
@media (max-width: 640px) { .dup-head { flex-wrap: wrap; } .dup-members { grid-template-columns: minmax(0, 1fr); } }

.selbar {
  display: flex; align-items: center; gap: var(--sp-3); margin: 0 0 var(--sp-2);
  padding: 6px 6px 6px 12px; border-radius: var(--r-md);
  background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line);
  font-size: var(--fs-ui); color: var(--accent);
}
.selbar b { font-weight: 600; }

/* Pager */
.pager { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 2px 0; font-size: var(--fs-caption); color: var(--text-2); flex-wrap: wrap; }
.pager-range { font-family: var(--num); font-size: var(--fs-caption); }
.pager-size { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.pager-size select { height: 28px; width: auto; padding: 0 24px 0 8px; font-size: var(--fs-caption); }
.pager-btns { display: inline-flex; gap: 4px; }
.pager-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pager-nums { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.pager-nums .btn { min-width: 32px; font-family: var(--num); }
.pager-nums .btn[aria-current="page"] { opacity: 1; }
.pager-gap { padding: 0 4px; color: var(--text-3); }

/* Companies: the sort menu beside the search box. */
.sort-pick { display: inline-flex; align-items: center; gap: 4px; }
.sort-pick select { width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.co-count { font-family: var(--num); text-align: right; }

/* The company panel's yearly figures. */
.table-scroll { overflow-x: auto; }
.fin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-caption); }
.fin-table th { text-align: left; font-weight: 500; color: var(--text-2); padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.fin-table td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dsub { font-size: var(--fs-caption); color: var(--text-2); font-weight: 500; margin: var(--sp-3) 0 4px; }
.table-foot { font-size: var(--fs-caption); color: var(--text-3); padding: var(--sp-3) 2px 0; }

/* Actions menu */
.menu { position: relative; }
.menu-btn .icon { width: 14px; height: 14px; color: var(--text-3); margin-right: -2px; }
.menu-list {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 260px;
  padding: 6px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-pop);
}
.menu.open .menu-list { display: block; }
.menu-list button {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 10px; align-items: center;
  width: 100%; padding: 7px 10px; border: none; border-radius: var(--r-sm); background: none; cursor: pointer;
  font: 500 var(--fs-ui)/1.3 var(--sans); color: var(--text); text-align: left;
}
.menu-list button .icon { width: 15px; height: 15px; color: var(--text-3); }
.menu-list button:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-note { grid-column: 2; font-size: var(--fs-caption); font-weight: 400; color: var(--text-3); }
@media (hover: hover) { .menu-list button:hover:not(:disabled) { background: var(--surface-2); } }
.menu-list button:focus-visible { outline-offset: -2px; }
.menu-sep {
  padding: 8px 10px 4px; font-size: var(--fs-micro); font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.menu-sep + button { margin-top: 0; }
.menu-sep:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 10px; }

/* ── The company panel (drawer) ──────────────────────────────── */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgb(15 17 17 / 0.28);
  @starting-style { opacity: 0; }
  transition: opacity 200ms ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: min(var(--drawer-w), 100vw);
  background: var(--surface); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  @starting-style { translate: 24px 0; opacity: 0.4; }
  transition: translate 260ms var(--ease-out), opacity 200ms ease;
}
#drawer:focus { outline: none; }
#drawer-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.drawer-head {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.drawer-title { flex: 1; min-width: 0; }
.drawer-title h2 { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; overflow-wrap: anywhere; }
.drawer-sub { font-size: var(--fs-caption); color: var(--text-3); margin-top: 3px; }
.drawer-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-2) var(--sp-5) var(--sp-5); }
.drawer-foot { display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); }
.dsec { padding: var(--sp-4) 0; }
.dsec + .dsec { border-top: 1px solid var(--line); }
.dsec h3 {
  display: flex; align-items: center; gap: 7px; margin-bottom: var(--sp-2);
  font-size: var(--fs-micro); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em;
}
.dsec h3 .icon { width: 14px; height: 14px; }
.dsec h3 .count { font-family: var(--num); font-weight: 500; color: var(--text-3); margin-left: 2px; }
.dsec .none { font-size: var(--fs-ui); }
.drow { display: flex; align-items: center; gap: 10px; padding: 5px 0; min-width: 0; }
.drow .mono.big { font-size: var(--fs-lead); }
.drow .drow-meta { font-size: var(--fs-caption); color: var(--text-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.drow .copy { margin-left: auto; }
.drow.addr { flex-wrap: wrap; gap: 2px 10px; }
.drow.addr .drow-text { min-width: 0; overflow-wrap: anywhere; }
.drow.addr .drow-meta { white-space: normal; flex-basis: 100%; }
.person { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.person .cell-stack { flex: 1; }
.person-lines { font-size: var(--fs-caption); margin-top: 3px; line-height: 1.6; }
.facts-list { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 14px; font-size: var(--fs-ui); }
.facts-list dt { color: var(--text-3); }
.facts-list dd { overflow-wrap: anywhere; }
.skeleton { height: 52px; margin-top: var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: pulse 1.4s ease-in-out infinite; }
}

/* ── 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-radius: var(--r-lg); box-shadow: var(--shadow-sheet); padding: var(--sp-3) var(--sp-4);
}
.queue-item.bare { padding: 0; box-shadow: none; background: none; }
.queue-icon {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  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(--accent-soft); color: var(--accent); }
.queue-item .qtext { flex: 1; min-width: 0; }
.queue-item .qtitle { font-size: var(--fs-body); font-weight: 600; }
.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-4) var(--sp-5);
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet);
}
.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: 9px 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-next .btn { margin-left: auto; }
.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; } }

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

.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 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 0; }
.tl-time { font: var(--fs-caption) var(--mono); 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, check list */
.check-item { display: flex; gap: 10px; padding: 9px 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;
}
.check-icon .icon { width: 11px; height: 11px; stroke-width: 2.5; }
.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-2); }
.setup-head h3 { font-size: var(--fs-body); 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; }
.check-help a { color: var(--accent); }
.setup-pct { font: 500 var(--fs-caption) var(--num); color: var(--text-3); }
.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; }

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; }

/* ── 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-sheet);
  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-sheet); 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.2rem; 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; }
.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); }
.desk-held { margin-bottom: var(--sp-3); }
@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-3) var(--sp-4); margin-bottom: var(--sp-3); 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); }
.mode-banner { align-items: center; }
.mode-banner > div { flex: 1; }
.mode-banner:not(.wait) { background: var(--surface); border-color: var(--line); }
.mode-card h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-body); }
.mode-card p { margin: 0 0 var(--sp-2); font-size: var(--fs-ui); line-height: 1.55; max-width: 76ch; }
.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; }

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

.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.prov-card {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); cursor: pointer; text-align: left;
  font: inherit; color: inherit; border: none;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet); transition: box-shadow 150ms ease-out;
}
@media (hover: hover) { .prov-card:hover { box-shadow: 0 0 0 1px var(--line-strong), 0 2px 6px rgb(23 24 26 / 0.06); } }
.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-ui); font-weight: 600; }
.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: 52px; flex: none; }
.prov-card .row .v { color: var(--text-2); }
.prov-card .row a { color: var(--accent); }
.prov-head input[type="checkbox"] { flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.prov-head h3 { flex: 1; }
.source-filters { margin-bottom: var(--sp-4); }
.source-filters h3, .finder-card h2 { font-size: var(--fs-ui); font-weight: 600; margin-bottom: var(--sp-2); }
.run-card { margin-bottom: var(--sp-3); }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: var(--sp-2); }
.finder-card { margin-bottom: var(--sp-3); }
.finder-status { margin: 0 0 var(--sp-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: 500 var(--fs-kpi)/1.1 var(--num); letter-spacing: -0.04em; }
.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-radius: var(--r-lg); box-shadow: var(--shadow-sheet); padding: var(--sp-4); }
.stat-card .label { font-size: var(--fs-caption); color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.stat-card .value { font: 500 var(--fs-kpi)/1.1 var(--num); letter-spacing: -0.04em; }
.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; }

.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: var(--fs-caption) var(--mono); color: var(--text-3); margin-top: 6px; }
.hint { font-weight: 400; }

/* ── 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: 34px; padding: 0 11px; 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 11px; }
select.form-input { cursor: pointer; }
.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-row { display: grid; grid-template-columns: 280px 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: var(--sp-2); }
.settings-row:last-child { padding-bottom: var(--sp-2); }
.settings-row h3 { font-size: var(--fs-ui); 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; }
.more-fields { margin-bottom: var(--sp-3); }
.more-fields summary { 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; }
.check-line.small { font-size: var(--fs-caption); }
@media (max-width: 860px) { .settings-row { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); } }

/* Model: linking a Codex account by a device code (the page, the code to type there) */
.codex-link { margin: var(--sp-3) 0; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--line); }
.codex-link a { overflow-wrap: anywhere; }
.codex-code { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-3); }
.codex-code code { font-size: 26px; font-weight: 600; letter-spacing: 0.08em; user-select: all; overflow-wrap: anywhere; }

/* Classifier: its tasks, its profiles side by side (sorted by name, none put first) */
.settings-row .fields.cls-wide { max-width: none; }
#classify-card .hint { font-size: var(--fs-caption); color: var(--text-2); margin-top: 4px; text-wrap: pretty; }
#classify-card .hint.warn, .run-report .hint.warn { color: var(--wait); }
.cls-list { margin: 4px 0 var(--sp-3) 18px; color: var(--text-2); }
.cls-list li + li { margin-top: 2px; }
.cls-task { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: var(--sp-4); padding: var(--sp-3) 0; }
.cls-task + .cls-task { border-top: 1px solid var(--line); }
.cls-task h4, .cls-profile h4, .cls-edit h4 { font-size: var(--fs-ui); font-weight: 600; }
.cls-task p { margin-top: 2px; text-wrap: pretty; }
.cls-profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: var(--sp-3); }
.cls-profile { padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
               display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cls-profile-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.cls-line { font-size: var(--fs-caption); overflow-wrap: anywhere; }
.cls-counts { margin-top: 4px; }
.cls-profile .btn-row { margin-top: auto; padding-top: var(--sp-2); }
.cls-use-for { width: auto; height: 30px; font-size: var(--fs-caption); }
.cls-edit { margin-bottom: var(--sp-3); }
.cls-test { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--line); }
.run-report { margin: var(--sp-2) 0; }
.run-report p + p { margin-top: 2px; }
.job-run + .job-run { border-top: 1px solid var(--line); margin-top: var(--sp-2); padding-top: var(--sp-2); }
@media (max-width: 860px) { .cls-task { grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); } }

/* Module switch */
.module-row { display: flex; align-items: center; gap: var(--sp-5); padding: var(--sp-2) 0; }
.module-text { flex: 1; min-width: 0; }
.module-text h3 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-body); font-weight: 600; }
.module-text h3 .icon { color: var(--accent); }
.module-text .desc { font-size: var(--fs-ui); color: var(--text-2); margin-top: 4px; max-width: 72ch; text-wrap: pretty; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong);
  transition: background-color 160ms ease;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: translate 180ms var(--ease-out);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { translate: 16px 0; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: var(--fs-ui); font-weight: 500; color: var(--text-2); min-width: 4ch; }
.switch input:disabled + .track { opacity: 0.55; cursor: not-allowed; }

/* Surse: one row per module */
.module-list .module-row { align-items: flex-start; padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.module-list .module-row:first-child { border-top: 0; }
.module-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--sp-3); margin-top: var(--sp-3); font-size: var(--fs-caption); }
.module-meta .k { color: var(--text-3); }
.module-meta .v { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; color: var(--text-2); min-width: 0; }
.module-meta .email-tag { margin-left: 0; }
.module-terms { margin-top: var(--sp-2); font-size: var(--fs-caption); color: var(--wait); background: var(--wait-bg); padding: 8px 10px; border-radius: var(--r-sm); max-width: 72ch; text-wrap: pretty; }
/* Date publice: the local official datasets, above the modules */
.pd-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; margin-top: var(--sp-3); }
.pd-setting { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: 100%; font-size: var(--fs-caption); color: var(--text-2); }
.pd-setting input[type="number"] { width: 5ch; flex: none; }
.module-problems ul { margin: 6px 0 0 18px; }
.module-problems li { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  /* Stretch, not flex-start: in a column a row's children would size to
     their content (a line of signal chips) and push the page sideways. */
  .module-list .module-row { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .module-meta { grid-template-columns: minmax(0, 1fr); }
}

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

.campaign-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet); margin-bottom: var(--sp-3); overflow: hidden; }
.campaign-top { padding: var(--sp-4) 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-body); font-weight: 600; }
.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; }
.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: 500 var(--fs-caption) var(--mono); 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: 76ch; }
.step-actions { margin-top: var(--sp-3); display: flex; flex-direction: column; max-width: 76ch; 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-radius: var(--r-lg); box-shadow: var(--shadow-sheet); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3); }
.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); 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); 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%; } }
/* An answer written to an SMS or WhatsApp conversation, and a channel's
   sending controls on Settings → Channels. */
.convo-answer { display: flex; flex-direction: column; gap: 6px; margin-top: var(--sp-3); }
.convo-answer textarea { width: 100%; max-width: 100%; box-sizing: border-box; resize: vertical; }
.convo-answer .btn { align-self: flex-start; }
.ch-send { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px dashed var(--line); }
.ch-send select, .ch-send input[type="number"] { max-width: 100%; }
.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; }

/* 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; }

.warmup-actions { margin-top: var(--sp-2); align-items: center; }
.warmup-actions .form-input { flex: 1 1 200px; height: 28px; min-width: 0; }

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

.control-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: var(--sp-3); align-items: start; }
@media (max-width: 900px) { .control-panel { grid-template-columns: minmax(0, 1fr); } }
.control-stack { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.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.offline { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); }
.status-big .dot.running { background: var(--good); box-shadow: 0 0 0 4px var(--good-bg); }
.status-big .label { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.015em; }
.status-big.compact .label { font-size: var(--fs-body); letter-spacing: 0; }
.status-big.compact .dot { width: 8px; height: 8px; }
.status-big .label.running { color: var(--good); }
.status-meta { font-size: var(--fs-ui); color: var(--text-3); min-height: 20px; }
.log-viewer {
  background: #0E1010; color: #C7CCC8; 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: 80ch; }
.help-section h2 { font-size: var(--fs-h3); font-weight: 600; 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; }
/* Steps as a list, not a column-aligned <pre>: wraps on a phone. */
.help-section ol.how-steps { margin: var(--sp-2) 0 var(--sp-3); padding-left: 1.4em; }
.help-section ol.how-steps li + li { margin-top: 6px; }
.help-section ol.how-steps li { padding-left: 2px; font-size: var(--fs-body); color: var(--text-2); line-height: 1.6; }
.help-section ol.how-steps b { color: var(--text); font-weight: 600; }
.help-section ol.how-steps code { overflow-wrap: anywhere; }
.help-section pre { background: var(--surface); box-shadow: var(--shadow-sheet); border-radius: var(--r-md); padding: var(--sp-4); overflow-x: auto; font-family: var(--mono); font-size: 12px; line-height: 1.7; margin: var(--sp-2) 0 var(--sp-3); }
.help-section details { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-sheet); margin-bottom: var(--sp-2); }
.help-section details summary { padding: 11px var(--sp-4); font-size: var(--fs-ui); 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; }
.file-table { width: 100%; font-size: var(--fs-ui); border-collapse: collapse; }
.file-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); }
.file-table td:first-child { font-family: var(--mono); font-size: 12px; white-space: nowrap; width: 200px; 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; background: var(--surface-2); color: var(--text-2); }
.empty .title { font-size: var(--fs-body); font-weight: 600; margin-bottom: 4px; }
.empty .empty-copy { font-size: var(--fs-ui); color: var(--text-2); line-height: 1.6; max-width: 52ch; margin: 0 auto; text-wrap: pretty; opacity: 1; }
.empty .empty-copy b { color: var(--text); font-weight: 500; }
.empty .empty-action { margin-top: var(--sp-4); }
.empty.boxed { grid-column: 1 / -1; }
#overview-stats > .empty { margin-bottom: var(--sp-2); }
.section > .empty, .content-inner > .empty, .empty.boxed, #companies-list > .empty, #prospects-table > .empty,
#campaigns-list > .empty, #conversations-list > .empty, #activity-list > .empty, #usage-tables > .empty {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet);
}

.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 { background: var(--bg); }
#lock-screen .card { box-shadow: var(--shadow-pop); padding: var(--sp-5); }
#lock-screen h2 { font-size: var(--fs-h2); margin-bottom: var(--sp-2); }
#lock-screen .lede { font-size: var(--fs-ui); color: var(--text-2); margin-bottom: var(--sp-3); }

/* 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; }
table.clip td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

/* ── Small screens ───────────────────────────────────────────── */

@media (max-width: 900px) {
  :root { --topbar-h: 52px; }
  .topbar { padding: 0 var(--sp-4); }
  .tagline { display: none; }
  .harvey-status span:last-child { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: var(--topbar-h); z-index: 20; height: auto; flex-direction: row;
    padding: 6px var(--sp-4); gap: 0; border-right: none; border-bottom: 1px solid var(--line);
    background: var(--bg); overflow: visible;
  }
  nav { flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; margin: 0 calc(-1 * var(--sp-4)); padding: 0 var(--sp-4); }
  nav::-webkit-scrollbar { display: none; }
  .nav-group { flex-direction: row; gap: 2px; }
  .nav-group + .nav-group { padding-left: 6px; margin-left: 4px; border-left: 1px solid var(--line); }
  .nav-label { display: none; }
  nav button { width: auto; height: 32px; flex: none; }
  .nav-count.soft { display: none; }
  .sidebar-foot { display: none; }
  main.content { padding: var(--sp-4) var(--sp-4) 80px; }
  .tl-item { grid-template-columns: 48px 24px minmax(0, 1fr); }
  .tl-agent { display: none; }
  .queue-item { flex-wrap: wrap; }
  .queue-item .qtext { flex-basis: calc(100% - 48px); }
  .queue-item .btn { margin-left: 46px; }
  .step-detail { grid-column: 2 / 4; text-align: left; }
}

@media (max-width: 700px) {
  .hero-search { grid-template-columns: minmax(0, 1fr); }
  .hero-search .btn { width: 100%; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat, .stat:nth-child(n+4) { grid-column: auto; }
  .stat:first-child { grid-column: 1 / -1; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  #company-actions, #contact-actions { margin-left: 0; }
  .menu-list { right: auto; left: 0; }
  .pager-size { margin-left: 0; }
  .pager-btns { margin-left: auto; }
  .drawer { width: 100vw; }
  .facts-list { grid-template-columns: 84px minmax(0, 1fr); }

  /* Data tables become stacked cards: name, then phone and email, big. */
  .table-card:has(table.data) { background: none; box-shadow: none; overflow: visible; }
  table.data, table.data tbody { display: block; }
  table.data thead { display: none; }
  table.data tr {
    display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 4px 10px;
    padding: 12px 14px; margin-bottom: 8px; border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-sheet);
  }
  table.data tr.selected { box-shadow: 0 0 0 1.5px var(--accent-line); }
  table.data td { display: block; padding: 0; border: none; grid-column: 2; min-width: 0; max-width: none; background: none !important; }
  table.data td.sel { grid-column: 1; grid-row: 1 / span 2; padding-top: 2px; width: auto; }
  table.data td[data-label]::before {
    content: attr(data-label); display: block; margin-top: 6px;
    font-size: var(--fs-micro); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em;
  }
  table.data td.sel::before { display: none; }
  table.data .co-acts, table.data .co-src { display: none; }
  table.data .co-count { text-align: left; }
  table.data td[data-label]::before { margin-top: 4px; }
  .stat-note { white-space: normal; }
  table.data a.tel { font-size: var(--fs-lead); white-space: normal; overflow-wrap: anywhere; overflow: visible; }
  .sel-page-mobile {
    display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 0 14px;
    font-size: var(--fs-caption); color: var(--text-2); cursor: pointer;
  }
  .sel-page-mobile input { width: 15px; height: 15px; accent-color: var(--accent); }
  table.data .copy { opacity: 1; }
  table.data tr.detail-row { display: block; }
  table.data .ct-name .avatar { display: none; }
  .co-name, .co-phone, .co-email, .co-acts { min-width: 0; }
  /* Stretch, as for the module list: at flex-start a row's text sizes to
     its content (a long description, Settings' background-search share)
     and a narrow phone scrolls sideways; the switch keeps its own width. */
  .module-row { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .module-row > .switch { align-self: flex-start; }

  /* The run log becomes one small card per run: what ran on its own line,
     then state, when, records and cost, so no column hides off-screen. */
  table.runs-table, table.runs-table tbody { display: block; }
  table.runs-table thead { display: none; }
  table.runs-table tr {
    display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 6px 12px;
    grid-template-areas: "what what what when" "state records cost cost";
    padding: 10px 16px; border-bottom: 1px solid var(--line);
  }
  table.runs-table tbody tr:last-child { border-bottom: none; }
  table.runs-table td { display: block; padding: 0; border: none; white-space: normal; text-align: left; min-width: 0; }
  table.runs-table td:nth-child(1) { grid-area: what; }
  table.runs-table td:nth-child(2) { grid-area: state; }
  table.runs-table td:nth-child(3) { grid-area: records; }
  table.runs-table td:nth-child(4) { grid-area: cost; }
  table.runs-table td:nth-child(5) { grid-area: when; white-space: nowrap; }
  table.runs-table td[data-label]::before {
    content: attr(data-label) ' '; font-size: var(--fs-micro); font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.06em; margin-right: 4px;
  }
}

@media (max-width: 420px) {
  .brand-name { font-size: 14px; }
  .icon-btn span { display: none; }
}

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

/* Queue (Coadă): a card per lane, a row per job */
.lane-card { margin-bottom: 14px; }
.lane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lane-head h3 { margin: 0; }
.job-group { margin-top: 12px; }
.job-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 4px; }
.job-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap;
           padding: 8px 0; border-top: 1px solid var(--line); }
.job-main { min-width: 0; flex: 1 1 260px; }
.job-title { overflow-wrap: anywhere; }
.job-kind { font-weight: 600; }
.job-detail { color: var(--text-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.job-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* The database upgrade screen */
#upgrade-screen { background: var(--bg); }
.upgrade-card { max-width: 720px; width: 100%; }
.upgrade-card table { margin: var(--sp-3) 0; }
.upgrade-stages { list-style: none; padding: 0; margin: var(--sp-3) 0; }
.upgrade-stage { display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.upgrade-stage.running { font-weight: 600; }
.upgrade-stage.failed, .upgrade-stage.stopped { color: var(--bad); }
.upgrade-stage.todo { color: var(--text-2); }
#old-files-note { align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Campaigns: what a campaign would take, counted (the wizard and Audiences). */
.preview-counts { margin: var(--sp-2) 0; padding-left: 18px; columns: 2 220px; color: var(--text-2); }
.preview-counts li { margin: 2px 0; break-inside: avoid; }
#campaign-wizard .card, #campaign-detail .card { margin-bottom: var(--sp-4); }
#campaign-wizard .card .card { margin: var(--sp-3) 0; }
#campaigns-table + #campaigns-list .subhead:first-child { margin-top: var(--sp-5); }

/* ── A dialog (the cold-email acknowledgement) ─────────────────── */

.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
.modal::backdrop { background: rgb(15 17 17 / 0.28); }
.modal[open] { display: flex; flex-direction: column; }
#ack-body { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 50px); }
.modal-head { display: flex; align-items: baseline; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5) var(--sp-3); border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: var(--fs-h3); font-weight: 600; line-height: 1.3; }
.modal-head .meta { font-size: var(--fs-caption); color: var(--text-3); white-space: nowrap; }
.modal-scroll { overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-3) var(--sp-5); }
.modal-scroll p { margin: 0 0 var(--sp-3); font-size: var(--fs-ui); line-height: 1.6; max-width: 72ch; }
.modal-foot { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) var(--sp-4); border-top: 1px solid var(--line); }
.ack-card p { max-width: 72ch; }


/* ── Chat with Harvey's agent ── */
.chat-card { display: flex; flex-direction: column; gap: var(--sp-3); }
.chat-list { display: flex; flex-direction: column; gap: var(--sp-3); max-height: 60vh; overflow-y: auto; }
.chat-msg { max-width: 85%; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-lg); background: var(--surface-2); }
.chat-msg.user { align-self: flex-end; background: var(--surface-3); }
.chat-msg.agent { align-self: flex-start; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface); }
.chat-msg.error { box-shadow: inset 0 0 0 1px var(--bad-line); }
.chat-msg.pending { opacity: 0.85; }
.chat-meta { font-size: var(--fs-caption); color: var(--text-3); margin-bottom: 2px; }
.chat-text { font-size: var(--fs-ui); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-calls { margin-top: var(--sp-2); font-size: var(--fs-caption); }
.chat-calls summary { cursor: pointer; color: var(--text-2); }
.chat-calls ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-4); }
.chat-calls li { margin: 2px 0; overflow-wrap: anywhere; }
.chat-args code { font-size: var(--fs-caption); white-space: pre-wrap; }
.chat-form { display: flex; gap: var(--sp-2); align-items: flex-end; }
.chat-form textarea { flex: 1; min-width: 0; resize: vertical; }
.chat-provider { display: inline-flex; gap: var(--sp-1); align-items: center; }
.chat-provider-pick { width: auto; min-width: 0; max-width: 100%; padding-block: 2px; }
#chat-tokens { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
/* The chats beside the open one; on a narrow screen folded behind Chats. */
.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--sp-3); align-items: start; }
.chat-side { display: flex; flex-direction: column; gap: var(--sp-2); max-height: 75vh; }
.chat-chats { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.chat-item { display: flex; align-items: center; gap: 2px; border-radius: var(--r-sm); }
.chat-item.on { background: var(--select); }
.chat-item .icon-btn { padding: 0 6px; background: none; box-shadow: none; opacity: 0; }
.chat-item.on .icon-btn, .chat-item:focus-within .icon-btn { opacity: 1; }
@media (hover: hover) { .chat-item:hover { background: var(--surface-2); } .chat-item.on:hover { background: var(--select); } .chat-item:hover .icon-btn { opacity: 1; } }
@media (hover: none) { .chat-item .icon-btn { opacity: 1; } }
.chat-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left; padding: 6px 8px; border: none; background: none; cursor: pointer; color: var(--text); font: inherit; }
.chat-item-title { font-size: var(--fs-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-when { font-size: var(--fs-caption); color: var(--text-3); }
.chat-head { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: baseline; justify-content: space-between; }
.chat-head h3 { font-size: var(--fs-body); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.chat-retry { margin-top: var(--sp-2); }
.chat-older { align-self: center; }
.chat-toggle { display: none; }
.chat-side-head { font-size: var(--fs-caption); font-weight: 600; color: var(--text-2); margin: var(--sp-2) 0 0; }
.chat-plans { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.chat-plan-item { border-radius: var(--r-sm); }
@media (hover: hover) { .chat-plan-item:hover { background: var(--surface-2); } }
.plan-card { align-self: stretch; max-width: 100%; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: var(--sp-1); overflow-wrap: anywhere; }
.plan-head { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.plan-goal { font-size: var(--fs-ui); }
.plan-steps { margin: 0; padding-left: var(--sp-4); font-size: var(--fs-ui); }
.plan-runs ul { margin: 2px 0 0; padding-left: var(--sp-4); font-size: var(--fs-caption); }
.plan-runs li { margin: 2px 0; }
.plan-card .btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-1); }
.plan-wakes ul { margin: 2px 0 0; padding-left: var(--sp-4); font-size: var(--fs-caption); }
.plan-wakes li { margin: 2px 0; }
.plan-campaigns ul { margin: 2px 0 0; padding-left: var(--sp-4); font-size: var(--fs-caption); }
.plan-campaigns li { margin: 2px 0; }
.plan-tasks ul { margin: 2px 0 0; padding-left: var(--sp-4); font-size: var(--fs-caption); }
.plan-tasks li { margin: 2px 0; overflow-wrap: anywhere; }
.start-card { margin: var(--sp-1) 0; padding: var(--sp-2); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.start-card ul, .start-card ol { margin: 2px 0 0; padding-left: var(--sp-4); }
.start-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg.wake { box-shadow: inset 3px 0 0 var(--line), inset 0 0 0 1px var(--line); }
.chat-memory { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.chat-memory[hidden] { display: none; }
.memory-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.memory-list textarea, .memory-add textarea { width: 100%; resize: vertical; }
.memory-list summary { cursor: pointer; overflow-wrap: anywhere; }
.memory-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-1); }
.memory-add { display: flex; gap: var(--sp-2); align-items: flex-end; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-toggle { display: inline-flex; }
  .chat-side { display: none; }
  .chat-side.open { display: flex; }
}

/* Settings → Model: one block per provider, under the default's row. */
.model-provider { border-top: 1px solid var(--line); margin-top: var(--sp-3); padding-top: var(--sp-3); }
.model-provider-head { font-size: var(--fs-body); font-weight: 600; display: flex; gap: var(--sp-2); align-items: center; }
