/* Lead Engine: a calm, dense internal tool. One accent (teal), one radius (6px), mono numbers. */

:root {
  --bg: #f4f5f4;
  --surface: #fcfdfc;
  --surface-2: #eceeec;
  --border: #dde1de;
  --border-strong: #c5cbc7;
  --text: #161a19;
  --muted: #5a625f;
  --accent: #0f6f66;
  --accent-hover: #0b5b54;
  --accent-soft: #dcefec;
  --accent-ink: #f7fbfa;
  --ok: #18753c;
  --ok-soft: #e1f1e6;
  --warn: #9a5a06;
  --warn-soft: #f8ecd6;
  --bad: #b42323;
  --bad-soft: #f8e1df;
  --p2: #8a5a00;
  --p2-soft: #fbf1c7;
  --p3: #b4430b;
  --p3-soft: #fde6d4;
  --r: 6px;
  --sidebar: 252px;
  --font: "Geist Variable", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono Variable", ui-monospace, "Cascadia Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1211;
    --surface: #161a19;
    --surface-2: #1f2422;
    --border: #2a302e;
    --border-strong: #3a4240;
    --text: #e6eae8;
    --muted: #9aa39f;
    --accent: #3fb3a5;
    --accent-hover: #5cc4b7;
    --accent-soft: #173330;
    --accent-ink: #08110f;
    --ok: #5cc27f;
    --ok-soft: #16301f;
    --warn: #e0a54c;
    --warn-soft: #33270f;
    --bad: #f07b72;
    --bad-soft: #3a1a18;
    --p2: #e8c547;
    --p2-soft: #322b0e;
    --p3: #f0955a;
    --p3-soft: #3a2314;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-feature-settings: "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
code, kbd, .mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
kbd { font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; padding: 0 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0;
           overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 12.5px; }
.block { display: block; }
/* A cap set above the provider's free allowance: past it, calls are paid. */
.paid-past { color: var(--warn); font-size: 13px; vertical-align: -1px; }
.ph { font-size: 16px; line-height: 1; vertical-align: -2px; }

/* --- shell -------------------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 18px 14px; border-right: 1px solid var(--border); background: var(--surface);
}
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 70; padding: 8px 12px; border-radius: var(--r);
             background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.skip-link:focus { top: 12px; text-decoration: none; }
.main:focus { outline: none; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* .sidebar in front so it outranks .btn, which is declared further down. */
.sidebar .nav-toggle { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-size: 12px; font-weight: 700;
}
/* Nav tree: groups of related pages. A collapsed group still shows the work waiting inside it. */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item, .nav-group > summary {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r);
  color: var(--muted); font-weight: 500;
}
.nav-item:hover, .nav-group > summary:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.nav-item[aria-current="page"] .ph { color: var(--accent); }
.nav .count {
  margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: var(--r); text-align: center;
  background: var(--surface-2); color: var(--text); font: 600 11.5px/20px var(--mono);
}
.nav .count.hot { background: var(--accent); color: var(--accent-ink); }

.nav-group { margin-top: 2px; }
.nav-group > summary { cursor: pointer; list-style: none; font-size: 12px; letter-spacing: 0.01em; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-caret { font-size: 12px; transition: transform 120ms ease; }
.nav-group[open] > summary .nav-caret { transform: rotate(90deg); }
/* The children sit under a hairline that lines up with the caret, so the tree reads as a tree. */
.nav-children {
  margin: 1px 0 2px 15px; padding-left: 9px; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1px;
}
.nav-children .nav-item { padding: 6px 8px; }
@media (prefers-reduced-motion: reduce) { .nav-caret { transition: none; } }

.limits { border-top: 1px solid var(--border); padding-top: 16px; }
.limits > summary { list-style: none; cursor: default; }
.limits > summary::-webkit-details-marker { display: none; }
.limits-title { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 10px; }
.limits-title h2 { font-size: 13px; }
.limit-group { padding: 0 8px; margin-bottom: 14px; }
.limit-group h3 { font-size: 11.5px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.limit { display: block; color: var(--text); margin-bottom: 9px; }
.limit:hover { text-decoration: none; }
.limit-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.limit-row .num { font-size: 12px; }
.meter { height: 4px; margin-top: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.limit.warn .meter > span { background: var(--warn); }
.limit.full .meter > span { background: var(--bad); }
.limit.full .num { color: var(--bad); font-weight: 600; }
.limit.done .meter > span { background: var(--ok); }
.limit.off { color: var(--muted); }
.limit.off .meter { display: none; }

.mobile-only { display: none; }
@media (max-width: 900px) { .mobile-only { display: inline; } }

.user-box { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
            padding: 10px 8px 0; border-top: 1px solid var(--border); }

.main { min-width: 0; padding: 24px 32px 64px; }
.main-inner { max-width: 1180px; margin: 0 auto; }

/* --- page structure ------------------------------------------------------------------ */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { min-width: 0; flex: 1 1 320px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.page-head h1 a { color: inherit; }
.back-link { margin: 0 0 4px; }
.page-head > .actions { flex: 0 1 auto; justify-content: flex-end; }
.flash { margin-bottom: 4px; }
.how-to-read { margin: -6px 0 14px; border-top: 0; padding-top: 0; }
.how-to-read p { max-width: 80ch; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.panel-body { padding: 16px; }
.panel + .panel { margin-top: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
/* The Zoom call page: the lead stays in view on the left while Zoom's own phone runs on the
   right. The phone column never drops below Zoom's documented minimum of 350 x 580. */
.call-ws { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 420px); gap: 16px; align-items: start; }
.call-ws-phone .panel-body { padding: 12px; }
/* `.btn` sets a display, which would otherwise beat the hidden attribute the cancel button uses. */
.call-ws [hidden] { display: none !important; }
.zoom-phone-frame { display: block; width: 100%; min-width: 350px; height: 600px; min-height: 580px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
[data-zoom-state][data-tone="ok"] { background: var(--ok-soft); }
[data-zoom-state][data-tone="bad"] { background: var(--bad-soft); }
[data-zoom-state][data-tone="warn"] { background: var(--warn-soft); }
@media (max-width: 1100px) {
  /* Stacked, not hidden: the lead first, then the phone, then the outcome. */
  .call-ws { grid-template-columns: minmax(0, 1fr); }
  .call-ws-phone { max-width: 480px; }
}
@media (max-width: 400px) {
  /* Below Zoom's minimum width the frame scrolls sideways inside its panel rather than
     squeezing Zoom's controls, and the page itself never scrolls sideways. */
  .call-ws-phone .panel-body { overflow-x: auto; }
}
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* stats: numbers on a shared baseline, divided by hairlines rather than boxed */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface);
         border: 1px solid var(--border); border-radius: var(--r); }
.stat { display: block; padding: 14px 16px; color: var(--text); border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
a.stat:hover { background: var(--surface-2); text-decoration: none; }
/* Not the mono face: at 26px a mono full stop takes a whole character cell and "0.0%" reads as
   "0 . 0%". Proportional figures too, not tabular: tabular gives every digit the width of a zero,
   which looks loose at display size. Tabular belongs in columns that have to line up, not here. */
.stat .num { display: block; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15;
             font-family: var(--font); }

/* --- KPI tiles ------------------------------------------------------------------------- */
/* A handful of headline numbers is a row of stat tiles, not a chart: label, value, and one
   supporting figure each. The tile that carries a ratio against a limit gets a meter; the one
   that carries a count over time gets a spark line. */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  color: var(--text);
}
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; }
.kpi .k-label, .kpi .kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi .k-value, .kpi .kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .k-note, .kpi .kpi-note { font-size: 12px; color: var(--muted); min-height: 15px; }
.kpi .k-note b { font-weight: 600; }
.kpi.is-ok { background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface)); }
.kpi.is-ok .k-value, .kpi.is-ok .k-note b { color: var(--ok); }
.kpi.is-warn { background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.kpi.is-warn .k-value, .kpi.is-warn .k-note b { color: var(--warn); }
.kpi.is-bad { background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.kpi.is-bad .k-value, .kpi.is-bad .k-note b { color: var(--bad); }
/* A change gets a colour only where up or down actually means better or worse. A count of API
   calls is neither, so its arrow carries the direction and the text stays in ink. */
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta .ph { font-size: 13px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text); }
.spark { display: block; width: 100%; height: 26px; overflow: visible; }
.spark rect { fill: var(--border-strong); }
.spark rect.now { fill: var(--accent); }
/* On a KPI meter the unfilled track is a lighter step of the fill's own colour rather than plain
   grey, so the state reads across the whole bar and not just the filled part. */
/* --- agent runs ------------------------------------------------------------------------ */
/* A log you read down: the clock first with the state as a dot, then the agent behind its own
   glyph, and the duration coloured only where it is worth remarking on. The row tint is a very
   light wash of the state so a failure is findable without reading the status column. */
.runs td { vertical-align: middle; }
.runs .run-time { white-space: nowrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.runs .run-time .block { font-family: var(--font); }
.runs .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%;
             margin-right: 7px; background: var(--border-strong); vertical-align: 1px; }
.runs .is-ok .dot { background: var(--ok); }
.runs .is-limited .dot { background: var(--warn); }
.runs .is-failed .dot { background: var(--bad); }
.runs .is-running .dot { background: var(--accent); }
.runs tr.is-limited td { background: color-mix(in srgb, var(--warn-soft) 42%, transparent); }
.runs tr.is-failed td { background: color-mix(in srgb, var(--bad-soft) 42%, transparent); }
.run-agent { display: inline-flex; align-items: center; gap: 9px; }
.run-agent > span { min-width: 0; }
.run-agent strong { white-space: nowrap; }
.run-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: none;
            border-radius: 7px; background: var(--surface-2); color: var(--muted); }
.runs tr:hover .run-icon { color: var(--text); }
/* A duration is one word: "2 min" breaking after the number reads as two numbers. */
.runs .took { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted);
              white-space: nowrap; }
.runs td.num { white-space: nowrap; }
.runs td.num .block { white-space: normal; }
.runs .took.quick { color: var(--ok); }
.runs .took.slow { color: var(--warn); }
.run-status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
              font-size: 12.5px; font-weight: 500; color: var(--muted); }
.run-status .ph { font-size: 14px; }
.run-status.ok { color: var(--ok); }
.run-status.limited { color: var(--warn); }
.run-status.failed { color: var(--bad); }
.run-status.running { color: var(--accent); }

.budget-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 20px; }
.budget-facts { display: flex; gap: 26px; }
.budget-facts span.num { display: block; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }

.kpi .meter { height: 6px; border-radius: 3px; margin-top: 1px;
              background: color-mix(in srgb, var(--accent) 15%, var(--surface-2)); }
.kpi .meter > span { background: var(--accent); border-radius: 3px; }
.kpi.is-ok .meter { background: color-mix(in srgb, var(--ok) 18%, var(--surface-2)); }
.kpi.is-ok .meter > span { background: var(--ok); }
.kpi.is-warn .meter { background: color-mix(in srgb, var(--warn) 20%, var(--surface-2)); }
.kpi.is-warn .meter > span { background: var(--warn); }
.kpi.is-bad .meter { background: color-mix(in srgb, var(--bad) 20%, var(--surface-2)); }
.kpi.is-bad .meter > span { background: var(--bad); }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: minmax(0, 1fr); } }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat.alert .num { color: var(--bad); }

/* pipeline strip */
.pipeline { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 0; border: 1px solid var(--border);
            border-radius: var(--r); background: var(--surface); overflow: hidden; }
.pipeline a { padding: 10px 12px; color: var(--text); border-left: 1px solid var(--border); }
.pipeline a:first-child { border-left: 0; }
.pipeline a:hover { background: var(--surface-2); text-decoration: none; }
.pipeline .num { display: block; font-size: 18px; font-weight: 600; }
.pipeline .label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
/* A stage holding nothing is context, not news. */
.pipeline a.is-empty .num { color: var(--muted); font-weight: 500; }
/* Where the leads are sitting, in proportion. One hue stepped by position, so the bar reads as
   one pipeline rather than nine competing categories. */
.funnel-bar { display: flex; gap: 2px; height: 6px; margin-top: 6px; }
.funnel-bar > span { display: block; border-radius: 3px; background: var(--accent); min-width: 3px; }
.funnel-bar > span:nth-child(even) { background: color-mix(in srgb, var(--accent) 62%, var(--surface-2)); }
.pipeline-exits { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* --- tables --------------------------------------------------------------------------- */

/* position: relative keeps anything absolutely placed inside (a screen-reader caption) within
   the scrolling box, so a wide table scrolls in its box instead of widening the page. */
.table-wrap { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 9px 12px;
     border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
td.num, th.num { text-align: right; }
th.num { font-family: var(--font); }
.row-link { color: var(--text); font-weight: 500; }

/* --- controls -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 500 13px/1 var(--font); cursor: pointer;
  transition: background-color .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, .msg:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.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); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn[disabled], .btn.htmx-request { opacity: .55; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error-text { font-size: 12px; color: var(--bad); }
input, select, textarea {
  width: 100%; padding: 7px 10px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 13.5px/1.45 var(--font);
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="file"] { padding: 5px; }
/* field-sizing lets the box grow to its text, so a message you are about to send is never read
   through a 84px window. min-height stays as the floor, max-height stops a very long reply
   pushing the Approve button off screen. Browsers without it keep the old fixed box. */
textarea { resize: vertical; min-height: 84px; max-height: 60vh; font-size: 14px; line-height: 1.55;
           field-sizing: content; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 160px; flex: 0 1 200px; }
.filters .field.grow { flex: 1 1 240px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
input[type="radio"] { width: auto; accent-color: var(--accent); margin: 0; }
.send-mode { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; margin: 0 0 12px;
             display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.send-mode legend { padding: 0 4px; }
.send-mode input[type="datetime-local"] { width: auto; flex: 0 1 220px; }
.send-mode .hint { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.svc-form { display: grid; gap: 14px; }
.svc-form .panel + .panel { margin-top: 0; }
.cat-grid { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; margin: 4px 0 0;
            display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; }
.cat-grid legend { padding: 0 4px; }
.angle-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .angle-row { grid-template-columns: minmax(0, 1fr); } }
.row-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(260px, 1fr); gap: 16px;
            padding: 14px 16px; border-top: 1px solid var(--border); align-items: start; }
.row-card:first-child { border-top: 0; }
.phone-link { font: 600 15px/1.2 var(--mono); }
.outcomes { display: flex; flex-wrap: wrap; gap: 6px; }
.logged { padding: 14px 16px; border-top: 1px solid var(--border); color: var(--ok); }
@media (max-width: 1000px) { .row-card { grid-template-columns: minmax(0, 1fr); } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .num { font-size: 12px; color: var(--muted); margin-left: 4px; }

details.disclosure { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
details.disclosure > summary { cursor: pointer; font-weight: 500; color: var(--accent); list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "+ "; font-family: var(--mono); }
details.disclosure[open] > summary::before { content: "- "; }
details.disclosure[open] > summary { margin-bottom: 12px; }

/* --- tags, grades, notices -------------------------------------------------------------- */

.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
       background: var(--surface-2); color: var(--text); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.tag.ok, .tag.approved, .tag.verified, .tag.sent, .tag.done { background: var(--ok-soft); color: var(--ok); }
.tag.warn, .tag.limited, .tag.likely, .tag.draft { background: var(--warn-soft); color: var(--warn); }
.tag.bad, .tag.rejected, .tag.failed, .tag.invalid, .tag.bounced, .tag.do_not_contact { background: var(--bad-soft); color: var(--bad); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
/* The grade gets its own rank ramp rather than borrowing a colour: teal means "you can do
   something here", and green to red belongs to ICP priority (P1-P4). Without nowrap, "D 20" broke onto a second line inside a 20px box and became a smudge. */
.grade {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 6px 0 5px;
  border-radius: 4px; white-space: nowrap; border: 1px solid transparent;
  font: 600 11.5px/1 var(--font); letter-spacing: 0.01em;
  background: var(--surface-2); color: var(--muted);
}
.grade .g { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.grade .s { font-family: var(--mono); font-variant-numeric: tabular-nums; opacity: .75; font-weight: 500; }
.grade.gA { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.grade.gB { background: var(--surface-2); color: var(--text); }
.grade.gC { background: transparent; color: var(--muted); border-color: var(--border); }
.grade.gD { background: transparent; color: var(--muted); }
td .grade, .page-head .grade { height: 22px; font-size: 12px; }

/* US B2B priority labels (P1 green → P4 red) */
.priority {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
}
.priority.P1 { background: var(--ok-soft); color: var(--ok); }
.priority.P2 { background: var(--p2-soft); color: var(--p2); }
.priority.P3 { background: var(--p3-soft); color: var(--p3); }
.priority.P4 { background: var(--bad-soft); color: var(--bad); }
.priority.needs_review { background: var(--surface-2); color: var(--muted); }
.priority.excluded { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.tag.hq.US_CONFIRMED { background: var(--ok-soft); color: var(--ok); }
.tag.hq.NON_US { background: var(--surface-2); color: var(--muted); }
.tag.hq.LOCATION_UNKNOWN, .tag.hq.LOCATION_CONFLICT { background: var(--warn-soft); color: var(--warn); }
.filters-wrap { flex-wrap: wrap; gap: 8px; }
.leads-table th { white-space: nowrap; }
.advanced-discover { margin: 8px 0 0; border: 1px solid var(--border); border-radius: var(--r); padding: 8px 12px; }
.advanced-discover summary { cursor: pointer; font-weight: 500; font-size: 13px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r);
          border: 1px solid var(--border); background: var(--surface); margin-bottom: 14px; font-size: 13px; }
.notice .ph { font-size: 18px; flex: none; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); }
.notice.warn .ph { color: var(--warn); }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-soft); }
.notice.bad .ph { color: var(--bad); }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.notice.ok .ph { color: var(--ok); }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .ph { font-size: 28px; display: block; margin: 0 auto 8px; color: var(--border-strong); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 2px; }

/* --- messages (approval + send) ---------------------------------------------------------- */

.msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 12px; }
.msg:focus { outline: none; }
.msg-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
            padding: 12px 16px; border-bottom: 1px solid var(--border); }
.msg-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.msg-title .row-link { font-size: 14.5px; }
.msg-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.msg-main { padding: 14px 16px; min-width: 0; }
.msg-side { padding: 14px 16px; border-left: 1px solid var(--border); font-size: 12.5px; display: flex; flex-direction: column; gap: 12px; }
.msg-side h4 { font-size: 11.5px; font-weight: 500; color: var(--muted); margin-bottom: 3px; }
.fact-quote { margin: 4px 0 0; padding-left: 9px; border-left: 2px solid var(--accent); color: var(--muted); }
.msg-text { white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 14px; line-height: 1.6; margin: 0;
            padding: 10px 12px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border); }
.msg.approved, .msg.sent { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.msg.rejected { opacity: .6; }
.msg.approved .msg-text, .msg.sent .msg-text, .msg.rejected .msg-text { background: transparent; }
.wc { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.wc.over { color: var(--bad); font-weight: 600; }
.to-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }

/* --- login --------------------------------------------------------------------------------- */

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { padding: 0; margin-bottom: 20px; }
.login .panel-body { padding: 22px; }

/* --- htmx --------------------------------------------------------------------------------- */

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }

/* --- responsive ---------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .msg-body { grid-template-columns: minmax(0, 1fr); }
  .msg-side { border-left: 0; border-top: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; gap: 16px; }
  .msg-side > div { flex: 1 1 200px; }
  /* Nine stages: 3 columns divide evenly, 5 would leave an empty cell at the end. */
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pipeline a:nth-child(3n+1) { border-left: 0; }
  .pipeline a:nth-child(n+4) { border-top: 1px solid var(--border); }
  .cols-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 12px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  /* The full labelled tree, folded behind the Menu button. The strip of two dozen bare icons it
     replaces could not be read: Calls, Call allowances and Find a call were three phone-ish glyphs. */
  .sidebar .nav-toggle { display: inline-flex; }
  .sidebar .nav { display: none; }
  .sidebar.nav-open .nav { display: flex; }
  .sidebar.nav-open { max-height: 100dvh; overflow-y: auto; }
  .limits { padding-top: 10px; }
  .limits > summary { cursor: pointer; }
  .limits-title { padding-bottom: 0; }
  .limits[open] .limits-title { padding-bottom: 10px; }
  .limits-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .user-box { display: none; }
  /* Logging out is navigation too; it rides inside the open menu rather than vanishing. */
  .sidebar.nav-open .user-box { display: flex; }
  .main { padding: 18px 16px 48px; }
  .split, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
}

@media (max-width: 560px) {
  .limits-body { grid-template-columns: minmax(0, 1fr); }
  .filters .field { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Research */
.research-ask textarea { width: 100%; resize: vertical; font: inherit; margin-bottom: 10px; }
.example-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-align: left; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.research-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.research-row:first-of-type { border-top: 0; }
.research-row:hover span:first-child { color: var(--accent); }
.steps { margin: 0 0 10px; padding-left: 20px; color: var(--muted); }
.steps li { padding: 2px 0; overflow-wrap: anywhere; }
.steps li.current { color: inherit; font-weight: 500; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.research-answer p { max-width: 70ch; line-height: 1.6; }
.cite { font-size: 0.8em; vertical-align: super; text-decoration: none; margin-left: 1px; }
.prospect { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.prospect:first-of-type { border-top: 0; }
.prospect-add { flex-wrap: nowrap; }
.finding { padding: 8px 0; border-top: 1px solid var(--border); }
.sources { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.sources li { overflow-wrap: anywhere; }
.sources li:target { background: var(--surface-2); border-radius: 4px; }
.disclosure-panel > summary { cursor: pointer; list-style: revert; }
@media (max-width: 720px) {
  .prospect, .research-row { flex-direction: column; }
  .prospect-add { flex-wrap: wrap; }
}

/* Case team: evidence board, reviewer verdict, trail */
/* Evidence rows. The fact is why the page exists, so it is the row; what kind of fact it is, who
   found it and where all sit beneath it in a quieter line. Before this the fact was bare inline
   text between chips, and the smallest thing on its own row. */
.evidence { padding: 11px 0; }
.evidence.is-stale { opacity: 0.6; }
.evidence .fact { display: block; font-size: 13.5px; line-height: 1.45; color: var(--text); }
.evidence .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; }
.evidence .meta .where { white-space: nowrap; }
.evidence .kind {
  font: 500 11.5px/1 var(--font); letter-spacing: 0.02em; color: var(--muted);
  background: var(--surface-2); border-radius: 4px; padding: 4px 7px; white-space: nowrap;
}
.evidence .kind.is-system { background: var(--warn-soft); color: var(--warn); }
.review-verdict { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 600; flex-wrap: wrap; }
.review-verdict.ok .ph { color: var(--ok, #18753c); }
.review-verdict.bad .ph { color: var(--bad, #b42323); }
.review-flags { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.review-flags li { display: flex; gap: 6px; align-items: baseline; }
.review-flags .block .ph { color: var(--bad, #b42323); }
.review-flags .warn .ph { color: var(--warn, #9a6700); }
.review-flags .note .ph { color: var(--muted); }
.trail { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 8px; }

/* Settings */
.setting { display: grid; grid-template-columns: minmax(160px, 220px) minmax(0, 1fr); gap: 4px 16px; padding: 10px 0; border-top: 1px solid var(--border); align-items: center; }
.setting:first-of-type { border-top: 0; }
.setting > label { font-weight: 500; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.setting-input { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.setting-input input[type="password"], .setting-input input:not([type]) { flex: 1 1 260px; min-width: 0; }
.setting-help { grid-column: 2; margin: 0; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
.settings-save { position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); }
@media (max-width: 720px) {
  .setting { grid-template-columns: 1fr; }
  .setting-help { grid-column: 1; }
}

/* Key setup guide */
.guide { max-width: 78ch; }
.guide h2 { margin-bottom: 8px; }
.guide h3 { margin: 0 0 6px; font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.guide ol, .guide ul { margin: 8px 0; padding-left: 22px; display: grid; gap: 4px; }
.guide p { line-height: 1.6; }
.guide-group { margin: 22px 0 10px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.roman-urdu { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 4px; font-size: 13.5px; }
.guide-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.guide-table th, .guide-table td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.guide-table th { color: var(--muted); font-weight: 500; border-top: 0; }
@media (max-width: 720px) { .guide-table { display: block; overflow-x: auto; } }

/* Global */
.global-find { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.global-find .field { margin: 0; }
.global-find .grow { flex: 1 1 280px; }
.global-options { display: flex; flex-wrap: wrap; gap: 6px 16px; flex-basis: 100%; }

/* Progress: the bar across the top, task cards, and the waiting bar for button actions */
.topbar, .busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none; overflow: hidden; }
.topbar span, .busy-bar span { display: block; height: 100%; background: var(--accent); transition: width 0.6s ease; }
.topbar.indeterminate span, .busy-bar span, .task-meter.indeterminate span { animation: slide 1.4s ease-in-out infinite; }
.busy-bar { display: none; }
body.is-busy .busy-bar { display: block; }
body.is-busy .busy-bar span { width: 35%; }
@keyframes slide { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
.task-dock { position: fixed; right: 16px; bottom: 16px; z-index: 55; display: grid; gap: 8px; width: min(320px, calc(100vw - 32px)); }
.task { display: grid; gap: 4px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); color: inherit; text-decoration: none; }
.task:hover { border-color: var(--accent); }
.task-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 13px; }
.task-stage { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.task-meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.6s ease; }
.task-more { justify-self: end; }
.task-done { position: fixed; right: 16px; bottom: 16px; z-index: 56; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--ok); border-radius: var(--r); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); font-size: 13px; }
.task-done .ph { color: var(--ok); }
@media (prefers-reduced-motion: reduce) {
  .topbar.indeterminate span, .busy-bar span, .task-meter.indeterminate span { animation: none; width: 100% !important; opacity: 0.5; }
}

/* Budget amounts: the currency sign sits with the field so the number reads as money. */
.money-input { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.money-input input { text-align: right; }

/* "Test every key" report: a quiet table, one row per provider. */
.key-report { width: 100%; border-collapse: collapse; }
.key-report td { padding: 6px 8px 6px 0; vertical-align: top; border-top: 1px solid var(--border); }
.key-report tr:first-child td { border-top: 0; }
.key-report tr.off { opacity: 0.65; }


/* --- daily summary: the day's numbers, each one a way in ------------------------------------ */
.figures { list-style: none; margin: 0; padding: 0; }
.figures li + li { border-top: 1px solid var(--border); }
.figures a, .figures > li > span {
  display: flex; align-items: baseline; gap: 14px; padding: 12px 16px; color: var(--text);
}
.figures a:hover { background: var(--surface-2); text-decoration: none; }
.figure-n {
  flex: none; min-width: 2.5ch; text-align: right; font-size: 20px; font-weight: 600;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.figure-n.live { color: var(--accent); }
.figure-label { display: flex; flex-direction: column; gap: 1px; font-size: 13.5px; }
.figure-hint { color: var(--muted); font-size: 12px; }
/* Caps shown on a page rather than in the sidebar need room to breathe. */
.limits-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; }
.limits-inline .limit { margin: 0; }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li + li { margin-top: 4px; }

/* Research coverage: what the run set out to establish, and whether it managed it. */
.checked { list-style: none; margin: 0; padding: 0; }
.checked li { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; }
.checked li + li { border-top: 1px solid var(--border); }
.checked li > span:first-of-type { flex: 1; }
.checked .ph { flex: none; }
.checked li.yes .ph { color: var(--ok); }
.checked li.no .ph { color: var(--muted); }

/* "Finish setting up": shown on Today until the essentials are done, then it disappears. */
.setup-list { list-style: none; margin: 0; padding: 0; }
.setup-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px;
                 padding: 10px 0; }
.setup-list li + li { border-top: 1px solid var(--border); }
.setup-list strong { display: block; font-size: 13.5px; }
.setup-list .small { display: block; margin-top: 2px; max-width: 70ch; }
.setup-list .btn { flex: none; }

/* --- Find leads ------------------------------------------------------------------------------ */
/* A short form: four or five choices in one grid, the number, then one button. */
.find-service { max-width: 520px; }
.find-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.find-count { border: 0; padding: 0; margin: 4px 0 12px; }
.find-count legend { font-size: 12.5px; font-weight: 500; margin-bottom: 6px; padding: 0; }
.find-count .count-input { width: 9em; }
.find-count .hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.preset[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.find-sources { padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); color: var(--muted); margin: 0 0 4px; }
.find-sources strong { color: var(--text); font-weight: 500; }
.find-checks { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 6px; }
.find-submit { margin-top: 16px; }
.btn.lg { height: 38px; padding: 0 18px; font-size: 14px; }
.find-status { margin-bottom: 16px; }
.find-status.is-running { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.find-status-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.find-status-head h2 { display: flex; align-items: center; gap: 8px; }
.find-stage { margin: 4px 0 12px; font-weight: 500; }
.find-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1px; margin: 12px 0;
               background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.find-counts > div { background: var(--surface); padding: 10px 12px; }
.find-counts dt { font-size: 12px; color: var(--muted); }
.find-counts dd { margin: 2px 0 0; }
.find-counts dd.num { font-size: 18px; font-weight: 600; }
.find-results { margin-top: 4px; }
.search-scope a[aria-current] { font-weight: 600; color: var(--text); }

/* --- All leads table ------------------------------------------------------------------------ */
/* Eight columns a manager scans across: number, company, phone, owner, place, priority, status,
   actions. Everything else lives on the company's own page. */
.lead-filters .field.narrow { min-width: 110px; flex: 0 1 120px; }
.lead-filters .more-filters { flex-basis: 100%; margin-top: 2px; padding-top: 8px; }
.lead-filters .more-filters .filters { margin: 8px 0 0; }
.owner-groups { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 10px; }
.owner-groups a { color: var(--muted); }
.owner-groups a[aria-current] { color: var(--text); font-weight: 600; }
.owner-groups .num { font-size: 12px; margin-left: 2px; }
.leads-table td { vertical-align: middle; }
.leads-table .serial { color: var(--muted); width: 1%; white-space: nowrap; }
.leads-table .site-link { margin-left: 4px; color: var(--muted); }
.leads-table .site-link:hover { color: var(--accent); }
/* The number never breaks; the status and source line under it may, so a long source does not
   push the table wider than the page. */
.leads-table .phone-cell { min-width: 150px; }
.leads-table .phone-cell .num { white-space: nowrap; }
.leads-table .pstat { max-width: 210px; }
.pstat { font-size: 12px; color: var(--muted); }
.pstat a { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); }
.pstat.verified { color: var(--ok); }
.pstat.invalid { color: var(--bad); }
.pstat::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
                 margin-right: 5px; vertical-align: 1px; background: var(--border-strong); }
.pstat.verified::before { background: var(--ok); }
.pstat.invalid::before { background: var(--bad); }
.pstat.none::before { background: transparent; border: 1px solid var(--border-strong); }
.leads-table .row-actions { white-space: nowrap; text-align: right; width: 1%; }
.leads-table .row-actions form { display: inline; }
.pagination { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 20px; }

/* --- Lead inbox -------------------------------------------------------------------------------- */
.selection-bar { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 8px 12px; margin: 0 0 10px;
                 border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.inbox-table th.sel, .inbox-table td.sel { width: 1%; }
.inbox-table td { vertical-align: top; }
.preview-toggle { margin-top: 2px; }
.preview-row > td { background: var(--bg); }
.lead-preview dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; margin: 4px 0 8px; max-width: 900px; }
.lead-preview dt { color: var(--muted); }
.lead-preview dd { margin: 0; }
.lead-preview ul { margin: 0; padding-left: 16px; }
.ready { white-space: nowrap; font-weight: 500; }
.ready.ready { color: var(--ok); }
.ready.blocked { color: var(--bad); }
.ready.phone, .ready.review { color: var(--warn); }
.ready.assigned { color: var(--muted); }

.task-done.is-error { border-color: var(--bad); }
.task-done.is-error .ph { color: var(--bad); }

/* The background jobs switch at the foot of the sidebar: green on, grey off, amber stalled. */
.jobs-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; margin: 8px 10px 0; border: 1px solid var(--border); border-radius: 8px; }
.jobs-switch .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; background: var(--muted, #999); vertical-align: middle; }
.jobs-switch.on .dot { background: var(--ok); }
.jobs-switch.stalled { border-color: var(--warn); background: var(--warn-soft); }
.jobs-switch.stalled .dot { background: var(--warn); }
.jobs-switch.off { background: var(--bad-soft); border-color: var(--bad); }
.jobs-switch.off .dot { background: var(--bad); }
.jobs-switch form { margin: 0; }

/* The admin's two bars (base.html): a rail of sections, then that section's pages. Less on the
   screen at once; the rest is one click away on the rail. */
.shell.two-bar { grid-template-columns: 64px 224px minmax(0, 1fr); }
.rail { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 12px 6px; background: var(--surface); border-right: 1px solid var(--border); }
.rail-brand { margin-bottom: 10px; text-decoration: none; }
.rail-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 52px; padding: 8px 2px; border-radius: 10px; color: var(--muted); text-decoration: none; }
.rail-item .ph { font-size: 20px; }
.rail-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.rail-item[aria-current="true"] { background: var(--accent-soft); color: var(--text); }
.rail-item[aria-current="true"] .ph { color: var(--accent); }
.rail-label { font-size: 10px; line-height: 1.1; max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-count { position: absolute; top: 3px; right: 5px; min-width: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 10px; line-height: 16px; text-align: center; }
.nav-panel-title { margin: 4px 8px 8px; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; }
.nav-panel[hidden] { display: none; }
@media (max-width: 900px) {
  /* On a phone the rail goes and the Menu button shows every section, labelled, as before. */
  .shell.two-bar { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .nav-panel[hidden] { display: block; }
}
@media (min-width: 901px) { .two-bar .sidebar .brand { display: none; } }  /* the rail carries the logo */
