/* ─────────────────────────────────────────────────────────────────────────
   L.H Platform · Design System v2
   ─────────────────────────────────────────────────────────────────────────
   Netflix-inspired information architecture:
   - Hero (the one thing that matters most right now)
   - Horizontal swimlanes by category (scroll right for depth)
   - Visual hierarchy: image/data → title → metadata
   - Generous whitespace, minimal decoration

   Foundation: semantic tokens, scaled spacing, restrained palette.
   Everything theme-able via CSS variables. No build step required.
   ─────────────────────────────────────────────────────────────────────── */

:root {
  /* ── Color · semantic ───────────────────────────────────────────────── */
  /* Brand kept as accent only — not structural. */
  --brand-50:  #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;

  /* Background hierarchy */
  --bg:           #f6f8fa;   /* page background, cool light gray */
  --surface:      #ffffff;   /* card faces */
  --surface-2:    #f8fafc;   /* alt rows, sunken sections */
  --surface-sunken: #f1f5f9;
  --surface-dim:  rgba(15,17,21,.04);

  /* Ink hierarchy */
  --ink-900: #0f1115;
  --ink-700: #2d3038;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #a8b3c4;
  --ink-200: #cbd5e1;

  /* Borders */
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --border-muted:  #eef2f6;

  /* Intent (semantic only — never raw red/green in components) */
  --success:    #059669;
  --success-bg: #d1fae5;
  --danger:     #dc2626;
  --danger-bg:  #fee2e2;
  --warn:       #d97706;
  --warn-bg:    #fef3c7;
  --info:       #2563eb;
  --info-bg:    #dbeafe;

  --ring: 0 0 0 3px rgba(13,148,136,.25);

  /* ── Spacing scale (4px base) ───────────────────────────────────────── */
  --s-0:  0;
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  28px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* Layout */
  --gutter: 16px;
  --container: 1280px;

  /* ── Typography ─────────────────────────────────────────────────────── */
  --font-sans: 'Heebo', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --text-xs:    12px;
  --text-sm:    13px;
  --text-base:  14px;   /* body default */
  --text-md:    15px;
  --text-lg:    17px;
  --text-xl:    20px;
  --text-2xl:   24px;
  --text-3xl:   30px;
  --text-display: 36px;

  --lh-tight:   1.2;
  --lh-snug:    1.35;
  --lh-normal:  1.5;
  --lh-relaxed: 1.65;

  /* ── Radius ─────────────────────────────────────────────────────────── */
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-pill: 9999px;

  /* ── Shadow (subtle, layered) ───────────────────────────────────────── */
  --shadow-xs: 0 1px 2px rgba(15,17,21,.04);
  --shadow-sm: 0 1px 3px rgba(15,17,21,.06), 0 1px 2px rgba(15,17,21,.04);
  --shadow-md: 0 4px 12px rgba(15,17,21,.08);
  --shadow-lg: 0 12px 32px rgba(15,17,21,.12);
  --shadow-xl: 0 24px 48px rgba(15,17,21,.18);

  /* ── Motion ─────────────────────────────────────────────────────────── */
  --dur-fast: 120ms;
  --dur:      200ms;
  --dur-slow: 320ms;
  --ease:     cubic-bezier(.2,.7,.2,1);

  /* ── Z-index scale ──────────────────────────────────────────────────── */
  --z-sticky:  10;
  --z-drawer:  40;
  --z-modal:   50;
  --z-toast:   60;
  --z-popover: 70;
}

@media (min-width: 640px)  { :root { --gutter: 20px; } }
@media (min-width: 1024px) { :root { --gutter: 28px; } }
@media (min-width: 1280px) { :root { --gutter: 32px; } }

/* ───────────────────────────────────────────────────────────────────────
   Backward-compat aliases so the existing crm.js keeps working
   while we adopt the new system gradually.
   ─────────────────────────────────────────────────────────────────────── */
:root {
  --gold:      var(--brand-500);
  --gold-soft: var(--brand-100);
  --cream:     var(--brand-50);
  --ink:       var(--ink-900);
  --muted:     var(--ink-500);
  --card:      var(--surface);
  --ok:        var(--success);
  --err:       var(--danger);
  --line:      var(--border-muted);
}

/* ───────────────────────────────────────────────────────────────────────
   Reset · accessibility · focus rings
   ─────────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink-900);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[lang="en"] body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

button, input, select, textarea { font-family: inherit; }

button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-md);
}

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* ───────────────────────────────────────────────────────────────────────
   Utilities
   ─────────────────────────────────────────────────────────────────────── */
.muted { color: var(--ink-500); }
.err   { color: var(--danger); font-size: var(--text-sm); min-height: 18px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ───────────────────────────────────────────────────────────────────────
   Login screen
   ─────────────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-5);
  background:
    radial-gradient(ellipse at top right, var(--brand-50) 0%, transparent 50%),
    radial-gradient(ellipse at bottom left, #f8fafc 0%, transparent 50%),
    var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-2xl);
  padding: var(--s-8);
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow-lg);
  display: grid; gap: var(--s-4);
}
.login-card h1 { margin: 0; font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.01em; }
.login-card .muted { font-size: var(--text-sm); margin-top: -6px; }
.login-card label { display: grid; gap: var(--s-1); font-weight: 600; font-size: var(--text-sm); }
.login-card input {
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.login-card input:focus { border-color: var(--brand-500); box-shadow: var(--ring); outline: none; }
.login-card button {
  background: var(--ink-900); color: #fff;
  border: none; border-radius: var(--r-md);
  padding: var(--s-3) var(--s-5);
  font-weight: 700; font-size: var(--text-md);
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.login-card button:hover { background: var(--ink-700); }
.login-card button:active { transform: scale(0.98); }

/* ───────────────────────────────────────────────────────────────────────
   Top bar / App shell
   ─────────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--gutter);
  background: var(--surface);
  border-block-end: 1px solid var(--border-muted);
  position: sticky; top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: saturate(180%) blur(8px);
}
.brand {
  font-weight: 800; font-size: var(--text-md);
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: var(--s-2);
}
.topbar nav { display: flex; gap: var(--s-1); }
.nav-btn {
  background: transparent; border: 1px solid transparent;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--text-sm);
  color: var(--ink-700);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-btn { display: inline-flex; align-items: center; gap: 7px; }
.nav-btn svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .85; }
.nav-btn.active svg { opacity: 1; }
.nav-btn:hover { background: var(--surface-sunken); color: var(--ink-900); }
.nav-btn.active {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600)); color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px rgba(13,148,136,.30);
}
.user-info { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); }
.topbar-select {
  width: auto; max-width: 160px;
  padding: 6px 28px 6px 10px;
  font-size: var(--text-xs); font-weight: 600;
  border: 1px solid var(--border-muted); border-radius: var(--r-md);
  background-color: var(--surface);
}
.user-info button {
  background: transparent; border: 1px solid var(--border);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-pill);
  font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-700);
  transition: background var(--dur) var(--ease);
}
.user-info button:hover { background: var(--surface-sunken); }
.hamburger {
  display: none;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 18px; line-height: 1; padding: var(--s-2) var(--s-3);
}

main {
  padding: var(--s-6) var(--gutter) var(--s-12);
  max-width: var(--container);
  margin: 0 auto;
}

/* ───────────────────────────────────────────────────────────────────────
   Toolbar (search + new + actions row)
   ─────────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; gap: var(--s-2);
  margin-bottom: var(--s-4);
  align-items: center; flex-wrap: wrap;
}
.toolbar input[type="search"] {
  flex: 1; min-width: 220px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--text-base);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.toolbar input[type="search"]:focus { border-color: var(--brand-500); box-shadow: var(--ring); outline: none; }

/* ───────────────────────────────────────────────────────────────────────
   Buttons (.btn = primary, .btn.secondary, .btn.ghost, .btn.danger, .btn.ok)
   ─────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  background: var(--ink-900); color: #fff;
  border: 1px solid var(--ink-900);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 600; font-size: var(--text-sm);
  line-height: 1;
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
  text-decoration: none;
}
.btn:hover { background: var(--ink-700); }
.btn.gold, .btn.primary { background: linear-gradient(135deg, var(--brand-500), var(--brand-600)); border-color: transparent; box-shadow: 0 4px 14px rgba(13,148,136,.30); }
.btn.gold:hover, .btn.primary:hover { background: linear-gradient(135deg, var(--brand-500), var(--brand-600)); filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(13,148,136,.35); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface); color: var(--ink-900); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-sunken); }
.btn.ghost {
  background: transparent; color: var(--ink-700);
  border-color: transparent;
}
.btn.ghost:hover { background: var(--surface-sunken); color: var(--ink-900); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ok     { background: var(--success); border-color: var(--success); color: #fff; }
.btn.ok:hover { background: #0c7c46; }

/* ───────────────────────────────────────────────────────────────────────
   Cards (the core surface)
   ─────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-xl);
  padding: var(--s-5) var(--s-5);
  box-shadow: var(--shadow-xs), 0 10px 30px -14px rgba(15,23,42,.10);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-sm), 0 14px 34px -12px rgba(15,23,42,.14); }
.card h2 { margin: 0 0 var(--s-3); font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.01em; }
.card h2 svg, .card h3 svg, .card h4 svg, .lane__title svg { vertical-align: -0.13em; margin-inline-end: 0.18em; opacity: .9; }
.modal-head h2 svg, .modal-head h3 svg, h2 svg, h3 svg { vertical-align: -0.13em; }
.btn svg, .seg-tab svg { vertical-align: -0.14em; }
.card h3 { margin: 0 0 var(--s-2); font-size: var(--text-md); font-weight: 700; }

/* ───────────────────────────────────────────────────────────────────────
   Forms · fields
   ─────────────────────────────────────────────────────────────────────── */
.field { display: grid; gap: var(--s-1); margin-bottom: var(--s-3); }
.field label {
  font-size: var(--text-xs);
  color: var(--ink-500);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.field input, .field select, .field textarea {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: 100%;
  font-size: var(--text-base);
  background: var(--surface);
  color: var(--ink-900);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-500); box-shadow: var(--ring); outline: none;
}
.field textarea { min-height: 72px; resize: vertical; line-height: var(--lh-normal); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-3); }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ───────────────────────────────────────────────────────────────────────
   Lead detail grid (12-col responsive)
   ─────────────────────────────────────────────────────────────────────── */
.back-link {
  background: transparent; border: none;
  color: var(--ink-500); cursor: pointer;
  padding: 0; margin-bottom: var(--s-3);
  font-size: var(--text-sm); font-weight: 500;
  display: inline-flex; align-items: center; gap: var(--s-1);
}
.back-link:hover { color: var(--ink-900); }
.lead-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--s-4);
  align-items: start;
}

/* Settings page uses an auto-fill grid so cards lay out in 1 / 2 / 3 columns
   automatically based on viewport — no wasted whitespace on wide screens,
   stacks cleanly on mobile. Cards stay full-width within their column. */
/* 12-column grid so makeCardsCollapsible's width steps map to real fractions:
   span 12 = full · span 9 = ¾ · span 6 = ½ · span 3 = ¼. The inline span the
   JS sets per card therefore resizes it. min-width:0 lets a card actually get
   narrow (titles use word-break, so no vertical-letter rendering). */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--s-4);
  align-items: start;
}
.settings-grid > .card { max-width: none !important; width: 100%; min-width: 0; grid-column: span 6; }
/* A collapsed card keeps its chosen width span too, so you can tile quarter/
   half-width title bars side by side. */
/* On phones, one column — spans don't apply. */
@media (max-width: 720px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid > .card { grid-column: auto !important; }
}
.lead-grid > .card { min-width: 220px; grid-column: span 6; }
/* Section dividers inside the lead-detail grid. Non-card nodes (no .card,
   no H2/H3 first child) so makeCardsCollapsible ignores them. They group the
   ~23 cards into readable bands: WHO → CAMPAIGNS → CONTENT → MONEY → AI →
   CLIENT. Quiet eyebrow + hairline rule; the hero band stands out in gold. */
.lead-section {
  margin: var(--s-5) 0 calc(-1 * var(--s-1));
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--rule, var(--border-muted, #e2e8f0));
  display: flex;
  align-items: center;
}
.lead-grid > .lead-section:first-child { margin-top: 0; }
.lead-section__eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted, #64748b);
}
/* The campaigns band is the hero — louder label + gold accent rule. */
.lead-section--hero {
  border-bottom-color: var(--gold, #14b8a6);
}
.lead-section--hero .lead-section__eyebrow {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold, #14b8a6);
}
@media (max-width: 720px) { .lead-section { grid-column: 1 / -1 !important; } }
/* Clean switch for the "allow client to manage clients" toggle in lead detail. */
.cm-toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 10px;
  padding: 9px 12px; background: var(--cream, #f8fafc); border: 1px solid var(--gold-soft, #ccfbf1);
  border-radius: 10px; cursor: pointer; }
.cm-toggle-lbl { flex: 1; font-weight: 600; font-size: 13px; }
.cm-switch + .cm-sw { position: relative; width: 42px; height: 24px; border-radius: 999px;
  background: #d2d2d8; transition: .15s; flex: 0 0 auto; }
.cm-switch + .cm-sw::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .15s; }
.cm-switch:checked + .cm-sw { background: var(--ink-900, #1b1b1b); }
.cm-switch:checked + .cm-sw::after { inset-inline-start: 20px; }
/* Titles in any card: prefer word-break, never per-character vertical text.
   Fixes the "vertical letters" rendering when a card gets squeezed below
   its natural title width by an overlapping side-panel or narrow span. */
.card > h2, .card > h3, .lane-card__title, .hero-card__title {
  word-break: keep-all;
  overflow-wrap: anywhere;
  hyphens: none;
  min-width: 0;
}
/* Belt-and-suspenders: when a card is collapsed (its body hidden), the
   container can shrink to the natural width of the title. Force the title
   to stay on one line + ellipsis instead of breaking each Hebrew char to
   its own line — that was the "vertical letters" bug. */
.card.collapsible.collapsed > h2,
.card.collapsible.collapsed > h3 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 1024px) { .lead-grid > .card { grid-column: span 12 !important; } }
@media (max-width: 720px)  { .lead-grid > .card { grid-column: 1 / -1 !important; width: 100% !important; } }

/* ───────────────────────────────────────────────────────────────────────
   Wide data grids (campaigns / ad-sets / creative breakdown) — these have
   too many columns to ever fit a phone. Instead of letting the browser
   crush each cell to one char per line, give the table a min-width and let
   the wrapper scroll horizontally with momentum.
   ─────────────────────────────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  /* Hint that there's more to scroll: subtle inset edge shadow */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent),
    linear-gradient(to left, var(--surface) 30%, transparent) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.08), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.08), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.data-grid {
  min-width: 760px;          /* forces horizontal scroll on phones */
  width: 100%;
  border-collapse: collapse;
}
.data-grid th, .data-grid td {
  white-space: nowrap;       /* no more 1-char-per-line wrapping */
  padding: 8px 10px;
  vertical-align: middle;
}
.data-grid thead th {
  font-size: var(--text-xs); font-weight: 700;
  color: var(--ink-500);
  position: sticky; top: 0;
  background: var(--surface);
}

/* ───────────────────────────────────────────────────────────────────────
   Tables
   ─────────────────────────────────────────────────────────────────────── */
.lead-table {
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border-muted);
}
.lead-table table { width: 100%; border-collapse: collapse; }
.lead-table th, .lead-table td {
  padding: var(--s-3) var(--s-4);
  text-align: start;
  border-bottom: 1px solid var(--border-muted);
}
.lead-table th {
  background: var(--surface-2);
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--ink-500);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.lead-table tr.clickable { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.lead-table tr.clickable:hover { background: var(--surface-2); }
.lead-table-inner { width: 100%; border-collapse: collapse; }
.lead-table-inner th, .lead-table-inner td {
  padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border-muted);
  font-size: var(--text-sm); text-align: start;
}
.lead-table-inner th { color: var(--ink-500); font-weight: 600; font-size: var(--text-xs); }

/* ───────────────────────────────────────────────────────────────────────
   Status badges (parametric — old .s-* aliases preserved)
   ─────────────────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 3px var(--s-2);
  border-radius: var(--r-pill);
  font-size: var(--text-xs); font-weight: 700;
  line-height: 1.4;
}
.s-draft    { background: #ececec; color: #4a4a4a; }
.s-sent     { background: var(--info-bg); color: var(--info); }
.s-viewed   { background: var(--warn-bg); color: var(--warn); }
.s-accepted { background: var(--success-bg); color: var(--success); }
.s-declined { background: var(--danger-bg); color: var(--danger); }
.s-expired  { background: #efefef; color: var(--ink-500); }
.signed-flag {
  display: inline-block;
  margin-inline-start: var(--s-2);
  padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--text-xs); font-weight: 700;
  background: var(--success-bg); color: var(--success);
  vertical-align: middle;
}

/* ───────────────────────────────────────────────────────────────────────
   KPIs
   ─────────────────────────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-xl);
  padding: var(--s-4) var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-1);
}
.kpi-num {
  font-size: var(--text-3xl); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1;
  color: var(--ink-900);
}
.kpi-label {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-500);
  text-transform: uppercase; letter-spacing: 0.04em;
}
@media (max-width: 768px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
}

/* ───────────────────────────────────────────────────────────────────────
   Quote rows (lead detail "תשלומים", "הצעות")
   ─────────────────────────────────────────────────────────────────────── */
.quote-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border-muted);
  flex-wrap: wrap;
}
.quote-row:last-child { border-bottom: none; }
.quote-info { display: flex; flex-direction: column; gap: 2px; }
.quote-title { font-weight: 700; font-size: var(--text-sm); }
.quote-meta  { font-size: var(--text-xs); color: var(--ink-500); }
.quote-actions { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  transition: background var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-sunken); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-bg); }
.create-quote-row {
  display: flex; align-items: stretch; gap: var(--s-2);
  flex-wrap: wrap; margin-bottom: var(--s-3);
}

/* ───────────────────────────────────────────────────────────────────────
   Tags / chips
   ─────────────────────────────────────────────────────────────────────── */
.tag-mini {
  display: inline-block;
  padding: 1px var(--s-2); margin-inline-start: var(--s-1);
  background: var(--brand-50); color: var(--brand-700);
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700;
}
.tag-chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.tagc {
  background: var(--surface-sunken);
  border: 1px solid var(--border-muted);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
  color: var(--ink-700);
  user-select: none;
}
.tagc.pick {
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tagc.pick:hover { background: var(--surface); border-color: var(--ink-900); color: var(--ink-900); }
.tagc.pick.on {
  background: var(--ink-900); border-color: var(--ink-900); color: #fff; font-weight: 600;
}
.tagc.pick.on:hover { background: var(--ink-900); color: #fff; }

/* ───────────────────────────────────────────────────────────────────────
   Toast root
   ─────────────────────────────────────────────────────────────────────── */
#toastRoot {
  position: fixed;
  inset-block-end: var(--s-4);
  inset-inline-end: var(--s-4);
  display: grid; gap: var(--s-2);
  z-index: var(--z-toast);
  max-width: calc(100vw - 32px);
}
#toastRoot > div {
  background: var(--ink-900); color: #fff;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-slow) var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 640px) {
  #toastRoot {
    inset-inline: var(--s-3);
    inset-block-end: calc(var(--s-3) + env(safe-area-inset-bottom));
  }
}

/* ───────────────────────────────────────────────────────────────────────
   Notification bell + panel (mobile becomes bottom sheet)
   ─────────────────────────────────────────────────────────────────────── */
.notif-wrap { position: relative; z-index: 2; }
.notif-bell, .notif-badge { pointer-events: auto; }
.notif-bell {
  position: relative; z-index: 2;
  background: transparent; border: 1px solid var(--border);
  width: 38px; height: 38px;
  border-radius: var(--r-pill);
  font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
  transition: background var(--dur-fast) var(--ease);
}
.notif-bell:hover { background: var(--surface-sunken); }
.notif-badge {
  position: absolute; top: -2px; inset-inline-end: -2px;
  background: var(--danger); color: #fff;
  border-radius: var(--r-pill);
  font-size: 10px; font-weight: 700;
  padding: 1px 5px;
  min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
/* Lives on <body> (moved by JS) and is position:fixed so it's immune to
   any ancestor that creates a containing block (the topbar's backdrop-filter
   used to trap it). Desktop: anchored under the bell at top-inline-start. */
.notif-panel {
  position: fixed; top: 60px; inset-inline-start: var(--s-4);
  width: 360px; max-width: calc(100vw - 32px);
  max-height: min(70vh, 480px); overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 1201;
}
.notif-panel[hidden] { display: none; }
.notif-item {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-muted);
  cursor: pointer;
  display: grid; gap: var(--s-1);
  transition: background var(--dur-fast) var(--ease);
}
.notif-item:hover { background: var(--surface-sunken); }
.notif-item:last-child { border-bottom: none; }
.notif-item b { font-size: var(--text-sm); }
.notif-item span { font-size: var(--text-xs); color: var(--ink-500); }
.notif-item.unread { background: var(--brand-50); }
.notif-item.unread:hover { background: var(--brand-100); }
/* On phones the panel is a bottom sheet — full width, anchored to the
   bottom edge, unmistakably visible. ONE rule, no conflicting overrides. */
@media (max-width: 720px) {
  .notif-panel {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    top: auto;
    width: 100%; max-width: 100%;
    max-height: 80vh;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,.22);
    padding-block-end: env(safe-area-inset-bottom);
    z-index: 1201;
  }
  /* Dim backdrop behind the sheet so it's obviously a modal layer. */
  body.notif-open::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1200;
  }
}

/* ───────────────────────────────────────────────────────────────────────
   Modals (.modal-back + .modal)
   ─────────────────────────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(15,17,21,.45);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-5);
  z-index: var(--z-modal);
  animation: fade-in var(--dur) var(--ease);
}
.modal {
  background: var(--surface);
  border-radius: var(--r-2xl);
  padding: var(--s-6);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modal-in var(--dur-slow) var(--ease);
}
.modal h2, .modal h3 { margin-block-start: 0; }
/* Fullscreen lock: covers entire viewport, no escape via background click. */
.modal-back.modal-fullscreen {
  padding: 0;
  background: rgba(15,17,21,.85);
}
.modal.modal-fullscreen-card {
  max-width: 100vw; width: 100vw;
  max-height: 100vh; height: 100vh;
  border-radius: 0;
  padding: var(--s-6);
  overflow-y: auto;
}
.modal-actions {
  display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap;
  margin-top: var(--s-5);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@media (max-width: 640px) {
  .modal-back { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    max-height: 92vh;
    padding-block-end: max(var(--s-6), env(safe-area-inset-bottom));
  }
}

/* ───────────────────────────────────────────────────────────────────────
   Netflix-style swimlanes (NEW)
   ─────────────────────────────────────────────────────────────────────── */
.lane {
  margin-bottom: var(--s-8);
}
.lane__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-3); padding-block: var(--s-2);
  margin-bottom: var(--s-3);
}
.lane__title {
  font-size: var(--text-xl); font-weight: 800;
  letter-spacing: -0.01em; color: var(--ink-900);
  margin: 0;
}
.lane__hint {
  font-size: var(--text-xs); color: var(--ink-500);
  font-weight: 500;
}
.lane__scroller {
  display: flex; gap: var(--s-3);
  overflow-x: auto; overflow-y: visible;
  padding-block-end: var(--s-2);
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  /* Bleed to viewport edge so cards align with content padding nicely */
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
}
.lane__scroller > * {
  flex: 0 0 auto;
  scroll-snap-align: start;
}
.lane__scroller::-webkit-scrollbar { height: 6px; }
.lane__scroller::-webkit-scrollbar-thumb { background: var(--border-strong); }

.lane-card {
  width: 280px; min-height: 140px;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.lane-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.lane-card__eyebrow {
  font-size: var(--text-xs); font-weight: 700;
  color: var(--ink-500);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.lane-card__title {
  font-size: var(--text-md); font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.005em;
  line-height: var(--lh-snug);
}
.lane-card__body {
  font-size: var(--text-sm); color: var(--ink-500);
  line-height: var(--lh-normal);
  flex: 1;
}
.lane-card__foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--text-xs); color: var(--ink-500);
  margin-top: auto;
}
.lane-card--more {
  background: var(--bg, #fafaf7);
  border-style: dashed;
  width: 200px; min-height: 140px;
  align-items: center; justify-content: center;
  color: var(--ink-500);
}
.lane-card--more:hover { background: var(--surface); color: var(--ink-900); border-color: var(--ink-900); }
.lane-card[data-intent="danger"]  { border-inline-start: 3px solid var(--danger); }
.lane-card[data-intent="warn"]    { border-inline-start: 3px solid var(--warn); }
.lane-card[data-intent="success"] { border-inline-start: 3px solid var(--success); }
.lane-card[data-intent="info"]    { border-inline-start: 3px solid var(--info); }

/* ───────────────────────────────────────────────────────────────────────
   Hero (the one most-urgent thing)
   ─────────────────────────────────────────────────────────────────────── */
.hero-card {
  background:
    radial-gradient(ellipse at top right, var(--brand-100) 0%, transparent 60%),
    var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-2xl);
  padding: var(--s-6) var(--s-6);
  margin-bottom: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.hero-card__eyebrow {
  font-size: var(--text-xs); font-weight: 700;
  color: var(--brand-700);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.hero-card__title {
  font-size: var(--text-2xl); font-weight: 800;
  letter-spacing: -0.02em; line-height: var(--lh-tight);
  color: var(--ink-900); margin: 0;
}
.hero-card__body {
  font-size: var(--text-md); color: var(--ink-700);
  line-height: var(--lh-normal);
  max-width: 60ch;
}
.hero-card__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-2); }

/* ───────────────────────────────────────────────────────────────────────
   Empty + skeleton states
   ─────────────────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: var(--s-10) var(--s-5);
  color: var(--ink-500);
}
.empty__icon { font-size: 32px; margin-bottom: var(--s-2); opacity: 0.5; }
.empty__title { font-size: var(--text-md); font-weight: 700; color: var(--ink-900); margin-bottom: var(--s-1); }
.empty__body  { font-size: var(--text-sm); }

.skel {
  background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--surface-2) 50%, var(--surface-sunken) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
  display: inline-block;
  height: 14px; min-width: 60px;
}
@keyframes skel-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ───────────────────────────────────────────────────────────────────────
   Misc legacy classes — keep working
   ─────────────────────────────────────────────────────────────────────── */
.kpi-row .kpi-num { font-feature-settings: "tnum"; }

/* posts editor / gallery / month label */
.pe-month {
  grid-column: 1 / -1;
  font-size: var(--text-sm); font-weight: 700;
  color: var(--ink-500);
  margin-block: var(--s-4) var(--s-2);
  padding-bottom: var(--s-1);
  border-bottom: 1px solid var(--border-muted);
}

/* Responsive nav */
@media (max-width: 1024px) {
  .topbar nav { display: none; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .topbar nav.open {
    display: flex; flex-direction: column;
    position: absolute; top: 100%; inset-inline-start: 0; right: 0;
    background: var(--surface);
    border-block-end: 1px solid var(--border-muted);
    padding: var(--s-3);
    gap: var(--s-1);
    box-shadow: var(--shadow-md);
    z-index: var(--z-drawer);
  }
  .topbar nav.open .nav-btn { width: 100%; text-align: start; border-radius: var(--r-md); }
}

@media (max-width: 640px) {
  main { padding: var(--s-4) var(--gutter) var(--s-12); }
  .topbar { padding: var(--s-2) var(--gutter); }
  .user-info button { padding: var(--s-1) var(--s-2); font-size: 11px; }
  .brand { font-size: var(--text-sm); }
  .lane-card { width: 240px; }
  .hero-card { padding: var(--s-5) var(--s-4); }
  .hero-card__title { font-size: var(--text-xl); }
}

/* Safe areas for any fixed-bottom UI */
.fab-bottom {
  position: fixed;
  inset-block-end: max(var(--s-4), env(safe-area-inset-bottom));
  inset-inline-end: var(--s-4);
  z-index: var(--z-popover);
}

/* ───────────────────────────────────────────────────────────────────────
   Global AI advisor — floating button + chat panel
   ─────────────────────────────────────────────────────────────────────── */
.ai-fab {
  position: fixed;
  inset-inline-end: 18px;
  inset-block-end: max(18px, env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--ink-900); color: #fff;
  border: none; cursor: pointer;
  box-shadow: var(--shadow-lg);
  font-size: 22px;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--dur) var(--ease);
}
.ai-fab:hover { transform: scale(1.05); }
.ai-chat {
  position: fixed;
  inset-inline-end: 18px;
  inset-block-end: 18px;
  width: 380px; max-width: calc(100vw - 36px);
  height: 560px; max-height: calc(100vh - 36px);
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.ai-chat[hidden] { display: none; }
.ai-chat__head {
  background: var(--surface-sunken);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-muted);
}
.ai-chat__body {
  flex: 1; overflow-y: auto;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.ai-chat__foot {
  border-top: 1px solid var(--border-muted);
  padding: 8px 10px;
  display: flex; gap: 8px;
}
.ai-chat__foot input { flex: 1; }
.ai-chat__foot .btn { flex-shrink: 0; }
/* On phones the advisor is a full bottom sheet, not a floating card. */
@media (max-width: 640px) {
  .ai-chat {
    inset-inline: 0; inset-block-end: 0; top: auto;
    width: 100%; max-width: 100%;
    height: 85vh; max-height: 85vh;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding-block-end: env(safe-area-inset-bottom);
  }
}

/* ───────────────────────────────────────────────────────────────────────
   Collapsible cards — clicking the heading hides the body, leaves the
   heading visible. The .collapsible class is added by makeCardsCollapsible.
   ─────────────────────────────────────────────────────────────────────── */
.card.collapsible > h2,
.card.collapsible > h3 {
  cursor: pointer;
  display: flex; align-items: center; gap: var(--s-2);
  margin: 0;
  user-select: none;
}
.card.collapsible > h2::after,
.card.collapsible > h3::after {
  content: "▾";
  margin-inline-start: auto;
  color: var(--ink-400);
  font-size: 14px;
  transition: transform var(--dur) var(--ease);
}
.card.collapsible.collapsed > h2::after,
.card.collapsible.collapsed > h3::after { transform: rotate(-90deg); }
.card.collapsible.collapsed > *:not(h2):not(h3) { display: none !important; }
.card.collapsible.collapsed { padding-block: var(--s-3); }

/* Autonomy badge in lead detail header */
.lead-aut {
  font-size: var(--text-xs); font-weight: 600;
  background: var(--surface-sunken);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  color: var(--ink-700);
}

/* Task swimlane cards inherit lane-card, just need overrides */
.task-card.is-done .lane-card__title { text-decoration: line-through; opacity: 0.6; }
.task-card .lane-card__foot input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink-900); cursor: pointer; }

/* ───────────────────────────────────────────────────────────────────────
   Facebook posts — proper card layout (was a floated thumbnail mess)
   ─────────────────────────────────────────────────────────────────────── */
.posts-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* AI posts gallery — tighter than .posts-grid because there are many cards
   and each is a thumbnail, not a full post preview. On desktop you want
   to scan the whole month at a glance. Clicking the image opens the
   lightbox (data-lb already wired) for the full-size view. */
.ai-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.ai-posts-grid .post-card { min-width: 0; }
.ai-posts-grid .post-card__media { aspect-ratio: 1 / 1; cursor: zoom-in; }
.ai-posts-grid .post-card__media img { transition: transform var(--dur) var(--ease); }
.ai-posts-grid .post-card__media:hover img { transform: scale(1.04); }
.ai-posts-grid .post-card__body { padding: var(--s-2) var(--s-3); gap: var(--s-2); }
.ai-posts-grid .post-card__text {
  font-size: 11px; line-height: 1.4;
  -webkit-line-clamp: 2;
}
.ai-posts-grid .post-card__meta { display: none; }    /* model/delete moved into actions */
.ai-posts-grid .post-card__actions { gap: 3px; }
.ai-posts-grid .post-card__actions .btn { padding: 3px 6px; font-size: 10px; }
.ai-posts-grid .post-card__btn-lbl { display: none; }  /* icon-only on small thumbs */
@media (min-width: 1200px) {
  .ai-posts-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
.post-card {
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.post-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.post-card__media { background: var(--surface-sunken); aspect-ratio: 1 / 1; overflow: hidden; }
.post-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); flex: 1; }
.post-card__text {
  font-size: var(--text-sm); line-height: var(--lh-normal); color: var(--ink-900);
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.post-card__meta {
  display: flex; gap: var(--s-3);
  font-size: var(--text-xs); color: var(--ink-500); font-weight: 600;
  padding-top: var(--s-2); border-top: 1px solid var(--border-muted);
}
.post-card__actions {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto;
}
.post-card__actions .btn { padding: 5px 10px; font-size: 12px; flex: 1 1 auto; min-width: 0; }
.post-card__badge {
  position: absolute; top: var(--s-2); inset-inline-start: var(--s-2);
  background: rgba(0,0,0,.72); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: var(--r-pill);
  letter-spacing: 0.02em;
}
.post-card__badge--ok { background: var(--success); }
.post-card__media { position: relative; }
.post-card__btn-lbl { display: inline; }
.ai-post .post-card__cta, .ai-post__cta {
  background: var(--brand-500) !important; color: #fff !important; border: none !important; font-weight: 700;
}
.ai-post.is-approved { border-color: var(--success); box-shadow: 0 0 0 1px var(--success) inset; }

/* ───────────────────────────────────────────────────────────────────────
   Brief readonly content — long URLs were forcing horizontal overflow
   and pushing all text off the screen.
   ─────────────────────────────────────────────────────────────────────── */
.brief-sec { margin-bottom: var(--s-5); }
.brief-sec h4 {
  margin: 0 0 var(--s-3);
  font-size: var(--text-md); font-weight: 800;
  color: var(--ink-900);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border-muted);
}
.brief-row {
  display: grid; grid-template-columns: minmax(140px, 30%) 1fr;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--border-muted);
  align-items: start;
}
.brief-row:last-child { border-bottom: none; }
.brief-q {
  font-weight: 700; color: var(--ink-700);
  font-size: var(--text-sm);
}
.brief-a {
  color: var(--ink-900);
  font-size: var(--text-sm); line-height: var(--lh-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
@media (max-width: 640px) {
  .brief-row { grid-template-columns: 1fr; gap: 4px; padding: var(--s-3) 0; }
  .brief-q { color: var(--ink-500); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
}

/* Belt-and-suspenders against horizontal page overflow caused by any
   long unbreakable token (URL, prompt, error message) anywhere. */
.card, .lane-card, .hero-card { overflow-wrap: anywhere; word-break: break-word; }
.card pre, .card code, .alert__detail { word-break: break-all; }

/* Inline post comments (reply from the system) */
.post-comments { border-top: 1px solid var(--border-muted); margin-top: var(--s-2); padding-top: var(--s-2); }
.post-comments .cmt { padding: var(--s-2) 0; border-bottom: 1px solid var(--border-muted); }
.post-comments .cmt:last-child { border-bottom: none; }

/* ───────────────────────────────────────────────────────────────────────
   Content calendar (scheduled posts grouped by day)
   ─────────────────────────────────────────────────────────────────────── */
.sched-day { margin-bottom: var(--s-4); }
.sched-day__head {
  font-size: var(--text-sm); font-weight: 800; color: var(--ink-900);
  padding: var(--s-2) 0; margin-bottom: var(--s-2);
  border-bottom: 1px solid var(--border-muted);
}
.sched-item {
  display: flex; gap: var(--s-3); align-items: center;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  margin-bottom: var(--s-2);
  background: var(--surface);
}
.sched-badge {
  font-size: 11px; font-weight: 700;
  background: var(--brand-50); color: var(--brand-700);
  border-radius: var(--r-pill); padding: 2px 8px;
  white-space: nowrap;
}
/* month-grid calendar (scheduler) */
.sched-view-btn {
  font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--surface); color: var(--ink-900);
  border: 1px solid var(--border-muted); border-radius: var(--r-md);
  padding: 5px 12px;
}
.sched-view-btn.active { background: var(--brand-600, #0d9488); color: #fff; border-color: var(--brand-600, #0d9488); }
.cal-wrap { border: 1px solid var(--border-muted); border-radius: var(--r-md); background: var(--cream, #f8fafc); padding: 10px; overflow-x: auto; }
.cal-head { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 8px; }
.cal-title { font-weight: 800; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; min-width: 560px; direction: rtl; }
.cal-wd { text-align: center; font-weight: 800; font-size: 12px; color: var(--ink-500, #888); padding: 2px 0; }
.cal-cell { border: 1px solid var(--border-muted); border-radius: var(--r-sm, 8px); background: var(--surface); min-height: 74px; padding: 3px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell--empty { border: none; background: transparent; }
.cal-cell--has { cursor: pointer; }
.cal-cell--has:hover { border-color: var(--brand-600, #0d9488); }
.cal-cell--today { box-shadow: inset 0 0 0 2px var(--brand-600, #0d9488); }
.cal-num { font-size: 12px; font-weight: 700; color: var(--ink-900); }
.cal-chip { display: flex; align-items: center; gap: 3px; font-size: 10px; background: var(--surface-sunken, #f8fafc); border-radius: 5px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip--more { justify-content: center; font-weight: 700; color: var(--ink-500, #888); }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* ───────────────────────────────────────────────────────────────────────
   Custom fields — value form + the definition editor
   ─────────────────────────────────────────────────────────────────────── */
.cf-grid {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.cf-edit-row {
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--surface);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.cf-edit-main { display: flex; gap: var(--s-2); }
.cf-edit-main .cf-label { flex: 1; }
.cf-edit-main .cf-type { width: 130px; flex-shrink: 0; }
.cf-edit-foot { display: flex; align-items: center; gap: var(--s-2); }
.cf-edit-foot .btn { padding: 3px 9px; font-size: 12px; }

/* ───────────────────────────────────────────────────────────────────────
   Modules picker (replaces the inline "מוסתר:" pill bar)
   ─────────────────────────────────────────────────────────────────────── */
.modules-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.modules-btn:hover { background: var(--surface-sunken); border-color: var(--border-strong); color: var(--ink-900); }
.modules-badge {
  background: var(--ink-900); color: #fff;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); }

/* Lightweight search-as-you-type combobox (replaces native <select> for
   long lists). Used by the onboarding Meta-link step; reusable. */
.combo { position: relative; }
.combo-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  background: var(--surface);
}
.combo-input:focus { outline: none; border-color: var(--ink-900); box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.combo-list {
  /* position + coordinates are set inline by JS (position:fixed) so the list
     escapes any overflow:hidden ancestor card. z-index must clear modals. */
  position: fixed; z-index: 1200;
  max-height: 260px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.combo-item {
  padding: 8px 12px; cursor: pointer; font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-muted);
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover,
.combo-item.active { background: var(--surface-sunken); }
.combo-empty { padding: 10px 12px; color: var(--ink-500); font-size: var(--text-sm); }
.combo-clear {
  position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 14px;
  color: var(--ink-500); padding: 4px 6px; line-height: 1; border-radius: 4px;
}
.combo-clear:hover { background: var(--surface-sunken); color: var(--ink-900); }
.combo-input.has-value { padding-inline-end: 30px; }
.combo-hint { font-size: 11px; color: var(--ink-500); margin-top: 4px; }

/* ───────────────────────────────────────────────────────────────────────
   Lead onboarding wizard (post-create flow)
   ─────────────────────────────────────────────────────────────────────── */
.onb-progress {
  display: flex; align-items: center; gap: var(--s-1);
  padding: var(--s-2) 0 var(--s-4);
  border-bottom: 1px solid var(--border-muted);
  margin-bottom: var(--s-4);
  overflow-x: auto;
}
.onb-step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 60px; }
.onb-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-sunken); color: var(--ink-500);
  border: 1px solid var(--border-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.onb-step.done .onb-dot { background: var(--success); color: #fff; border-color: var(--success); }
.onb-step.active .onb-dot { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }
.onb-lbl { font-size: 11px; color: var(--ink-500); text-align: center; line-height: 1.2; white-space: nowrap; }
.onb-step.active .onb-lbl { color: var(--ink-900); font-weight: 700; }
.onb-body { min-height: 180px; }
.onb-foot {
  display: flex; align-items: center; gap: var(--s-2);
  border-top: 1px solid var(--border-muted);
  margin-top: var(--s-4); padding-top: var(--s-3);
}
@media (max-width: 640px) {
  .onb-step .onb-lbl { display: none; }
  .onb-step { min-width: 0; }
  .onb-step.active .onb-lbl { display: block; }
}
.mod-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.mod-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mod-row:hover { background: var(--surface-sunken); border-color: var(--border-strong); }
.mod-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ink-900); cursor: pointer; }
.mod-row__name { flex: 1; min-width: 0; font-weight: 600; color: var(--ink-900); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-row__hint { font-size: 11px; color: var(--ink-500); font-weight: 600; }
.mod-row__handle { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.mod-move {
  width: 26px; height: 22px; padding: 0;
  background: var(--surface-sunken);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-sm);
  font-size: 12px; line-height: 1;
  color: var(--ink-700);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.mod-move:hover:not(:disabled) { background: var(--surface); border-color: var(--ink-900); color: var(--ink-900); }
.mod-move:disabled { opacity: 0.3; cursor: not-allowed; }

/* ───────────────────────────────────────────────────────────────────────
   Card management controls (↑ ↓ ✕ ½) — useful on desktop, noisy on mobile
   ─────────────────────────────────────────────────────────────────────── */
.card-ctrl {
  display: inline-flex; gap: 2px; align-items: center;
  margin-inline-end: var(--s-2);
  vertical-align: middle;
}
.card-ctrl button {
  background: var(--surface-sunken);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  font-size: 11px; line-height: 1.2;
  color: var(--ink-500);
  cursor: pointer;
}
.card-ctrl button:hover { background: var(--surface); color: var(--ink-900); }

/* Hidden-cards restore bar — was wrapping into 3 lines of cramped pills.
   Now a single horizontally scrollable row. */
.blocks-restore {
  display: flex; align-items: center; gap: var(--s-2);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: var(--s-2) 0;
  margin-bottom: var(--s-3);
  scrollbar-width: thin;
}
.blocks-restore::-webkit-scrollbar { height: 4px; }
.block-chip {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-size: var(--text-xs); font-weight: 600;
  color: var(--ink-700);
  white-space: nowrap;
  cursor: pointer;
}
.block-chip:hover { background: var(--brand-50); border-color: var(--brand-500); color: var(--ink-900); }

@media (max-width: 720px) {
  /* Card management controls eat half the header row on mobile and don't
     add value (you can't reorder a single-column stack meaningfully).
     Keep only the collapse-by-clicking-header behavior. */
  .card-ctrl { display: none; }

  /* Restore bar gets even tighter */
  .blocks-restore { padding-inline: var(--gutter); margin-inline: calc(-1 * var(--gutter)); }
  .block-chip { font-size: 11px; padding: 3px 8px; }
}

/* ───────────────────────────────────────────────────────────────────────
   Global form controls — kill default browser chrome on all inputs/
   selects/textareas so nothing inherits the ugly native look anywhere
   in the app. Components that need to override (.filter-pill,
   .modules-btn, etc.) still win because they set explicit values.
   ─────────────────────────────────────────────────────────────────────── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  padding: 9px 12px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--ink-900);
  box-shadow: 0 0 0 3px rgba(27,27,27,.08);
}
input::placeholder, textarea::placeholder { color: var(--ink-400); }

/* Custom-styled chevron for selects so they don't look like an OS dropdown */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-500) 50%),
                    linear-gradient(135deg, var(--ink-500) 50%, transparent 50%);
  background-position: calc(0% + 14px) 50%, calc(0% + 19px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-start: 32px;
  cursor: pointer;
}
[dir="rtl"] select {
  background-position: calc(0% + 14px) 50%, calc(0% + 19px) 50%;
}
select:disabled { background: var(--surface-sunken); color: var(--ink-400); cursor: not-allowed; }

textarea { min-height: 80px; resize: vertical; line-height: var(--lh-normal); }
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"] {
  font-family: inherit;
}

/* Native checkbox/radio — use system but pinned to brand color */
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink-900); cursor: pointer; }

/* ───────────────────────────────────────────────────────────────────────
   Filter bar — used in social/campaigns and anywhere we need a clean
   row of filter controls. On mobile each pill takes its own line.
   ─────────────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.filter-bar__title {
  margin: 0;
  flex: 1 0 100%;
  font-size: var(--text-md); font-weight: 800;
}
.filter-pill {
  display: inline-flex; align-items: center;
  gap: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  padding: 4px 10px;
  font-size: var(--text-sm); font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
  white-space: nowrap;
}
.filter-pill:hover { background: var(--surface); border-color: var(--border-strong); }
.filter-pill__lbl { color: var(--ink-500); font-size: var(--text-xs); font-weight: 600; }
.filter-pill select,
.filter-pill input[type="date"],
.filter-pill input[type="text"] {
  background: transparent;
  background-image: none;          /* kill the global custom chevron — pill has its own visual */
  border: none;
  font-size: var(--text-sm); font-weight: 600;
  color: var(--ink-900);
  padding: 2px 22px 2px 4px;        /* room for native browser arrow on selects */
  outline: none;
  cursor: pointer;
  font-family: inherit;
  width: auto;                      /* override global "select{width:100%}" */
  min-width: 0;
  box-shadow: none;
}
.filter-pill input[type="date"],
.filter-pill input[type="text"] { padding: 2px 4px; }
.filter-pill select:focus,
.filter-pill input:focus { box-shadow: none; }
.filter-pill input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--ink-900); margin: 0; cursor: pointer; }
.filter-pill--search {
  flex: 1 1 220px; min-width: 200px;
  padding: 0;
  background: var(--surface);
}
.filter-pill--search input {
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  cursor: text;
}
.filter-pill--range input[type="date"] {
  background: var(--surface); border: 1px solid var(--border-muted);
  border-radius: var(--r-sm); padding: 3px 6px;
}
.filter-pill--range .btn { padding: 4px 10px; font-size: 12px; }
.filter-pill--link {
  background: var(--brand-50); border-color: var(--brand-100);
}
.filter-pill--link b { color: var(--ink-900); }
.filter-pill--link .btn { padding: 3px 9px; font-size: 11px; margin-inline-start: 4px; }

.ad-acct-list {
  position: absolute; z-index: 20;
  top: calc(100% + 4px); inset-inline-start: 0; inset-inline-end: 0;
  max-height: 320px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-muted); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 720px) {
  .filter-bar { gap: 6px; }
  .filter-pill { flex: 1 1 auto; justify-content: space-between; }
  .filter-pill--search { flex-basis: 100%; }
  .filter-pill--range { flex-wrap: wrap; }
  .filter-pill--link { flex-basis: 100%; justify-content: space-between; }
}

/* ───────────────────────────────────────────────────────────────────────
   Segmented tab bar (used inside cards — e.g. social page panel)
   ─────────────────────────────────────────────────────────────────────── */
.seg-tabs {
  display: flex; gap: 4px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
  padding: 4px;
  margin-bottom: var(--s-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tab {
  flex: 1 0 auto;
  background: transparent; border: none;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--text-sm); font-weight: 600;
  color: var(--ink-500);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-tab:hover { color: var(--ink-900); }
.seg-tab.is-active {
  background: var(--surface);
  color: var(--ink-900);
  box-shadow: var(--shadow-xs);
}

/* ───────────────────────────────────────────────────────────────────────
   Alert / inline notice — for Meta API errors etc.
   ─────────────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  border-inline-start: 4px solid var(--border);
  background: var(--surface-sunken);
  margin-block: var(--s-2);
}
.alert--warn   { background: var(--warn-bg);    border-inline-start-color: var(--warn); }
.alert--danger { background: var(--danger-bg);  border-inline-start-color: var(--danger); }
.alert--info   { background: var(--info-bg);    border-inline-start-color: var(--info); }
.alert--success{ background: var(--success-bg); border-inline-start-color: var(--success); }
.alert__title { font-weight: 700; color: var(--ink-900); font-size: var(--text-sm); margin-bottom: 2px; }
.alert__body  { font-size: var(--text-sm); color: var(--ink-700); line-height: var(--lh-normal); }
.alert__more  { margin-top: var(--s-2); font-size: var(--text-xs); }
.alert__more summary { color: var(--ink-500); font-weight: 600; cursor: pointer; padding: 2px 0; }
.alert__detail {
  margin-top: var(--s-1); padding: var(--s-2);
  background: var(--surface); border-radius: var(--r-sm);
  font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--ink-700);
  word-break: break-word; white-space: pre-wrap;
  direction: ltr; text-align: left;
}

/* ───────────────────────────────────────────────────────────────────────
   Quote templates list (was unstyled <details>)
   ─────────────────────────────────────────────────────────────────────── */
.tpl {
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-3);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tpl[open] { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.tpl > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--s-4);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--ink-900);
}
.tpl > summary::-webkit-details-marker { display: none; }
.tpl > summary::before {
  content: "▸";
  color: var(--ink-400);
  transition: transform var(--dur) var(--ease);
  display: inline-block;
}
.tpl[open] > summary::before { transform: rotate(90deg); }
.tpl > summary > span:first-of-type { flex: 1; min-width: 0; }
.tpl > summary > .muted { font-size: var(--text-xs); font-weight: 500; }
.tpl-body {
  padding: var(--s-4);
  border-top: 1px solid var(--border-muted);
  background: var(--surface-sunken);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.tpl-actions {
  display: flex; gap: var(--s-2); flex-wrap: wrap;
  padding-top: var(--s-2); border-top: 1px solid var(--border-muted);
  margin-top: var(--s-2);
}

/* ───────────────────────────────────────────────────────────────────────
   Generic <details> assistant/AI cards — fix vertical-text glitch on RTL
   ─────────────────────────────────────────────────────────────────────── */
details > summary {
  cursor: pointer;
  display: flex; align-items: center; gap: var(--s-2);
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
details > summary > * { min-width: 0; }

/* ───────────────────────────────────────────────────────────────────────
   Mobile polish pass — fix the issues visible in the latest screenshots
   ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  /* Topbar was wrapping "L.H Group · CRM" onto 3 lines because user-info
     takes too much width. Re-flow: hamburger + brand on one tight row,
     controls on the right, brand truncates instead of wrapping. */
  .topbar {
    flex-wrap: nowrap;
    gap: var(--s-2);
    padding-inline: var(--s-3);
  }
  .brand {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 14px;
  }
  .user-info { gap: 4px; flex-shrink: 0; }
  .user-info #userName { display: none; }      /* freed up for brand */
  .user-info #langSwitch { max-width: 70px; padding: 4px 6px; font-size: 11px; }
  .user-info #orgSwitch  { max-width: 90px; padding: 4px 6px; font-size: 11px; }
  .notif-bell { padding: 4px 6px !important; }

  /* Lead detail card was floating in the middle of the screen with empty
     left side. On mobile it must span the full width. */
  .lead-card, #leadDetailCard, .detail-card {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }

  /* Cramped wide tables → enable horizontal scroll instead of crushing */
  .lead-table-inner, table.responsive-stack {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  /* The leads-list tables (awaiting / prospects / churned) have 6 columns
     and overflow:hidden — which crushed them. Let them scroll sideways. */
  .lead-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lead-table table { min-width: 560px; }
  .lead-table th, .lead-table td { white-space: nowrap; }

  /* Template summary wraps cleanly */
  .tpl > summary {
    flex-wrap: wrap; padding: var(--s-3);
    font-size: var(--text-sm);
  }
  .tpl > summary > .muted { width: 100%; }

  /* Toolbar h2 + button row stacks instead of overflowing */
  .toolbar { flex-wrap: wrap; }
  .toolbar h2 { font-size: var(--text-lg); }
}

@media (max-width: 480px) {
  /* Below 480px the brand text becomes wasteful — keep only the L.H logo
     style abbreviation so the user-info row breathes. */
  .brand {
    font-size: 13px;
  }
  /* Hide secondary controls behind hamburger on very small phones */
  .user-info #orgSwitch { display: none; }
}

/* Voice engine dashboard tiles */
.stat-tile{background:#fafafa;border:1px solid var(--border);border-radius:8px;padding:8px 6px;text-align:center;font-size:12px}
.stat-tile b{display:block;font-size:18px;margin-top:2px}
.stat-tile .muted{font-size:10.5px}


/* Quick-jump-to-client box — mobile: it shares position:sticky top:0 with the
   .topbar, so on a phone the two collided and the search cramped under the
   header. Drop the stickiness on mobile and stack label / input / count on
   their own full-width lines. */
@media (max-width: 640px) {
  #quickJumpBox { position: static !important; padding: 8px 0 !important; }
  #quickJumpBox > div { gap: 6px !important; }
  #quickJumpBox > div > b { flex: 1 1 100%; font-size: 12.5px; }
  #quickJumpBox > div > div { flex: 1 1 100% !important; min-width: 0 !important; max-width: none !important; }
  #quickJumpBox #quickJumpInput { font-size: 16px; }
  #quickJumpBox #quickJumpCount { flex: 0 0 auto; }
}

/* ── 2026-09 shell: RTL side navigation ─────────────────────────────── */
:root { --crm-sidebar-w: 252px; --crm-sidebar-compact: 76px; }
.topbar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--crm-sidebar-w); height: 100dvh;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  gap: 14px; padding: 20px 14px 14px; background: rgba(255,255,255,.98);
  border-block-end: 0; border-inline-end: 1px solid var(--border);
  box-shadow: -8px 0 28px rgba(15,23,42,.06); overflow: visible; z-index: var(--z-drawer);
}
.topbar .brand {
  min-height: 42px; padding: 8px 10px 14px; border-bottom: 1px solid var(--border-muted);
  font-size: 17px; justify-content: center; text-align: center;
}
.topbar nav, .topbar #mainNav {
  display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; align-items: stretch;
  gap: 5px; overflow-y: auto; overflow-x: hidden; padding: 2px;
}
.topbar .nav-btn {
  width: 100%; min-height: 43px; justify-content: flex-start; gap: 11px;
  padding: 10px 13px; border-radius: 11px; font-size: 13px; color: var(--ink-500); text-align: start;
}
.topbar .nav-btn svg { width: 19px; height: 19px; }
.topbar .nav-btn.active { color: #fff; background: linear-gradient(135deg,#14b8a6,#0d9488); box-shadow: 0 7px 18px rgba(13,148,136,.22); }
.topbar .user-info {
  flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
  padding-top: 12px; border-top: 1px solid var(--border-muted);
}
.topbar .user-info > * { min-width: 0; }
.topbar .user-info #userName { grid-column: 1 / -1; text-align: center; font-weight: 700; }
.topbar .user-info #orgSwitch, .topbar .user-info #docsLink { grid-column: 1 / -1; max-width: none; justify-content: center; }
.topbar .user-info #logoutBtn { width: 100%; }
.topbar .notif-wrap { display: flex; justify-content: center; }
.sidebar-toggle {
  position: absolute; inset-inline-end: -15px; top: 76px; width: 30px; height: 42px;
  display: grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--ink-500); box-shadow: var(--shadow-sm); font-size: 22px; z-index: 2;
}
main {
  max-width: none; margin: 0; margin-inline-start: var(--crm-sidebar-w);
  padding: 28px clamp(18px,3vw,42px) 48px; transition: margin-inline-start var(--dur) var(--ease);
}
.sidebar-collapsed .topbar { width: var(--crm-sidebar-compact); padding-inline: 9px; }
.sidebar-collapsed main { margin-inline-start: var(--crm-sidebar-compact); }
.sidebar-collapsed .topbar .brand { font-size: 0; padding-inline: 0; }
.sidebar-collapsed .topbar .brand::after { content: 'L.H'; font-size: 15px; font-weight: 900; }
.sidebar-collapsed .topbar .nav-btn { justify-content: center; padding-inline: 8px; }
.sidebar-collapsed .topbar .nav-btn span { display: none; }
.sidebar-collapsed .topbar .user-info > *:not(.notif-wrap):not(#langSwitch) { display: none !important; }
.sidebar-collapsed .topbar .user-info { grid-template-columns: 1fr; }
.sidebar-collapsed .topbar #langSwitch { width: 100%; padding-inline: 4px; font-size: 0; }
@media (max-width: 1024px) {
  :root { --crm-sidebar-w: var(--crm-sidebar-compact); }
  .topbar { width: var(--crm-sidebar-compact); padding: 14px 9px; }
  main, .sidebar-collapsed main { margin-inline-start: var(--crm-sidebar-compact); padding: 18px 14px 42px; }
  .topbar nav, .topbar nav.open { display: flex; position: static; box-shadow: none; border: 0; padding: 2px; }
  .topbar .brand { flex: 0 0 auto; font-size: 0; padding-inline: 0; }
  .topbar .brand::after { content: 'L.H'; font-size: 14px; font-weight: 900; }
  .topbar .nav-btn { justify-content: center; padding-inline: 8px; }
  .topbar .nav-btn span { display: none; }
  .topbar .user-info > *:not(.notif-wrap) { display: none !important; }
  .topbar .user-info { display: block; }
  .sidebar-toggle, .hamburger { display: none !important; }
}
