/* Outbound Engine MIS — design system.
   Light theme in the stamina.io design language: shadcn/ui conventions,
   Untitled UI color scale, Lucide-style outline icons, Inter everywhere.
   Organization: tokens → base → layout → components → views → responsive. */

/* The [hidden] attribute must always win, even over component display rules
   (otherwise the drawer/scrim/badges show when they should be hidden). */
[hidden] { display: none !important; }

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  /* surfaces */
  --background: #ffffff;
  --card: #ffffff;
  --muted: #f5f5f5;
  --border: #e9eaeb;
  --sidebar-bg: #fafafa;
  --sidebar-border: #e4e4e7;
  --sidebar-fg: #3f3f46;
  --sidebar-accent: #f4f4f5;      /* hover/active nav bg */

  /* text */
  --fg: #181d27;
  --fg-secondary: #535862;
  --fg-muted: #717680;
  --fg-faint: #a4a7ae;

  /* action */
  --primary: #0f172a;             /* near-black primary buttons */
  --primary-fg: #f8fafc;
  --accent-blue: #2e90fa;
  --accent-blue-strong: #1570ef;
  --accent-blue-soft: #eff8ff;

  /* semantic (Untitled UI) */
  --success: #16b364;
  --success-strong: #099250;
  --success-soft: #edfcf2;
  --success-pill-bg: #d3f8df;
  --warning: #f79009;
  --warning-strong: #dc6803;
  --warning-soft: #fffaeb;
  --warning-pill-bg: #fef0c7;
  --danger: #d92d20;
  --danger-mid: #f04438;
  --danger-soft: #fef3f2;
  --danger-pill-bg: #fee4e2;
  --brand-purple: #7a5af8;
  --brand-purple-soft: #f1edfd;
  --info-indigo: #6172f3;

  --radius: 0.5rem;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --ring: #94a3b8;
  --font-sans: 'Inter', ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgb(0 0 0/.05);
  --shadow-pop: 0 10px 15px -3px rgb(0 0 0/.1), 0 4px 6px -4px rgb(0 0 0/.1);

  --sidebar-w: 248px;

  /* spacing scale: 4 / 8 / 12 / 16 / 24 / 32 */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;

  /* track + reply-category palette (semantic + extended, light theme) */
  --c-positive: var(--success);
  --c-negative: var(--danger-mid);
  --c-operational: var(--warning);
  --c-interested: var(--success);
  --c-objection: var(--accent-blue);
  --c-question: var(--info-indigo);
  --c-not_now: var(--warning);
  --c-not_interested: var(--danger-mid);
  --c-unsubscribe: var(--danger);
  --c-out_of_office: var(--fg-faint);
  --c-wrong_person: var(--brand-purple);
  --c-instantly: var(--accent-blue);
}

/* ============================================================
   2. BASE
   ============================================================ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--background);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--font-mono); font-size: .9em; }
.mono { font-family: var(--font-mono); font-size: .95em; font-variant-numeric: tabular-nums; }
.err { color: var(--danger); }
.ink-2 { color: var(--fg-secondary); }
.ink-3 { color: var(--fg-muted); }
.mono-sm { font-family: var(--font-mono); font-size: 12px; }
.score { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Visible keyboard focus everywhere (mouse clicks stay clean via :focus-visible). */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Lucide-style inline icons */
.ico { flex: none; vertical-align: -3px; }

/* ============================================================
   3. LAYOUT — shell, sidebar, topbar, view chrome
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- API-down banner ---------- */
.api-down {
  background: var(--danger-soft); color: var(--danger);
  border-bottom: 1px solid var(--danger-pill-bg); padding: 10px 24px; font-size: 13px;
}
.api-down code { background: rgb(0 0 0/.05); padding: 1px 6px; border-radius: 4px; }
.api-down button {
  margin-left: 4px; border: 1px solid var(--danger); background: transparent;
  color: var(--danger); padding: 3px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font: inherit; font-weight: 500; transition: all .12s;
}
.api-down button:hover { background: var(--danger); color: #fff; }

/* ---------- Sidebar (light) ---------- */
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  padding: var(--s-4) var(--s-3); gap: var(--s-4);
}
.brand { display: flex; align-items: center; gap: 10px; padding: var(--s-1) var(--s-2); }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--primary);
  position: relative; flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 8px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; border-bottom-left-radius: 3px;
}
.brand-text h1 { font-size: 14px; font-weight: 600; color: var(--fg); line-height: 1.2; }
.brand-text p { margin: 0; font-size: 11px; color: var(--fg-muted); line-height: 1.3; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-faint); padding: var(--s-3) var(--s-2) var(--s-1);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-fg); font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item .ico { color: var(--fg-muted); transition: color .12s; }
.nav-item:hover { background: var(--sidebar-accent); color: var(--fg); }
.nav-item:hover .ico { color: var(--fg-secondary); }
.nav-item.active { background: var(--sidebar-accent); color: var(--fg); font-weight: 600; }
.nav-item.active .ico { color: var(--fg); }

.nav-badge {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  background: var(--warning-pill-bg); color: var(--warning-strong);
  border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center;
}

.sidebar-foot {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding-top: var(--s-3); border-top: 1px solid var(--sidebar-border);
}
.attention {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); color: var(--fg-secondary);
  font-size: 12px; font-weight: 500; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .12s, background .12s;
}
.attention:hover { border-color: var(--fg-faint); background: var(--muted); }
.attention .na-count { font-family: var(--font-mono); font-weight: 600; color: var(--fg); }
.conn {
  display: flex; align-items: center; gap: 8px; font-size: 11px;
  color: var(--fg-muted); padding: 0 var(--s-2); letter-spacing: .02em;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint); flex: none; }
.conn-dot.up { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.conn-dot.down { background: var(--danger-mid); box-shadow: 0 0 0 3px var(--danger-soft); }

/* ---------- Main column + topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--background); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-5);
  padding: 10px var(--s-6); background: var(--background);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.switcher { display: flex; align-items: center; gap: var(--s-2); font-size: 11px; font-weight: 600; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .06em; }
.switcher select {
  font: inherit; font-size: 13.5px; font-weight: 500; text-transform: none; letter-spacing: 0;
  color: var(--fg);
  padding: 6px 30px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23717680' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; cursor: pointer; min-width: 240px; box-shadow: var(--shadow-sm);
  transition: border-color .12s;
}
.switcher select:hover { border-color: var(--fg-faint); }
.topbar-right { display: flex; align-items: center; gap: var(--s-3); }
.mode-toggle {
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px 5px 28px;
  background: var(--card); color: var(--fg-secondary); position: relative;
  box-shadow: var(--shadow-sm); transition: all .12s;
}
.mode-toggle::before {
  content: ""; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--fg-faint);
}
.mode-toggle[data-mode="admin"] { color: var(--accent-blue-strong); border-color: #b2ddff; background: var(--accent-blue-soft); }
.mode-toggle[data-mode="admin"]::before { background: var(--accent-blue); }
.mode-toggle[data-mode="client"]::before { background: var(--warning); }
.mode-toggle:hover { border-color: var(--fg-faint); }

/* ---------- Health alert banner ---------- */
.health-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--s-6); font-size: 13px; font-weight: 500;
  background: var(--warning-soft); color: var(--warning-strong);
  border-bottom: 1px solid var(--warning-pill-bg);
}
.health-banner[data-severity="critical"] { background: var(--danger-soft); color: var(--danger); border-bottom-color: var(--danger-pill-bg); }
.hb-mark { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.hb-msg { font-weight: 600; }
.hb-view {
  margin-left: var(--s-2); font-size: 12px; font-weight: 600; padding: 2px 12px;
  border-radius: 999px; border: 1px solid currentColor; color: inherit; transition: all .12s;
}
.health-banner .hb-view:hover { background: var(--warning-strong); color: #fff; border-color: var(--warning-strong); }
.health-banner[data-severity="critical"] .hb-view:hover { background: var(--danger); border-color: var(--danger); }
.hb-dismiss {
  margin-left: auto; border: 0; background: none; cursor: pointer; color: inherit;
  font-size: 20px; line-height: 1; padding: 0 4px; opacity: .65; transition: opacity .12s;
  border-radius: var(--radius-sm);
}
.hb-dismiss:hover { opacity: 1; }

/* ---------- View chrome ---------- */
.view { padding: var(--s-5) var(--s-6) var(--s-6); max-width: 1400px; margin: 0 auto; width: 100%; }
.loading { color: var(--fg-muted); }
section.block { margin-bottom: var(--s-6); }
section.block:last-child { margin-bottom: 0; }
.block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--s-3); padding-bottom: var(--s-2); gap: var(--s-3);
  border-bottom: 1px solid var(--border);
}
.block-head h2 { font-size: 14px; font-weight: 600; color: var(--fg); }
.block-head .sub { font-size: 12px; color: var(--fg-muted); text-align: right; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); align-items: start; }
.two-col > .block { margin-bottom: var(--s-6); }

.page-head {
  margin-bottom: var(--s-5); padding-bottom: var(--s-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
}
.page-head .eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-faint); font-weight: 600; }
.page-head h2 { font-size: 22px; font-weight: 600; line-height: 1.2; margin-top: 4px; letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--fg-secondary); font-size: 13.5px; max-width: 76ch; line-height: 1.55; }
.page-head h2 .pill { font-size: 11.5px; vertical-align: middle; margin-left: 6px; }
.page-head-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ============================================================
   4. COMPONENTS
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
  padding: 6px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  transition: all .12s;
}
.btn:hover:not(:disabled) { background: var(--muted); border-color: var(--fg-faint); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover:not(:disabled) { background: #1e293b; border-color: #1e293b; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger:hover:not(:disabled) { background: #b42318; border-color: #b42318; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--fg-secondary); }
.btn.ghost:hover:not(:disabled) { background: var(--muted); color: var(--fg); }
.btn:disabled { opacity: .55; cursor: default; box-shadow: none; }
.btn .ico { vertical-align: -2px; }

/* ---------- KPI / metric cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: var(--s-4); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s-4); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: #d5d7da; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 18px; }
.card .label { font-size: 13px; color: var(--fg-muted); font-weight: 500; }
.card .value { font-size: 28px; font-weight: 600; line-height: 1.15; margin-top: var(--s-2); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card .value.mono { font-family: var(--font-sans); }
.card.flag { border-color: var(--danger-pill-bg); background: var(--danger-soft); }
.card.flag .value { color: var(--danger); }
.card .hint { font-size: 12px; color: var(--fg-muted); margin-top: var(--s-1); }
.card .delta { font-size: 12.5px; font-weight: 600; margin-top: var(--s-1); }
.card .delta.up { color: var(--success-strong); }
.card .delta.down { color: var(--danger); }

/* honest-sourcing tag */
.src {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap; line-height: 1.4;
}
.src-instantly { background: var(--accent-blue-soft); color: var(--accent-blue-strong); }
.src-brain { background: var(--brand-purple-soft); color: var(--brand-purple); }
.src-close { background: var(--warning-soft); color: var(--warning-strong); }
.src-derived { background: var(--muted); color: var(--fg-secondary); }

/* ---------- Panels ---------- */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s-4) var(--s-4); box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s-3); }
.panel-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-muted); font-weight: 600; }
.panel-sub { font-size: 12px; color: var(--fg-muted); }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap; letter-spacing: .01em;
}
.pill.positive { background: var(--success-pill-bg); color: var(--success-strong); }
.pill.negative { background: var(--danger-pill-bg); color: var(--danger); }
.pill.operational { background: var(--warning-pill-bg); color: var(--warning-strong); }
.pill.neutral { background: var(--muted); color: var(--fg-secondary); }
.pill.accent { background: var(--accent-blue-soft); color: var(--accent-blue-strong); }
.pill.brand { background: var(--brand-purple-soft); color: var(--brand-purple); }
.pill.flag { background: var(--danger-pill-bg); color: var(--danger); box-shadow: inset 0 0 0 1px rgb(217 45 32/.18); }
.pill.client { background: var(--card); color: var(--fg-secondary); font-family: var(--font-mono); font-weight: 500; font-size: 11px; box-shadow: inset 0 0 0 1px var(--border); }
.pill.nodata { background: var(--muted); color: var(--fg-faint); font-weight: 500; }
.pill.below90 { letter-spacing: .04em; font-size: 10.5px; padding: 1px 8px; }

/* ---------- Bars (light gridlines, semantic series) ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 44px; align-items: center; gap: var(--s-3); font-size: 13px; }
.bar-row .name { color: var(--fg-secondary); text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--muted); border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; min-width: 3px; transition: width .35s cubic-bezier(.2,.7,.3,1); }
.bar-row .n { text-align: right; font-family: var(--font-mono); color: var(--fg); font-variant-numeric: tabular-nums; }
.fill-positive { background: var(--c-positive); }
.fill-negative { background: var(--c-negative); }
.fill-operational { background: var(--c-operational); }
.fill-neutral, .fill-instantly { background: var(--c-instantly); }

/* ---------- Donut ---------- */
.donut-wrap { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.donut { width: 136px; height: 136px; flex: none; }
.donut-empty { fill: none; stroke: var(--muted); stroke-width: 17; }
.donut-seg { transition: stroke-dasharray .45s cubic-bezier(.2,.7,.3,1); }
.donut-total { font-family: var(--font-sans); font-weight: 600; font-size: 24px; fill: var(--fg); text-anchor: middle; }
.donut-cap { font-size: 8.5px; fill: var(--fg-faint); text-anchor: middle; text-transform: uppercase; letter-spacing: .1em; }
.legend { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 176px; }
.legend-row { display: grid; grid-template-columns: 13px 1fr auto auto; align-items: center; gap: var(--s-2); font-size: 13px; padding: 3px 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-name { color: var(--fg-secondary); text-transform: capitalize; }
.legend-n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.legend-pct { font-family: var(--font-mono); color: var(--fg-muted); width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.legend-row.zero { opacity: .45; }

/* ---------- Funnel ---------- */
.funnel-panel { padding: var(--s-4); }
.funnel { display: flex; flex-direction: column; gap: var(--s-3); }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 48px 104px; align-items: center; gap: var(--s-3); font-size: 13px; }
.funnel-label { color: var(--fg); font-weight: 500; display: flex; align-items: center; gap: var(--s-2); }
.funnel-track { background: var(--muted); border-radius: var(--radius-sm); height: 24px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: var(--radius-sm); min-width: 4px; transition: width .4s cubic-bezier(.2,.7,.3,1); }
.funnel-n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel-rate { font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.metrics-note { font-size: 12.5px; color: var(--fg-secondary); margin: var(--s-4) 0 0; line-height: 1.6; padding-top: var(--s-3); border-top: 1px solid var(--border); }
.dot-key { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 4px 0 2px; vertical-align: middle; }
.dot-key.instantly { background: var(--c-instantly); }
.dot-key.positive { background: var(--c-positive); }

/* ---------- Tables (no zebra, hairline rows, hover #fafafa) ---------- */
.tablewrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 8px 10px; font-size: 12px; font-weight: 500;
  color: var(--fg-muted); background: var(--card); border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th.num, td.num { text-align: right; }
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--sidebar-bg); }
tbody tr.clickable { cursor: pointer; }
td .lead-name, .lead-name { font-weight: 500; color: var(--fg); }
td .lead-sub, .lead-sub { color: var(--fg-muted); font-size: 12px; margin-top: 1px; }
td.num .mono { font-variant-numeric: tabular-nums; }
.row-go { color: var(--accent-blue-strong); font-weight: 600; font-size: 12.5px; opacity: 0; transition: opacity .12s; }
tbody tr.clickable:hover .row-go { opacity: 1; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: var(--s-3); align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--s-4); }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .05em; }
.filters select, .filters input[type="search"] {
  font: inherit; font-size: 13.5px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--fg);
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); min-width: 150px; box-shadow: var(--shadow-sm);
  transition: border-color .12s;
}
.filters select {
  padding-right: 28px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23717680' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.filters input:hover, .filters select:hover { border-color: var(--fg-faint); }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgb(148 163 184/.2); }
.filters .count { font-size: 12.5px; color: var(--fg-muted); margin-left: auto; align-self: center; }

/* ---------- Reputation / health bars ---------- */
.rep { display: flex; align-items: center; gap: 10px; }
.rep-track { width: 110px; height: 6px; background: var(--muted); border-radius: 999px; overflow: hidden; flex: none; }
.rep-fill { height: 100%; border-radius: 999px; transition: width .35s cubic-bezier(.2,.7,.3,1); }
.rep-fill.good { background: var(--success); }
.rep-fill.warn { background: var(--warning); }
.rep-fill.bad { background: var(--danger-mid); }
.rep-val { font-family: var(--font-mono); font-size: 13px; min-width: 40px; font-variant-numeric: tabular-nums; }
.rep-val.good { color: var(--success-strong); }
.rep-val.warn { color: var(--warning-strong); }
.rep-val.bad { color: var(--danger); }

/* sends-today / daily-limit usage bar */
.usage { display: flex; align-items: center; gap: 9px; }
.usage-track { width: 72px; height: 6px; background: var(--muted); border-radius: 999px; overflow: hidden; flex: none; }
.usage-fill { height: 100%; border-radius: 999px; background: var(--accent-blue); transition: width .35s cubic-bezier(.2,.7,.3,1); }
.usage-fill.hot { background: var(--warning); }
.usage-val { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--fg); }
.usage-lim { color: var(--fg-muted); }

/* ---------- Needs attention ---------- */
.na-panel { padding: var(--s-3) var(--s-4); }
.na-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.na-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.na-item:last-child { border-bottom: 0; }
.na-link { color: var(--fg); }
.na-link:hover { color: var(--accent-blue-strong); text-decoration: underline; }
.na-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.na-dot.warn { background: var(--warning); }
.na-dot.bad { background: var(--danger-mid); }
.na-dot.good { background: var(--success); }
.panel-ok { display: flex; align-items: center; gap: 9px; color: var(--fg-secondary); font-size: 13.5px; }

/* ---------- Empty / error states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1); padding: var(--s-6) var(--s-5); text-align: center; }
.empty-mark {
  width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: var(--accent-blue-soft); color: var(--accent-blue-strong);
  display: flex; align-items: center; justify-content: center; margin-bottom: var(--s-2);
}
.empty-mark .ico { width: 26px; height: 26px; }
.empty-msg { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--fg); }
.empty-sub { margin: 0; font-size: 13px; color: var(--fg-muted); max-width: 44ch; line-height: 1.5; }
.empty-state.error .empty-mark { background: var(--danger-soft); color: var(--danger); }
.empty-state.error .empty-msg { color: var(--danger); }
.empty-state .btn { margin-top: var(--s-3); }
.empty { color: var(--fg-muted); font-size: 13px; font-style: italic; }

/* ---------- Skeletons ---------- */
.sk-page { display: flex; flex-direction: column; gap: var(--s-5); }
.sk {
  background: linear-gradient(90deg, var(--muted) 25%, #ededee 37%, var(--muted) 63%);
  background-size: 400% 100%; animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-head { height: 52px; width: 320px; }
.sk-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: var(--s-4); }
.sk-card { height: 96px; } .sk-card.tall { height: 224px; }
.sk-panels { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
.sk-panel { height: 208px; }
.sk-table { height: 300px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: var(--s-5); right: var(--s-5); z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--card); color: var(--fg); border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; max-width: 340px;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast.err { border-left-color: var(--danger); color: var(--danger); }

/* ---------- Drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgb(15 23 42/.32); z-index: 40; animation: scrim-in .2s ease; }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(580px, 94vw);
  background: var(--card); border-left: 1px solid var(--border); z-index: 50;
  display: flex; flex-direction: column; box-shadow: var(--shadow-pop);
  transform: translateX(16px); opacity: .4; transition: transform .22s cubic-bezier(.2,.7,.3,1), opacity .22s ease;
}
.drawer.open { transform: translateX(0); opacity: 1; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); background: var(--card); }
.drawer-head h2 { font-size: 16px; font-weight: 600; }
.drawer-head button {
  font-size: 24px; line-height: 1; border: 0; background: none; cursor: pointer;
  color: var(--fg-muted); padding: 2px 6px; border-radius: var(--radius-sm);
  transition: color .12s, background .12s;
}
.drawer-head button:hover { color: var(--fg); background: var(--muted); }
.drawer-body { overflow-y: auto; padding: var(--s-5); }
.dd-section { margin-bottom: var(--s-5); }
.dd-section > h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin-bottom: var(--s-3); display: flex; align-items: center; gap: 8px; }
.dd-src { margin-left: auto; }
.dd-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.dd-meta .k { font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.dd-meta .v { font-size: 13.5px; margin-top: 1px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 var(--s-4) var(--s-5); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent-blue); }
.timeline .t-type { font-weight: 600; font-size: 13px; text-transform: capitalize; }
.timeline .t-time { font-size: 11.5px; color: var(--fg-muted); font-family: var(--font-mono); }
.timeline .t-detail { font-size: 13px; color: var(--fg-secondary); margin-top: 2px; }

/* message thread */
.msg { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); background: var(--card); }
.msg.inbound { border-left: 3px solid var(--fg-faint); }
.msg.outbound { border-left: 3px solid var(--accent-blue); background: var(--sidebar-bg); }
.msg .msg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.msg .dir { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.msg.inbound .dir { color: var(--fg-secondary); }
.msg.outbound .dir { color: var(--accent-blue-strong); }
.msg .msg-time { font-size: 11.5px; color: var(--fg-muted); font-family: var(--font-mono); }
.msg .msg-body { white-space: pre-wrap; font-size: 13.5px; color: var(--fg); }
.msg .msg-body.muted { color: var(--fg-faint); }
/* Unibox: real email thread — unread emails get an accent edge + a leading dot */
.msg.unread { border-left-color: var(--accent-blue); box-shadow: inset 1px 0 0 var(--accent-blue); }
.msg .dir .unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-blue); margin-right: 6px; vertical-align: middle; }
.email-thread { display: flex; flex-direction: column; }

/* Unibox console header: unread indicator + sync action */
.rc-unibox { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.rc-unibox .act-status { font-size: 12px; color: var(--fg-muted); }

/* decision card */
.decision { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); background: var(--card); box-shadow: var(--shadow-sm); }
.decision .dec-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.decision .dec-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.decision .dec-row.col { flex-direction: column; }
.decision .dec-row .k { color: var(--fg-muted); min-width: 96px; flex: none; }
.decision .draft { background: var(--accent-blue-soft); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; font-size: 13px; margin-top: 4px; }
.decision .kb { display: flex; gap: 6px; flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  font: inherit; font-size: 14px; font-weight: 500; color: var(--fg-muted);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 14px; margin-bottom: -1px; cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: color .12s, background .12s, border-color .12s;
}
.tab:hover { color: var(--fg); background: var(--muted); }
.tab.active { color: var(--fg); font-weight: 600; border-bottom-color: var(--primary); }

/* ============================================================
   5. VIEWS
   ============================================================ */

/* ---------- Deliverability: actions, domain groups, DNS gate ---------- */
.deliv-actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.deliv-actions .act-status { font-size: 12.5px; color: var(--fg-muted); }

.dom-groups { display: flex; flex-direction: column; gap: var(--s-4); }
.dom-group.has-risk .tablewrap { border-color: var(--danger-pill-bg); }
.mbx-table { width: 100%; }
.dom-head td { background: var(--sidebar-bg); border-bottom: 1px solid var(--border); padding: 10px 10px; }
.dom-head.has-risk td { background: var(--danger-soft); }
.dom-head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.dom-id { display: flex; align-items: center; gap: 9px; }
.dom-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dom-dot.good { background: var(--success); }
.dom-dot.warn { background: var(--warning); }
.dom-dot.bad { background: var(--danger-mid); }
.dom-name { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; color: var(--fg); }
.dom-stats { display: flex; align-items: center; gap: var(--s-5); }
.dom-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.dom-stat .ds-val { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.dom-stat .ds-lab { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); }
.mbx-colhead th {
  position: static; text-align: left; padding: 7px 10px; font-size: 12px; font-weight: 500;
  color: var(--fg-muted); background: var(--card); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.mbx-row td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mbx-table tbody tr:last-child td { border-bottom: 0; }
.mbx-row.below90 td { background: var(--warning-soft); }
.mbx-row.below90 td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

/* DNS health table */
.dns-row.gate-fail td { background: var(--danger-soft); }
.dns-row.gate-fail td:first-child { box-shadow: inset 3px 0 0 var(--danger-mid); }
.dns-row.expandable { cursor: pointer; }
.dns-detail-row td {
  background: var(--sidebar-bg); font-size: 12.5px; color: var(--fg-secondary);
  padding: var(--s-2) var(--s-4); white-space: pre-wrap; font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
}
.dns-toggle { color: var(--fg-faint); font-size: 11px; margin-left: 6px; }

/* ---------- Overview: AI accuracy ---------- */
.acc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); margin-bottom: var(--s-3); }
.acc-stat .k { font-size: 12px; color: var(--fg-muted); font-weight: 500; }
.acc-stat .v { font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.acc-stat .v .unit { font-size: 13px; color: var(--fg-muted); font-weight: 500; }
.acc-table table { font-size: 12.5px; }
.acc-table thead th, .acc-table tbody td { padding: 5px 8px; }
.acc-client-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.acc-client-row:last-child { border-bottom: 0; }
.acc-client-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.acc-client-row .vals { display: flex; gap: var(--s-3); font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-secondary); font-variant-numeric: tabular-nums; }
.acc-note { font-size: 12px; color: var(--fg-muted); margin: var(--s-2) 0 0; }

/* ---------- Reply console ---------- */
.rc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: var(--s-4); }
.rc-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s-4); box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: opacity .18s, transform .18s;
}
.rc-card.removing { opacity: 0; transform: scale(.98); }
.rc-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.rc-who { font-weight: 600; font-size: 14px; }
.rc-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-3); }
.rc-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.rc-row .k { color: var(--fg-muted); min-width: 84px; flex: none; }
.rc-row .kb { display: flex; gap: 6px; flex-wrap: wrap; }
.rc-draft-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-muted); font-weight: 600; margin: 4px 0 5px; display: flex; gap: 8px; align-items: center; }
.rc-edited { text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--accent-blue-strong); font-weight: 600; }
.rc-draft {
  font: inherit; font-size: 13.5px; color: var(--fg); width: 100%; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  background: var(--card); line-height: 1.5; box-shadow: var(--shadow-sm); transition: border-color .12s;
}
.rc-draft:hover { border-color: var(--fg-faint); }
.rc-draft:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgb(148 163 184/.2); }
.rc-actions { display: flex; align-items: center; gap: 10px; margin-top: var(--s-3); }
.rc-status { font-size: 12.5px; color: var(--fg-muted); }

/* ---------- Campaign page ---------- */
.cp-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.cp-back { font: inherit; font-size: 13.5px; font-weight: 500; color: var(--fg-secondary); background: none; border: 0; cursor: pointer; padding: 4px 0; border-radius: var(--radius-sm); }
.cp-back:hover { color: var(--fg); }
.cp-finalize-status { font-size: 12.5px; color: var(--fg-muted); }
.btn.cp-finalize:disabled { opacity: 1; background: var(--success-soft); border-color: var(--success-pill-bg); color: var(--success-strong); }
.cp-actions { display: flex; align-items: center; gap: var(--s-2); }
.cp-finalized-tag { font-size: 13px; font-weight: 600; color: var(--success-strong); background: var(--success-soft); border: 1px solid var(--success-pill-bg); border-radius: var(--radius); padding: 6px 12px; white-space: nowrap; }
.cp-tabs { margin-bottom: var(--s-5); }

.var-token { font-family: var(--font-mono); font-size: .92em; background: var(--accent-blue-soft); color: var(--accent-blue-strong); border-radius: 4px; padding: 0 4px; white-space: nowrap; }

.wrapper-shell { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.ws-row { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); align-items: baseline; }
.ws-row:last-child { border-bottom: 0; }
.ws-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); font-weight: 600; }
.ws-text { font-size: 13.5px; white-space: pre-wrap; }
.ws-text.muted { color: var(--fg-muted); font-style: italic; }
.ws-body { background: var(--sidebar-bg); }

.var-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.var-chip {
  display: inline-flex; flex-direction: column; gap: 2px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px;
  box-shadow: var(--shadow-sm); transition: border-color .12s;
}
.var-chip:hover { border-color: var(--accent-blue); }
.var-chip .var-key { font-family: var(--font-mono); font-size: 12px; color: var(--accent-blue-strong); }
.var-chip .var-label { font-size: 12px; color: var(--fg-secondary); }
.var-chip .var-source { font-size: 10.5px; color: var(--fg-faint); }

.tmpl { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--s-4); margin-bottom: var(--s-4); }
.tmpl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: var(--s-3); }
.tmpl-save-status { font-size: 12.5px; color: var(--fg-muted); margin-left: auto; }
.tmpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.tmpl-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--s-3); }
.tmpl-flabel { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-muted); font-weight: 600; }
.tmpl-subject, .tmpl-body {
  font: inherit; font-size: 13.5px; color: var(--fg); width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px;
  background: var(--card); line-height: 1.5; box-shadow: var(--shadow-sm); transition: border-color .12s;
}
.tmpl-body { resize: vertical; }
.tmpl-subject:hover, .tmpl-body:hover { border-color: var(--fg-faint); }
.tmpl-subject:focus, .tmpl-body:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgb(148 163 184/.2); }
.tmpl-subject:disabled, .tmpl-body:disabled { color: var(--fg-secondary); cursor: default; background: var(--muted); }
.tmpl-rendered { background: var(--sidebar-bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: var(--s-3); }
.tmpl-r-subject { font-weight: 600; font-size: 13.5px; margin-bottom: 6px; white-space: pre-wrap; }
.tmpl-r-body { font-size: 13.5px; white-space: pre-wrap; line-height: 1.55; }
.tmpl-row { display: flex; gap: 8px; margin-bottom: var(--s-3); font-size: 13px; align-items: baseline; }
.tmpl-row .k { color: var(--fg-muted); min-width: 96px; flex: none; }
.tmpl-row .kb { display: flex; gap: 6px; flex-wrap: wrap; }
.tmpl-actions { display: flex; align-items: center; gap: 10px; }
.tmpl-locked-note { font-size: 12px; color: var(--fg-muted); font-style: italic; }
.tmpl-preview { background: var(--accent-blue-soft); border-radius: var(--radius); padding: var(--s-4); align-self: start; }
.tmpl-preview .tmpl-flabel { color: var(--accent-blue-strong); margin-bottom: 8px; }
.tmpl-p-subject { font-size: 13.5px; margin-bottom: 8px; }
.tmpl-p-subject .k { color: var(--fg-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }
.tmpl-p-body { font-size: 13.5px; white-space: pre-wrap; line-height: 1.55; color: var(--fg); }

/* ============================================================
   5b. AUTH — login screen (render mode) + topbar user chip
   ============================================================ */
.login-screen {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--sidebar-bg); padding: var(--s-5);
}
.login-card {
  width: 100%; max-width: 384px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: var(--s-6);
}
.login-brand { padding: 0; margin-bottom: var(--s-6); }
.login-title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.login-sub { margin: 4px 0 var(--s-5); color: var(--fg-muted); font-size: 13px; }
.login-field {
  display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--s-4);
  font-size: 11px; font-weight: 600; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.login-field input {
  font: inherit; font-size: 14px; font-weight: 400;
  text-transform: none; letter-spacing: 0; color: var(--fg);
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); box-shadow: var(--shadow-sm); transition: border-color .12s;
}
.login-field input:hover { border-color: var(--fg-faint); }
.login-field input:focus {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px rgb(148 163 184/.2);
}
.login-error {
  margin: 0 0 var(--s-4); padding: 8px 11px;
  font-size: 13px; font-weight: 500; color: var(--danger);
  background: var(--danger-soft); border: 1px solid var(--danger-pill-bg);
  border-radius: var(--radius-sm);
}
.login-submit { width: 100%; justify-content: center; padding: 8px 16px; font-weight: 600; }

/* Topbar user chip: username + role pill (+ tenant name for clients). */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.uc-name { font-weight: 600; color: var(--fg); }
.uc-tenant {
  color: var(--fg-muted); font-size: 12.5px;
  border-left: 1px solid var(--border); padding-left: 8px;
}
.uc-domain {
  color: var(--fg-muted); font-size: 12.5px;
  border-left: 1px solid var(--border); padding-left: 8px;
}
.pill.role-pill { text-transform: uppercase; font-size: 10px; letter-spacing: .06em; }
.pill.role-pill.admin { background: var(--accent-blue-soft); color: var(--accent-blue-strong); }
.pill.role-pill.client { background: var(--brand-purple-soft); color: var(--brand-purple); }

/* Account menu: the user chip is a button that opens a small dropdown. */
.user-menu { position: relative; }
button.user-chip { cursor: pointer; font: inherit; transition: border-color .12s, background .12s; }
button.user-chip:hover { border-color: var(--fg-faint); background: var(--muted); }
.uc-caret { color: var(--fg-faint); transition: transform .12s; }
button.user-chip[aria-expanded="true"] .uc-caret { transform: rotate(180deg); }
.account-pop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 220px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: var(--s-1);
  animation: scrim-in .12s ease;
}
.account-pop-head { padding: 8px 10px var(--s-2); border-bottom: 1px solid var(--border); margin-bottom: var(--s-1); }
.account-pop-name { font-weight: 600; font-size: 13.5px; color: var(--fg); }
.account-pop-meta { font-size: 12px; color: var(--fg-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.account-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  font: inherit; font-size: 13.5px; color: var(--fg); cursor: pointer;
  background: none; border: 0; padding: 8px 10px; border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.account-item:hover { background: var(--muted); }
.account-item .ico { color: var(--fg-muted); }
.account-item.danger { color: var(--danger); }
.account-item.danger .ico { color: var(--danger); }

/* Demo-mode switch (admin) — a labelled toggle near the client switcher. */
.demo-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--fg-secondary);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 10px;
  background: var(--card); box-shadow: var(--shadow-sm); transition: all .12s; user-select: none;
}
.demo-toggle:hover { border-color: var(--fg-faint); }
.demo-toggle .demo-track {
  width: 30px; height: 16px; border-radius: 999px; background: var(--border);
  position: relative; flex: none; transition: background .15s;
}
.demo-toggle .demo-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
.demo-toggle[aria-pressed="true"] { color: var(--brand-purple); border-color: #d6cdfb; background: var(--brand-purple-soft); }
.demo-toggle[aria-pressed="true"] .demo-track { background: var(--brand-purple); }
.demo-toggle[aria-pressed="true"] .demo-track::after { transform: translateX(14px); }

/* Demo-mode banner — persistent strip telling the admin they're previewing. */
.demo-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--s-6); font-size: 13px; font-weight: 600;
  background: var(--brand-purple-soft); color: var(--brand-purple);
  border-bottom: 1px solid #e4dcfb;
}
.demo-banner .db-mark { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.demo-banner .db-exit {
  margin-left: auto; font: inherit; font-size: 12px; font-weight: 600; padding: 3px 12px;
  border-radius: 999px; border: 1px solid currentColor; color: inherit; background: transparent;
  cursor: pointer; transition: all .12s;
}
.demo-banner .db-exit:hover { background: var(--brand-purple); color: #fff; border-color: var(--brand-purple); }

/* Integration status pills + drawer manage sections. */
.mng-int-row { display: grid; grid-template-columns: 1fr auto; gap: 10px var(--s-3); align-items: center; margin-bottom: var(--s-3); }
.mng-int-row .mng-int-label { font-size: 13px; font-weight: 500; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.mng-int-row input { grid-column: 1 / -1; }
.dd-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-3); }
.dd-act-status { font-size: 12.5px; color: var(--fg-muted); }
.dd-save-bar { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
.dd-login-line { font-size: 13px; color: var(--fg-secondary); margin-bottom: var(--s-2); }
.dd-login-line .mono { color: var(--fg); }

/* ---------- Modal (centered dialog: add-client onboarding) ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgb(15 23 42/.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(24px, 8vh, 96px) var(--s-4) var(--s-4);
  overflow-y: auto; animation: scrim-in .18s ease;
}
.modal {
  width: min(560px, 100%); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  font-size: 24px; line-height: 1; border: 0; background: none; cursor: pointer;
  color: var(--fg-muted); padding: 2px 8px; border-radius: var(--radius-sm);
  transition: color .12s, background .12s;
}
.modal-close:hover { color: var(--fg); background: var(--muted); }
.modal-body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  margin-top: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--border);
}

/* ---------- AI Agents detail ---------- */
.agent-list { margin: 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-1); }
.agent-list li { line-height: 1.5; }
.agent-kv { display: flex; flex-direction: column; gap: var(--s-3); }
.agent-kv > div { display: grid; grid-template-columns: 180px 1fr; gap: var(--s-3); align-items: start; }
.agent-kv .k { color: var(--fg-muted); font-size: 12.5px; }
.agent-kv .v { color: var(--fg); line-height: 1.5; }
.agent-kv .v.mono { font-family: var(--font-mono); }
@media (max-width: 640px) { .agent-kv > div { grid-template-columns: 1fr; gap: var(--s-1); } }

/* ---------- Form fields (modal forms) ---------- */
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field > span {
  font-size: 11px; font-weight: 600; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.form-field input, .form-field textarea {
  font: inherit; font-size: 14px; font-weight: 400; color: var(--fg);
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); box-shadow: var(--shadow-sm); transition: border-color .12s; width: 100%;
}
.form-field textarea { resize: vertical; min-height: 52px; line-height: 1.45; }
.form-field input:hover, .form-field textarea:hover { border-color: var(--fg-faint); }
.form-field input:focus, .form-field textarea:focus {
  outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgb(148 163 184/.2);
}
.form-hint { font-size: 11.5px; font-weight: 400; color: var(--fg-faint); text-transform: none; letter-spacing: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.form-inline { display: flex; gap: var(--s-2); align-items: stretch; }
.form-inline input { flex: 1; }
.form-field.cb { flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; }
.form-field.cb input { width: auto; flex: 0 0 auto; }
.form-error {
  margin: 0; padding: 8px 11px; font-size: 13px; font-weight: 500; color: var(--danger);
  background: var(--danger-soft); border: 1px solid var(--danger-pill-bg); border-radius: var(--radius-sm);
}

/* Per-row actions on the Clients roster (archive + open). */
.row-actions { display: inline-flex; align-items: center; gap: var(--s-3); justify-content: flex-end; }
.btn.btn-sm { padding: 4px 10px; font-size: 12.5px; }

/* ============================================================
   6. RESPONSIVE — graceful at laptop widths before collapsing
   ============================================================ */
@media (max-width: 1180px) {
  :root { --sidebar-w: 216px; }
  .view { padding: var(--s-5); }
  .two-col { gap: var(--s-4); }
  .funnel-row { grid-template-columns: 132px 1fr 44px 92px; }
}
@media (max-width: 1040px) {
  .two-col { grid-template-columns: 1fr; }
  .sk-panels { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: var(--s-3); border-right: 0; border-bottom: 1px solid var(--sidebar-border); }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; align-items: center; }
  .nav-group-label { padding: 0 var(--s-2); }
  .sidebar-foot { flex-direction: row; align-items: center; border-top: 0; padding-top: 0; }
  .topbar { top: 0; }
}
@media (max-width: 760px) {
  .view { padding: var(--s-4); }
  .topbar { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  .switcher select { min-width: 200px; }
  .rc-grid { grid-template-columns: 1fr; }
  .tmpl-grid { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 110px 1fr 40px; }
  .funnel-rate { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .bar-row { grid-template-columns: 100px 1fr 40px; }
  .acc-stats { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
