/* ============================================================
   AerialReports CRM — Quantum Platform
   Enterprise design system — Stripe × Linear × Vercel
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700;800&family=Hanken+Grotesk:wght@500;600;700;800;900&family=Montserrat:wght@600;700;800;900&display=swap');

/* ── DESIGN TOKENS ───────────────────────────────────────── */
:root {
  /* Dark theme (default) */
  --bg-0: #0a0d14;
  --bg-1: #11151f;
  --bg-2: #161b28;
  --bg-3: #1d2333;
  --bg-4: #252c40;

  --border: rgba(255,255,255,0.06);
  --border-2: rgba(255,255,255,0.11);
  --border-3: rgba(255,255,255,0.18);

  --text: #e8ecf4;
  --text-2: #9aa5b9;
  --text-3: #5b6578;
  --text-4: #363d4f;

  --accent: #1ab6f1;
  --accent-2: #0d9bda;
  --accent-3: #06b6d4;
  --accent-rgb: 26, 182, 241;

  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --pink: #ec4899;
  --blue: #3b82f6;

  /* Typography — Montserrat (brand display) + Inter (body) */
  --display: 'Montserrat', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Shadows — layered & soft (2026) */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.18), 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.18), 0 8px 24px rgba(0,0,0,0.28);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.32), 0 24px 56px rgba(0,0,0,0.42);
  --shadow-glow: 0 0 0 3px rgba(26,182,241,0.22);
  --hairline: inset 0 1px 0 rgba(255,255,255,0.05);
  --surface: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  --surface-3: linear-gradient(180deg, var(--bg-3), var(--bg-2));

  /* Transitions */
  --tr-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

/* Light theme overrides — ServiceTitan-sharp
 *
 * 2026-07-15 enterprise pass: the previous --text-3 (#6b7280) hit only 4.83:1
 * contrast against #ffffff — technically WCAG AA but visibly "faded grey" that
 * customers reported as hard to read, especially on KPI subtitles, filter
 * labels, and empty-state hints. Bumped to #475569 (slate-600) → 7.55:1
 * contrast, matching what Linear / Stripe / Vercel / Notion use for secondary
 * text. --text-2 nudged darker for the same reason (12.63:1). --text-4 lifted
 * from #d1d5db (near-invisible) to #94a3b8 so "muted" text still conveys
 * something instead of vanishing. Also added the commonly-cross-referenced
 * aliases (--text-primary, --text-secondary, --text-muted, --bg-soft,
 * --accent-blue, --accent-green) that scheduler.html and several other pages
 * were referencing but were UNSET, silently cascading to whatever `color:
 * inherit` picked up — which made hierarchy read inconsistently across pages.
 * The refined shadow ramp adds subtle depth that reads as "expensive" without
 * heavy drop-shadows: cards get a hairline border + a 1px shadow, elevated
 * surfaces get a 2-layer soft shadow, modals get a 3-layer ambient shadow.
 */
html.theme-light {
  /* Surface ramp — subtle warm-cool progression from off-white to slate */
  --bg-0: #f5f7fa;   /* page background — a hair warmer than pure white */
  --bg-1: #ffffff;   /* card surface */
  --bg-2: #f9fafb;   /* nested surface / hover */
  --bg-3: #f1f5f9;   /* input backgrounds, muted panels */
  --bg-4: #e2e8f0;   /* dividers, chip backgrounds */
  --bg-soft: #f9fafb;
  --surface: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f5f9;

  /* Borders — hairlines that read at both 100% and 150% zoom */
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --border-3: #9ca3af;

  /* Text — a proper hierarchy, every level above WCAG AA on white */
  --text: #0f172a;              /* 18.4:1 — headings, primary body */
  --text-primary: #0f172a;
  --text-1: #0f172a;
  --text-2: #334155;            /* 12.6:1 — secondary body, labels */
  --text-secondary: #334155;
  --text-3: #475569;            /* 7.55:1 — subtitles, hints, KPI captions */
  --text-muted: #475569;
  --text-4: #94a3b8;            /* 3.2:1 — placeholder-only, decorative dividers */

  /* Accent scale — brand color used consistently for interactive affordances */
  --accent: #1AB6F1;
  --accent-blue: #1AB6F1;
  --accent-2: #0D9BDA;
  --accent-3: #0284C7;          /* pressed / active */
  --accent-soft: rgba(26,182,241,0.10);  /* subtle tinted backgrounds */
  --accent-green: #10B981;

  /* Elevation — 3-tier ramp that reads as depth, not "heavy shadow" */
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05), 0 0 0 1px rgba(15,23,42,0.03);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,0.06), 0 2px 4px -2px rgba(15,23,42,0.04);
  --shadow-lg: 0 12px 24px -8px rgba(15,23,42,0.10), 0 4px 8px -2px rgba(15,23,42,0.05);
  --shadow-glow: 0 0 0 3px rgba(26,182,241,0.16);   /* focus rings */
  --hairline: inset 0 1px 0 rgba(255,255,255,0.85);

  /* Typography scale — real hierarchy, not a wall of 14px */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 30px;
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-loose: 1.65;
  --tracking-tight: -0.011em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
}

/* ── Focus rings: consistent, keyboard-accessible, brand-tinted ─────────────
 * The default browser focus outline was inconsistent across inputs/buttons/
 * links, which reads as "cheap" on an enterprise dashboard. This one rule
 * gives every interactive element the same accent-tinted 3px ring on focus
 * — the same convention Stripe / Linear / Vercel use. */
html.theme-light *:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
  border-radius: 6px;
}

/* ── Card polish ────────────────────────────────────────────────────────────
 * Cards get a hairline border + a single subtle shadow so they read as
 * distinct surfaces without heavy drop-shadow noise. Hovering an interactive
 * card lifts it 1px — the "expensive" micro-interaction. */
html.theme-light .card,
html.theme-light .kpi-card,
html.theme-light .settings-section-card {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 180ms ease, transform 180ms ease;
}
html.theme-light .kpi-card:hover,
html.theme-light [role="button"].card:hover,
html.theme-light .card.is-interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ── KPI label refinement: uppercase tracked labels, tabular-numeric values ─
 * Standard enterprise-dashboard convention (Stripe, Datadog, Linear): tiny
 * uppercase label above a large tabular-numeric value. Fixes the "row of
 * mystery numbers" look pages had when labels sat mid-grey at 13px normal. */
html.theme-light .kpi-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-3);
}
html.theme-light .kpi-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}
/* ── Navy chrome, white workspace ────────────────────────────────────────
 * The light theme's canvas/cards/tables stay white/near-white (unchanged
 * below), but the sidebar is dark navy — an "operations command center"
 * pairing, not a fully-white admin panel. Scoped custom-property overrides
 * so every existing bg, text, border and accent-rgb token reference inside
 * .sidebar (nav items, section labels, badges, hover states) repaints for
 * navy-on-white without new selectors per element. */
html.theme-light .sidebar {
  --bg-0: #0a2038;
  --bg-1: #0d2a4a;
  --bg-3: #163a5e;
  --bg-4: #1c4468;
  --border: rgba(255,255,255,0.09);
  --text: #eef3f8;
  --text-2: #aec2d6;
  --text-3: #7f93a9;
  --accent-rgb: 26, 182, 241;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right-color: transparent;
}
html.theme-light .topbar {
  background: rgba(255,255,255,0.82);
  border-bottom-color: #e5e7eb;
}
html.theme-light .sidebar .nav-item.active {
  color: #ffffff;
}
html.theme-light .kpi-card {
  border-color: #e5e7eb;
}
html.theme-light .card {
  border-color: #e5e7eb;
}
html.theme-light .table-wrap {
  border-color: #e5e7eb;
}
html.theme-light .table th {
  color: #4b5563;
  border-bottom-color: #e5e7eb;
}
html.theme-light .table td {
  border-bottom-color: #f3f4f6;
  color: #111827;
}
html.theme-light .table tbody tr:hover td {
  background: #f9fafb;
}
html.theme-light .badge-green { background: #ecfdf5; color: #059669; }
html.theme-light .badge-amber { background: #fffbeb; color: #b45309; }
html.theme-light .badge-red   { background: #fef2f2; color: #b91c1c; }
html.theme-light .badge-blue  { background: #eff6ff; color: #1d4ed8; }
html.theme-light .badge-purple{ background: #f5f3ff; color: #6d28d9; }
html.theme-light .badge-cyan  { background: #ecfeff; color: #0891b2; }
html.theme-light .badge-pink  { background: #fdf2f8; color: #be185d; }
html.theme-light .badge-gray  { background: #f3f4f6; color: #4b5563; }
html.theme-light .form-input,
html.theme-light .form-select,
html.theme-light .form-textarea {
  background: #ffffff;
  border-color: #d1d5db;
}
html.theme-light .form-input:focus,
html.theme-light .form-select:focus,
html.theme-light .form-textarea:focus {
  border-color: #1ab6f1;
  box-shadow: 0 0 0 3px rgba(26,182,241,0.12);
}
html.theme-light .modal .modal-backdrop {
  background: rgba(17,24,39,0.35);
}
html.theme-light .toast {
  background: #ffffff;
  border-color: #e5e7eb;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
html.theme-light .avatar {
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
html.theme-light .sidebar-section { color: #64748b; }   /* was #9ca3af (~2.5:1) → ~4.9:1 */
html.theme-light .logo-sub { color: #64748b; }
html.theme-light .kanban-col { background: #f9fafb; border-color: #e5e7eb; }
html.theme-light .kanban-card { background: #ffffff; border-color: #e5e7eb; }
html.theme-light .kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
html.theme-light .progress { background: #e5e7eb; }
html.theme-light .btn-secondary { background: #f3f4f6; border-color: #d1d5db; color: #374151; }
html.theme-light .btn-secondary:hover { background: #e5e7eb; }
html.theme-light .btn-ghost:hover { background: #f3f4f6; }
html.theme-light .topbar-btn, html.theme-light .theme-toggle {
  background: #f9fafb; border-color: #d1d5db; color: #6b7280;
}
html.theme-light .topbar-btn:hover, html.theme-light .theme-toggle:hover {
  background: #f3f4f6; color: #111827;
}
html.theme-light .topbar-search {
  background: #f9fafb; border-color: #d1d5db;
}
html.theme-light .topbar-search:focus-within {
  border-color: #1ab6f1; background: #ffffff;
}
html.theme-light .kbd { background: #e5e7eb; border-color: #d1d5db; color: #6b7280; }
html.theme-light .notif-dot { border-color: #ffffff; }
html.theme-light .tabs { border-bottom-color: #e5e7eb; }
html.theme-light .tab { color: #6b7280; }
html.theme-light .tab:hover { color: #111827; }
html.theme-light .tab.active { color: #1ab6f1; border-bottom-color: #1ab6f1; }

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

h1, h2, h3, h4, h5, h6,
[class*="-title"], [class*="-value"], [class*="-heading"], [class*="-head-title"],
.kpi-label, .ksi-label, .logo-text, .sidebar-section, .dash-head-title {
  font-family: var(--display);
  letter-spacing: -0.015em;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

/* Accessible focus ring — keyboard only */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Selection */
::selection { background: rgba(var(--accent-rgb), 0.35); color: var(--text); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-3); background-clip: padding-box; border: 2px solid transparent; }

/* ── UTILITIES ───────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.hidden { display: none !important; }
.relative { position: relative; }
.absolute { position: absolute; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-500 { font-weight: 500; }
.font-600 { font-weight: 600; }
.font-700 { font-weight: 700; }
.font-800 { font-weight: 800; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-md { font-size: 13px; }
.text-lg { font-size: 15px; }
.text-xl { font-size: 18px; }
.text-2xl { font-size: 22px; }
.text-3xl { font-size: 28px; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-accent { color: var(--accent); }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; }

/* ── APP SHELL ───────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(1100px 560px at 100% -8%, rgba(26,182,241,0.10), transparent 58%),
    radial-gradient(900px 480px at -6% 108%, rgba(10,132,255,0.07), transparent 55%),
    var(--bg-0);
}
html.theme-light .app {
  background:
    radial-gradient(1100px 560px at 100% -8%, rgba(26,182,241,0.07), transparent 58%),
    radial-gradient(900px 480px at -6% 108%, rgba(10,132,255,0.05), transparent 55%),
    var(--bg-0);
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.sidebar-logo {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-link { display: flex; align-items: center; width: 100%; }
.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark svg { border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.10); }
html.theme-light .logo-mark svg { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.sidebar-logo-img {
  max-width: 100%;
  max-height: 30px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.logo-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.1;
  background: linear-gradient(135deg, #e8ecf4, #9aa5b9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
html.theme-light .logo-text {
  background: linear-gradient(135deg, #111827, #374151);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-text span {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-3);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}
.sidebar-section {
  padding: 13px 14px 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
}
.sidebar-section:hover { color: var(--text-2); background: var(--bg-3); }
.sidebar-section-chevron {
  transition: transform .15s ease;
  flex-shrink: 0;
  opacity: .7;
}
.sidebar-section.collapsed .sidebar-section-chevron { transform: rotate(-90deg); }
.sidebar-section-items {
  overflow: hidden;
  max-height: 800px;
  transition: max-height .18s ease;
}
.sidebar-section-items.collapsed { max-height: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.005em;
  transition: background var(--tr), color var(--tr);
  position: relative;
  margin-bottom: 1px;
  -webkit-font-smoothing: antialiased;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .92; }
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(var(--accent-rgb),0.16), rgba(var(--accent-rgb),0.05));
  color: var(--accent);
  font-weight: 700;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.nav-item span:first-of-type { flex: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-4);
  color: var(--text-2);
}
.nav-badge-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  transition: background var(--tr);
  cursor: pointer;
}
.user-card:hover { background: var(--bg-3); }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-3); }

/* ── MAIN / TOPBAR ───────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg-1) 72%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  flex-shrink: 0;
  gap: 20px;
  position: relative;
  z-index: 10;
}
.topbar-title-group { display: flex; flex-direction: column; }
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.topbar-sub {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.2;
  margin-top: 1px;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-search {
  width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 10px;
  height: 34px;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.topbar-search svg { color: var(--text-3); }
.topbar-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-3); }
.kbd {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  padding: 2px 6px;
  border-radius: 4px;
}
.topbar-btn, .theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all var(--tr);
  position: relative;
}
.topbar-btn:hover, .theme-toggle:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-3);
}
.notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-1);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html.theme-light .theme-toggle .icon-sun { display: block; }
html.theme-light .theme-toggle .icon-moon { display: none; }

.content {
  flex: 1;
  overflow: auto;
  padding: 24px;
}

/* ── PAGE WRAPPER ────────────────────────────────────────── */
.page {
  animation: fadeIn 0.3s ease;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.page-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow-sm), var(--hairline);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.card-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ── KPI ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm), var(--hairline);
  transition: border-color var(--tr), transform var(--tr), box-shadow var(--tr);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: -45%;
  right: -18%;
  width: 190px;
  height: 190px;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.16), transparent 70%);
  pointer-events: none;
}
.kpi-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--hairline);
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  margin: 8px 0 6px;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi-delta {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--tr);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 1px 2px rgba(var(--accent-rgb),0.4), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(var(--accent-rgb),0.45), inset 0 1px 0 rgba(255,255,255,0.18); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--bg-3);
  border-color: var(--border-2);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-4); border-color: var(--border-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16,185,129,0.3);
}
.btn-green:hover { background: #0ea572; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #dc2626; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.badge-green { background: rgba(16,185,129,0.14); color: #34d399; }
.badge-amber { background: rgba(245,158,11,0.14); color: #fbbf24; }
.badge-red   { background: rgba(239,68,68,0.14);  color: #f87171; }
.badge-blue  { background: rgba(59,130,246,0.14); color: #60a5fa; }
.badge-purple{ background: rgba(139,92,246,0.14); color: #a78bfa; }
.badge-cyan  { background: rgba(6,182,212,0.14);  color: #22d3ee; }
.badge-pink  { background: rgba(236,72,153,0.14); color: #f472b6; }
.badge-gray  { background: var(--bg-3); color: var(--text-2); }

html.theme-light .badge-green { background: rgba(16,185,129,0.12); color: #059669; }
html.theme-light .badge-amber { background: rgba(245,158,11,0.14); color: #b45309; }
html.theme-light .badge-red   { background: rgba(239,68,68,0.1);  color: #b91c1c; }
html.theme-light .badge-blue  { background: rgba(59,130,246,0.1); color: #1d4ed8; }
html.theme-light .badge-purple{ background: rgba(139,92,246,0.1); color: #6d28d9; }

/* ── TABLES ─────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.table td {
  padding: 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr { transition: background var(--tr-fast); }
.table tbody tr:hover td { background: var(--bg-3); }
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm), var(--hairline);
}

/* ── PROGRESS ───────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.green { background: linear-gradient(90deg, var(--green), #34d399); }
.progress-fill.amber { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.progress-fill.red { background: linear-gradient(90deg, var(--red), #f87171); }

/* ── AVATARS ────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.18);
}
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 20px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--bg-2); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-input,
.form-select,
.form-textarea,
.form-control,
.form-group input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--tr), box-shadow var(--tr);
  outline: none;
}
html.theme-light .form-input,
html.theme-light .form-select,
html.theme-light .form-textarea,
html.theme-light .form-control,
html.theme-light .form-group input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
html.theme-light .form-group select,
html.theme-light .form-group textarea {
  background: var(--bg-1);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.form-input::placeholder, .form-control::placeholder, .form-group input::placeholder { color: var(--text-3); }
.form-textarea, textarea.form-control, .form-group textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.form-select, select.form-control, .form-group select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa5b9' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
/* .form-group's bare <label>/<input>/<select>/<textarea> children (no explicit
   .form-label/.form-input/etc class) were completely unstyled — settings.html's
   entire Company Profile / Proposal Design section (~35 fields) rendered as
   native browser inputs. Scoped rules here give every .form-group the same
   look as .form-row/.form-label/.form-input without touching that markup. */
.form-group > label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
/* .form-control is a legacy alias found in tasks.html/orders.html/scheduler.html/
   permits.html — was previously undefined anywhere in the stylesheet, so every
   field in those forms rendered as an unstyled native input. Mapped onto the
   same rules as .form-input/.form-select/.form-textarea above rather than
   rewriting markup in 4 files; new forms should use the specific classes. */

/* ── FORM SYSTEM — required/disabled/read-only/helper/error/currency/measurement ──
   Additive to the .form-group/.form-row/.form-label/.form-input base above (used
   across leads/contacts/orders/etc.) so existing pages keep working unchanged;
   new pages and refactors should reach for these classes too instead of inventing
   another -field/-row family (this codebase had 12+ of those before this pass). */
.form-label .required {
  color: var(--red);
  margin-left: 2px;
  font-weight: 700;
}
.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
  line-height: 1.4;
}
.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 6px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 5px;
}
.form-error svg { width: 13px; height: 13px; flex-shrink: 0; }
.form-input.has-error,
.form-select.has-error,
.form-textarea.has-error {
  border-color: var(--red);
}
.form-input.has-error:focus,
.form-select.has-error:focus,
.form-textarea.has-error:focus {
  box-shadow: 0 0 0 3px rgba(239,68,68,0.16);
}
.form-input.has-success,
.form-select.has-success {
  border-color: var(--green);
}
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg-3);
}
/* Read-only is NOT disabled — the value is real and selectable/copyable, it just
   can't be edited here. Distinct from :disabled (flat, muted, unclickable). */
.form-input[readonly],
.form-textarea[readonly] {
  background: var(--bg-2);
  border-style: dashed;
  color: var(--text-2);
  cursor: default;
}
html.theme-light .form-input[readonly],
html.theme-light .form-textarea[readonly] {
  background: var(--bg-3);
}

.form-section { margin-bottom: 28px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* Currency: symbol prefix inside the field, right-aligned numerals, no letters typeable */
.form-currency { position: relative; }
.form-currency::before {
  content: '$';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-3);
  font-weight: 600;
  pointer-events: none;
}
.form-currency input.form-input {
  padding-left: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Percentage: unit suffix inside the field */
.form-pct { position: relative; }
.form-pct input.form-input {
  padding-right: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.form-pct::after {
  content: '%';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-3);
  font-weight: 600;
  pointer-events: none;
}

/* Measurement: SQ / LF / SF / etc — unit shown adjacent, never bare numbers */
.form-measure { position: relative; }
.form-measure input.form-input { padding-right: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.form-measure .unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-3);
  pointer-events: none;
}

/* Sticky form actions — long forms get a footer that stays visible while scrolling */
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  margin: 24px -20px -20px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  z-index: 3;
}
.form-actions-sticky .unsaved-flag {
  font-size: 12px;
  color: var(--amber, #f59e0b);
  font-weight: 600;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 5px;
}
.form-actions-sticky .unsaved-flag::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--amber, #f59e0b);
}

/* ── KANBAN ─────────────────────────────────────────────── */
.kanban {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 14px;
  min-height: 500px;
}
.kanban-col {
  min-width: 280px;
  width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  flex-shrink: 0;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.kanban-col-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.kanban-col-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.kanban-col[data-stage="new"] .kanban-col-title::before { background: var(--text-3); }
.kanban-col[data-stage="contacted"] .kanban-col-title::before { background: var(--blue); }
.kanban-col[data-stage="qualified"] .kanban-col-title::before { background: var(--accent); }
.kanban-col[data-stage="proposal"] .kanban-col-title::before { background: var(--amber); }
.kanban-col[data-stage="won"] .kanban-col-title::before { background: var(--green); }
.kanban-col[data-stage="lost"] .kanban-col-title::before { background: var(--red); }
.kanban-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: grab;
  transition: all var(--tr);
}
.kanban-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.kanban-card-sub { font-size: 11px; color: var(--text-3); margin-bottom: 8px; }

/* ── MODALS ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: none;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal-backdrop.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  width: min(560px, 90vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.25s ease;
}
.modal-lg { width: min(780px, 92vw); }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: all var(--tr);
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── CHAT ───────────────────────────────────────────────── */
.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg.assistant {
  background: var(--bg-3);
  color: var(--text);
  align-self: flex-start;
  border-top-left-radius: 2px;
}
.msg.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-top-right-radius: 2px;
}
.msg-time {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
}
.chat-input {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.chat-input input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.chat-input input:focus { border-color: var(--accent); }

/* ── TOAST ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: auto;
  border-left: 3px solid var(--accent);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-warn { border-left-color: var(--amber); }
.toast-info { border-left-color: var(--accent); }

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--bg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--text-2);
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-2); }

/* ── DIVIDER ────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── LOADING SHIMMER ────────────────────────────────────── */
.shimmer {
  background: linear-gradient(90deg, var(--bg-3) 0%, var(--bg-4) 50%, var(--bg-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}

/* ── ANIMATIONS ─────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── STAT LIST ──────────────────────────────────────────── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label { color: var(--text-2); }
.stat-row-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── TABS ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--tr);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; transition: left var(--tr); z-index: 999; }
  .sidebar.open { left: 0; }
  .kpi-grid, .kpi-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { width: 180px; }
  .content { padding: 16px; }
}
@media (max-width: 600px) {
  .kpi-grid, .kpi-grid-5 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .topbar-search { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}

/* 5-up KPI variant (leads.html) — base class already has display:grid/gap via
   .kpi-grid; this only overrides the column count, and only above the two
   breakpoints just above where it collapses like every other .kpi-grid. */
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ── NEW ITEM DROPDOWN ─────────────────────────────────── */
.new-item-dropdown {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--tr-fast), transform var(--tr-fast);
}
.new-item-dropdown.show {
  opacity: 1;
  transform: translateY(0);
}
.new-item-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--tr-fast), color var(--tr-fast);
}
.new-item-option:hover {
  background: var(--bg-3);
  color: var(--text);
}
.new-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-3);
  border-radius: 6px;
  color: var(--text-2);
}
.new-item-option:hover .new-item-icon {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
}

/* ── LEAD DETAIL GRID ──────────────────────────────────── */
.lead-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.lead-detail-grid .stat-row {
  padding: 8px 0;
}

/* ── MODAL OVERLAY SYSTEM (updated) ────────────────────── */
/* Scoped to body.app > .modal (the outer-container convention: client.html,
   contacts.html, estimates.html, financials.html, jobs.html, leads.html,
   media.html, pipeline.html, work-orders.html) so it never touches the
   classic convention's INNER `.modal` dialog box nested one level deeper
   inside `.modal-backdrop` (approvals/checklists/commissions/labor/orders/
   permits/scheduler/supplements/tasks/xactimate-requests, etc.) — both
   conventions reuse the class name `.modal` for structurally different
   roles, and an unscoped `display:none` here silently made every one of
   those OTHER pages' modals render as an empty dark backdrop with no
   visible dialog. Direct-child selector is deliberate: don't widen this.  */
body.app > .modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
body.app > .modal.active {
  display: flex;
}
.modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5,7,15,0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.modal .modal-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  width: min(560px, 90vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg), var(--hairline);
  animation: fadeIn 0.25s ease;
  padding: 24px;
  z-index: 1;
}
.modal .modal-panel.modal-lg {
  width: min(780px, 92vw);
}
.modal .modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

/* ── FORM GRID (for lead/convert modals) ───────────────── */
.form-grid .form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-grid .form-row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.form-grid .form-row input,
.form-grid .form-row select,
.form-grid .form-row textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-grid .form-row input:focus,
.form-grid .form-row select:focus,
.form-grid .form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.form-grid .form-row input[readonly] {
  opacity: 0.7;
  cursor: default;
}
.form-grid .form-row-full {
  grid-column: 1 / -1;
}
.form-grid .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.modal-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 18px;
}

/* ── MODAL HEADER SPLIT (lead detail) ──────────────────── */
.modal-header-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.modal-header-split h2 {
  font-size: 18px;
  font-weight: 700;
  margin-top: 10px;
  display: flex;
  align-items: center;
}
.modal-header-split .muted { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.score-big { text-align: center; }
.score-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
}
.score-circle span { font-size: 18px; font-weight: 800; color: #fff; }
.score-big > div:last-child { font-size: 11px; color: var(--text-3); margin-top: 4px; font-weight: 600; }
.modal-section { margin-bottom: 18px; }
.modal-section h4 { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.breakdown { display: flex; flex-direction: column; gap: 8px; }
.bd-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bd-row span:first-child { width: 120px; color: var(--text-2); flex-shrink: 0; }
.bd-row .progress { flex: 1; }
.bd-row b { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.ai-rec {
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.ai-rec-head { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.ai-rec p { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── STATUS BADGES ─────────────────────────────────────── */
.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
/* Legacy statuses (backward compat) */
.status-new { background: var(--bg-3); color: var(--text-2); }
.status-contacted { background: rgba(59,130,246,0.14); color: #60a5fa; }
.status-qualified { background: rgba(139,92,246,0.14); color: #a78bfa; }
.status-proposal, .status-proposal_sent { background: rgba(245,158,11,0.14); color: #fbbf24; }
.status-won { background: rgba(16,185,129,0.14); color: #34d399; }
.status-lost { background: rgba(239,68,68,0.14); color: #f87171; }
html.theme-light .status-won { color: #059669; }
html.theme-light .status-contacted { color: #1d4ed8; }
/* Roofer pipeline statuses */
.status-lead_in { background: var(--bg-3); color: var(--text-1); }
.status-appt_set { background: #dbeafe; color: #1e40af; }
.status-inspected { background: #ede9fe; color: #6d28d9; }
.status-estimate_sent { background: #fef3c7; color: #92400e; }
.status-sold { background: #d1fae5; color: #065f46; }
.status-production { background: #ccfbf1; color: #0d9488; }
.status-complete { background: #d1fae5; color: #065f46; }
.status-paid { background: #d1fae5; color: #047857; }
/* Dark-theme overrides for roofer statuses */
html:not(.theme-light) .status-lead_in { background: var(--bg-3); color: var(--text-2); }
html:not(.theme-light) .status-appt_set { background: rgba(59,130,246,0.14); color: #60a5fa; }
html:not(.theme-light) .status-inspected { background: rgba(139,92,246,0.14); color: #a78bfa; }
html:not(.theme-light) .status-estimate_sent { background: rgba(245,158,11,0.14); color: #fbbf24; }
html:not(.theme-light) .status-sold { background: rgba(16,185,129,0.14); color: #34d399; }
html:not(.theme-light) .status-production { background: rgba(20,184,166,0.14); color: #2dd4bf; }
html:not(.theme-light) .status-complete { background: rgba(16,185,129,0.14); color: #34d399; }
html:not(.theme-light) .status-paid { background: rgba(16,185,129,0.14); color: #6ee7b7; }

/* ── DATA TABLE ────────────────────────────────────────── */
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-name { font-weight: 600; font-size: 13px; }
.cell-sub { font-size: 11px; color: var(--text-3); }
.cell-muted { color: var(--text-2); }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.score-cell { display: flex; align-items: center; gap: 8px; }
.score-bar { width: 50px; height: 5px; background: var(--bg-4); border-radius: 99px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 99px; }
.score-green { background: var(--green); }
.score-amber { background: var(--amber); }
.score-red { background: var(--red); }

/* ── FILTER BAR ────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 10px;
  height: 36px;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.search-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
}
.search-wrap input::placeholder { color: var(--text-3); }
.search-icon { font-size: 14px; }
.select {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 8px 28px 8px 10px;
  font-size: 12px;
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa5b9' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  outline: none;
  cursor: pointer;
}
.select:focus { border-color: var(--accent); box-shadow: var(--shadow-glow); }
/* .input-sm was used in job-detail.html/work-orders.html/commissions.html/
   approvals.html but never defined — those elements still got a base
   appearance from the broad html.theme-light input/select/textarea rule
   further down, just not the compact sizing "sm" implies. Mirrors .btn-sm's
   existing padding/font-size convention. */
.input-sm { padding: 6px 10px; font-size: 12px; }
.kpi-delta.muted { color: var(--text-3); }

/* ── JOB DETAIL ────────────────────────────────────────── */
.job-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.job-header-info h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 4px;
}
.job-header-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-2);
  align-items: center;
}
.job-header-meta .badge { margin-left: 4px; }
.job-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── JOB MILESTONE BAR ─────────────────────────────────── */
.job-milestone-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 24px 0;
  margin-bottom: 24px;
}
.job-milestone-bar::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 24px;
  right: 24px;
  height: 3px;
  background: var(--bg-4);
  border-radius: 99px;
  transform: translateY(-50%);
  z-index: 0;
}
.milestone-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
  flex: 1;
}
.milestone-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--bg-4);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  transition: all var(--tr);
}
.milestone-step.completed .milestone-dot {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(16,185,129,0.18);
}
.milestone-step.active .milestone-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb),0.22);
  animation: pulse 2s infinite;
}
.milestone-step.upcoming .milestone-dot {
  background: var(--bg-3);
  border-color: var(--bg-4);
  color: var(--text-3);
}
.milestone-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 80px;
}
.milestone-step.completed .milestone-label { color: var(--green); }
.milestone-step.active .milestone-label { color: var(--accent); }
/* Connector line for completed steps */
.milestone-step.completed + .milestone-step::before {
  content: '';
  position: absolute;
  top: 16px;
  right: 50%;
  width: 100%;
  height: 3px;
  background: var(--green);
  z-index: -1;
}

/* ── JOB LAYOUT ────────────────────────────────────────── */
.job-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}
@media (max-width: 900px) {
  .job-layout { grid-template-columns: 1fr; }
}

/* ── CONTACT SIDEBAR ───────────────────────────────────── */
.contact-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.contact-sidebar .card {
  padding: 16px;
}
.contact-sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.contact-sidebar-header .avatar { flex-shrink: 0; }
.contact-sidebar-name { font-size: 14px; font-weight: 600; color: var(--text); }
.contact-sidebar-sub { font-size: 11px; color: var(--text-3); }
.contact-sidebar .stat-row { padding: 6px 0; font-size: 12px; }

/* ── COMMUNICATION THREAD ──────────────────────────────── */
.comm-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.comm-msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}
.comm-msg.outbound {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.comm-msg.inbound {
  background: var(--bg-3);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.comm-msg-meta {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.comm-msg.outbound .comm-msg-meta { color: rgba(255,255,255,0.6); }
.comm-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: 0 0 10px 10px;
}
.comm-input-bar input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.comm-input-bar input:focus { border-color: var(--accent); }
.comm-channel-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  background: var(--bg-3);
  border-radius: 8px;
  padding: 3px;
}
.comm-channel-tab {
  flex: 1;
  text-align: center;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.comm-channel-tab:hover { color: var(--text-2); }
.comm-channel-tab.active {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ── PHOTO GRID ────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.photo-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color var(--tr), transform var(--tr);
  cursor: pointer;
}
.photo-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.photo-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 24px;
}
.photo-card-info {
  padding: 8px 10px;
}
.photo-card-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-card-cat {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}
.photo-category-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  margin-top: 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.photo-category-header:first-child { margin-top: 0; }

/* ── CHECKLIST ─────────────────────────────────────────── */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background var(--tr-fast);
  cursor: pointer;
}
.checklist-item:hover { background: var(--bg-3); }
.checklist-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--tr-fast);
  background: transparent;
}
.checklist-item.checked .checklist-check {
  background: var(--green);
  border-color: var(--green);
}
.checklist-item.checked .checklist-check::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}
.checklist-item.checked .checklist-label {
  text-decoration: line-through;
  color: var(--text-3);
}
.checklist-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.checklist-meta {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ── TAB PANELS ────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── TIMELINE / ACTIVITY ───────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border-2);
  border-radius: 2px;
}
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--border-2);
  z-index: 1;
}
.timeline-item.activity-success .timeline-dot { background: var(--green); border-color: var(--green); }
.timeline-item.activity-warning .timeline-dot { background: var(--amber); border-color: var(--amber); }
.timeline-item.activity-info .timeline-dot { background: var(--accent); border-color: var(--accent); }
.timeline-item.activity-error .timeline-dot { background: var(--red); border-color: var(--red); }
.timeline-content { flex: 1; }
.timeline-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.timeline-desc {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}
.timeline-time {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ── STAT GRID (job overview) ──────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-grid-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  transition: border-color var(--tr);
}
.stat-grid-item:hover { border-color: var(--border-2); }
.stat-grid-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-grid-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-grid-delta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}


/* ============================================================
   MOBILE RESPONSIVE — added for launch
   ============================================================ */
@media (max-width: 1100px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; --topbar-h: 56px; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 260px;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--tr);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
  }
  .sidebar.open + .sidebar-backdrop,
  body.sidebar-open .sidebar-backdrop { display: block; }
  .main { width: 100%; }
  .topbar { padding: 0 14px; }
  .topbar-search { display: none; }
  .topbar-title { font-size: 15px; }
  .content { padding: 14px; }
  .kpi-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 16px; }
  .hero-card { padding: 24px 20px; }
  .hero-title { font-size: 24px !important; }
  .hero-form { flex-direction: column; align-items: stretch; }
  .hero-form input, .hero-form .btn { width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 600px; }
  .kanban-board { overflow-x: auto; }
  .modal { width: calc(100vw - 24px); max-width: 100%; margin: 12px; }
  /* Mobile hamburger button — added via JS, styled here */
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    margin-right: 8px;
  }
}
@media (min-width: 769px) { .mobile-menu-btn { display: none; } }
@media (max-width: 480px) {
  body { font-size: 13px; }
  .kpi-value { font-size: 22px !important; }
  .btn-lg { padding: 10px 16px; font-size: 14px; }
}

/* ============================================================
   PRINT STYLES — for estimates, invoices, contracts
   ============================================================ */
@media print {
  @page { margin: 0.6in; size: letter; }
  body { background: white !important; color: #0f172a !important; font-size: 11pt; }
  .sidebar, .topbar, .topbar-actions, .sidebar-backdrop,
  .modal-backdrop, .toast-container, .mobile-menu-btn,
  .btn, .chip, .quick-prompts, .compose-area,
  .nav-item, .new-item-dropdown, .notif-dot {
    display: none !important;
  }
  .main, .content, .page { padding: 0 !important; margin: 0 !important; width: 100% !important; height: auto !important; overflow: visible !important; }
  .card, .kpi-card, .hero-card {
    background: white !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    color: #0f172a !important;
  }
  .card-title, .hero-title, h1, h2, h3, h4 { color: #0f172a !important; }
  .text-2, .muted, .card-sub { color: #475569 !important; }
  table { border-collapse: collapse; width: 100%; }
  th, td { border: 1px solid #cbd5e1 !important; padding: 6pt 8pt !important; }
  a { color: #0f172a !important; text-decoration: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #475569; }
  .badge { border: 1px solid currentColor; background: transparent !important; }
  .page-break { page-break-before: always; }
}

/* ============================================================
   SKELETON LOADERS & EMPTY STATES
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
  border-radius: 6px;
}
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.med { width: 70%; }
.skeleton-block { height: 80px; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty-state-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; max-width: 320px; margin: 0 auto 16px; line-height: 1.5; }

/* Step spinner animation (measurements) */
.step-spinner { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .step-spinner, .skeleton { animation: none !important; }
}


/* ============================================================
   MISSION CONTROL POLISH PASS
   Aerospace data-room aesthetic — premium beyond Roofr/ST/JN
   ============================================================ */

/* ── ATMOSPHERIC BACKGROUND ─────────────────────────────── */
body.app {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(99,102,241,0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(6,182,212,0.05), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
}
html.theme-light body.app {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(99,102,241,0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(6,182,212,0.04), transparent 60%),
    var(--bg-0);
  background-attachment: fixed;
}

/* Faint noise texture for premium tactility */
body.app::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.025;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}
/* Only real layout children get positioned/stacked — NOT modals, overlays,
   drawers or scripts (forcing position:relative on those broke fixed overlays
   and caused the half-page layout bug). */
body.app > .sidebar, body.app > .main { position: relative; z-index: 2; }

/* ── TOPBAR: backdrop blur + subtle gradient seam ─────── */
.topbar {
  background: rgba(17, 21, 31, 0.72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: relative;
}
html.theme-light .topbar {
  background: rgba(255,255,255,0.72);
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.4), rgba(139,92,246,0.4), transparent);
  opacity: 0.5;
  pointer-events: none;
}

/* ── SIDEBAR: gradient brand seam + refined active state ── */
.sidebar { position: relative; }
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(99,102,241,0.25) 50%, transparent);
  pointer-events: none;
}
.nav-item {
  position: relative;
  transition: background var(--tr), color var(--tr), transform var(--tr);
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,0.14), rgba(99,102,241,0.04));
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(99,102,241,0.6);
}

/* ── KPI CARDS: depth, glow accent, refined hover ─── */
.kpi-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 40%),
    var(--bg-2);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, var(--shadow-sm);
}
html.theme-light .kpi-card {
  background:
    linear-gradient(180deg, rgba(15,23,42,0.015), transparent 40%),
    var(--bg-1);
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.kpi-card::before {
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  opacity: 0.65;
  filter: blur(0.3px);
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: -40%; right: -20%;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.10), transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 280ms ease;
}
.kpi-card:hover::after { opacity: 1; }
.kpi-card:hover {
  border-color: rgba(99,102,241,0.32);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 0 0 1px rgba(99,102,241,0.10);
}
.kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'cv11', 'ss01';
  letter-spacing: -0.025em;
}
.kpi-delta.up::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  margin-right: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  transform: translateY(-1px);
}
.kpi-delta.down::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  margin-right: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transform: translateY(1px);
}

/* ── HERO CARD: gradient mesh + grain ─────────────────── */
.hero-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(800px 400px at 110% -20%, rgba(99,102,241,0.18), transparent 50%),
    radial-gradient(600px 380px at -10% 120%, rgba(139,92,246,0.14), transparent 55%),
    radial-gradient(500px 300px at 50% 50%, rgba(6,182,212,0.06), transparent 55%),
    var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.hero-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04), transparent 30%),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.04), transparent 30%);
  pointer-events: none;
}
.hero-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.04;
  pointer-events: none;
  mix-blend-mode: overlay;
}
.hero-content { position: relative; z-index: 2; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.28);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #a5b4fc;
  text-transform: uppercase;
  box-shadow: 0 0 24px rgba(99,102,241,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
}
.hero-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 14px 0 8px;
  background: linear-gradient(180deg, var(--text), rgba(154,165,185,0.85));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── PRIMARY BUTTONS: refined with sheen ─────────────── */
/* This block silently won the cascade over the earlier, brand-correct
   .btn-primary (line ~828: var(--accent)/var(--accent-2), the app's actual
   cyan-blue #1ab6f1 used as the single source of truth everywhere else —
   badges, links, focus rings, the logo). It hardcoded an off-brand indigo/
   purple (#6e71f3/#5a5ee0, rgba(99,102,241,...)) instead — every primary
   button in the entire app has been the WRONG COLOR the whole time. This is
   the concrete, mechanical answer to "colors don't feel sharp/right" — not
   a vague aesthetic complaint, a duplicate-rule bug matching the exact same
   shape as the .card depth bug fixed just above. Keeping this block's real
   design upgrade (sheen highlight, hover lift, layered shadow — genuinely
   better than the plain first definition) but swapped its hardcoded purple
   for the real brand accent tokens. */
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 1px 2px rgba(0,0,0,0.2),
    0 6px 18px rgba(var(--accent-rgb),0.30);
  position: relative;
  overflow: hidden;
  transition: transform var(--tr), box-shadow var(--tr), background var(--tr);
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 40%);
  pointer-events: none;
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 1px 2px rgba(0,0,0,0.2),
    0 10px 26px rgba(var(--accent-rgb),0.42);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* ── BADGES: refined AI chip with gradient outline ──── */
.badge-ai {
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(139,92,246,0.18));
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.34);
  box-shadow: 0 0 16px rgba(99,102,241,0.18);
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ── LIVE PULSE refined ───────────────────────────────── */
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--green);
  text-transform: uppercase;
}
.live-dot > span {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* ── PAGE ENTRANCE: staggered reveal ────────────────── */
@keyframes ar-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page > * {
  animation: ar-enter 480ms cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}
.page > *:nth-child(1) { animation-delay: 40ms; }
.page > *:nth-child(2) { animation-delay: 100ms; }
.page > *:nth-child(3) { animation-delay: 160ms; }
.page > *:nth-child(4) { animation-delay: 220ms; }
.page > *:nth-child(5) { animation-delay: 280ms; }
.page > *:nth-child(6) { animation-delay: 340ms; }
@media (prefers-reduced-motion: reduce) {
  .page > * { animation: none !important; }
}

/* ── SECTION TITLES (reports) refined ──────────────── */
.report-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.report-section-title::after {
  content: '';
  position: absolute;
  left: 0; bottom: -1px;
  width: 32px; height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ── COMPARE LIST featured row "BEST" badge ─────────── */
.compare-row.featured {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.04));
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 10px;
  box-shadow: 0 0 24px rgba(99,102,241,0.10);
  position: relative;
}
.compare-row.featured::after {
  content: 'BEST';
  position: absolute;
  top: -10px; right: 14px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  padding: 3px 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}
.compare-row.featured .compare-name { color: #a5b4fc; font-weight: 700; }

/* ── PRICE PILL refined ────────────────────────────── */
.price-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  background: linear-gradient(135deg, rgba(16,185,129,0.16), rgba(16,185,129,0.06));
  border: 1px solid rgba(16,185,129,0.34);
  color: #6ee7b7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 0 18px rgba(16,185,129,0.12);
}

/* ── EMPTY STATE refined ────────────────────────────── */
.empty-state-icon {
  background:
    radial-gradient(circle at 30% 30%, rgba(99,102,241,0.10), transparent 50%),
    var(--bg-2);
  border: 1px solid var(--border-2);
}

/* ── LOGO MARK: depth ───────────────────────────────── */
.logo-mark svg {
  filter: drop-shadow(0 4px 14px rgba(99,102,241,0.45));
  transition: filter var(--tr);
}
.logo-link:hover .logo-mark svg {
  filter: drop-shadow(0 6px 20px rgba(99,102,241,0.7));
}

/* ── SEARCH BAR refined ─────────────────────────────── */
.topbar-search {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  transition: border-color var(--tr), background var(--tr);
}
html.theme-light .topbar-search { background: rgba(15,23,42,0.03); }
.topbar-search:focus-within {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.05);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.10);
}
.topbar-search .kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--text-3);
  background: rgba(255,255,255,0.04);
}

/* ── SCROLLBAR refined ──────────────────────────────── */
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--border-2), var(--border-3));
  background-clip: padding-box;
}

/* ── PROGRESS STEPS (measurements) refined ──────────── */
.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  margin-top: 8px;
  transition: all var(--tr);
  font-size: 13px;
}
.progress-step.active {
  background: linear-gradient(90deg, rgba(99,102,241,0.10), rgba(99,102,241,0.02));
  border-color: rgba(99,102,241,0.36);
  box-shadow: 0 0 18px rgba(99,102,241,0.10);
}
.progress-step.done {
  background: rgba(16,185,129,0.06);
  border-color: rgba(16,185,129,0.30);
}
.progress-step.done .step-check { color: var(--green); }
.progress-step .step-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
}
.progress-step.active .step-icon {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: rgba(99,102,241,0.6);
  color: #fff;
}
.progress-step .step-label { flex: 1; color: var(--text); font-weight: 500; }
.progress-step .step-check { color: var(--text-3); }
.progress-step.active .step-check { color: var(--accent); }

/* ── RESULT PANEL (measurements) refined ─────────── */
.result-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(99,102,241,0.06));
  border: 1px solid rgba(16,185,129,0.28);
}
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.result-head h3 { font-size: 15px; font-weight: 700; }
.result-head .result-tag {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--green);
}
.result-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 768px) { .result-grid { grid-template-columns: repeat(2, 1fr); } }
.result-kv {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.result-kv > b {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.result-actions { display: flex; gap: 8px; }


/* ============================================================
   COMMAND PALETTE (⌘K) — Linear/Vercel-grade
   ============================================================ */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.62);
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.cmdk-overlay.open { opacity: 1; pointer-events: auto; }

.cmdk-panel {
  width: 100%;
  max-width: 640px;
  background: linear-gradient(180deg, rgba(29,35,51,0.96), rgba(17,21,31,0.96));
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.55),
    0 0 0 1px rgba(99,102,241,0.08),
    inset 0 1px 0 rgba(255,255,255,0.05);
  overflow: hidden;
  transform: translateY(-10px) scale(0.985);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.2,0.7,0.2,1), opacity 240ms;
}
.cmdk-overlay.open .cmdk-panel { transform: translateY(0) scale(1); opacity: 1; }
html.theme-light .cmdk-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,247,251,0.98));
}

.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.cmdk-input-wrap::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.4), transparent);
  opacity: 0.6;
}
.cmdk-search-icon { color: var(--text-3); display: flex; align-items: center; }
.cmdk-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  letter-spacing: -0.01em;
}
.cmdk-input-wrap input::placeholder { color: var(--text-3); }
.cmdk-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--text-3);
  background: rgba(255,255,255,0.04);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cmdk-results {
  max-height: 56vh;
  overflow-y: auto;
  padding: 6px 6px;
}
.cmdk-results::-webkit-scrollbar { width: 6px; }

.cmdk-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 12px 6px;
}
.cmdk-group-label:first-child { padding-top: 8px; }

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 1px 0;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background var(--tr-fast);
}
.cmdk-item.selected {
  background: linear-gradient(90deg, rgba(99,102,241,0.18), rgba(99,102,241,0.06));
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.25);
}
.cmdk-item.selected::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.cmdk-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  flex-shrink: 0;
}
.cmdk-item.selected .cmdk-icon {
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(139,92,246,0.18));
  border-color: rgba(99,102,241,0.45);
  color: #c7d2fe;
}

.cmdk-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.cmdk-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmdk-type {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 3px 7px;
  border: 1px solid var(--border-2);
  border-radius: 99px;
  flex-shrink: 0;
}
.cmdk-item.selected .cmdk-type {
  color: #c7d2fe;
  border-color: rgba(99,102,241,0.35);
  background: rgba(99,102,241,0.08);
}

.cmdk-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.cmdk-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
  background: rgba(0,0,0,0.18);
}
html.theme-light .cmdk-footer { background: rgba(15,23,42,0.02); }
.cmdk-footer kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 5px;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text-2);
  background: rgba(255,255,255,0.04);
  margin-right: 3px;
}
.cmdk-brand {
  margin-left: auto;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

@media (max-width: 600px) {
  .cmdk-overlay { padding-top: 8vh; align-items: stretch; }
  .cmdk-panel { max-width: 100%; }
  .cmdk-type { display: none; }
}


/* ============================================================
   MISSING-CLASS RECOVERY + PAGE-LEVEL POLISH
   Fixes orphaned class names referenced in pages.
   ============================================================ */

/* ── PAGE HEADER (used on pipeline, others) ─────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.page-head::after {
  content: '';
  position: absolute;
  left: 0; bottom: -1px;
  width: 64px; height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.page-title-inline {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.15;
}
.page-head .muted, .muted {
  color: var(--text-2);
  font-size: 13px;
}
.live-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   KANBAN — Pipeline page (kan-* classes)
   Premium drag-and-drop board, scrolling horizontally on overflow
   ============================================================ */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(260px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.kanban::-webkit-scrollbar { height: 8px; }

.kan-col {
  background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent 50%), var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px 12px;
  min-height: 60vh;
  scroll-snap-align: start;
  position: relative;
  transition: border-color var(--tr), background var(--tr);
}
.kan-col.drag-over {
  border-color: rgba(99,102,241,0.55);
  background: linear-gradient(180deg, rgba(99,102,241,0.08), transparent 60%), var(--bg-2);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.25), 0 12px 32px rgba(99,102,241,0.12);
}

.kan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.kan-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}
.kan-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.kan-dot-grey   { background: #6b7280; box-shadow: 0 0 8px rgba(107,114,128,0.45); }
.kan-dot-blue   { background: var(--blue);    box-shadow: 0 0 8px rgba(59,130,246,0.55); }
.kan-dot-purple { background: var(--accent-2); box-shadow: 0 0 8px rgba(139,92,246,0.55); }
.kan-dot-amber  { background: var(--amber);   box-shadow: 0 0 8px rgba(245,158,11,0.55); }
.kan-dot-pink   { background: var(--pink);    box-shadow: 0 0 8px rgba(236,72,153,0.55); }
.kan-dot-green  { background: var(--green);   box-shadow: 0 0 8px rgba(16,185,129,0.55); }
.kan-dot-teal   { background: #14b8a6;        box-shadow: 0 0 8px rgba(20,184,166,0.55); }
.kan-dot-red    { background: #ef4444;         box-shadow: 0 0 8px rgba(239,68,68,0.55); }

.kan-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  min-width: 22px;
  text-align: center;
}
.kan-total {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin: 0 4px 14px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.kan-total::after {
  content: 'total';
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.kan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kan-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 60%), var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 12px 12px 11px;
  cursor: grab;
  transition: transform var(--tr), border-color var(--tr), box-shadow var(--tr), background var(--tr);
  position: relative;
  overflow: hidden;
}
.kan-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity var(--tr);
}
.kan-card:hover {
  border-color: rgba(99,102,241,0.36);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.32), 0 0 0 1px rgba(99,102,241,0.10);
}
.kan-card:hover::before { opacity: 1; }
.kan-card:active { cursor: grabbing; }

.kan-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
  margin-bottom: 3px;
}
.kan-card-addr {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
}
.kan-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-bottom: 6px;
}
.kan-card-foot > b {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mini-score {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(139,92,246,0.12));
  border: 1px solid rgba(99,102,241,0.28);
  color: #a5b4fc;
}
.engagement-dots {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.eng-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bg-4);
  transition: background var(--tr);
}
.eng-dot.on {
  background: var(--green);
  box-shadow: 0 0 6px rgba(16,185,129,0.5);
}

/* Stage-specific kan-col accent on top */
.kan-col[data-stage="new"]         { border-top: 2px solid rgba(107,114,128,0.5); }
.kan-col[data-stage="contacted"]   { border-top: 2px solid rgba(59,130,246,0.55); }
.kan-col[data-stage="inspection"]  { border-top: 2px solid rgba(139,92,246,0.55); }
.kan-col[data-stage="proposal"]    { border-top: 2px solid rgba(245,158,11,0.55); }
.kan-col[data-stage="negotiating"] { border-top: 2px solid rgba(236,72,153,0.55); }
.kan-col[data-stage="won"]         { border-top: 2px solid rgba(16,185,129,0.6); }

@media (max-width: 1400px) {
  .kanban { grid-template-columns: repeat(6, 240px); }
}
@media (max-width: 768px) {
  .kanban { grid-template-columns: repeat(6, 78vw); gap: 10px; }
  .kan-col { min-height: 50vh; }
}

/* ============================================================
   MODAL DETAIL (used in pipeline card modal)
   Scoped to body.app > .modal — same reasoning as the "MODAL OVERLAY
   SYSTEM (updated)" block above; do not widen past a direct child of
   body.app, see that comment for the full explanation.
   ============================================================ */
body.app > .modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
body.app > .modal.active { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5,8,14,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg, rgba(29,35,51,0.98), rgba(17,21,31,0.98));
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.04);
  z-index: 2;
  animation: modal-rise 240ms cubic-bezier(0.2,0.7,0.2,1);
}
.modal-panel.modal-lg { max-width: 640px; }
html.theme-light .modal-panel {
  background: linear-gradient(180deg, #fff, #f7f9fd);
}
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: background var(--tr), color var(--tr);
}
.modal-close:hover { background: var(--bg-4); color: var(--text); }

.modal-panel h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.modal-panel h3 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.modal-panel .muted { font-size: 13px; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.mt-20 { margin-top: 20px; }

.stat-box {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat-box .muted {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-box h3 { margin-top: 4px; font-variant-numeric: tabular-nums; }

.ai-rec {
  background: linear-gradient(135deg, rgba(99,102,241,0.10), rgba(139,92,246,0.06));
  border: 1px solid rgba(99,102,241,0.28);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 0 24px rgba(99,102,241,0.08);
}
.ai-rec-head {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a5b4fc;
  margin-bottom: 6px;
}
.ai-rec p { font-size: 13px; line-height: 1.55; color: var(--text); margin: 0; }
.ai-rec p b { color: var(--green); font-weight: 700; }

/* ============================================================
   CHIPS — Filter pills (dashboard, others)
   ============================================================ */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,0.03);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--tr);
  font-family: inherit;
}
.chip:hover { color: var(--text); border-color: var(--border-3); }
.chip.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(139,92,246,0.16));
  border-color: rgba(99,102,241,0.5);
  color: #c7d2fe;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.15);
}

/* ============================================================
   DROPDOWNS (new-item)
   ============================================================ */
.new-item-dropdown {
  background: linear-gradient(180deg, rgba(29,35,51,0.98), rgba(17,21,31,0.98));
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
  z-index: 600;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transition: opacity var(--tr), transform var(--tr);
}
.new-item-dropdown.show { opacity: 1; transform: translateY(0) scale(1); }
.new-item-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--tr-fast);
}
.new-item-option:hover {
  background: linear-gradient(90deg, rgba(99,102,241,0.15), rgba(99,102,241,0.04));
  color: var(--text);
}
.new-item-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: 7px;
  color: var(--text-2);
}
.new-item-option:hover .new-item-icon { color: var(--accent); background: rgba(99,102,241,0.18); }


/* ============================================================
   PAGE STYLE RECOVERY — Dashboard, Measurements, Estimates,
   Jobs, Leads, Client — all classes the HTML actually uses.
   ============================================================ */

/* Alias .card-head -> same as .card-header for legacy markup */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* ── DASHBOARD: Activity feed ───────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  transition: background var(--tr-fast);
}
.activity-item:hover { background: rgba(255,255,255,0.025); }
.activity-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(99,102,241,0.14);
  color: #a5b4fc;
  flex-shrink: 0;
  font-size: 14px;
}
.activity-icon.green { background: rgba(16,185,129,0.14); color: #6ee7b7; }
.activity-icon.amber { background: rgba(245,158,11,0.14); color: #fcd34d; }
.activity-icon.blue  { background: rgba(59,130,246,0.14); color: #93c5fd; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.35; }
.activity-time {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.activity-user { color: var(--accent); font-weight: 600; }
.activity-text { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.activity-action {
  font-size: 11px; font-weight: 600; color: var(--accent);
  margin-top: 4px; cursor: pointer;
}

/* ── DASHBOARD: AI Insight cards ────────────────────── */
.insight-list { display: flex; flex-direction: column; gap: 10px; }
.insight {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  position: relative;
  transition: border-color var(--tr), transform var(--tr);
}
.insight:hover { transform: translateY(-1px); }
.insight-green  { border-left: 3px solid var(--green); background: linear-gradient(90deg, rgba(16,185,129,0.06), transparent 30%), var(--bg-2); }
.insight-amber  { border-left: 3px solid var(--amber); background: linear-gradient(90deg, rgba(245,158,11,0.06), transparent 30%), var(--bg-2); }
.insight-purple { border-left: 3px solid var(--accent-2); background: linear-gradient(90deg, rgba(139,92,246,0.06), transparent 30%), var(--bg-2); }
.insight-red    { border-left: 3px solid var(--red); background: linear-gradient(90deg, rgba(239,68,68,0.06), transparent 30%), var(--bg-2); }
.insight-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.insight-head strong { font-size: 12.5px; color: var(--text); }
.insight-icon {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-2);
}
.insight p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); margin: 0 0 8px; }
.insight p b { color: var(--text); font-weight: 700; }

/* ── DASHBOARD: Job row, lead row in card lists ──────── */
.job-list, .lead-list { display: flex; flex-direction: column; gap: 2px; }
.job-row, .lead-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  transition: background var(--tr-fast);
}
.job-row:hover, .lead-row:hover { background: rgba(255,255,255,0.025); cursor: pointer; }
.job-info, .lead-body { flex: 1; min-width: 0; }
.job-addr, .lead-meta {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job-row > .job-info > div:first-child,
.lead-name {
  font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px;
}
.job-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.job-pct {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(99,102,241,0.14);
  color: #a5b4fc;
  font-variant-numeric: tabular-nums;
}
.link-sm {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  transition: opacity var(--tr-fast);
}
.link-sm:hover { opacity: 0.8; }

/* ── DASHBOARD: KPI spark + chart wrap ──────────────── */
.kpi-spark {
  height: 28px;
  margin-top: 8px;
  background-image: linear-gradient(90deg, rgba(99,102,241,0.25), rgba(139,92,246,0.25));
  -webkit-mask: linear-gradient(180deg, currentColor, currentColor) no-repeat;
          mask: linear-gradient(180deg, currentColor, currentColor) no-repeat;
  position: relative;
  border-radius: 4px;
  opacity: 0.45;
}
.kpi-spark::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 60%, rgba(99,102,241,0.10) 100%),
    repeating-linear-gradient(90deg, transparent 0 12px, rgba(255,255,255,0.04) 12px 13px);
  border-radius: inherit;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(17,21,31,0.95);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--tr-fast);
  z-index: 5;
}

/* ── BADGE COLORS — fill the gaps ───────────────────── */
/* This re-declared the .badge base (same shape as the .card/.btn-primary
   cascade bugs above) and, in doing so, silently dropped the earlier
   block's `gap` (icon+text badges lost their spacing) and inset box-shadow
   ring. Restored both; kept this block's actual point — the uppercase/
   letter-spaced treatment + color variants below it. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  white-space: nowrap;
}
.badge-gray   { background: rgba(148,163,184,0.14); color: #cbd5e1; border-color: rgba(148,163,184,0.25); }
.badge-grey   { background: rgba(148,163,184,0.14); color: #cbd5e1; border-color: rgba(148,163,184,0.25); }
.badge-blue   { background: rgba(59,130,246,0.16);  color: #93c5fd; border-color: rgba(59,130,246,0.32); }
.badge-purple { background: rgba(139,92,246,0.16);  color: #c4b5fd; border-color: rgba(139,92,246,0.32); }
.badge-amber  { background: rgba(245,158,11,0.16);  color: #fcd34d; border-color: rgba(245,158,11,0.32); }
.badge-green  { background: rgba(16,185,129,0.16);  color: #6ee7b7; border-color: rgba(16,185,129,0.32); }
.badge-red    { background: rgba(239,68,68,0.16);   color: #fca5a5; border-color: rgba(239,68,68,0.32); }
.badge-pink   { background: rgba(236,72,153,0.16);  color: #f9a8d4; border-color: rgba(236,72,153,0.32); }
.badge-cyan   { background: rgba(6,182,212,0.16);   color: #67e8f9; border-color: rgba(6,182,212,0.32); }

/* ── MEASUREMENTS: hero, progress, compare ──────────── */
.hero-card { padding: 28px 28px 26px; }
.hero-bg { display: none; }
.hero-sub {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0 0 16px;
  max-width: 640px;
}
.hero-form {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  max-width: 640px;
}
.hero-form input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color var(--tr), background var(--tr);
}
.hero-form input:focus {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.06);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}
.hero-form input::placeholder { color: var(--text-3); }
.hero-pricing {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.btn-lg { padding: 11px 22px; font-size: 14px; font-weight: 600; border-radius: 10px; }

.progress-panel {
  margin-top: 18px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
}

.compare-list { display: flex; flex-direction: column; gap: 8px; }
.compare-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 10px;
  gap: 12px;
  transition: border-color var(--tr);
}
.compare-row:hover { border-color: var(--border-2); }
.compare-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.compare-stats {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.compare-stats > div { display: flex; flex-direction: column; align-items: flex-end; }
.compare-stats b { font-size: 13px; font-weight: 700; color: var(--text); margin-top: 1px; }

/* ── DATA TABLES: canonical definition ──────────────── */
/* Previously three separate .data-table blocks scattered through this file
   (widely-spaced additions each redeclaring the base), cascade-order and
   specificity dependent as to which behavior a given page actually got —
   same bug class as .card/.btn-primary/.badge. Consolidated to one block;
   the row-hover tint used to be `rgba(99,102,241,...)` — leftover indigo,
   not the app's brand accent — now uses --accent-rgb like everywhere else. */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
  position: sticky; top: 0; z-index: 2;
  font-feature-settings: 'cv11', 'ss01';
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tbody td b { color: var(--text); font-weight: 600; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; transition: background var(--tr-fast); }
.data-table tbody tr:hover td { background: linear-gradient(90deg, rgba(var(--accent-rgb),0.07), transparent); }
.data-table.compact thead th { padding: 8px 12px; }
.data-table.compact tbody td { padding: 9px 12px; }
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-1);
}
.cell-muted { color: var(--text-3); font-size: 12px; }

/* ── LEADS / GENERIC: score & status badges ─────────── */
.score-green, .score-pos { background: rgba(16,185,129,0.16); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.32); padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-amber, .score-mid { background: rgba(245,158,11,0.16); color: #fcd34d; border: 1px solid rgba(245,158,11,0.32); padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-red, .score-neg, .score-low { background: rgba(239,68,68,0.16); color: #fca5a5; border: 1px solid rgba(239,68,68,0.32); padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── ESTIMATES: summary boxes ───────────────────────── */
.est-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.est-ctrl-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ctrl-box { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--text-2); }
.summary-box {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 50%), var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.summary-total {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.savings-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(16,185,129,0.20), rgba(16,185,129,0.08));
  border: 1px solid rgba(16,185,129,0.34);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 700;
}
.status-lg {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.modal-xl { max-width: 880px; }

/* ── JOBS: calendar / view toggle / progress slider ─── */
.view-toggle { display: inline-flex; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.toggle-btn {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--tr);
}
.toggle-btn.active {
  background: var(--bg-3);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.cal-dow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
  padding: 4px 0;
}
.cal-cell {
  min-height: 90px;
  padding: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background var(--tr-fast);
}
.cal-cell:hover { background: rgba(255,255,255,0.04); }
.cal-cell.today {
  background: linear-gradient(180deg, rgba(99,102,241,0.10), transparent 50%);
  border-color: rgba(99,102,241,0.36);
}
.cal-date {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.cal-cell.today .cal-date { color: var(--accent); }
.cal-pill {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(99,102,241,0.18);
  color: #c7d2fe;
  border: 1px solid rgba(99,102,241,0.28);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.crew-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.pct {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.pct-good { background: rgba(16,185,129,0.16); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.32); }
.pct-warn { background: rgba(245,158,11,0.16); color: #fcd34d; border: 1px solid rgba(245,158,11,0.32); }
.slider {
  flex: 1;
  height: 4px;
  background: var(--bg-4);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.slider::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--pct, 50%);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
}

/* ── CLIENT page ────────────────────────────────────── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.client-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 50%), var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color var(--tr), transform var(--tr);
}
.client-card:hover { border-color: rgba(99,102,241,0.32); transform: translateY(-2px); }
.client-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.client-card-info { flex: 1; min-width: 0; }
.client-name { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.client-email, .client-phone {
  font-size: 12px;
  color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 2px;
}
.client-tags { display: flex; gap: 5px; flex-wrap: wrap; margin: 8px 0; }
.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(99,102,241,0.14);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.24);
}
.client-stats { display: flex; gap: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.mini-stats { display: flex; flex-direction: column; }
.mini-stats > span:first-child {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3);
}
.mini-stats > span:last-child {
  font-size: 14px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.prop-list { display: flex; flex-direction: column; gap: 6px; }
.prop-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  background: rgba(255,255,255,0.025);
  border-radius: 8px;
  font-size: 12px;
}
.prop-row .icon { color: var(--text-3); }
.comm-list { display: flex; flex-direction: column; gap: 6px; }
.comm-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.comm-row:hover { background: rgba(255,255,255,0.025); }
.comm-body { flex: 1; }
.filter-bar-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.btn-block { width: 100%; }

/* ── BUTTON BASE / VARIANTS (ensure all exist) ─────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--bg-3);
  color: var(--text);
  font-family: inherit;
  transition: all var(--tr);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); border-color: var(--border-3); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── CARD base, ensure presence ─────────────────────── */
/* This block used to silently win the cascade over the EARLIER, more
   deliberate .card rule (line ~729: var(--surface) gradient background +
   var(--shadow-sm)+var(--hairline) for real elevation) — later rule, same
   specificity, wins regardless of intent. Every card in the app rendered
   completely flat (var(--bg-1), no shadow at all) the whole time, which is
   a real, concrete piece of "why does this look dated/flat" — not a vague
   color complaint, a duplicate-rule bug identical in shape to the modal and
   toast z-index cascade bugs fixed earlier this session. Merged: keep this
   block's subtle gradient sheen + position:relative (child badges rely on
   it), restore the original's shadow + --surface tone instead of flat bg-1. */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent 60%), var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-sm), var(--hairline);
}
html.theme-light .card { background: linear-gradient(180deg, rgba(15,23,42,0.012), transparent 60%), var(--surface); }

/* KPI bar (scheduler) — same layout as kpi-grid */
.kpi-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .kpi-bar { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .kpi-bar { grid-template-columns: 1fr; } }

/* Status pills used by estimates */
.status {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.status-draft     { background: rgba(148,163,184,0.14); color: #cbd5e1; border-color: rgba(148,163,184,0.25); }
.status-sent      { background: rgba(59,130,246,0.16);  color: #93c5fd; border-color: rgba(59,130,246,0.32); }
.status-approved  { background: rgba(16,185,129,0.16);  color: #6ee7b7; border-color: rgba(16,185,129,0.32); }
.status-declined  { background: rgba(239,68,68,0.16);   color: #fca5a5; border-color: rgba(239,68,68,0.32); }
.status-signed    { background: rgba(16,185,129,0.16);  color: #6ee7b7; border-color: rgba(16,185,129,0.32); }
.status-accepted  { background: rgba(16,185,129,0.16);  color: #6ee7b7; border-color: rgba(16,185,129,0.32); }
.status-invoiced  { background: rgba(139,92,246,0.16);  color: #c4b5fd; border-color: rgba(139,92,246,0.32); }
.status-voided    { background: rgba(148,163,184,0.10); color: #94a3b8; border-color: rgba(148,163,184,0.20); }
.status-pending   { background: rgba(245,158,11,0.16);  color: #fcd34d; border-color: rgba(245,158,11,0.32); }

/* Delta variants used by scheduler */
.delta-up      { color: var(--green); }
.delta-down    { color: var(--red); }
.delta-neutral { color: var(--text-3); }
.delta-up::before, .delta-down::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  margin-right: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.delta-up::before   { border-bottom: 5px solid currentColor; transform: translateY(-1px); }
.delta-down::before { border-top: 5px solid currentColor; transform: translateY(1px); }

/* TOPBAR title group, ensure presence */
.topbar {
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 22px;
  gap: 16px;
}
.topbar-title-group { flex: 1; min-width: 0; }
.topbar-title { font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: -0.005em; }
.topbar-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  min-width: 280px;
}
.topbar-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.topbar-search input::placeholder { color: var(--text-3); }
.topbar-search svg { color: var(--text-3); }
.topbar-btn, .theme-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  position: relative;
  transition: all var(--tr);
}
.topbar-btn:hover, .theme-toggle:hover { background: var(--bg-3); color: var(--text); }
.notif-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 999px;
  box-shadow: 0 0 0 2px var(--bg-1);
}
.icon-sun { display: none; }
html.theme-light .icon-moon { display: none; }
html.theme-light .icon-sun { display: block; }

/* Main / content fallbacks */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.page { display: flex; flex-direction: column; gap: 18px; }

/* Toast container (in case unstyled) */
/* z-index MUST stay above .modal-backdrop (1000) and .modal (1000/500).
   This later rule used to set 800, overriding the earlier 2000 and burying
   every toast BEHIND the modal — so validation errors raised while a modal
   was open ("Select a supplier", "Could not save the order: ...") rendered
   invisibly under the dimmed backdrop. The form looked frozen: the click
   did something, the user just couldn't see what. Keep this above 1000. */
.toast-container { position: fixed; bottom: 22px; right: 22px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px;
  background: linear-gradient(180deg, rgba(29,35,51,0.98), rgba(17,21,31,0.98));
  border: 1px solid var(--border-2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--tr), transform var(--tr);
  min-width: 220px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

/* Sidebar internals (in case unstyled) */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar-section {
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item svg { color: currentColor; }
.nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
}
.nav-badge-accent {
  background: linear-gradient(135deg, rgba(99,102,241,0.28), rgba(139,92,246,0.20));
  color: #c7d2fe;
}
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
  transition: background var(--tr-fast);
}
.user-card:hover { background: var(--bg-3); }
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-3); }
.logo-text { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.05; color: var(--text); }
.logo-text span { font-weight: 600; color: var(--text-2); }
.logo-sub { font-size: 9px; font-weight: 800; letter-spacing: 0.18em; color: var(--text-3); margin-top: 2px; }

/* ── Pipeline stage bar (under the topbar) ──────────────────────────────────
   Shows the job lifecycle Lead → … → Get Paid and highlights the current stage,
   so the workflow is visible without hunting through the sidebar. */
.stage-bar {
  display: flex; align-items: stretch; gap: 2px;
  padding: 8px 18px; overflow-x: auto; flex: none;
  background: var(--bg-1); border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}
.stage-bar .stage {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px 7px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--text-3); text-decoration: none;
  transition: background 140ms, color 140ms;
}
.stage-bar .stage:hover { background: var(--bg-2); color: var(--text); }
.stage-bar .stage-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border-radius: 50%; flex: none;
  font-size: 10.5px; font-weight: 800;
  background: var(--bg-3); color: var(--text-3);
}
.stage-bar .stage.done { color: var(--text-2); }
.stage-bar .stage.done .stage-num { background: rgba(16,185,129,.16); color: #059669; }
.stage-bar .stage.current { background: var(--accent); color: #fff; }
.stage-bar .stage.current:hover { background: var(--accent); color: #fff; filter: brightness(1.05); }
.stage-bar .stage.current .stage-num { background: rgba(255,255,255,.24); color: #fff; }
@media (max-width: 760px) {
  .stage-bar { padding: 6px 10px; }
  .stage-bar .stage-label { display: none; }   /* numbers only on small screens */
  .stage-bar .stage { padding: 7px 9px; }
}
@media print { .stage-bar { display: none !important; } }

/* Dismiss control on the "Getting Started" nav item. */
.nav-item .nav-dismiss {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 12px; line-height: 1; padding: 3px 4px;
  border-radius: 5px; opacity: 0;
}
.nav-item:hover .nav-dismiss { opacity: 1; }
.nav-item .nav-dismiss:hover { background: var(--bg-3); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════════
   ENTERPRISE POLISH LAYER  (2026-07-15)
   Appended last so it refines the components above without rewriting them.
   Goal: the "$100M SaaS dashboard" feel — quiet depth, tight hierarchy, one
   consistent focus/hover/scroll language. Scoped to html.theme-light for
   color-specific rules; theme-agnostic rules (scrollbars, focus, selection)
   apply everywhere. Nothing here changes layout structure or JS hooks.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom scrollbars — thin, unobtrusive, the single biggest "premium" tell ─ */
* { scrollbar-width: thin; scrollbar-color: var(--border-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--border-3); background-clip: padding-box; }

/* ── Text selection: brand-tinted instead of default OS blue ── */
::selection { background: var(--accent-soft, rgba(26,182,241,0.18)); color: var(--text); }

/* ── Page canvas: give the content a hair of warmth so white cards "pop" ── */
html.theme-light body,
html.theme-light .main,
html.theme-light .content { background: var(--bg-0); }

/* ── Sidebar refinement ─────────────────────────────────────────────────────
   .sidebar's own background/border are set once, near the top of the light
   theme (the navy-chrome-on-white-workspace block) — not redeclared here.
   Redeclaring it in this block was the exact silent-override bug already
   fixed for .badge/.data-table/.card: this rule and the navy block share
   specificity, so whichever loads later always won, regardless of intent. */
html.theme-light .sidebar-section {
  color: var(--text-4);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  margin-top: 6px;
}
html.theme-light .nav-item {
  color: var(--text-2);
  font-weight: 500;
  border-radius: 8px;
}
html.theme-light .nav-item svg { color: var(--text-3); transition: color var(--tr-fast); }
html.theme-light .nav-item:hover { background: var(--bg-2); color: var(--text); }
html.theme-light .nav-item:hover svg { color: var(--text-2); }
html.theme-light .nav-item.active {
  background: var(--accent-soft, rgba(26,182,241,0.10));
  color: var(--accent-2);
  font-weight: 600;
}
html.theme-light .nav-item.active svg { color: var(--accent); }

/* ── Topbar: sits on the canvas as a clean bar, subtle bottom hairline ── */
html.theme-light .topbar {
  background: rgba(255,255,255,0.85);
  border-bottom: 1px solid var(--border);
}
html.theme-light .topbar-title { font-size: 15px; font-weight: 650; letter-spacing: var(--tracking-tight); }
html.theme-light .topbar-sub { color: var(--text-3); }
html.theme-light .topbar-search { background: var(--bg-3); border-color: var(--border); }
html.theme-light .topbar-search:focus-within { background: #fff; border-color: var(--accent); }
html.theme-light .topbar-btn,
html.theme-light .theme-toggle { background: var(--bg-1); border-color: var(--border); }
html.theme-light .topbar-btn:hover,
html.theme-light .theme-toggle:hover { background: var(--bg-3); border-color: var(--border-2); }

/* ── Tables: sticky header, quiet zebra, brand-tinted row hover, cell rhythm ──
   Applies to both .table and the .data-table variant used on list pages. */
html.theme-light .table th,
html.theme-light .data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-2);
  backdrop-filter: saturate(140%) blur(6px);
}
html.theme-light .table tbody tr:nth-child(even) td,
html.theme-light .data-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-3) 45%, transparent); }
html.theme-light .table tbody tr:hover td,
html.theme-light .data-table tbody tr:hover td { background: var(--accent-soft, rgba(26,182,241,0.08)); }
html.theme-light .table td:first-child,
html.theme-light .data-table td:first-child,
html.theme-light .table th:first-child,
html.theme-light .data-table th:first-child { padding-left: 18px; }
html.theme-light .table td:last-child,
html.theme-light .data-table td:last-child,
html.theme-light .table th:last-child,
html.theme-light .data-table th:last-child { padding-right: 18px; }

/* ── Buttons: consistent height, tighter label, crisp interaction ── */
html.theme-light .btn { font-weight: 600; letter-spacing: 0; border-radius: 8px; transition: background var(--tr-fast), box-shadow var(--tr-fast), transform var(--tr-fast); }
html.theme-light .btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 1px 2px rgba(15,23,42,0.10), inset 0 1px 0 rgba(255,255,255,0.20);
}
html.theme-light .btn-primary:hover { box-shadow: 0 4px 12px rgba(26,182,241,0.32), inset 0 1px 0 rgba(255,255,255,0.24); }
html.theme-light .btn-secondary { background: var(--bg-1); border: 1px solid var(--border-2); color: var(--text); }
html.theme-light .btn-secondary:hover { background: var(--bg-2); border-color: var(--border-3); }
html.theme-light .btn-ghost { color: var(--text-2); }
html.theme-light .btn-ghost:hover { background: var(--bg-3); color: var(--text); }

/* ── Inputs: uniform surface, one focus language everywhere ── */
html.theme-light input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.theme-light select,
html.theme-light textarea,
html.theme-light .input {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: 8px;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
html.theme-light input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"])::placeholder,
html.theme-light textarea::placeholder { color: var(--text-4); }
html.theme-light input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):focus,
html.theme-light select:focus,
html.theme-light textarea:focus,
html.theme-light .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(26,182,241,0.16));
}

/* ── Badges / status pills: consistent rounded chips, semantic tints ── */
html.theme-light .badge {
  font-weight: 650;
  font-size: 11px;
  letter-spacing: 0.01em;
  border-radius: 999px;
  padding: 3px 10px;
}
html.theme-light .badge-green, html.theme-light .badge.badge-green { background: rgba(16,185,129,0.12); color: #047857; }
html.theme-light .badge-amber, html.theme-light .badge.badge-amber { background: rgba(245,158,11,0.14); color: #b45309; }
html.theme-light .badge-red,   html.theme-light .badge.badge-red   { background: rgba(239,68,68,0.12);  color: #b91c1c; }
html.theme-light .badge-blue,  html.theme-light .badge.badge-blue  { background: var(--accent-soft, rgba(26,182,241,0.12)); color: #0369a1; }
html.theme-light .badge-gray,  html.theme-light .badge.badge-gray  { background: var(--bg-4); color: var(--text-2); }

/* ── Dividers / hairlines read consistently ── */
html.theme-light hr { border: none; border-top: 1px solid var(--border); }

/* ── Reduced-motion respect: kill the lift/transition micro-interactions ── */
@media (prefers-reduced-motion: reduce) {
  html.theme-light .kpi-card:hover,
  html.theme-light .card.is-interactive:hover { transform: none; }
  * { scroll-behavior: auto !important; }
}

/* ════════════════════════════════════════════════════════════════════════════
   SIDEBAR READABILITY — AUTHORITATIVE (last word)
   The file layers several .nav-item / .sidebar-section rules (base + light
   theme + appended polish), so earlier passes kept getting overridden. This
   block is last + uses the .sidebar ancestor for higher specificity so it wins
   definitively. Targets: crisp, AA-contrast menu that's easy to scan.
   Colors are tokens, not hardcoded hex, so this repaints correctly against
   the navy sidebar chrome (see the html.theme-light .sidebar block near the
   top of the file) instead of assuming a white surface. */
html.theme-light .sidebar .nav-item {
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.006em;
}
html.theme-light .sidebar .nav-item:hover { color: var(--text); background: var(--bg-3); }
html.theme-light .sidebar .nav-item.active,
html.theme-light .sidebar .nav-item.active:hover {
  color: var(--accent);
  background: rgba(var(--accent-rgb),0.16);
  font-weight: 700;
}
html.theme-light .sidebar .sidebar-section {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
/* Icons: a touch larger + fully opaque so labels + glyphs read as one crisp row */
html.theme-light .sidebar .nav-item svg { width: 17px; height: 17px; opacity: 1; color: var(--text-3); }
html.theme-light .sidebar .nav-item.active svg { color: var(--accent); }
html.theme-light .sidebar .nav-item:hover svg { color: var(--text); }

/* ════════════════════════════════════════════════════════════════════════════
   ENTERPRISE REFINEMENT — "$100M dashboard" pass (LAST layer, wins the cascade)
   Direction: refined-minimal, financial-grade. Not louder — SHARPER. A cool
   canvas so white cards read crisp + elevated; hairline borders with a whisper
   of blue; a proper 2-layer soft shadow; a distinctive display face (Hanken
   Grotesk) with tight tracking; tabular figures everywhere numbers live; and
   componentry (buttons, inputs, tables, KPIs) tuned to Linear/Ramp/Mercury
   crispness. Scoped to html.theme-light (the default) so dark theme is untouched.
   ════════════════════════════════════════════════════════════════════════════ */

/* Display face — replaces dated Montserrat on every heading / KPI value / label */
:root { --display: 'Hanken Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }
html.theme-light h1, html.theme-light h2, html.theme-light h3,
html.theme-light h4, html.theme-light h5, html.theme-light h6,
html.theme-light [class*="-title"], html.theme-light [class*="-heading"],
html.theme-light .kpi-value, html.theme-light .ksi-value, html.theme-light .dash-head-title {
  font-family: var(--display);
  letter-spacing: -0.021em;
  font-feature-settings: 'ss01','cv11';
}

/* Financial-grade numerals: line up columns of money/metrics like a ledger */
html.theme-light .kpi-value, html.theme-light .ksi-value,
html.theme-light .table td, html.theme-light .table th,
html.theme-light .money, html.theme-light [class*="-amount"], html.theme-light [class*="-total"],
html.theme-light .data-table td, html.theme-light .summary-total b, html.theme-light .summary-box b {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum','ss01';
}

/* ── Refined light surface system — flat canvas, crisp elevated cards ──
 * Single source of truth for these tokens: this was previously the third
 * of three overlapping :root/html.theme-light blocks redefining --bg-0/
 * --border/--shadow-*, which is exactly the silent-cascade-override bug
 * class already found in .badge/.btn-primary/.data-table. Canvas value
 * now matches the spec exactly (#F5F7FA) and the decorative dual-radial
 * wash — one leg of which was indigo/purple, off-brand and purely
 * decorative — is gone in favor of a flat canvas. */
html.theme-light {
  --bg-0: #f5f7fa;
  --border:   #d8dee7;
  --border-2: #cdd4de;
  /* Two-layer soft shadow ramp — reads "expensive" without heavy drop-shadows */
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --shadow-md: 0 2px 4px rgba(16,24,40,.05), 0 12px 28px -8px rgba(16,24,40,.14);
  --shadow-lg: 0 4px 8px rgba(16,24,40,.06), 0 32px 64px -16px rgba(16,24,40,.22);
  --hairline: inset 0 1px 0 rgba(255,255,255,.7);
}
html.theme-light body.app,
html.theme-light .content,
html.theme-light .main { background: var(--bg-0); }

/* Cards & KPI tiles — pure white, crisp hairline, refined depth, quiet lift */
html.theme-light .card,
html.theme-light .kpi-card,
html.theme-light .table-wrap,
html.theme-light .ksi-card,
html.theme-light .panel {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
html.theme-light .card.is-interactive:hover,
html.theme-light .kpi-card:hover {
  border-color: #d3dae4;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
/* KPI tiles get a hairline accent rule on top — subtle "instrument" cue */
html.theme-light .kpi-card { position: relative; overflow: hidden; }
html.theme-light .kpi-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: .55;
}
html.theme-light .kpi-value { font-weight: 800; letter-spacing: -0.03em; }

/* ── Buttons — sharper, quiet depth, confident primary ── */
html.theme-light .btn { border-radius: 9px; font-weight: 600; letter-spacing: -0.005em; }
html.theme-light .btn-primary {
  background: linear-gradient(180deg, #22bef5, var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(13,155,218,.35), inset 0 1px 0 rgba(255,255,255,.25);
}
html.theme-light .btn-primary:hover { filter: brightness(1.03); box-shadow: 0 4px 12px rgba(13,155,218,.4), inset 0 1px 0 rgba(255,255,255,.25); }
html.theme-light .btn-ghost, html.theme-light .btn-outline {
  background: #fff; border: 1px solid var(--border-2); color: var(--text-2);
  box-shadow: 0 1px 1px rgba(16,24,40,.03);
}
html.theme-light .btn-ghost:hover, html.theme-light .btn-outline:hover { border-color: #b6c0cc; color: var(--text); background: #fbfcfe; }

/* ── Inputs — crisp, calm, one focus language ── */
html.theme-light .form-input, html.theme-light .form-select, html.theme-light .form-textarea,
html.theme-light input[type="text"], html.theme-light input[type="email"],
html.theme-light input[type="number"], html.theme-light input[type="search"] {
  border-radius: 9px; border-color: var(--border-2);
}
html.theme-light .form-input:focus, html.theme-light .form-select:focus, html.theme-light .form-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3.5px rgba(26,182,241,.14);
}

/* ── Tables — a data grid, not a spreadsheet ── */
html.theme-light .table th, html.theme-light .data-table th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 800; color: #6b7686; background: #f7f9fc;
}
html.theme-light .table td, html.theme-light .data-table td { border-bottom-color: #eef1f5; }
html.theme-light .table tbody tr:hover td, html.theme-light .data-table tbody tr:hover td { background: #f7fafd; }

/* ── Topbar — sharper hairline + a cleaner glass ── */
html.theme-light .topbar {
  background: rgba(255,255,255,.78);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(150%) blur(16px); backdrop-filter: saturate(150%) blur(16px);
}

/* Section / eyebrow micro-labels read as intentional, not leftover */
html.theme-light .section-label, html.theme-light .eyebrow, html.theme-light [class*="-eyebrow"] {
  text-transform: uppercase; letter-spacing: .1em; font-weight: 800; font-size: 11px; color: var(--text-3);
}

/* Status badges — tighter, sharper pill */
html.theme-light .badge, html.theme-light .status, html.theme-light [class*="badge-"], html.theme-light [class*="status-"] {
  font-weight: 700; letter-spacing: .01em; border-radius: 7px;
}

/* Catch prominent page-specific tiles that hardcode their own borders/shadows in
   inline <style> (dashboard .kpi, reports/insight tiles, list cards) so the depth
   system reaches them too. Scoped to light theme; harmless where absent. */
html.theme-light .kpi, html.theme-light .stat-card, html.theme-light .metric-card,
html.theme-light .report-card, html.theme-light .chart-card, html.theme-light .list-card,
html.theme-light .info-card, html.theme-light .summary-card {
  border-color: #e3e7ee !important;
  box-shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04) !important;
  border-radius: 12px !important;
}
html.theme-light .kpi:hover, html.theme-light .stat-card:hover, html.theme-light .metric-card:hover {
  border-color: #d3dae4 !important;
  box-shadow: 0 2px 4px rgba(16,24,40,.05), 0 12px 28px -8px rgba(16,24,40,.14) !important;
  transform: translateY(-2px);
}
html.theme-light .kpi-value, html.theme-light .kpi .value, html.theme-light .stat-value, html.theme-light .metric-value {
  font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCOUNT AREA — AUTHORITATIVE (2026-07-18)
   The sidebar footer is a real account control: pinned to the bottom, always
   visible (only .sidebar-nav scrolls), and its menu opens UPWARD so it cannot
   clip at short laptop heights. Lives at the END of app.css on purpose — the
   sidebar rule sets earlier in this file are layered and the last block wins.
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar .sidebar-footer { position: relative; flex-shrink: 0; padding: 10px 12px; border-top: 1px solid var(--border); }
.sidebar .sidebar-footer .user-card {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; cursor: pointer; text-align: left; font-family: inherit;
  min-height: 44px; /* touch target */
}
.sidebar .sidebar-footer .user-card:hover,
.sidebar .sidebar-footer .user-card:focus-visible { background: var(--bg-3); border-color: var(--border); }
.sidebar .sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar .sidebar-footer .user-name { font-size: 13px; font-weight: 650; color: var(--text); line-height: 1.25; }
.sidebar .sidebar-footer .user-role { font-size: 11px; font-weight: 550; color: var(--text-2); line-height: 1.3; }
.sidebar .sidebar-footer .user-card-chevron { color: var(--text-3); flex-shrink: 0; }
/* Dark-theme fallback: the hardcoded #1e293b name color rendered nearly invisible
   against the dark sidebar (~1.05:1 contrast). Force the light text token there. */
html.theme-dark .sidebar .sidebar-footer .user-name { color: #f1f5f9; }
html.theme-dark .sidebar .sidebar-footer .user-role { color: #cbd5e1; }
html.theme-dark .sidebar .sidebar-footer .user-card-chevron { color: #94a3b8; }
html.theme-dark .sidebar .sidebar-footer .user-card:hover,
html.theme-dark .sidebar .sidebar-footer .user-card:focus-visible { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14); }
html.theme-dark .sidebar .acct-menu { background: #1e293b; border-color: rgba(255,255,255,0.14); }
html.theme-dark .sidebar .acct-menu-item { color: #cbd5e1; }
html.theme-dark .sidebar .acct-menu-item:hover,
html.theme-dark .sidebar .acct-menu-item:focus-visible { background: rgba(255,255,255,0.08); color: #7dd3fc; }
html.theme-dark .sidebar .acct-menu-sep { background: rgba(255,255,255,0.12); }
.sidebar .acct-menu {
  position: absolute; bottom: calc(100% + 4px); left: 10px; right: 10px; z-index: 60;
  background: var(--bg-1, #fff); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px -8px rgba(16,24,40,.22), 0 2px 6px rgba(16,24,40,.08);
  padding: 6px; display: flex; flex-direction: column;
}
.sidebar .acct-menu[hidden] { display: none; }
.sidebar .acct-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; box-sizing: border-box;
  padding: 9px 10px; border: none; border-radius: 8px; background: transparent;
  font-size: 12.5px; font-weight: 600; color: #334155; text-decoration: none;
  cursor: pointer; font-family: inherit; text-align: left; min-height: 38px;
}
.sidebar .acct-menu-item:hover, .sidebar .acct-menu-item:focus-visible { background: var(--bg-3); color: #0b6fa0; }
.sidebar .acct-menu-item svg { flex-shrink: 0; }
.sidebar .acct-menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.sidebar .acct-menu-danger { color: #b91c1c; }
.sidebar .acct-menu-danger:hover, .sidebar .acct-menu-danger:focus-visible { background: rgba(239,68,68,.08); color: #b91c1c; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE DRAWER — AUTHORITATIVE (2026-07-18)
   The ≤768px drawer rules earlier in this file lose to later theme layers
   (theme-cartographer.css re-declares `.sidebar { position: relative }` after
   app.css, which silently killed `position: fixed` — an "open" drawer stayed
   translated off-canvas and the mobile nav was unreachable). Same pattern as
   the sidebar-readability block above: last word lives at the END of app.css.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body.app .sidebar {
    position: fixed !important;
    left: 0; top: 0;
    width: 260px;
    height: 100vh !important;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform var(--tr, 0.2s ease);
    box-shadow: var(--shadow-lg);
  }
  body.app .sidebar.open { transform: translateX(0); }
  body.app:has(#mkt-back) .sidebar { top: 36px; height: calc(100vh - 36px) !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR RESPONSIVE — AUTHORITATIVE (2026-07-18)
   At 900×720 with a trial pill, the New button sat 186px off-screen and the
   theme toggle was clipped — a broken primary action on 13" laptops. Compact
   the topbar progressively as width shrinks. Rules live at the end of app.css
   so theme-cartographer.css cannot override them (fourth-layer trap; see §16).
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1180px) {
  /* Search shrinks but stays usable */
  body.app .topbar-search { max-width: 260px; }
}
@media (max-width: 1080px) {
  /* Trial pill drops the trailing "Upgrade →" segment — keeps the countdown +
     the whole pill still links to Settings/billing, so the CTA is preserved.
     !important because renderTopbar() emits inline `style="display:inline-flex"`
     on the pill spans and the language switcher — inline beats CSS otherwise. */
  body.app .topbar .lang-switcher { display: none !important; }
  body.app .topbar-actions > a[href*="billing"] > span:nth-child(3) { display: none !important; }
  body.app .topbar-search { max-width: 220px; }
}
@media (max-width: 960px) {
  /* The Help button is now in the account menu (Sidebar footer → Help & support),
     so hiding it here is not a lost affordance. The New button stays — it is the
     primary CTA. Notifications stay — status glance. Theme toggle stays — cheap. */
  body.app .topbar-actions > button[title*="Help"] { display: none; }
  body.app .topbar-search { max-width: 180px; }
  body.app .topbar-title-group .topbar-sub { display: none; }
}
@media (max-width: 900px) {
  body.app .topbar-actions { gap: 4px; }
  body.app .topbar-search { max-width: 140px; }
}
@media (max-width: 768px) {
  /* Mobile: existing rule already hides .topbar-search entirely. Compact the
     rest so the mobile-menu button + title + New always fit. */
  body.app .topbar-actions > a[href*="billing"] { padding: 4px 8px; font-size: 11px; }
  body.app .topbar-actions > a[href*="billing"] > svg { display: none; }
  body.app .topbar-actions > button.theme-toggle { display: none; }
}

/* ── Pipeline (master-detail) view — shared across jobs/leads/contacts/etc ──
   Left = stage/type filter with live counts, middle = dense list, right =
   inline preview so triaging a record never leaves the page. First built for
   jobs.html; factored out here once a second page (leads.html) needed it. */
.pipeline-layout {
  display: grid;
  grid-template-columns: 200px 1fr 340px;
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
@media (max-width: 1100px) { .pipeline-layout { grid-template-columns: 160px 1fr; } .pipeline-detail { display: none; } }
@media (max-width: 760px) { .pipeline-layout { grid-template-columns: 1fr; min-height: auto; } .pipeline-stages { display: flex; overflow-x: auto; } }

.pipeline-stages { background: var(--bg-2); border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.pipeline-stage {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text-2); white-space: nowrap;
}
.pipeline-stage:hover { background: var(--bg-3); }
.pipeline-stage.active { background: var(--accent-soft, rgba(26,182,241,0.12)); color: var(--accent); }
.pipeline-stage-count { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-3); }
.pipeline-stage.active .pipeline-stage-count { color: var(--accent); }

.pipeline-list { overflow-y: auto; border-right: 1px solid var(--border); }
.pipeline-card {
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background var(--tr);
}
.pipeline-card:hover { background: var(--bg-2); }
.pipeline-card.selected { background: var(--accent-soft, rgba(26,182,241,0.08)); border-left: 3px solid var(--accent); padding-left: 13px; }
.pipeline-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pipeline-card-addr { font-weight: 700; font-size: 13.5px; color: var(--text); }
.pipeline-card-value { font-weight: 700; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.pipeline-card-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pipeline-detail { overflow-y: auto; padding: 20px; background: var(--bg-1); }
.pipeline-detail-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-3); font-size: 13px; text-align: center; padding: 20px; }
.pipeline-detail-addr { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.pipeline-detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.pipeline-detail-row .lbl { color: var(--text-3); }
.pipeline-detail-row .val { font-weight: 600; color: var(--text); }
