/* ============================================================
   LeadRadar — design tokens
   Palette: validated categorical slots (blue/orange/aqua/…)
   ============================================================ */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --page: #f9f9f7;
  --page-2: #f2f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.16);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;

  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --accent: var(--series-1);
  --accent-soft: color-mix(in srgb, var(--series-1) 12%, transparent);
  --accent-ink: #ffffff;

  --funnel-1: #86b6ef;
  --funnel-2: #5598e7;
  --funnel-3: #2a78d6;
  --funnel-4: #1c5cab;
  --funnel-5: #104281;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(11, 11, 11, .06), 0 1px 3px rgba(11, 11, 11, .04);
  --shadow-2: 0 8px 24px rgba(11, 11, 11, .10), 0 2px 6px rgba(11, 11, 11, .06);
  --sidebar-w: 244px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #212120;
    --page: #0d0d0d;
    --page-2: #151514;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --good-text: #0ca30c;
    --accent-soft: color-mix(in srgb, var(--series-1) 22%, transparent);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
    --funnel-1: #cde2fb;
    --funnel-2: #9ec5f4;
    --funnel-3: #5598e7;
    --funnel-4: #2a78d6;
    --funnel-5: #184f95;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #212120;
  --page: #0d0d0d;
  --page-2: #151514;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --good-text: #0ca30c;
  --accent-soft: color-mix(in srgb, var(--series-1) 22%, transparent);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
  --funnel-1: #cde2fb;
  --funnel-2: #9ec5f4;
  --funnel-3: #5598e7;
  --funnel-4: #2a78d6;
  --funnel-5: #184f95;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.012em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Brand ───────────────────────────────────────────────── */
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background:
    radial-gradient(circle at 50% 50%, var(--page) 0 2.6px, transparent 3px),
    radial-gradient(circle at 50% 50%, transparent 0 10px, var(--surface-2) 10.5px 12.5px, transparent 13px),
    linear-gradient(135deg, var(--series-1), var(--series-7));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}

/* ── Login ───────────────────────────────────────────────── */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 480px at 18% -8%, var(--accent-soft), transparent 65%),
    radial-gradient(700px 420px at 88% 108%, color-mix(in srgb, var(--series-7) 14%, transparent), transparent 60%),
    var(--page);
}
.login-card {
  width: min(404px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 28px 26px;
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 14px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.login-brand h1 { font-size: 21px; }
.login-brand p { color: var(--text-muted); font-size: 12.5px; margin-top: 1px; }
.login-error {
  color: var(--critical); font-size: 13px;
  background: color-mix(in srgb, var(--critical) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--critical) 28%, transparent);
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.login-hint { color: var(--text-muted); font-size: 12.5px; }

/* ── Shell ───────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 14px 12px 12px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.sidebar-brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: -0.02em; }

.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 500;
  text-decoration: none; transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--page-2); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { opacity: .85; }
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 0 6px;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  background: var(--accent); color: var(--accent-ink); border-radius: 9px;
}
.nav-sep { height: 1px; background: var(--border); margin: 8px 6px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--radius-sm); background: var(--page-2);
  cursor: pointer;
}
.user-chip:hover { background: var(--page-3, var(--border)); }
.user-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); text-transform: uppercase;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 22px;
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 650; font-size: 15px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.view { padding: 22px; max-width: 1460px; width: 100%; margin: 0 auto; }
.menu-btn { display: none; }

/* ── Buttons & controls ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-1);
  color: var(--text-primary); font-weight: 550; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .05s;
}
.btn:hover { background: var(--page-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 34%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 10%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--page-2); color: var(--text-primary); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; }

.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--page-2); color: var(--text-primary); }

.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.field small { color: var(--text-muted); font-size: 11.5px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; height: 34px; padding: 0 10px;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .13s, box-shadow .13s;
}
textarea { height: auto; min-height: 78px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Layout blocks ───────────────────────────────────────── */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { margin-left: auto; }
.stack { display: grid; gap: 12px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 13.5px; font-weight: 650; }
.card-head .sub { color: var(--text-muted); font-size: 12px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px 16px; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--border); }

.section-title { font-size: 13px; font-weight: 650; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }

/* ── Stat tiles ──────────────────────────────────────────── */
.stat {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: grid; gap: 5px; position: relative; overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 550; }
.stat-value { font-size: 26px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.1; }
.stat-foot { font-size: 12px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }
.stat-accent { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.stat-delta-good { color: var(--good-text); font-weight: 600; }
.stat-delta-bad { color: var(--critical); font-weight: 600; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--surface-1); padding: 9px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--page-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--text-muted); }
table.data .strong { font-weight: 600; }

/* ── Pills / badges ──────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--page-2); color: var(--text-secondary);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-new { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--series-1); }
.pill-contacted { background: color-mix(in srgb, var(--series-4) 22%, transparent); color: #8a5f00; }
.pill-replied { background: color-mix(in srgb, var(--series-3) 18%, transparent); color: #0b6b4c; }
.pill-negotiation { background: color-mix(in srgb, var(--series-7) 18%, transparent); color: var(--series-7); }
.pill-won { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good-text); }
.pill-lost { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.pill-neutral { background: var(--page-2); color: var(--text-secondary); }
.pill-good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good-text); }
.pill-warn { background: color-mix(in srgb, var(--warning) 24%, transparent); color: #7a5300; }
.pill-bad { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.pill-info { background: color-mix(in srgb, var(--series-1) 15%, transparent); color: var(--series-1); }
:root[data-theme="dark"] .pill-contacted,
:root[data-theme="dark"] .pill-warn { color: #f0c05a; }
:root[data-theme="dark"] .pill-replied { color: #4fd1a5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-contacted,
  :root:not([data-theme="light"]) .pill-warn { color: #f0c05a; }
  :root:not([data-theme="light"]) .pill-replied { color: #4fd1a5; }
}

/* ── Toolbar / filters ───────────────────────────────────── */
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { min-width: 210px; flex: 1; max-width: 340px; position: relative; }
.toolbar .search input { padding-left: 32px; }
.toolbar .search svg { position: absolute; left: 9px; top: 8px; width: 16px; height: 16px; color: var(--text-muted); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--page-2); border-radius: 9px; border: 1px solid var(--border); }
.seg button {
  border: 0; background: transparent; color: var(--text-secondary);
  height: 26px; padding: 0 11px; border-radius: 7px; font-size: 12.5px; font-weight: 550; cursor: pointer;
}
.seg button.active { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-1); }

/* ── Stage tabs ──────────────────────────────────────────── */
.stage-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.stage-tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-secondary); font-size: 12.5px; font-weight: 550;
  transition: border-color .13s, background .13s;
}
.stage-tab:hover { border-color: var(--border-strong); color: var(--text-primary); }
.stage-tab.active { background: var(--page-2); border-color: var(--border-strong); color: var(--text-primary); }
.stage-tab .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.stage-tab .count {
  font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums;
  background: var(--page-2); border-radius: 5px; padding: 1px 5px;
}
.stage-tab.active .count { background: var(--surface-1); }

/* ── Kanban ──────────────────────────────────────────────── */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(248px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--page-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.kcol-head .name { font-size: 12.5px; font-weight: 650; }
.kcol-head .count { margin-left: auto; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.kcol-head .bar { width: 3px; height: 14px; border-radius: 2px; }
.kcol-body { padding: 8px; display: grid; gap: 7px; align-content: start; overflow-y: auto; max-height: 62vh; }
.kcard {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 10px; cursor: pointer;
  display: grid; gap: 4px; box-shadow: var(--shadow-1);
  transition: border-color .13s, transform .08s;
}
.kcard:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kcard .kname { font-weight: 600; font-size: 12.8px; line-height: 1.35; }
.kcard .kmeta { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 6px; flex-wrap: wrap; }
.kcard .kphone { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ── Drawer ──────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 40; backdrop-filter: blur(1px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--surface-1); border-left: 1px solid var(--border);
  z-index: 50; display: flex; flex-direction: column; box-shadow: var(--shadow-2);
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(16px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 15px; flex: 1; min-width: 0; }
.drawer-body { padding: 16px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.42); padding: 18px; }
.modal-card {
  width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-2);
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; flex: 1; }
.modal-body { padding: 16px; overflow-y: auto; display: grid; gap: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ── Detail rows ─────────────────────────────────────────── */
.kv { display: grid; gap: 8px; }
.kv-row { display: grid; grid-template-columns: 118px 1fr; gap: 10px; font-size: 13px; align-items: baseline; }
.kv-row dt { color: var(--text-muted); font-size: 12px; }
.kv-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 18px 1fr; gap: 9px; padding-bottom: 12px; position: relative; }
.tl-item::before {
  content: ""; position: absolute; left: 8px; top: 15px; bottom: 0; width: 1px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--axis); margin: 6px 0 0 5px; z-index: 1; }
.tl-dot.stage { background: var(--series-1); }
.tl-dot.project { background: var(--good); }
.tl-dot.note { background: var(--series-4); }
.tl-text { font-size: 12.8px; }
.tl-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* ── Progress ────────────────────────────────────────────── */
.progress { height: 6px; border-radius: 3px; background: var(--page-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.progress.done > i { background: var(--good); }
.progress.err > i { background: var(--critical); }

.empty {
  padding: 34px 20px; text-align: center; color: var(--text-muted); font-size: 13px;
}
.empty strong { display: block; color: var(--text-secondary); font-size: 14px; margin-bottom: 4px; }

/* ── Charts ──────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .axis-label { font-size: 10.5px; fill: var(--text-muted); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick-label { font-size: 11px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart .value-label { font-size: 11.5px; fill: var(--text-secondary); font-weight: 600; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; }

.tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 9px; font-size: 12px; box-shadow: var(--shadow-2);
  display: grid; gap: 2px; min-width: 92px;
}
.tooltip .tt-title { font-weight: 650; font-size: 11.5px; color: var(--text-muted); }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }

/* ── Toasts ──────────────────────────────────────────────── */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent); border-radius: 9px;
  padding: 10px 13px; font-size: 13px; box-shadow: var(--shadow-2);
  animation: toast-in .16s ease-out;
}
.toast.error { border-left-color: var(--critical); }
.toast.success { border-left-color: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ── Source rows ─────────────────────────────────────────── */
.source-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.source-row.off { opacity: .6; }
.source-row input { margin-top: 2px; }
.source-row .sname { font-weight: 600; font-size: 13px; }
.source-row .sdesc { font-size: 12px; color: var(--text-muted); }

/* ── Misc ────────────────────────────────────────────────── */
.hint { font-size: 12px; color: var(--text-muted); }
.yes { color: var(--good-text); font-weight: 600; }
.no { color: var(--critical); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 45; transform: translateX(-100%);
    transition: transform .18s ease-out; box-shadow: var(--shadow-2);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block !important; z-index: 44; }
  .menu-btn { display: grid; }
  .view { padding: 14px; }
  .topbar { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kv-row { grid-template-columns: 96px 1fr; }
  .drawer { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}