/**
 * JustAWeb webgen console styles.
 *
 * WHY this look: the console is Blake's daily working screen, so it borrows the
 * justaweb.agency brand (warm paper, ink, one orange accent, system fonts, 8/14/22px
 * radii, pill buttons; tokens copied from justawebagency/src/styles/global.css) but
 * tuned for density: small type scale, tabular numbers, clear status badges, and a
 * sticky filter bar. No web fonts, no decorative backgrounds.
 *
 * HOW:
 *  - Every color is a token on :root, swapped wholesale under [data-theme="dark"]. The
 *    attribute is set before paint by the inline script in index.html (saved choice,
 *    else prefers-color-scheme) and flipped by the header toggle.
 *  - Contrast: every text/background pair used here was picked to clear WCAG 2.1 AA
 *    (4.5:1 for text). Badge tones use a tinted background with a dark (light theme) or
 *    light (dark theme) foreground of the same hue.
 *  - Boards (Leads funnel, Pipeline, Clients) are lists of CSS grid rows, never <table>, so the
 *    same markup is a dense table on wide screens and stacked cards on phones with no
 *    horizontal scroll.
 */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --ink: #15171c;
  --ink-2: #454a55;
  --muted: #62666f;
  --line: #e4e0d6;
  --line-strong: #cfc9bb;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-ink: #ffffff;
  --accent-soft: #fdebdf;
  --accent-text: #9a3412;
  --focus: #c2410c;

  /* badge tones: background / foreground pairs, all >= 4.5:1 */
  --t-ok-bg: #e3f4e8;   --t-ok-fg: #166534;
  --t-warn-bg: #fcefd6; --t-warn-fg: #854d0e;
  --t-err-bg: #fbe5e5;  --t-err-fg: #a11d1d;
  --t-info-bg: #e5eefb; --t-info-fg: #1e4fbf;
  --t-acc-bg: #fdebdf;  --t-acc-fg: #9a3412;
  --t-neu-bg: #efece6;  --t-neu-fg: #454a55;

  --bar-track: #ebe7de;
  --bar-ok: #15803d;
  --bar-warn: #b45309;
  --bar-err: #b91c1c;

  --shadow-sm: 0 1px 2px rgb(21 23 28 / 0.06), 0 2px 8px rgb(21 23 28 / 0.05);
  --shadow-lg: 0 2px 4px rgb(21 23 28 / 0.06), 0 24px 60px -12px rgb(21 23 28 / 0.25);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --head-h: 57px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #181b21;
  --surface-2: #20242c;
  --ink: #f2f0eb;
  --ink-2: #c7cad1;
  --muted: #a3a8b2;
  --line: #2d323b;
  --line-strong: #3d434e;
  --accent: #ff8a5c;
  --accent-hover: #ffa47f;
  --accent-ink: #1b0f0a;
  --accent-soft: #3a2219;
  --accent-text: #ffa47f;
  --focus: #ff8a5c;

  --t-ok-bg: #15301f;   --t-ok-fg: #86efac;
  --t-warn-bg: #362a12; --t-warn-fg: #fcd34d;
  --t-err-bg: #3b1a1c;  --t-err-fg: #fca5a5;
  --t-info-bg: #172338; --t-info-fg: #93c5fd;
  --t-acc-bg: #3a2219;  --t-acc-fg: #ffb08f;
  --t-neu-bg: #262a33;  --t-neu-fg: #d0d3d9;

  --bar-track: #2a2f38;
  --bar-ok: #4ade80;
  --bar-warn: #fbbf24;
  --bar-err: #f87171;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 24px 60px -12px rgb(0 0 0 / 0.7);
  color-scheme: dark;
}

/* ---- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.9375rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
[hidden] { display: none !important; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:root[data-theme="dark"] a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.375rem; font-weight: 750; }
h2, .h3 { font-size: 1rem; font-weight: 700; }
code { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.meta { color: var(--muted); font-size: 0.8125rem; margin: 0; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
.skip {
  position: absolute; left: 12px; top: -40px; z-index: 50; background: var(--accent);
  color: var(--accent-ink); padding: 8px 14px; border-radius: 999px; font-weight: 600;
}
.skip:focus { top: 8px; }

/* ---- Buttons, inputs ------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 0.8125rem/1.2 var(--font); cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--ink-2); background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.danger { color: var(--t-err-fg); }
.btn.danger:hover { border-color: var(--t-err-fg); background: var(--t-err-bg); }
.btn.sm { min-height: 30px; padding: 5px 12px; font-size: 0.75rem; }
.btn.link { border-color: transparent; background: transparent; color: var(--accent-text); text-decoration: underline; padding-inline: 6px; }
.btn.link:hover { background: transparent; color: var(--accent-hover); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.xs { width: 28px; height: 28px; }
.icon-btn.xs svg { width: 14px; height: 14px; }
.spin {
  display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } }

label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--ink-2); margin: 0 0 5px; }
input, select, textarea {
  width: 100%; min-height: 36px; padding: 7px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 400 0.875rem/1.4 var(--font);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
textarea { resize: vertical; min-height: 72px; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
@media (max-width: 600px) { input, select, textarea { font-size: 1rem; } }
.field { margin: 0 0 12px; min-width: 0; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: 2fr 1fr 1fr; }
.form-grid.four { grid-template-columns: 1.3fr 1.2fr 1.2fr .6fr; }
@media (max-width: 700px) { .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: minmax(0, 1fr); } }
.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 4px 0 12px; }
.opts .check { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 0.8125rem; font-weight: 500; color: var(--ink); }
.opts .inline { margin: 0; }
.opts input.short { width: 180px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- Login gate ------------------------------------------------------------ */

.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.gate.is-checking .gate-card { visibility: hidden; }
.gate-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px 24px; box-shadow: var(--shadow-lg);
}
.gate-card .brand { margin-bottom: 22px; }
.gate-card input { margin-bottom: 12px; }
.gate-err { min-height: 1.3em; margin: 10px 0 0; font-size: 0.8125rem; color: var(--t-err-fg); }

/* ---- App header ------------------------------------------------------------ */

.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: var(--accent-ink); stroke-width: 3.4; stroke-linecap: round; }
.brand-word { font-weight: 800; font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-weight: 500; color: var(--muted); }
.brand-lg .brand-mark { width: 32px; height: 32px; }
.brand-lg .brand-word { font-size: 1.125rem; }

.app-head {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px); -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.head-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 24px; min-height: var(--head-h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 24px;
}
.tabs { display: flex; gap: 2px; align-self: stretch; }
.tab {
  appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  font: 600 0.875rem/1 var(--font); padding: 0 14px; border-bottom: 2px solid transparent;
  border-top: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -4px; }
.head-tools { display: flex; align-items: center; gap: 10px; }
.svc { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.75rem; color: var(--muted); }
.svc li { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bar-err); flex: none; }
.dot.on { background: var(--bar-ok); }
:root[data-theme="dark"] .i-moon { display: none; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }

@media (max-width: 900px) {
  .head-inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand tools" "tabs tabs"; padding: 0 16px; gap: 0 12px; }
  .brand { grid-area: brand; min-height: 52px; }
  .head-tools { grid-area: tools; }
  .tabs { grid-area: tabs; margin: 0 -16px; padding: 0 8px; border-top: 1px solid var(--line); }
  .tab { flex: 1 1 0; padding: 13px 4px; }
  :root { --head-h: 98px; }
}
@media (max-width: 600px) {
  .head-tools .svc li span.lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .head-tools .svc { gap: 6px; }
  .brand-sub { display: none; }
}

/* ---- Layout ---------------------------------------------------------------- */

.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 24px 80px; }
@media (max-width: 600px) { .wrap { padding: 16px 16px 64px; } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin: 0 0 16px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 0.875rem; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 16px; box-shadow: var(--shadow-sm);
}
.panel > .h3, .panel h2.h3 { margin: 0 0 12px; }
.note {
  background: var(--t-warn-bg); color: var(--t-warn-fg); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 0.8125rem; margin: 0 0 14px;
}
.empty { text-align: center; color: var(--muted); padding: 40px 16px; margin: 0; }

/* ---- Badges, chips, segmented control ------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--t-neu-bg); color: var(--t-neu-fg);
}
.badge.ok { background: var(--t-ok-bg); color: var(--t-ok-fg); }
.badge.warn { background: var(--t-warn-bg); color: var(--t-warn-fg); }
.badge.err { background: var(--t-err-bg); color: var(--t-err-fg); }
.badge.info { background: var(--t-info-bg); color: var(--t-info-fg); }
.badge.acc { background: var(--t-acc-bg); color: var(--t-acc-fg); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 5px 12px; font: 600 0.75rem/1.3 var(--font); cursor: pointer; white-space: nowrap;
}
.chip b { font-weight: 700; margin-left: 5px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface); flex: none; }
.seg button {
  appearance: none; border: 0; background: none; color: var(--ink-2); cursor: pointer;
  font: 600 0.75rem/1 var(--font); padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.seg button b { font-weight: 700; margin-left: 4px; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---- Filter bar ------------------------------------------------------------ */

.filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; margin: 0 0 10px;
  background: var(--bg);
}
.filterbar .field { margin: 0; flex: 0 1 auto; }
.filterbar .field.grow { flex: 1 1 220px; }
.filterbar select { width: auto; max-width: 100%; }
.filterbar .count { margin: 0 0 0 auto; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 768px) {
  .filterbar.sticky { position: sticky; top: var(--head-h); z-index: 20; border-bottom: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .filterbar .field { flex: 1 1 calc(50% - 4px); }
  .filterbar .field.grow { flex-basis: 100%; }
  .filterbar select { width: 100%; }
  .filterbar .seg { width: 100%; }
  .filterbar .seg button { flex: 1 1 0; padding-inline: 4px; }
  .filterbar .count { margin: 0; }
}

/* ---- Row lists (shared) ---------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.row.open { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.row-main { display: grid; gap: 8px 14px; align-items: center; padding: 12px 14px; min-width: 0; }
.row-main > * { min-width: 0; }
.row-name { font-weight: 700; overflow-wrap: anywhere; }
.row-name a { color: var(--ink); text-decoration: none; }
.row-name a:hover { color: var(--accent-text); text-decoration: underline; }
.row-detail { border-top: 1px solid var(--line); padding: 14px; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid-head {
  display: none; gap: 14px; padding: 0 15px 6px; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.contact { display: flex; flex-direction: column; gap: 1px; font-size: 0.8125rem; overflow-wrap: anywhere; }
.contact a { text-decoration: none; }
.contact a:hover { text-decoration: underline; }
.pw {
  font-family: var(--mono); font-size: 0.8125rem; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
.pw-line { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; }
.prev { font-size: 0.8125rem; }
.prev a { font-weight: 600; }
.stars { color: var(--t-warn-fg); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: 0.8125rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 18px; }
.detail-grid h3 { font-size: 0.75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; font-weight: 700; }
.detail-grid section + section { margin-top: 16px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }

/* Leads rows.
   >= 1180px: one table-like line per lead (7 columns, header row visible).
   700 to 1179px: two lines: business | facts | toggle, then contact | preview.
   < 700px: a stacked card. `.facts` is display:contents on wide screens so angle,
   rating and status become their own grid columns, and a flex row on narrow ones. */
.l-row .row-main {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  grid-template-areas: "biz facts tog" "contact prev prev";
}
.l-biz { grid-area: biz; }
.l-facts { grid-area: facts; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.l-contact { grid-area: contact; }
.l-prev { grid-area: prev; }
.l-tog { grid-area: tog; justify-self: end; }
.rating { font-size: 0.8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 1180px) {
  .leads-head, .l-row .row-main {
    grid-template-columns: minmax(0, 2fr) 92px 96px 124px minmax(0, 1.5fr) minmax(0, 1.5fr) 84px;
    grid-template-areas: none;
  }
  .leads-head { display: grid; }
  .l-row .row-main > * { grid-area: auto; }
  .l-facts { display: contents; }
  .l-tog { justify-self: end; }
}
@media (max-width: 699px) {
  .l-row .row-main {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "biz tog" "facts facts" "contact contact" "prev prev";
  }
}
.review { margin: 0 0 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.review blockquote { margin: 0; font-size: 0.8125rem; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.review figcaption { margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
.drafts pre {
  margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 0.8125rem/1.55 var(--font);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
  max-height: 360px; overflow: auto;
}
.lead-actions { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }

/* Pipeline rows: same approach, 7 columns on wide screens. */
.p-group + .p-group { margin-top: 18px; }
.p-group-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; }
.p-group-head h2 { font-size: 0.875rem; }
.p-row .row-main {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "biz stage" "facts facts" "links links" "acts acts";
}
.p-biz { grid-area: biz; }
.p-facts { grid-area: facts; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 0.8125rem; }
.p-stage { grid-area: stage; }
.p-links { grid-area: links; font-size: 0.8125rem; overflow-wrap: anywhere; }
.p-acts { grid-area: acts; }
.p-row select { width: auto; min-width: 124px; }
@media (min-width: 1100px) {
  .p-row .row-main {
    grid-template-columns: minmax(0, 2fr) auto minmax(0, 1.4fr) 136px auto;
    grid-template-areas: "biz facts links stage acts";
  }
  .p-acts { justify-self: end; }
}
.edit-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
@media (max-width: 700px) { .edit-links { grid-template-columns: minmax(0, 1fr); } }

/* Clients rows. */
.c-row .row-main {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) auto 72px minmax(0, 1.5fr) auto;
}
.c-when { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.c-next { font-size: 0.8125rem; overflow-wrap: anywhere; }
.c-next .due { display: block; font-size: 0.75rem; color: var(--muted); }
.c-next.overdue .due { color: var(--t-err-fg); font-weight: 700; }
.c-row select { width: auto; min-width: 150px; }
.c-msg {
  font-size: 0.8125rem; line-height: 1.55; white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; margin: 0; overflow-wrap: anywhere;
}
.c-edit { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(150px, 1fr) minmax(0, .8fr); gap: 10px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 2px; border-left: 2px solid var(--line-strong); }
.timeline li { position: relative; padding: 0 0 10px 14px; font-size: 0.8125rem; overflow-wrap: anywhere; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); border: 2px solid var(--surface-2);
}
.timeline li.t-intake::before { background: var(--accent); }
.timeline li.t-contract::before { background: var(--bar-ok); }
.timeline li.t-stage::before { background: var(--bar-warn); }
.timeline .t-at { display: block; color: var(--muted); font-size: 0.75rem; }
@media (max-width: 1100px) {
  .c-row .row-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.3fr) auto auto; }
  .c-when { display: none; }
  .c-next { grid-column: 1 / -2; }
}
@media (max-width: 768px) {
  .c-row .row-main { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main stage" "email tog" "next next"; }
  .c-main { grid-area: main; } .c-stage { grid-area: stage; } .c-email { grid-area: email; }
  .c-tog { grid-area: tog; justify-self: end; } .c-next { grid-area: next; grid-column: auto; }
}
@media (max-width: 480px) {
  .c-row .row-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "email" "stage" "next" "tog"; }
  .c-row select { width: 100%; }
  .c-tog, .c-tog .btn { justify-self: stretch; width: 100%; }
  .c-edit { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Leads: find panel and free-tier usage -------------------------------- */

.find-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); gap: 22px; }
@media (max-width: 900px) { .find-grid { grid-template-columns: minmax(0, 1fr); } }
.find .meta { margin: 0 0 12px; }
.svc-caps { margin-top: 14px; }
.usage { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; }
.usage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.u-row { margin: 0 0 12px; }
.u-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8125rem; }
.u-top b { font-weight: 600; }
.u-bar { height: 8px; border-radius: 999px; background: var(--bar-track); overflow: hidden; margin: 5px 0 3px; }
.u-fill { height: 100%; border-radius: 999px; background: var(--bar-ok); }
.u-row.warn .u-fill { background: var(--bar-warn); }
.u-row.err .u-fill { background: var(--bar-err); }
.u-row .meta { font-size: 0.75rem; }
.u-row.warn .u-state { color: var(--t-warn-fg); font-weight: 600; }
.u-row.err .u-state { color: var(--t-err-fg); font-weight: 600; }

/* ---- Logs, results, toast -------------------------------------------------- */

.log {
  margin-top: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font: 400 0.75rem/1.65 var(--mono); max-height: 260px; overflow: auto; overflow-wrap: anywhere;
}
.log .l { white-space: pre-wrap; }
.log .l.warn { color: var(--t-warn-fg); }
.log .l.err { color: var(--t-err-fg); }
.log .l.ok, .log .l.hit { color: var(--t-ok-fg); }
.live-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.live-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.8125rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 14px; }
.card h2 { font-size: 1.0625rem; margin: 0 0 6px; }
.card h3 { font-size: 0.75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }
.card p, .card li { font-size: 0.875rem; line-height: 1.6; }
.card ul { margin: 4px 0; padding-left: 18px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.copybar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 8px; }
pre.code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px;
  font: 400 0.75rem/1.6 var(--mono); max-height: 340px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
}
.email { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 10px; }
.email .subj { color: var(--muted); font-size: 0.8125rem; margin-bottom: 6px; }
.email .body { font-size: 0.875rem; line-height: 1.6; white-space: pre-wrap; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 0.8125rem; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

@media (max-width: 600px) {
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .tool-seg { width: 100%; }
  .tool-seg button { flex: 1 1 0; }
}

/* ---- Funnel step bar --------------------------------------------------------
   The primary navigation of the Leads section. Five linked steps with live counts;
   the current one carries aria-current="step". Five equal columns at every width
   (sub-labels hide on phones) so it never scrolls sideways. */

.funnel { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.funnel li { min-width: 0; position: relative; }
.funnel a {
  display: flex; flex-direction: column; gap: 2px; height: 100%; min-width: 0; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none;
}
.funnel a:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }
.funnel a[aria-current="step"] { border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.funnel li + li::before {
  content: ""; position: absolute; left: -6px; top: 50%; width: 6px; height: 1px; background: var(--line-strong);
}
.f-label { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-n {
  display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2); font-size: 0.6875rem; font-weight: 700;
}
.funnel a[aria-current="step"] .f-n { background: var(--accent); color: var(--accent-ink); }
.f-count { font-size: 1.375rem; font-weight: 750; line-height: 1.15; }
.f-sub { font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-sub.hot { color: var(--t-err-fg); font-weight: 600; }
@media (max-width: 700px) {
  .funnel { gap: 4px; }
  .funnel a { padding: 8px 4px; align-items: center; text-align: center; }
  .f-label { font-size: 0.6875rem; flex-direction: column; gap: 2px; white-space: normal; text-align: center; line-height: 1.15; }
  .f-sub { display: none; }
  .f-count { font-size: 1.125rem; }
  .funnel li + li::before { display: none; }
}

.page-head .actions > span:not(.seg) { display: contents; }
.page-head .actions > span[hidden] { display: none !important; }
.list-title { margin: 22px 0 8px; }
.list-title .meta { font-weight: 400; }
.step > .list-title:first-child { margin-top: 0; }

/* ---- Follow up ("Today") groups ------------------------------------------- */

.due-group { margin: 0 0 16px; }
.due-group-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.due-group-head h2 { font-size: 0.9375rem; display: flex; align-items: center; gap: 8px; }
.due-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.due-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.due-item.hot { border-left-color: var(--accent); }
.due-item.late { border-left-color: var(--bar-err); }
.due-name { font-weight: 700; overflow-wrap: anywhere; }
.due-name a { color: var(--ink); }
.due-item .meta { overflow-wrap: anywhere; }
.due-item .actions { justify-content: flex-end; }
@media (max-width: 600px) { .due-item { grid-template-columns: minmax(0, 1fr); } .due-item .actions { justify-content: flex-start; } }
.all-clear { background: var(--t-ok-bg); color: var(--t-ok-fg); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 16px; font-weight: 600; }

/* ---- Inline forms inside a lead ------------------------------------------- */

.inline-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 12px; }
.inline-form h4 { margin: 0 0 10px; font-size: 0.875rem; }
.inline-form .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inline-form .field.wide { grid-column: 1 / -1; }
.inline-form .check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); }
@media (max-width: 700px) { .inline-form .form-grid { grid-template-columns: minmax(0, 1fr); } }
.state-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; font-size: 0.8125rem; }
.draft-tabs { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Tools ------------------------------------------------------------------ */

.tool-seg a {
  color: var(--ink-2); text-decoration: none; font: 600 0.75rem/1 var(--font); padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.tool-seg a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.tool-seg a:hover { color: var(--ink); }
.tool-seg a[aria-current="page"]:hover { color: var(--bg); }
@media (max-width: 600px) { .tool-seg a { flex: 1 1 0; text-align: center; padding-inline: 4px; } }
.tool-actions { margin: 0 0 12px; }
.u-msg:empty { display: none; }
.u-msg { margin-top: 8px; }

/* ---- Build engine: progress, review panel, batch results ------------------------------
   One Build click ends on .review-panel: the Review preview link is the largest control
   in the lead (Blake's next action), the password sits right under it with a copy
   button, then the notes box. Stage lists use the badge tones so both themes keep AA. */
.pick-name { display: flex; align-items: flex-start; gap: 10px; }
.pick { width: 18px; height: 18px; margin: 2px 0 0; flex: none; cursor: pointer; }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn.big { min-height: 46px; padding: 10px 22px; font-size: 0.9375rem; }
.btn.big svg { width: 16px; height: 16px; }
.note.err { background: var(--t-err-bg); color: var(--t-err-fg); }
.build-panel .stages { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.build-panel .stages li {
  display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--muted);
  padding-left: 22px; position: relative; min-height: 20px;
}
.build-panel .stages li::before {
  content: ""; position: absolute; left: 3px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface);
}
.build-panel .stages li.done { color: var(--t-ok-fg); }
.build-panel .stages li.done::before { background: var(--bar-ok); border-color: var(--bar-ok); }
.build-panel .stages li.now { color: var(--ink); font-weight: 700; }
.build-panel .stages li.now::before { display: none; }
.build-panel .stages li.now .spin { position: absolute; left: 0; margin: 0; }
.review-panel .review-link { margin: 2px 0 12px; }
.pw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.pw-row .pw { font-size: 0.9375rem; padding: 3px 8px; }
.revise-form { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.revise-form textarea { min-height: 96px; }
.revise-form .actions { margin-top: 8px; }
.rv-help { margin-top: 6px; }
.rv-help summary, .rv-list summary { cursor: pointer; font-size: 0.8125rem; color: var(--accent-text); width: fit-content; }
.rv-help p { margin-top: 6px; line-height: 1.7; }
.rv-help code { font-size: 0.75rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.rv-list { margin-top: 12px; }
.rv-list .timeline { margin-top: 8px; }
.build-results .br-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.br-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.br-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.br-list li:first-child { border-top: 0; }
.br-name { font-weight: 700; flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.br-err .meta { flex: 1 1 100%; }
/* Phones and small tablets: the lead's main action (build progress, review link, email,
   touch form) comes before the business facts, so the review link is on screen as soon
   as a build finishes, without scrolling past the address block. */
@media (max-width: 800px) { .detail-grid > div:last-child { order: -1; } }
