/* Webster Scanner - dashboard styles.
   Honours the Iron Mind AI brandbook (dark, restrained, amber reserved for the
   primary CTA, active nav underline and focus). Fonts: system stack only (no CDN). */

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #0E0E0E;
  --surface: #161616;
  --elev: #1C1C1C;
  --hover: #222222;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: #707070;      /* form controls: >= 3:1 against surfaces */
  --text: #F2F2F2;
  --text-2: #D2D2D2;
  --muted: #9C9C9C;
  --accent: #E87C2E;             /* amber: CTA, active nav, focus only */
  --accent-fg: #0E0E0E;
  --focus: #E87C2E;
  --ok: #6FD08C;      --ok-bg: rgba(111, 208, 140, 0.14);
  --info: #6CB2FF;    --info-bg: rgba(108, 178, 255, 0.14);
  --warn: #E5C14F;    --warn-bg: rgba(229, 193, 79, 0.14);
  --bad: #FF8F85;     --bad-bg: rgba(255, 143, 133, 0.15);
  --vio: #B9A0FF;     --vio-bg: rgba(185, 160, 255, 0.15);
  --neutral: #B0B0B0; --neutral-bg: rgba(255, 255, 255, 0.07);
  /* categorical chart palette (>= 3:1 on surface) */
  --c1: #5AA9FF; --c2: #2FCBB0; --c3: #B795FF; --c4: #F27BAE; --c5: #8BD450; --c6: #E3C04A; --c7: #C9C9C9;
  --seq-0: #1d3b36; --seq-1: #238370; --seq-2: #2a9d86; --seq-3: #4fd1b6; --seq-4: #9af0dc;
  --grid: rgba(255, 255, 255, 0.10);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --row-bg: var(--surface);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r-sm: 3px; --r-md: 4px; --r-lg: 8px;
  --topbar-h: 52px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F3F3F1; --surface: #FFFFFF; --elev: #F6F6F4; --hover: #EEEEEA;
  --border: rgba(0, 0, 0, 0.11); --border-strong: #8A8A8A;
  --text: #131313; --text-2: #2E2E2E; --muted: #5B5B5B;
  --focus: #B34E00;
  --ok: #136A2C;   --ok-bg: rgba(19, 106, 44, 0.10);
  --info: #1450A8; --info-bg: rgba(20, 80, 168, 0.09);
  --warn: #7A5700; --warn-bg: rgba(160, 112, 0, 0.13);
  --bad: #B0221A;  --bad-bg: rgba(176, 34, 26, 0.09);
  --vio: #5A32B0;  --vio-bg: rgba(90, 50, 176, 0.09);
  --neutral: #474747; --neutral-bg: rgba(0, 0, 0, 0.06);
  --c1: #1F6FD1; --c2: #0B7F6C; --c3: #7B4FD1; --c4: #C2307A; --c5: #3F7F10; --c6: #94700A; --c7: #555555;
  --seq-0: #e3f3ef; --seq-1: #3b9682; --seq-2: #207a67; --seq-3: #12604f; --seq-4: #0a4538;
  --grid: rgba(0, 0, 0, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #F3F3F1; --surface: #FFFFFF; --elev: #F6F6F4; --hover: #EEEEEA;
    --border: rgba(0, 0, 0, 0.11); --border-strong: #8A8A8A;
    --text: #131313; --text-2: #2E2E2E; --muted: #5B5B5B;
    --focus: #B34E00;
    --ok: #136A2C;   --ok-bg: rgba(19, 106, 44, 0.10);
    --info: #1450A8; --info-bg: rgba(20, 80, 168, 0.09);
    --warn: #7A5700; --warn-bg: rgba(160, 112, 0, 0.13);
    --bad: #B0221A;  --bad-bg: rgba(176, 34, 26, 0.09);
    --vio: #5A32B0;  --vio-bg: rgba(90, 50, 176, 0.09);
    --neutral: #474747; --neutral-bg: rgba(0, 0, 0, 0.06);
    --c1: #1F6FD1; --c2: #0B7F6C; --c3: #7B4FD1; --c4: #C2307A; --c5: #3F7F10; --c6: #94700A; --c7: #555555;
    --seq-0: #e3f3ef; --seq-1: #3b9682; --seq-2: #207a67; --seq-3: #12604f; --seq-4: #0a4538;
    --grid: rgba(0, 0, 0, 0.12);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 13.5px/1.45 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; }
h1 { font-size: 20px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; }
h2 { font-size: 14px; letter-spacing: 0.01em; }
h3 { font-size: 13px; }
p { margin: 0 0 0.6em; }
a { color: var(--text); text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: rgba(232, 124, 46, 0.35); }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 300; background: var(--accent); color: var(--accent-fg); padding: 8px 12px; border-radius: var(--r-sm); font-weight: 600; }
.skip-link:focus { top: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: 24px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 14px; }
.brand small { font-weight: 400; letter-spacing: 0.08em; font-size: 10.5px; color: var(--muted); }
.nav { display: flex; align-items: stretch; gap: 4px; height: 100%; }
.nav a {
  position: relative; display: flex; align-items: center; padding: 0 12px; text-decoration: none;
  color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  transition: color 150ms ease;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"]::after, .nav a:hover::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; background: var(--accent); }
.nav a:hover::after { opacity: .5; }
.nav a[aria-current="page"]::after { opacity: 1; }
.topbar .spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- Page ---------- */
.page { padding: 20px 24px 40px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-main-side { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.ov-top { align-items: stretch !important; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); min-height: 42px; flex-wrap: wrap; }
.card-h h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); }
.card-b { padding: 14px; }
.card-b.flush { padding: 0; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: transparent; color: var(--text);
  font: 500 12.5px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, filter 150ms ease;
}
.btn:hover { background: var(--hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.btn svg, .ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spin { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

input, select, textarea {
  font: 400 13px/1.3 var(--font); color: var(--text); background: var(--elev);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); height: 32px; padding: 0 9px; min-width: 0; max-width: 100%;
}
textarea { height: auto; padding: 8px 9px; resize: vertical; line-height: 1.45; }
select { padding-right: 4px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input[type="number"] { font-variant-numeric: tabular-nums; }
label.field, div.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
label.field > :not(.lbl):not(.hint), div.field > :not(.lbl):not(.hint) { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); }
label.field .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--elev); border: 1px solid var(--border-strong); position: relative; padding: 0; cursor: pointer; transition: background 150ms; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 150ms, background 150ms; }
.switch input:checked { background: var(--ok-bg); border-color: var(--ok); }
.switch input:checked::after { transform: translateX(14px); background: var(--ok); }

/* ---------- Pills / chips ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.sq::before { border-radius: 1px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.vio { background: var(--vio-bg); color: var(--vio); }
.pill.live::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.pill.plain::before { display: none; }
.tag { display: inline-block; padding: 0 6px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); font-size: 11px; font-weight: 600; line-height: 17px; color: var(--text-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); font: 500 12px/1 var(--font); cursor: pointer;
}
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .sw { width: 14px; height: 3px; border-radius: 2px; background: currentColor; }
.chip.removable { cursor: default; height: 24px; background: var(--elev); }
.chip.removable button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chip.removable button:hover { color: var(--text); }

/* ---------- Menu / popover ---------- */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 190px; max-height: 340px; overflow: auto;
  background: var(--elev); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 6px;
}
.menu-pop.right { left: auto; right: 0; }
.menu-pop label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; }
.menu-pop label:hover { background: var(--hover); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-count { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 11px; line-height: 16px; text-align: center; font-weight: 700; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; }
table.tbl { border-collapse: separate; border-spacing: 0; width: 100%; }
.tbl th, .tbl td { padding: 0 8px; height: 36px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th {
  position: sticky; top: 0; z-index: 3; background: var(--elev); color: var(--muted); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; height: 34px; border-bottom: 1px solid var(--border-strong);
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl th .sort-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tbl th[aria-sort="ascending"], .tbl th[aria-sort="descending"] { color: var(--text); }
.tbl th[aria-sort="ascending"] .arr::after { content: "\2191"; }
.tbl th[aria-sort="descending"] .arr::after { content: "\2193"; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.wrap { white-space: normal; }
.tbl tbody tr { background: var(--row-bg); }
.tbl tbody tr:hover { background: var(--hover); --row-bg: var(--hover); }
.tbl.compact td, .tbl.compact th { height: 30px; }
.tbl tr.clickable { cursor: pointer; }
.tbl .name-cell { display: inline-block; vertical-align: middle; max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
.tbl td.sticky-col, .tbl th.sticky-col { position: sticky; left: 0; z-index: 2; background: var(--row-bg); }
.tbl th.sticky-col { z-index: 4; background: var(--elev); }
.tbl tbody tr.row-active { --row-bg: var(--hover); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tbl tbody tr.row-active td:first-child { box-shadow: inset 3px 0 0 var(--text); }
.tbl tbody tr.row-due { --row-bg: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.tbl tbody tr.row-due td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl tbody tr.row-active.row-due td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl tbody tr.row-dim td { color: var(--muted); }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.cell-select { height: 26px; font-size: 12.5px; padding: 0 2px 0 6px; background: transparent; border-color: transparent; border-radius: var(--r-sm); cursor: pointer; }
.cell-select:hover { border-color: var(--border-strong); background: var(--elev); }
.cell-input { height: 26px; font-size: 12.5px; width: 84px; padding: 0 6px; background: transparent; border-color: transparent; }
.cell-input:hover { border-color: var(--border-strong); background: var(--elev); }
.cell-input:focus-visible, .cell-select:focus-visible { background: var(--elev); border-color: var(--border-strong); }
.cell-input::placeholder { color: var(--muted); }
.saving { opacity: .55; }
.score-bar { display: inline-block; vertical-align: middle; width: 42px; height: 6px; border-radius: 3px; background: var(--neutral-bg); margin-left: 8px; position: relative; overflow: hidden; }
.score-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--muted); border-radius: 3px; }
.due-flag { font-size: 11px; font-weight: 700; color: var(--warn); letter-spacing: 0.04em; margin-left: 6px; }
.kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 3px; font: 600 11px/16px var(--mono); text-align: center; color: var(--text-2); }

/* ---------- Leads page layout ---------- */
.page-leads { max-width: none; padding: 14px 20px 0; height: calc(100vh - var(--topbar-h) - var(--strip-h, 0px)); display: flex; flex-direction: column; gap: 10px; }
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filterbar .grow { flex: 1 1 220px; min-width: 200px; }
.filterbar label.field { min-width: 0; }
.filterbar select { max-width: 120px; }
.tbl td a.nm { text-decoration: none; }
.tbl td a.nm:hover { text-decoration: underline; }
.tbl tbody tr { scroll-margin-top: 40px; }
.filterbar input[type="number"] { width: 78px; }
.filterbar .btn-sel { height: 32px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.leads-card { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-bottom: 14px; }
.leads-card .tbl-wrap { flex: 1; min-height: 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 0; }

/* ---------- KPI / charts ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; text-decoration: none; display: block; }
a.kpi:hover { background: var(--hover); }
.kpi .k-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi .k-val { font-size: 26px; font-weight: 600; line-height: 1.15; margin-top: 4px; letter-spacing: -0.01em; }
.kpi .k-delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .k-delta b { color: var(--ok); font-weight: 600; }
.kpi .k-delta b.zero { color: var(--muted); }

.funnel { display: flex; flex-direction: column; gap: 6px; }
.fn-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 150px; gap: 12px; align-items: center; }
.fn-name { font-size: 12.5px; color: var(--text-2); }
.fn-bar { height: 22px; background: var(--neutral-bg); border-radius: 2px; position: relative; }
.fn-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--c1); border-radius: 2px; min-width: 2px; }
.fn-val { font-weight: 600; text-align: right; }
.fn-val small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-top: -1px; }
.fn-val .conv { font-weight: 400; color: var(--muted); font-size: 11.5px; margin-left: 6px; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.ch-axis { fill: var(--muted); font-size: 11px; }
.ch-lbl { font-size: 11.5px; font-weight: 600; }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tip { position: fixed; z-index: 200; pointer-events: none; background: var(--elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: var(--r-md); padding: 8px 10px; font-size: 12px; max-width: 280px; }
.tip b { display: block; margin-bottom: 4px; }
.tip .tr { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tip .tr i { display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }

.meters { display: grid; gap: 14px; }
.meter .m-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.meter .m-top span:first-child { color: var(--text-2); }
.meter-bar { height: 10px; background: var(--neutral-bg); border-radius: 2px; position: relative; overflow: hidden; }
.meter-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--c1); }
.meter.warn .meter-bar > i { background: var(--warn); }
.meter.bad .meter-bar > i { background: var(--bad); background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(0,0,0,.25) 5px 7px); }
.meter.warn .meter-bar > i { background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(0,0,0,.18) 8px 10px); }
.meter .m-note { font-size: 11.5px; margin-top: 3px; color: var(--muted); }
.meter.warn .m-note { color: var(--warn); }
.meter.bad .m-note { color: var(--bad); }

.stackbar { display: flex; height: 12px; border-radius: 2px; overflow: hidden; background: var(--neutral-bg); gap: 1px; }
.stackbar > i { display: block; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 78px 128px minmax(0, 1fr); gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--border); align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 12px; }
.feed .ev-type { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.feed .ev-text { overflow-wrap: anywhere; }
.feed .ev-text .muted { margin-left: 6px; }

/* ---------- States ---------- */
.skeleton { display: block; position: relative; overflow: hidden; background: var(--neutral-bg); border-radius: var(--r-sm); min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(128,128,128,.14), transparent); transform: translateX(-100%); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-wrap { display: grid; gap: 8px; padding: 14px; }
.state { padding: 28px 16px; text-align: center; color: var(--muted); }
.state b { display: block; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
.state.err b { color: var(--bad); }
.state .btn { margin-top: 10px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--warn); background: var(--warn-bg); color: var(--text); margin-bottom: 16px; }
.banner b { color: var(--warn); }
.banner.bad { border-color: var(--bad); background: var(--bad-bg); }
.banner.bad b { color: var(--bad); }
.banner .grow { flex: 1; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 400; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--elev); border: 1px solid var(--border-strong); border-left-width: 4px; border-radius: var(--r-md); box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast.info { border-left-color: var(--info); }
.toast .t-msg { flex: 1; overflow-wrap: anywhere; }
.toast .t-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.toast .t-x:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Dialog ---------- */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: 0; box-shadow: var(--shadow); max-width: min(520px, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { padding: 18px; display: grid; gap: 14px; }
dialog h2 { font-size: 15px; }
dialog.lightbox { max-width: min(1200px, 96vw); background: var(--bg); }
dialog.lightbox .lb { padding: 12px; display: grid; gap: 8px; max-height: 94vh; }
dialog.lightbox img { max-width: 100%; max-height: 80vh; margin: 0 auto; display: block; object-fit: contain; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Login ---------- */
.page-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; display: grid; gap: 16px; }
.login-card .brand { font-size: 16px; }
.login-err { color: var(--bad); font-size: 12.5px; min-height: 18px; }

/* ---------- Lead detail ---------- */
.lead-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.lead-head h1 { text-transform: none; letter-spacing: -0.01em; font-size: 24px; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; color: var(--text-2); }
.lead-meta .it { display: inline-flex; align-items: center; gap: 6px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stepper { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; list-style: none; margin: 0; padding: 14px; }
.step { position: relative; padding-top: 22px; padding-right: 8px; }
.step::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--border-strong); }
.step::after { content: ""; position: absolute; top: 0; left: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.step.done::before { background: var(--ok); }
.step.done::after { background: var(--ok); border-color: var(--ok); }
.step.cur::after { border-color: var(--text); background: var(--text); box-shadow: 0 0 0 3px var(--neutral-bg); }
.step.fail::after { background: var(--bad); border-color: var(--bad); border-radius: 2px; }
.step.skip::after { border-style: dashed; }
.step .s-name { font-weight: 600; }
.step .s-sub { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sig { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--elev); font-size: 12px; }
.sig b { font-family: var(--mono); font-weight: 600; color: var(--bad); }
.big-score { font-size: 34px; font-weight: 600; line-height: 1; }
.analysis-grid { display: grid; grid-template-columns: auto 1fr; gap: 14px 24px; align-items: start; }
.findings { margin: 0; padding-left: 18px; }
.findings li { margin: 3px 0; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.shot { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--elev); padding: 0; cursor: zoom-in; color: inherit; text-align: left; overflow: hidden; display: block; width: 100%; }
.shot:hover { border-color: var(--border-strong); }
.shot .img { height: 140px; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.shot span { display: block; padding: 6px 8px; font-size: 12px; color: var(--text-2); }
.ba-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.md { overflow-wrap: anywhere; line-height: 1.6; max-width: 80ch; }
.md h1, .md h2, .md h3, .md h4 { text-transform: none; letter-spacing: 0; margin: 1.1em 0 .4em; }
.md h1 { font-size: 18px; } .md h2 { font-size: 15.5px; } .md h3 { font-size: 14px; } .md h4 { font-size: 13.5px; }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 .7em; }
.md code { background: var(--elev); padding: 1px 5px; border-radius: 3px; }
.md pre { background: var(--elev); border: 1px solid var(--border); padding: 10px; border-radius: var(--r-md); overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 .7em; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md table { border-collapse: collapse; margin-bottom: .8em; }
.md th, .md td { border: 1px solid var(--border-strong); padding: 4px 8px; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }
.md-collapse { max-height: 340px; overflow: hidden; position: relative; }
.md-collapse::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 70px; background: linear-gradient(transparent, var(--surface)); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.form-grid > *, .sect-fields > * { min-width: 0; }
.sect-fields label.full input { max-width: 240px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }
.log .l-h { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Sweep ---------- */
.map-wrap { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); }
.map-wrap canvas { display: block; width: 100%; border-radius: var(--r-md); }
.map-wrap canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.legend-grad { display: inline-block; width: 120px; height: 10px; border-radius: 2px; vertical-align: middle; }
.sw-box { width: 14px; height: 14px; border-radius: 2px; display: inline-block; border: 1px solid var(--border-strong); vertical-align: middle; }
.progress { position: relative; width: 90px; height: 8px; background: var(--neutral-bg); border-radius: 2px; display: inline-block; vertical-align: middle; overflow: hidden; margin-right: 6px; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: var(--c2); }
tr.sel-row { --row-bg: var(--hover); }
tr.sel-row td:first-child { box-shadow: inset 3px 0 0 var(--text); }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.sect-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 14px; }
.sect-fields .full { grid-column: 1 / -1; }
.savebar { position: sticky; bottom: 0; z-index: 40; display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 14px; background: var(--elev); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow); margin-top: 16px; }
.runbtns { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border); align-items: flex-end; }
.add-row input[type="number"] { width: 92px; }

@media (max-width: 1100px) {
  .cols-main-side, .cols-2, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 16px; }
  .topbar { padding: 0 14px; gap: 14px; }
  .fn-row { grid-template-columns: 96px minmax(0, 1fr) 128px; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
}
@media (max-width: 720px) { .brand small { display: none; } .nav a { padding: 0 8px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print { .topbar, .toasts { display: none; } }

/* tag editor */
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 6px; min-height: 36px; background: var(--elev); border: 1px solid var(--border-strong); border-radius: var(--r-sm); cursor: text; }
.tag-box:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.tag-box input:focus-visible { outline: none; }

/* scheduler chip */
.sched { display: flex; align-items: center; gap: 8px; margin-right: 10px; }
/* daily target / pipeline stock */
.ov-target { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); margin-bottom: 16px; align-items: stretch; }
.big-frac { font-size: 44px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.big-frac small { font-size: 22px; font-weight: 400; color: var(--muted); }
.seg-bar { display: flex; height: 16px; background: var(--neutral-bg); border-radius: 2px; overflow: hidden; gap: 2px; margin: 14px 0 8px; }
.seg-bar > i { display: block; min-width: 0; }
.seg-done { background: var(--c2); }
.seg-fly { background: var(--c1); background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(0,0,0,.28) 5px 7px); }
.stock { display: grid; gap: 8px; }
.stock-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 6px 8px; border-radius: var(--r-sm); border: 1px solid transparent; }
.stock-row .st-bar { height: 8px; background: var(--neutral-bg); border-radius: 2px; position: relative; overflow: hidden; }
.stock-row .st-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--c1); min-width: 2px; }
.stock-row .st-n { text-align: right; font-weight: 600; }
.stock-row.is-bn { border-color: var(--warn); background: var(--warn-bg); }
.stock-row.is-bn .st-bar > i { background: var(--warn); }
.bn-tag { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--warn); color: var(--warn); border-radius: 3px; }

/* status strip */
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 6px 24px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 12px; line-height: 18px; min-height: 31px; }
.strip .si { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.strip .sl { color: var(--muted); }
.strip .sv { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.strip .sv.ok { color: var(--ok); } .strip .sv.bad { color: var(--bad); }
.strip .inert .sv { color: var(--muted); font-weight: 500; }
.strip .sep { width: 1px; height: 14px; background: var(--border-strong); opacity: .6; }
.strip .mini { position: relative; width: 28px; height: 6px; border-radius: 2px; background: var(--neutral-bg); overflow: hidden; display: inline-block; }
.strip .mini > i { position: absolute; inset: 0 auto 0 0; background: var(--c1); }
.strip .mini > i.fly { background: var(--c2); }
.strip .mini.warn > i { background: var(--warn); background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0,0,0,.25) 4px 6px); }
.strip .mini.bad > i { background: var(--bad); background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0,0,0,.3) 4px 6px); }
.strip .mini.pv > i { background: var(--c2); }
.strip .sv.warn { color: var(--warn); } 
.strip a.att { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-weight: 600; text-decoration: none; border: 1px solid transparent; }
.strip a.att.err { background: var(--bad-bg); color: var(--bad); }
.strip a.att:hover { border-color: currentColor; }
.strip .lj { flex: 1 1 170px; min-width: 0; max-width: 460px; overflow: hidden; text-overflow: ellipsis; }
.strip .lj .sum { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.strip .strip-msg { color: var(--muted); }
.strip .pill { height: 18px; font-size: 11px; }
@media (max-width: 1100px) { .strip { padding: 6px 16px; } }
