/* ============================================================================
   Beluga Ops Command Center — design system
   Light + dark theming via CSS custom properties. No external CSS.
   ============================================================================ */

:root {
  --bg: #f3f5f9;
  --bg-2: #e9edf4;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --fg: #1b2331;
  --fg-soft: #38425a;
  --muted: #6a7488;
  --faint: #98a1b3;
  --border: #e2e7ef;
  --border-strong: #d3dae4;
  --grid: #eaedf3;

  --accent: #2b7de9;
  --accent-2: #109c86;
  --purple: #7a5cf0;
  --good: #0f8f6f;
  --good-bg: #e6f6f0;
  --warn: #cf8114;
  --warn-bg: #fbf1df;
  --bad: #cf433c;
  --bad-bg: #fdeceb;
  --info: #2b7de9;
  --info-bg: #e8f1fd;

  --side-bg: #0f1729;
  --side-bg-2: #0b1120;
  --side-fg: #e7ecf5;
  --side-muted: #8b96ad;
  --side-active-bg: rgba(43, 125, 233, 0.18);
  --side-active-fg: #ffffff;
  --side-border: rgba(255, 255, 255, 0.07);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.14);

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 232px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1220;
    --bg-2: #0a0f1b;
    --card: #151c2c;
    --card-2: #1a2336;
    --fg: #e6ebf4;
    --fg-soft: #c3cbdb;
    --muted: #98a3ba;
    --faint: #6a7488;
    --border: #253049;
    --border-strong: #313d57;
    --grid: #222c40;
    --good-bg: rgba(15, 143, 111, 0.16);
    --warn-bg: rgba(207, 129, 20, 0.16);
    --bad-bg: rgba(207, 67, 60, 0.17);
    --info-bg: rgba(43, 125, 233, 0.16);
    --side-bg: #0a0f1b;
    --side-bg-2: #070b14;
    --side-active-bg: rgba(43, 125, 233, 0.24);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.46);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1220;
  --bg-2: #0a0f1b;
  --card: #151c2c;
  --card-2: #1a2336;
  --fg: #e6ebf4;
  --fg-soft: #c3cbdb;
  --muted: #98a3ba;
  --faint: #6a7488;
  --border: #253049;
  --border-strong: #313d57;
  --grid: #222c40;
  --good-bg: rgba(15, 143, 111, 0.16);
  --warn-bg: rgba(207, 129, 20, 0.16);
  --bad-bg: rgba(207, 67, 60, 0.17);
  --info-bg: rgba(43, 125, 233, 0.16);
  --side-bg: #0a0f1b;
  --side-bg-2: #070b14;
  --side-active-bg: rgba(43, 125, 233, 0.24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.46);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(43, 125, 233, 0.22); }

/* ── Shell layout ─────────────────────────────────────────────────────────── */
.app-root { height: 100vh; }
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--side-bg), var(--side-bg-2));
  color: var(--side-fg);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--side-border);
}

.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 6px 8px 20px; }
.brand-logo { height: 22px; width: auto; display: block; }
.brand-sub { font-size: 11px; color: var(--side-muted); letter-spacing: 0.3px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 8px;
  color: var(--side-muted); font-weight: 500; font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--side-fg); text-decoration: none; }
.nav-item.active { background: var(--side-active-bg); color: var(--side-active-fg); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; color: currentColor; }
.nav-icon svg { width: 18px; height: 18px; }

.sidebar-foot { margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid var(--side-border); }
.sidebar-foot-line { font-size: 11px; color: var(--side-fg); opacity: 0.8; }
.sidebar-foot-line.muted { color: var(--side-muted); opacity: 1; margin-top: 2px; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar / freshness ───────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 26px; background: var(--card);
  border-bottom: 1px solid var(--border); min-height: 62px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

.freshness { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.fresh-block { display: flex; align-items: center; gap: 10px; }
.fresh-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.fresh-dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.fresh-dot.stale { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.fresh-line1 { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; }
.fresh-clock { display: inline-flex; color: var(--muted); margin-right: 6px; }
.fresh-clock svg { width: 14px; height: 14px; }
.fresh-updated-label { color: var(--muted); font-weight: 600; margin-right: 5px; }
.fresh-rel { font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; }
.fresh-warn { color: var(--bad); font-weight: 700; letter-spacing: 0.4px; margin-left: 8px; padding: 1px 6px; background: var(--bad-bg); border-radius: 5px; font-size: 10.5px; }
.fresh-line2 { font-size: 11.5px; }

.fresh-quick { display: flex; gap: 16px; padding-left: 18px; border-left: 1px solid var(--border); }
.quick-stat { display: flex; flex-direction: column; line-height: 1.2; }
.qs-value { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.qs-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.qs-crit .qs-value { color: var(--bad); }
.qs-good .qs-value { color: var(--good); }
.qs-warn .qs-value { color: var(--warn); }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--fg-soft); border: 1px solid var(--border);
  padding: 7px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.icon-btn:hover { background: var(--card-2); border-color: var(--border-strong); text-decoration: none; }
.icon-btn svg { width: 15px; height: 15px; }
.theme-toggle { font-size: 15px; padding: 6px 10px; }

/* "New data available" pill — shown when a newer snapshot lands while the tab is open. */
.new-data-pill {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--accent); color: #fff; border: none;
  padding: 7px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-sm); animation: pill-in 0.2s ease-out;
}
.new-data-pill:hover { background: #1b6fd6; }
.new-data-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes pill-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ── Content ──────────────────────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 24px 26px 60px; }
.view { max-width: 1320px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.2px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.title-slug { font-size: 12px; font-weight: 500; color: var(--muted); font-family: var(--mono); background: var(--bg-2); padding: 2px 8px; border-radius: 6px; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 80ch; }
.page-head-actions { flex: none; }
/* Footnote under a page's main table. */
.page-note { font-size: 12px; margin: 14px 2px 0; max-width: 104ch; line-height: 1.5; }

/* "Updated HH:MM UTC" stamp in a page head (ui.js refreshStamp, and Sales follow-up). */
.feed-stamp { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.feed-stamp strong { color: var(--fg); font-weight: 600; }
.feed-stamp-sub { font-size: 12px; opacity: 0.85; }
.feed-stamp-sub::before { content: "·"; margin-right: 8px; }

/* Band divider: splits a page into the two audiences (client health / service delivery). */
.band-head { margin: 34px 0 16px; padding-top: 22px; border-top: 1px solid var(--border); }
.band-title { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.1px; }
.band-sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }

/* Partner-detail client-health summary line (churn + Slack). */
.ch-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ch-item { display: inline-flex; align-items: center; gap: 8px; }
.ch-note { color: var(--muted); font-size: 12.5px; }

/* ── KPI cards ────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid; gap: 14px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
}
.kpi-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px 13px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow 0.14s, transform 0.14s, border-color 0.14s;
}
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
.kpi-head { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-value { font-size: 27px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; min-height: 20px; }
.kpi-note { margin-top: 7px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }

.delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta-good { color: var(--good); }
.delta-bad { color: var(--bad); }
.delta-flat, .delta-none { color: var(--faint); font-weight: 500; }
.sparkline { opacity: 0.9; }

.info-dot {
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-strong);
  color: var(--faint); font-size: 10px; font-style: italic; font-weight: 700;
  display: inline-grid; place-items: center; cursor: help; user-select: none; font-family: Georgia, serif;
}
.info-dot:hover { color: var(--accent); border-color: var(--accent); }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-title { font-size: 14px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 7px; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.panel-body { padding: 16px; }
.panel.no-pad .panel-body { padding: 0; }
.panel-link { font-size: 12.5px; font-weight: 600; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.panel-link-icon svg, .cat-chip-arrow svg { width: 12px; height: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Category chips (overview) ────────────────────────────────────────────── */
.cat-chip-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cat-chip-row.wrap { margin-bottom: 12px; }
.cat-chip {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--fg-soft); transition: border-color 0.12s, transform 0.12s;
}
.cat-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.cat-chip-count { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-chip-arrow { margin-left: 2px; color: var(--faint); display: inline-flex; }
.cat-chip-critical { border-left: 3px solid var(--bad); }
.cat-chip-critical .cat-chip-count { color: var(--bad); }
.cat-chip-warn { border-left: 3px solid var(--warn); }
.cat-chip-warn .cat-chip-count { color: var(--warn); }
.cat-chip-info { border-left: 3px solid var(--info); }
.cat-chip-muted { border-left: 3px solid var(--faint); }

/* ── Mini tables / bar charts ─────────────────────────────────────────────── */
.mini-table { display: flex; flex-direction: column; }
.mini-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label val" "sub val"; gap: 0 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); align-items: center; }
.mini-row:last-child { border-bottom: none; }
.mini-row.clickable { cursor: pointer; border-radius: 6px; padding-left: 8px; padding-right: 8px; }
.mini-row.clickable:hover { background: var(--card-2); }
.mini-row-label { grid-area: label; font-weight: 600; }
.mini-row-sub { grid-area: sub; font-size: 11.5px; }
.mini-row-val { grid-area: val; }

.barchart { display: flex; flex-direction: column; gap: 8px; }
.barchart-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; padding: 3px 2px; border-radius: 6px; }
.barchart-row.clickable { cursor: pointer; }
.barchart-row.clickable:hover { background: var(--card-2); }
.barchart-label { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barchart-track { height: 20px; background: var(--bg-2); border-radius: 5px; overflow: hidden; }
.barchart-fill { height: 100%; border-radius: 5px; min-width: 2px; transition: width 0.3s; }
.barchart-value { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 34px; }
.barchart-sub { font-weight: 400; color: var(--muted); font-size: 11px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--card-2);
  text-align: left; font-weight: 650; font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px; padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--fg); }
.data-table thead th.sorted { color: var(--accent); }
.sort-arrow { font-size: 9px; }
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.row-clickable { cursor: pointer; }
.data-table tbody tr.row-clickable:hover { background: var(--card-2); }
.align-right { text-align: right; }
.align-right .count-cell, .align-right span { font-variant-numeric: tabular-nums; }
.align-center { text-align: center; }
.empty-cell { text-align: center; color: var(--muted); padding: 28px; }

.company-name { font-weight: 600; }
.vt-name { font-weight: 500; }
.muted { color: var(--muted); }
.muted-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.strong-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.sla-strict { color: var(--purple); font-weight: 700; }
.link-plain { color: var(--fg); font-weight: 600; }
.link-plain:hover { color: var(--accent); }

.pct-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.pct-ok { color: var(--good); }
.pct-warn { color: var(--warn); }
.pct-bad { color: var(--bad); }

.count-cell { font-variant-numeric: tabular-nums; font-weight: 600; }
.count-alarm { color: #fff; background: var(--bad); padding: 2px 8px; border-radius: 20px; font-weight: 700; display: inline-block; min-width: 22px; text-align: center; }
.count-warn { color: var(--warn); font-weight: 700; }
.count-zero { color: var(--faint); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.status-badge, .cat-badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.2px; white-space: nowrap;
}
.st-active { background: var(--bad-bg); color: var(--bad); }
.st-pending { background: var(--info-bg); color: var(--info); }
.st-holding { background: var(--warn-bg); color: var(--warn); }
.st-admin { background: var(--bg-2); color: var(--fg-soft); }
.st-resolved { background: var(--good-bg); color: var(--good); }
.st-canceled { background: var(--bg-2); color: var(--muted); }
.st-other { background: var(--bg-2); color: var(--muted); }

.cat-badge { border: 1px solid transparent; }
.cat-breach { background: var(--bad-bg); color: var(--bad); border-color: rgba(207,67,60,0.28); }
.cat-sync { background: var(--warn-bg); color: var(--warn); border-color: rgba(207,129,20,0.28); }
.cat-waiting { background: var(--info-bg); color: var(--info); }
.cat-hold { background: var(--bg-2); color: var(--fg-soft); }
.cat-other { background: var(--bg-2); color: var(--muted); }

/* Churn-risk tier */
.tier-badge { font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 2px 8px; letter-spacing: 0.2px; text-transform: uppercase; }
.tier-badge.tier-critical { background: var(--bad-bg); color: var(--bad); }
.tier-badge.tier-high { background: var(--warn-bg); color: var(--warn); }
.tier-badge.tier-watch { background: var(--info-bg); color: var(--info); }

.age-hot { color: var(--bad); font-weight: 700; font-variant-numeric: tabular-nums; }
.age-warn { color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; }
/* Breach idle cell: idle time + a muted "on patient" tag when it isn't counting against us. */
.breach-idle { display: inline-flex; align-items: baseline; gap: 6px; justify-content: flex-end; }
.breach-waiton { font-size: 10px; font-weight: 700; color: var(--muted); background: var(--bg-2); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.age-normal { font-variant-numeric: tabular-nums; }

/* ── Copy-id chip ─────────────────────────────────────────────────────────── */
.copy-id {
  display: inline-flex; align-items: center; gap: 6px; max-width: 320px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 7px; cursor: pointer; font-family: var(--mono); font-size: 11.5px; color: var(--fg-soft);
}
.copy-id:hover { border-color: var(--accent); color: var(--accent); }
.copy-id.copied { border-color: var(--good); color: var(--good); }
.copy-id-text { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-icon svg { width: 12px; height: 12px; flex: none; }
.copy-id.copied .copy-icon::after { content: " ✓"; }

/* ── Toolbar / filters ────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-icon { position: absolute; left: 10px; color: var(--faint); display: inline-flex; pointer-events: none; }
.search-icon svg { width: 15px; height: 15px; }
.filter-input {
  padding: 8px 12px 8px 32px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--fg); font-size: 13px; min-width: 260px;
}
.filter-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,125,233,0.14); }
.select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  color: var(--fg); font-size: 13px; cursor: pointer;
}
.select:focus { outline: none; border-color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg-soft); cursor: pointer; user-select: none; }
.chk { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.result-count { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-left: auto; font-variant-numeric: tabular-nums; }

.active-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--info-bg); color: var(--info); border-radius: 20px; padding: 4px 6px 4px 12px; font-size: 12px; font-weight: 600; }
.chip-x { border: none; background: rgba(0,0,0,0.08); color: inherit; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; }
.chip-x:hover { background: rgba(0,0,0,0.16); }

/* ── Category tabs ────────────────────────────────────────────────────────── */
.cat-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.cat-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--fg-soft);
}
.cat-tab:hover { border-color: var(--border-strong); }
.cat-tab.active { background: var(--fg); color: var(--card); border-color: var(--fg); }
.cat-tab-count { font-size: 12px; font-weight: 700; background: var(--bg-2); color: var(--fg-soft); padding: 1px 7px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.cat-tab.active .cat-tab-count { background: rgba(255,255,255,0.2); color: #fff; }
.cat-tab.tab-critical.active { background: var(--bad); border-color: var(--bad); }
.cat-tab.tab-warn.active { background: var(--warn); border-color: var(--warn); }
.cat-tab.tab-info.active { background: var(--info); border-color: var(--info); }

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented { display: inline-flex; background: var(--bg-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg-btn { border: none; background: transparent; padding: 6px 14px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { color: var(--fg); }
.seg-btn.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm); }
.seg-count { font-size: 11px; background: var(--bg); padding: 0 6px; border-radius: 10px; }

/* ── Buttons / breadcrumbs ────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; border: none; cursor: pointer; }
.btn:hover { background: #1b6fd6; text-decoration: none; }
.btn svg { width: 15px; height: 15px; }

.breadcrumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 12px; color: var(--muted); }
.crumb { color: var(--muted); font-weight: 500; }
.crumb.current { color: var(--fg); font-weight: 600; }
.crumb-sep { color: var(--faint); }

/* ── Partner-detail extras ────────────────────────────────────────────────── */
.mini-cat { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 8px 12px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--border); min-width: 88px; }
.mini-cat.zero { opacity: 0.55; }
.mini-cat-count { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mini-cat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.mini-cat-critical .mini-cat-count { color: var(--bad); }
.mini-cat-warn .mini-cat-count { color: var(--warn); }
.mini-cat-info .mini-cat-count { color: var(--info); }

.inline-breach-list { margin-top: 12px; display: flex; flex-direction: column; gap: 3px; }
.inline-breach-head { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.inline-breach-row { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 5px 2px; border-bottom: 1px solid var(--border); }
.inline-breach-row:last-child { border-bottom: none; }
.ib-age { color: var(--bad); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.good-note { margin-top: 12px; color: var(--good); font-weight: 600; font-size: 13px; }

.mini-kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.mini-kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.4px; }
.mini-kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }
.mini-kpi-warn .mini-kpi-value { color: var(--warn); }
.mini-kpi-good .mini-kpi-value { color: var(--good); }
.kpi-grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); max-width: 720px; }

/* ── Charts ───────────────────────────────────────────────────────────────── */
.linechart { position: relative; width: 100%; }
.linechart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-axis { font-size: 10px; font-family: var(--font); }
.chart-empty { fill: var(--muted); font-size: 13px; }
.lc-overlay { cursor: crosshair; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 8px; box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; min-width: 128px;
  transition: opacity 0.08s; z-index: 5;
}
.chart-tip-date { font-weight: 700; margin-bottom: 5px; font-size: 11.5px; }
.chart-tip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 2px; }
.chart-tip-key { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-soft); }
.chart-tip-key .dot { width: 8px; height: 8px; border-radius: 50%; }
.chart-tip-val { font-weight: 700; font-variant-numeric: tabular-nums; }

.trend-charts { margin-top: 4px; }
.trend-toolbar { justify-content: flex-start; gap: 16px; }
.trend-note { margin-bottom: 14px; font-size: 12.5px; font-weight: 500; }
.trend-note.muted { color: var(--muted); font-weight: 400; }

/* ── Empty / loading ──────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-icon { display: inline-flex; color: var(--faint); margin-bottom: 12px; }
.empty-icon svg { width: 40px; height: 40px; }
.empty-msg { font-size: 15px; font-weight: 600; color: var(--fg-soft); }
.empty-sub { font-size: 13px; margin-top: 6px; max-width: 52ch; margin-left: auto; margin-right: auto; }
.empty-note { color: var(--muted); font-size: 13px; padding: 8px; }

.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px; color: var(--muted); font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex: none; flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
  .brand { padding: 0 14px 0 4px; }
  .sidebar-nav { flex-direction: row; margin-top: 0; }
  .sidebar-foot { display: none; }
  .nav-label { display: none; }
  .nav-item { padding: 9px; }
  .content { height: auto; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .fresh-quick { padding-left: 0; border-left: none; }
  .page-head { flex-direction: column; }
}

/* ── Nav sections and badges ──────────────────────────────────────────────── */
.nav-section { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--side-muted); padding: 15px 12px 5px; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: inline-grid; place-items: center; padding: 0 5px; }
.nav-item.active .nav-badge { background: #fff; color: var(--bad); }

/* ── Client demand: per-partner list ──────────────────────────────────────── */
.visit-company-list { display: flex; flex-direction: column; }
.visit-company-row { display: grid; grid-template-columns: 1fr auto minmax(90px, 160px) 20px; gap: 14px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.visit-company-row:last-child { border-bottom: none; }
.visit-company-row:hover { background: var(--card-2); }
.vcr-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vcr-total { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; white-space: nowrap; }
.vcr-total-label { font-weight: 400; color: var(--muted); font-size: 11px; }
.vcr-spark { display: flex; justify-content: flex-end; }
.vcr-arrow { color: var(--faint); display: inline-flex; }
.vcr-arrow svg { width: 14px; height: 14px; }

/* ── Provider load: mix chips ─────────────────────────────────────────────── */
.mix-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.mix-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; }
.mix-chip-label { color: var(--fg-soft); }
.mix-chip-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.mix-chip-bar { height: 4px; border-radius: 2px; background: var(--accent); display: inline-block; opacity: 0.5; }
.mix-more { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ── Alert sections and cards ─────────────────────────────────────────────── */
.title-count { font-size: 14px; font-weight: 700; background: var(--bad); color: #fff; border-radius: 12px; padding: 2px 10px; vertical-align: middle; }
.alert-section { margin-bottom: 26px; }
.alert-section-head { margin-bottom: 12px; }
.alert-section-title { font-size: 15px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 9px; }
.alert-count { font-size: 12px; font-weight: 700; background: var(--bg-2); color: var(--muted); border-radius: 12px; padding: 1px 9px; }
.alert-count.has { background: var(--bad); color: #fff; }
.alert-section-help { font-size: 12px; color: var(--muted); margin: 5px 0 0; max-width: 96ch; }
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-clear { display: flex; align-items: center; gap: 8px; color: var(--good); font-size: 13px; font-weight: 600; padding: 6px 2px; }
.ok-check { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--good-bg); color: var(--good); font-weight: 700; }
.alert-card { display: flex; gap: 13px; background: var(--card); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.alert-card.alert-critical { border-left-color: var(--bad); }
.alert-card.alert-warn { border-left-color: var(--warn); }
.alert-card-icon { flex: none; width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); }
.alert-card.alert-critical .alert-card-icon { color: var(--bad); }
.alert-card.alert-warn .alert-card-icon { color: var(--warn); }
.alert-card-icon svg { width: 20px; height: 20px; }
.alert-card-body { flex: 1; min-width: 0; }
.alert-card-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.alert-card-title { font-weight: 700; font-size: 14px; }
.alert-badge { font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 1px 7px; letter-spacing: 0.2px; }
.alert-badge-critical { background: var(--bad-bg); color: var(--bad); }
.alert-badge-warn { background: var(--warn-bg); color: var(--warn); }
.alert-card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.alert-card-row { font-size: 13px; color: var(--fg-soft); margin-top: 6px; line-height: 1.5; }
.alert-card-row strong { font-variant-numeric: tabular-nums; color: var(--fg); }
.alert-card-msg { font-size: 12.5px; color: var(--muted); margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--border); }
.zero-strong { color: var(--bad); }

/* ── Provider alerts: cherry-picking table ────────────────────────────────── */
.cherry-panel { margin-top: 2px; }
.cp-conc { display: inline-flex; align-items: baseline; gap: 8px; }
.cp-conc-type { font-weight: 600; }
.cp-conc-pct { font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums; }
.cp-skips { display: flex; flex-wrap: wrap; gap: 5px; }
.cp-skip { display: inline-block; background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; cursor: help; }

/* ── Onboarding stage pill and 4-step progress bar ──────────────────────────── */
.onb-stagepill { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 8px; white-space: nowrap; }
.onb-stage-kickoff { color: var(--muted); background: var(--bg-2); }
.onb-stage-build { color: var(--purple); background: rgba(122, 92, 240, 0.14); }
.onb-stage-test { color: var(--accent); background: var(--info-bg); }
.onb-stage-prod { color: var(--good); background: var(--good-bg); }
.onb-stage-none { color: var(--muted); background: var(--bg-2); font-weight: 600; }
.onb-stagebar { display: flex; gap: 3px; }
.onb-stageseg { height: 4px; width: 22px; border-radius: 2px; background: var(--border); }
.onb-stageseg.on { background: var(--accent-2); }

/* ── Attio relationship and Slack status (partner detail) ─────────────────── */
.slack-chip { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 1px 7px; white-space: nowrap; cursor: help; }
.slack-chip.slack-silent { color: var(--bad); background: var(--bad-bg); }
.slack-chip.slack-owe { color: var(--warn); background: var(--warn-bg); }
.slack-chip.slack-ok { color: var(--muted); background: var(--card-2, rgba(127,127,127,0.10)); font-weight: 600; }

.outreach-block { display: flex; flex-direction: column; gap: 8px; }
.outreach-row { display: flex; gap: 12px; align-items: baseline; font-size: 13px; }
.outreach-k { flex: none; width: 108px; color: var(--muted); font-size: 12px; }
.outreach-v { flex: 1; min-width: 0; }
.outreach-v strong { font-variant-numeric: tabular-nums; }
.outreach-dnc-banner { font-size: 12px; font-weight: 700; color: var(--bad); background: var(--bad-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; }
.outreach-match { font-size: 11px; margin-top: 2px; padding-top: 8px; border-top: 1px dashed var(--border); }
.pct-muted { color: var(--muted); }

/* ── Pharmacy fulfillment ──────────────────────────────────────────────────── */
.ff-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ff-kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 16px; }
.ff-kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--fg); line-height: 1.1; font-variant-numeric: tabular-nums; }
.ff-kpi-label { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 5px; text-transform: uppercase; letter-spacing: 0.03em; }
.ff-kpi-sub { font-size: 12px; color: var(--faint); margin-top: 3px; }

.ff-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 2px 0 12px; }
.ff-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.ff-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.ff-pipeline { display: flex; flex-wrap: wrap; gap: 8px; }
.ff-stage { flex: 1 1 92px; min-width: 88px; background: var(--card-2); border: 1px solid var(--border); border-top: 3px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; }
.ff-stage-count { font-size: 20px; font-weight: 700; color: var(--fg); line-height: 1.1; font-variant-numeric: tabular-nums; }
.ff-stage-label { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 4px; text-transform: capitalize; }
.ff-stage-info { border-top-color: var(--info); }
.ff-stage-accent { border-top-color: var(--accent); }
.ff-stage-good { border-top-color: var(--good); }
.ff-stage-muted { border-top-color: var(--muted); }
.ff-stage-neutral { border-top-color: var(--border-strong); }

/* ── Beluga macro ──────────────────────────────────────────────────────────── */
.mac-bf { font-size: 10px; font-weight: 800; letter-spacing: 0.04em; color: var(--good); background: var(--good-bg); border-radius: 4px; padding: 1px 5px; }
.mac-vtgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 20px; }
.mac-vtblock { min-width: 0; }
.mac-vthead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 650; margin-bottom: 8px; text-transform: capitalize; }

/* ── Outreach queue ───────────────────────────────────────────────────────── */
.oq-table td { vertical-align: middle; }
.oq-acct { display: flex; flex-direction: column; gap: 4px; }
.oq-acct-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.oq-seg { font-size: 10px; font-weight: 800; letter-spacing: 0.03em; border-radius: 4px; padding: 1px 6px; text-transform: uppercase; }
.oq-seg-live { color: var(--good); background: var(--good-bg); }
.oq-seg-pre { color: var(--accent); background: var(--info-bg); }
.oq-crm { align-self: flex-start; font-size: 10px; font-weight: 700; color: var(--muted); background: var(--bg-2); border: 1px dashed var(--border-strong); border-radius: 4px; padding: 1px 6px; cursor: help; }

.oq-reasons { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }
.oq-chip { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.oq-chip-critical { color: var(--bad); background: var(--bad-bg); }
.oq-chip-warn { color: var(--warn); background: var(--warn-bg); }
.oq-chip-info { color: var(--accent); background: var(--info-bg); }
.oq-chip-muted { color: var(--muted); background: var(--bg-2); }

.oq-signal { display: flex; align-items: center; gap: 8px; }
.oq-signal-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.oq-signal-sub { font-size: 11.5px; white-space: nowrap; }
.oq-stage { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.oq-last { font-variant-numeric: tabular-nums; white-space: nowrap; }
.oq-route { display: flex; flex-direction: column; gap: 1px; }
.oq-route-role { font-size: 11px; }
.oq-bf { font-size: 10.5px; font-weight: 700; color: var(--fg-soft); background: var(--bg-2); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.oq-bf-yes { color: var(--good); background: var(--good-bg); }
.oq-vts { display: inline-flex; gap: 4px; flex-wrap: wrap; max-width: 200px; }
.oq-vt { font-size: 10px; color: var(--muted); background: var(--bg-2); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.oq-vt-more { font-size: 10px; color: var(--muted); font-weight: 700; }

/* ── Sales follow-up ──────────────────────────────────────────────────────── */
/* "read-only" tag beside the page title. */
.readonly-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--muted); background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 9px; vertical-align: middle;
}
.sf-tile { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.sf-tile:hover { border-color: var(--accent); }
.sf-stack { display: flex; flex-direction: column; gap: 2px; }
.sf-sub { font-size: 11.5px; }
.sf-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.alert-badge-muted { background: var(--bg-2); color: var(--muted); }
.sf-nobody { color: var(--bad); font-weight: 600; }
.sf-warn { border-color: var(--warn); color: var(--warn); margin-bottom: 14px; }
.sf-owner-sum { margin: 0 0 10px; }

/* ── Provider coverage, and the Outreach Labs / Pharmacy column ───────────── */
.alert-badge-good { background: var(--good-bg); color: var(--good); }
.cov-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cov-docinfo { font-size: 13px; margin-bottom: 10px; color: var(--fg); }
.oq-usage-wrap { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.oq-usage { font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--info-bg); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }

/* ── Client health ────────────────────────────────────────────────────────── */
.oq-chip-good { color: var(--good); background: var(--good-bg); }
.cat-tab.tab-good.active { background: var(--good); border-color: var(--good); }
.cat-tab.tab-muted.active { background: var(--muted); border-color: var(--muted); }
.ch-up { color: var(--good); font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-down { color: var(--bad); font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-stack { display: flex; flex-direction: column; gap: 2px; }
.ch-sub { font-size: 11.5px; }

/* ── State map (components/statemap.js) ───────────────────────────────────── */
.smap { position: relative; width: 100%; }
.smap-grid { display: block; width: 100%; height: auto; overflow: visible; }
.smap-tile { outline: none; }
.smap-tile rect { transition: stroke 0.12s ease; }
.smap-tile.clickable { cursor: pointer; }
.smap-tile.clickable:hover rect,
.smap-tile:focus-visible rect { stroke: var(--fg); stroke-width: 2; }
.smap-tile.smap-selected rect { stroke: var(--fg); stroke-width: 2.5; }
.smap-abbr { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700; user-select: none; pointer-events: none; }
.smap-tip { position: absolute; left: 0; top: 0; transform: translateX(-50%);
  max-width: 220px; background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  font-size: 12px; line-height: 1.35; pointer-events: none; opacity: 0;
  transition: opacity 0.1s ease; box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  z-index: 20; white-space: normal; }
.smap-tip-name { font-weight: 700; }
.smap-tip-val { color: var(--fg-soft, var(--fg)); font-variant-numeric: tabular-nums; }
.smap-tip-sub { color: var(--muted); font-size: 11px; margin-top: 1px; }
.smap-legend { display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.smap-legend-bar { height: 9px; width: 120px; max-width: 40vw; border-radius: 5px;
  border: 1px solid var(--border); }
.smap-empty-note { color: var(--muted); font-size: 12px; margin-top: 8px; }
