/* ==========================================================================
   SENQRA · app.css · light (default) + dark theme · single stylesheet (production)
   --------------------------------------------------------------------------
   Rules
   - All design tokens live on :root. Components only reference tokens.
   - Theme = token override only: `:root[data-theme="dark"] { … }` re-points the
     same custom properties (brand book palette). No component rule is forked.
     theme.js (head, render-blocking) sets data-theme before first paint;
     the toggle lives in app.js and persists to localStorage "senqra-theme".
   - No inline styles / inline scripts anywhere (CSP: style-src 'self').
   - Fonts self-hosted (static/fonts). No external requests at runtime.
   - Class naming: BEM-ish. Block `.card`, element `.card__head`,
     modifier `.card--flat`, state `.is-selected` / aria attributes.
   - Interactions that need JS are marked in HTML with data-action="…"
     and data-state="…"; CSS renders every state so htmx can swap them.

   Component index (in file order)
     0. Fonts, tokens (light), tokens (dark override), reset, focus
     1. Shell        .app .app-nav .app-nav__inner .nav-brand .nav-list .nav-item .nav-badge
                     .nav-foot .app-main .topbar .switcher .daterange
                     .source-chip .avatar .icon-btn .theme-toggle .skip-link
     2. Page         .page .page-head .page-title .page-meta .freshness
                     .label (bracket label) .signal-line .section
     3. Banner       .banner (gradient decision point, max ONE per screen)
     4. Buttons      .btn .btn--primary .btn--secondary .btn--ghost
                     .btn--danger .btn--on-dark .btn--sm .link
     5. Chips        .chip .chip--{success|warning|danger|info|accent|outline}
                     .dot .dot--{ok|warn|err|info|none|accent} .status
     6. KPI          .kpi-grid .kpi .pace
     7. Funnel       .funnel .funnel-step .funnel-arrow
     8. Card         .card .card__head .card__title .card__body .card__foot
     9. Tabs/tools   .tabs .tab .toolbar .search .dropdown .menu
    10. Table        .table-wrap .table .num .switch .pending-bar .note
    11. Connections  .conn .conn-item
    12. Recs         .rec-layout .rec .conds .change .confidence .history
    13. Draft        .draft-layout .changes .change-row .change-mark
                     .validation .vitem .steps .step
    14. Leads        .filters .filter-chip .leads-layout .panel .kv
                     .timeline .notice
    15. Utilities    .u-* .sr-only .w-*
    16. Responsive   ≤ 1100px, ≤ 900px, ≤ 480px
   ========================================================================== */

/* 0. Fonts ---------------------------------------------------------------- */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* 0. Tokens --------------------------------------------------------------- */
:root {
  color-scheme: light;    /* native controls + scrollbars follow the theme (see dark block) */

  /* Surfaces (light theme derived from brand dark tokens) */
  --bg: #F6F6F4;          /* page canvas, warm near-white */
  --surface: #FFFFFF;     /* cards, panels, table */
  --surface-rgb: 255, 255, 255; /* same colour as --surface, for rgba() fades (table edge hint) */
  --raised: #FAFAF8;      /* table header, step cards, observation cards */
  --sunken: #F1F1EE;      /* neutral chip bg, pace track */
  --dark: #0E0F12;        /* the one always-dark brand block (nav header, light wordmark on it) */
  --dark-2: #1A1830;      /* banner lavender-side base */
  --ink: #0E0F12;         /* "ink" = inverse of the page: avatar, chip--dark, skip-link */
  --ink-fg: #F2F2F0;      /* text on --ink (17.10:1) */

  /* Banner base (the gradient's three anchors) + its edge line (transparent in light) */
  --banner-l: var(--dark-2);
  --banner-core: var(--dark);
  --banner-r: #10182A;
  --banner-border: transparent;

  /* Text. Contrast ratios (WCAG, verified 2026-10-08):
     --fg        #0E0F12  19.17:1 on surface, 17.71:1 on bg
     --secondary #4A4B52   8.68:1 on surface,  8.02:1 on bg
     --muted     #6E6F76   4.97:1 on surface,  4.60:1 on bg  (AA for 11px labels)
                           NOTE: the proposed #7A7B82 was 4.21:1 on white, FAILS AA, darkened.
     --accent    #5B4BD6   6.14:1 on surface,  5.67:1 on bg,  5.25:1 on --signal-tint
     white       on --accent 6.14:1 (primary buttons)
     --fg        on --signal #A195F7 7.44:1 (signal is a FILL colour only;
                 white on signal is 2.57:1, never put light text on it) */
  --fg: #0E0F12;
  --secondary: #4A4B52;
  --muted: #6E6F76;
  --fg-on-dark: #F2F2F0;  /* 17.10:1 on --dark */
  --muted-on-dark: #9D9EA2;

  /* Brand signal + accent */
  --signal: #A195F7;       /* lavender fill / highlight / active rails */
  --signal-tint: #EEEBFE;  /* selected row, active nav, accent chip bg */
  --signal-tint-2: #DCD7FD;
  --accent: #5B4BD6;       /* links, active text, badge / current-step fill */
  --accent-hover: #4C3EC0;
  --accent-fg: #FFFFFF;    /* text on an --accent fill (6.14:1) */
  --cta: var(--accent);    /* primary button fill (light: accent; dark: brand light fill, lavender stays a signal) */
  --cta-hover: var(--accent-hover);
  --cta-fg: #FFFFFF;       /* text on --cta */
  --cold-blue: #3B82F6;    /* gradient only */
  --pink-trace: #F0A3FF;   /* gradient only */

  /* Status (restrained). Text on tint / on white, all ≥ 4.5:1:
     success #1B7A47 4.76 on #E7F5EC, 5.36 on white
     warning #8A5A00 5.40 on #FFF3DF, 5.93 on white
     danger  #B4302B 5.36 on #FCEBEA, 6.18 on white
     info    #2457B5 5.89 on #E8F0FC, 6.76 on white */
  --success: #1B7A47;  --success-tint: #E7F5EC;  --success-dot: #2EA865;
  --warning: #8A5A00;  --warning-tint: #FFF3DF;  --warning-dot: #E39A1E;
  --danger:  #B4302B;  --danger-tint:  #FCEBEA;  --danger-dot:  #DC4C45;
  --info:    #2457B5;  --info-tint:    #E8F0FC;  --info-dot:    #4A86E8;
  --pending-tint: #FFF8EA; /* own draft/pending row highlight (amber, not green) */
  --warning-line: rgba(227, 154, 30, .35);  /* pending-bar edge */
  --success-line: rgba(46, 168, 101, .45);  /* done-step edge */

  /* Lines */
  --border: rgba(9, 10, 12, .10);
  --border-strong: rgba(9, 10, 12, .18);
  --border-on-dark: rgba(255, 255, 255, .12);

  /* Controls */
  --switch-off: #C9C9CF;   /* status switch track, off */
  --switch-knob: #FFFFFF;
  --switch-knob-shadow: 0 1px 2px rgba(0, 0, 0, .25);

  /* Shape */
  --r-card: 16px;
  --r-ctl: 10px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(9, 10, 12, .06);
  --shadow-panel: 0 8px 24px rgba(9, 10, 12, .08);
  --focus: 0 0 0 3px rgba(91, 75, 214, .35);

  /* Type */
  --font: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-label: 11px;   /* labels 10–11 / 500 / 20% tracking / uppercase in brackets */
  --fs-btn: 13px;     /* buttons 13 / 600 / 12% tracking */
  --fs-body: 14px;
  --fs-sm: 13px;
  --fs-xs: 12px;

  /* Layout */
  --nav-w: 240px;
  --topbar-h: 56px;
  --page-max: 1280px;
  --page-pad: 32px;
  --ease: 200ms ease-out;
}

/* 0. Dark theme (brand book palette, SENQRA_Brand_Design_System_v1 p.6 / p.16) --
   Same tokens, re-pointed. Set by theme.js from localStorage "senqra-theme";
   light stays the default, prefers-color-scheme is deliberately NOT followed.
   Contrast ratios (WCAG, verified numerically 2026-10-08):
     --fg        #F2F2F0  16.43:1 on surface, 17.67 on bg, 15.30 on raised, 14.15 on sunken
     --secondary #C3C4C8  10.57:1 on surface, 11.36 on bg,  9.84 on raised,  9.10 on sunken
     --muted     #9D9EA2   6.88:1 on surface,  7.40 on bg,  6.41 on raised,  5.93 on sunken,
                           5.81 on --signal-tint, 6.20 on --pending-tint (AA for 11px labels)
     --accent    #A195F7   7.15:1 on surface,  7.69 on bg,  6.66 on raised,  6.04 on --signal-tint,
                           4.89 on --signal-tint-2 (selection)  — lavender is TEXT/signal here
     --cta-fg    #0E0F12  17.10:1 on --cta #F2F2F0 (primary button = brand light fill, not lavender)
     --accent-fg #0E0F12   7.44:1 on --accent (badge, current step number: the only lavender fills, ≤ 24px)
     --ink-fg    #0E0F12  17.10:1 on --ink #F2F2F0 (avatar, chip--dark)
     status text on tint / on surface / on raised (all ≥ 4.5):
       success #55C98A 7.45 on #10291C, 8.87 on surface, 8.26 on raised
       warning #E3AE4F 7.68 on #2D230D, 9.15 on surface, 8.52 on raised
       danger  #F27C75 6.22 on #341615, 6.94 on surface, 6.47 on raised
       info    #80AFF5 7.17 on #13213A, 8.22 on surface, 7.65 on raised
     dots (non-text, ≥ 3:1 on surface): success-dot 6.06, warning-dot 7.81, danger-dot 4.53, info-dot 5.15
     banner: --fg 16.12 on core #15161B / 14.12 on left #221F3B; --muted 6.75 core / 5.91 left / 6.48 right */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #090A0C;
  --surface: #131417;
  --surface-rgb: 19, 20, 23;
  --raised: #1B1B20;
  --sunken: #212228;       /* neutral chip / track: one step above raised (dark "sunken" reads as a lighter well) */
  --dark: #090A0C;         /* brand block sits on the canvas colour; wordmark stays light */
  --ink: #F2F2F0;
  --ink-fg: #0E0F12;

  --banner-l: #221F3B;
  --banner-core: #15161B;  /* lifted off the #090A0C canvas so the decision point still reads as a card */
  --banner-r: #121A2D;
  --banner-border: rgba(255, 255, 255, .10);

  --fg: #F2F2F0;
  --secondary: #C3C4C8;    /* brand "chrome" */
  --muted: #9D9EA2;

  --signal: #A195F7;
  --signal-tint: #23232E;  /* brand "accent surface": selected row, active nav, accent chip bg */
  --signal-tint-2: #332F52;
  --accent: #A195F7;
  --accent-hover: #B9B0FA;
  --accent-fg: #0E0F12;
  --cta: #F2F2F0;
  --cta-hover: #FFFFFF;
  --cta-fg: #0E0F12;

  --success: #55C98A;  --success-tint: #10291C;  --success-dot: #2EA865;
  --warning: #E3AE4F;  --warning-tint: #2D230D;  --warning-dot: #E39A1E;
  --danger:  #F27C75;  --danger-tint:  #341615;  --danger-dot:  #DC4C45;
  --info:    #80AFF5;  --info-tint:    #13213A;  --info-dot:    #4A86E8;
  --pending-tint: #231E10;
  --warning-line: rgba(227, 154, 30, .45);
  --success-line: rgba(46, 168, 101, .55);

  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .20);
  --border-on-dark: rgba(255, 255, 255, .12);

  --switch-off: #3A3B43;
  --switch-knob: #F2F2F0;
  --switch-knob-shadow: 0 1px 2px rgba(0, 0, 0, .6);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-panel: 0 8px 24px rgba(0, 0, 0, .6);
  --focus: 0 0 0 3px rgba(161, 149, 247, .40);
}

/* 0. Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
svg.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--signal-tint-2); }

/* 1. Shell ---------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: 100vh;
}
.skip-link {
  position: absolute; left: 8px; top: -40px; z-index: 100;
  padding: 8px 12px; background: var(--ink); color: var(--ink-fg);
  border-radius: var(--r-ctl); font-size: var(--fs-sm); text-decoration: none;
}
.skip-link:focus { top: 8px; }

.app-nav {
  /* stretches with the grid row = full document height; the sticky viewport column is .app-nav__inner */
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.app-nav__inner { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.nav-brand {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center;
  padding: 0 20px;
  background: var(--dark);            /* the one dark brand block: light wordmark lives here */
  border-bottom: 1px solid var(--border-on-dark);
}
.nav-brand__link { display: inline-flex; border-radius: 4px; }
.nav-brand__link:focus-visible { outline-color: var(--signal); }
.nav-brand img { height: 19px; width: auto; }
.nav-section { padding: 18px 22px 6px; }
.nav-list { list-style: none; padding: 0 12px; display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px;
  border-radius: var(--r-ctl);
  color: var(--secondary); font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  transition: background var(--ease), color var(--ease);
}
.nav-item:hover { background: var(--sunken); color: var(--fg); }
.nav-item[aria-current="page"] { background: var(--signal-tint); color: var(--accent); }
.nav-item .icon { opacity: .85; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill); background: var(--accent); color: var(--accent-fg);
  font-size: 11px; font-weight: 600; line-height: 1;
}
.nav-foot {
  margin-top: auto; padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
  display: grid; gap: 10px;
  font-size: var(--fs-xs); color: var(--muted);
}
.nav-foot__project { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.nav-foot__project img { width: 28px; height: 28px; border-radius: 7px; }
.nav-foot__project b { display: block; font-weight: 600; font-size: 12.5px; line-height: 1.2; }
.nav-foot__project span { display: block; color: var(--muted); font-size: 11.5px; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--page-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__spacer { flex: 1; }
.topbar .topbar__menu, .topbar .topbar__brand { display: none; }
.topbar__brand img { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  background: var(--surface); cursor: pointer;
}
/* Theme toggle: sun shows in light, moon in dark (aria-pressed = dark on). */
.theme-toggle { color: var(--secondary); transition: border-color var(--ease), background var(--ease), color var(--ease); }
.theme-toggle:hover { border-color: var(--signal); background: var(--raised); color: var(--fg); }
.theme-toggle__moon, :root[data-theme="dark"] .theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__moon { display: block; }
.switcher, .daterange {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 8px;
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  background: var(--surface); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 500; color: var(--fg);
  white-space: nowrap; max-width: 100%;
  transition: border-color var(--ease), background var(--ease);
}
.switcher:hover, .daterange:hover { border-color: var(--signal); background: var(--raised); }
.switcher img { width: 22px; height: 22px; border-radius: 5px; }
.switcher__org, .switcher__sep { color: var(--muted); font-weight: 500; }
.switcher__project { overflow: hidden; text-overflow: ellipsis; }
.daterange__cmp { color: var(--muted); font-weight: 400; }
.daterange .icon, .switcher .icon { color: var(--muted); }
.source-chips { display: inline-flex; gap: 6px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 500; color: var(--fg); background: var(--surface);
  white-space: nowrap;
}
.source-chip em { font-style: normal; color: var(--muted); font-weight: 400; }
.source-chip--off { color: var(--muted); border-style: dashed; }
.avatar {
  width: 32px; height: 32px; flex: none; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: var(--ink); color: var(--ink-fg);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; cursor: pointer;
}

/* 2. Page ----------------------------------------------------------------- */
.page {
  width: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: 24px var(--page-pad) 56px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start;
}
/* Every single-column grid uses minmax(0,1fr): a bare 1fr = minmax(auto,1fr) lets nowrap content widen the page. */
.page-head, .section, .rec-list, .steps, .card__titlegroup, .rec__titlegroup, .banner__main, .change-row__main, .history-item, .tl-item, .funnel-step, .nav-foot, .rec__section { grid-template-columns: minmax(0, 1fr); }
.page-head { display: grid; gap: 8px; padding-bottom: 4px; }
.page-head__row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.page-title--sm { font-size: 20px; }
.page-meta { font-size: var(--fs-sm); color: var(--secondary); margin-top: 6px; }
.page-meta em { font-style: normal; color: var(--muted); }
.freshness {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--muted);
}
.freshness .dot { width: 6px; height: 6px; }

/* Bracket label: 10–11px / 500 / 20% tracking / uppercase. Lavender for active topic, muted for index. */
.label {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: var(--fs-label); font-weight: 500; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); line-height: 1.2; white-space: nowrap;
}
.label--muted { color: var(--muted); }
.label--sm { font-size: 10px; }
.signal-line { display: inline-block; width: 56px; height: 1px; background: currentColor; opacity: .55; }
.section { display: grid; gap: 12px; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section__title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.section__hint { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* 3. Banner (decision point; the only gradient element on a screen) ------- */
.banner {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--r-card);
  padding: 18px 22px;
  color: var(--fg-on-dark);
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  /* lavender → near-black core → cold blue → pink trace. Saturation reduced for production.
     The three base anchors are tokens (--banner-l / --banner-core / --banner-r); the glows are
     the same in both themes. --banner-border is an inset line (no layout change), only in dark. */
  box-shadow: inset 0 0 0 1px var(--banner-border);
  background:
    radial-gradient(38% 160% at 97% 120%, rgba(240, 163, 255, .22) 0%, rgba(240, 163, 255, 0) 60%),
    radial-gradient(52% 180% at 100% 40%, rgba(59, 130, 246, .42) 0%, rgba(59, 130, 246, 0) 62%),
    radial-gradient(48% 180% at 0% 50%, rgba(161, 149, 247, .34) 0%, rgba(161, 149, 247, 0) 62%),
    linear-gradient(90deg, var(--banner-l) 0%, var(--banner-core) 42%, var(--banner-core) 58%, var(--banner-r) 100%);
}
.banner__main { flex: 1 1 320px; min-width: 0; display: grid; gap: 4px; }
.banner .label { color: rgba(242, 242, 240, .82); }  /* white label: lavender on the glow edge is < 4.5:1 */
.banner__title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.banner__text { font-size: var(--fs-sm); color: var(--muted-on-dark); }
.banner__items { display: flex; gap: 8px; flex-wrap: wrap; }
.banner__item {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--border-on-dark); border-radius: var(--r-pill);
  background: rgba(14, 15, 18, .45);
  font-size: var(--fs-xs); color: var(--fg-on-dark); text-decoration: none; white-space: nowrap;
  transition: border-color var(--ease), background var(--ease);
}
.banner__item:hover { border-color: var(--signal); background: rgba(161, 149, 247, .14); }
.banner__item .arrow { color: var(--signal); }
.banner__actions { display: flex; gap: 8px; flex: none; }

/* 4. Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-size: var(--fs-btn); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; line-height: 1;
  color: var(--fg); background: transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.btn .arrow { display: inline-block; transition: transform var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--cta); color: var(--cta-fg); }
.btn--primary:hover { background: var(--cta-hover); }
.btn--secondary { background: var(--surface); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--signal); background: var(--raised); }
.btn--ghost { color: var(--secondary); }
.btn--ghost:hover { background: var(--sunken); color: var(--fg); }
.btn--danger { color: var(--danger); border-color: transparent; }
.btn--danger:hover { background: var(--danger-tint); }
.btn--on-dark { border-color: var(--signal); color: var(--fg-on-dark); background: rgba(14, 15, 18, .35); }
.btn--on-dark:hover { background: rgba(161, 149, 247, .16); }
.btn--sm { height: 30px; padding: 0 12px; font-size: 11.5px; letter-spacing: .10em; }
.btn--xs { height: 26px; padding: 0 10px; font-size: 11px; letter-spacing: .08em; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[disabled]:hover .arrow { transform: none; }
.link { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.link:hover { text-decoration: underline; }
.link .arrow { display: inline-block; transition: transform var(--ease); }
.link:hover .arrow { transform: translateX(3px); }

/* 5. Chips, dots, status -------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--sunken); color: var(--secondary);
  font-size: var(--fs-label); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  white-space: nowrap; vertical-align: middle;
}
.chip--success { background: var(--success-tint); color: var(--success); }
.chip--warning { background: var(--warning-tint); color: var(--warning); }
.chip--danger  { background: var(--danger-tint);  color: var(--danger); }
.chip--info    { background: var(--info-tint);    color: var(--info); }
.chip--accent  { background: var(--signal-tint);  color: var(--accent); }
.chip--outline { background: transparent; border-color: var(--border-strong); color: var(--secondary); }
.chip--none    { background: transparent; border-color: var(--border); color: var(--muted); }
.chip--dark    { background: var(--ink); color: var(--ink-fg); }
.chip .dot { width: 6px; height: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot--ok { background: var(--success-dot); }
.dot--warn { background: var(--warning-dot); }
.dot--err { background: var(--danger-dot); }
.dot--info { background: var(--info-dot); }
.dot--accent { background: var(--signal); }
.dot--none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.status { display: inline-flex; align-items: center; gap: 4px 8px; white-space: nowrap; font-weight: 500; flex-wrap: wrap; }
.status__sub { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); flex-basis: 100%; padding-left: 16px; }

/* 6. KPI tiles ------------------------------------------------------------ */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi {
  min-width: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  transition: border-color var(--ease);
}
.kpi:hover { border-color: var(--signal); }
.kpi__label {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-size: 10.5px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.kpi__label .chip { height: 18px; padding: 0 7px; font-size: 9.5px; letter-spacing: .04em; }
.kpi__value {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi__value small { font-size: 13px; font-weight: 500; color: var(--secondary); letter-spacing: 0; margin-left: 4px; }
.kpi__value--na { color: var(--muted); font-weight: 500; font-size: 22px; }
.kpi__delta { font-size: var(--fs-xs); color: var(--secondary); line-height: 1.35; }  /* inline flow so the arrow never wraps alone */
.kpi__delta .arrow { font-weight: 600; margin-right: 5px; }
.kpi__delta--up .arrow { color: var(--success); }
.kpi__delta--down .arrow { color: var(--danger); }
.kpi__delta--neutral .arrow { color: var(--muted); }
.kpi__sub { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.kpi__sub--warn { color: var(--warning); }
.pace { height: 4px; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.pace__fill { height: 100%; border-radius: 2px; background: var(--signal); }
.pace--over .pace__fill { background: var(--warning-dot); }

/* 7. Funnel --------------------------------------------------------------- */
.funnel { display: flex; align-items: stretch; gap: 6px; }
.funnel-step {
  flex: 1 1 0; min-width: 0;
  padding: 12px 14px;
  background: var(--raised); border: 1px solid var(--border); border-radius: 12px;
  display: grid; gap: 4px;
}
.funnel-step__label { font-size: 10.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.funnel-step__value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.funnel-step__value--na { color: var(--muted); font-weight: 500; }
.funnel-step__sub { font-size: 11.5px; color: var(--muted); }
.funnel-step--off { border-style: dashed; background: transparent; }
.funnel-arrow {
  flex: none; width: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted); text-align: center; line-height: 1.25; padding: 0 2px;
}
.funnel-arrow__glyph { font-size: 16px; color: var(--accent); line-height: 1; display: inline-block; }
.funnel-arrow__glyph--off { color: var(--muted); }

/* 8. Card ----------------------------------------------------------------- */
.card {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card__head--plain { border-bottom: 0; padding-bottom: 8px; }
.card__title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card__titlegroup { display: grid; gap: 6px; }
.card__body { padding: 16px 20px; }
.card__foot { padding: 12px 20px; border-top: 1px solid var(--border); }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }

/* 9. Tabs, toolbar, dropdown ---------------------------------------------- */
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 13px 10px 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 500; color: var(--secondary);
  transition: color var(--ease), border-color var(--ease);
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab__count { font-size: 11px; font-weight: 500; color: var(--secondary); background: var(--sunken); border-radius: var(--r-pill); padding: 2px 7px; line-height: 1.2; }  /* secondary, not muted: muted on sunken is 4.42:1 */
.tab[aria-selected="true"] .tab__count { background: var(--signal-tint); color: var(--accent); }
.tabs__aside { margin-left: auto; align-self: center; padding: 0 8px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px; }
.toolbar__spacer { flex: 1; }
.search {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; min-width: 240px;
  border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--surface);
  color: var(--muted); font-size: var(--fs-sm);
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.search input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--fg); width: 100%; min-width: 0; }
.search input::placeholder { color: var(--muted); }
.dropdown {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--surface);
  font-size: var(--fs-sm); font-weight: 500; color: var(--fg); cursor: pointer; white-space: nowrap;
  transition: border-color var(--ease), background var(--ease);
}
.dropdown:hover { border-color: var(--signal); background: var(--raised); }
.dropdown .icon { color: var(--muted); }
.dropdown__key { color: var(--muted); font-weight: 400; }
.dropdown-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 260px;
  padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-panel); list-style: none;
}
.menu[data-state="closed"] { display: none; }
.menu__label { padding: 8px 10px 4px; }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left;
  font-size: var(--fs-sm); color: var(--fg); cursor: pointer;
}
.menu__item:hover { background: var(--sunken); }
.menu__item[aria-checked="true"] { background: var(--signal-tint); color: var(--accent); font-weight: 500; }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* 10. Table --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
}
.table th, .table td {
  padding: 10px 9px; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle; text-align: left;
}
.table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--raised);
  font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .num { text-align: right; }
.table .ctl { width: 44px; }
.table tbody tr { transition: background var(--ease); }
.table tbody tr:hover td { background: var(--raised); }
.table tbody tr.is-pending td { background: var(--pending-tint); }
.table tbody tr.is-selected td { background: var(--signal-tint); }
.table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table tbody tr[data-href] { cursor: pointer; }
.table tfoot td { background: var(--raised); font-weight: 600; border-bottom: 0; }
.table tfoot td:first-child { border-bottom-left-radius: var(--r-card); }
.table tfoot td:last-child { border-bottom-right-radius: var(--r-card); }
.table .is-muted { color: var(--muted); font-weight: 400; }
.table .is-weak { color: var(--muted); }
.table .is-weak sup { font-size: 9px; color: var(--warning); margin-left: 2px; }
.cell-name { display: grid; gap: 2px; min-width: 210px; white-space: normal; }
.cell-name a { color: var(--fg); font-weight: 500; text-decoration: none; }
.cell-name a:hover { color: var(--accent); text-decoration: underline; }
.cell-name small { font-size: var(--fs-xs); color: var(--muted); }
.cell-mono { font-weight: 500; letter-spacing: .01em; }
.cell-ellipsis { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.cell-ellipsis--sm { max-width: 170px; }
.table-wrap--hint { position: relative; }
.table-wrap--hint::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; pointer-events: none; background: linear-gradient(90deg, rgba(var(--surface-rgb), 0), rgba(var(--surface-rgb), .9)); }

/* Status switch. In SENQRA a toggle never applies instantly: it creates a PENDING change. */
.switch {
  position: relative; width: 34px; height: 20px; flex: none; padding: 0;
  border: 0; border-radius: var(--r-pill); background: var(--switch-off); cursor: pointer;
  transition: background var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--switch-knob); box-shadow: var(--switch-knob-shadow);
  transition: left var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 16px; }
.switch[data-state="pending"] { background: var(--warning-dot); }
.switch[data-state="pending"]::after { left: 9px; }

.pending-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 20px 12px; padding: 10px 14px;
  background: var(--warning-tint); border: 1px solid var(--warning-line); border-radius: 12px;
  font-size: var(--fs-sm);
}
.pending-bar__text { flex: 1 1 280px; min-width: 0; display: grid; grid-template-columns: 8px minmax(0, 1fr); align-items: start; gap: 8px; }
.pending-bar__text .dot { margin-top: 7px; }
.pending-bar__text b { font-weight: 600; }
.pending-bar .arrow { color: var(--accent); font-weight: 600; }
.pending-bar__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.note {
  display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center;
  padding: 12px 20px; border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--secondary);
}
.note__item { display: flex; align-items: flex-start; gap: 8px; }
.note__item .dot { width: 6px; height: 6px; margin-top: 6px; }
.note__item b { font-weight: 600; }

/* 11. Connections --------------------------------------------------------- */
.conn { display: grid; gap: 12px; }
.conn--row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.conn--row .conn-item { padding: 0 20px; border-left: 1px solid var(--border); }
.conn--row .conn-item:first-child { padding-left: 0; border-left: 0; }
.conn--row .conn-item:last-child { padding-right: 0; }
.conn-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.conn-item__name { font-weight: 500; }
.conn-item__name small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.conn-item__meta { color: var(--muted); font-size: var(--fs-xs); text-align: right; white-space: nowrap; }

/* 12. Recommendations ----------------------------------------------------- */
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.rec-list { display: grid; gap: 12px; }
.rec { overflow: hidden; }
.rec__head { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px 0; flex-wrap: wrap; }
.rec__head > .chip { margin-left: auto; }
.rec__titlegroup { flex: 1 1 320px; min-width: 0; display: grid; gap: 3px; }
.rec__title { font-size: 18px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.rec__object { font-size: var(--fs-sm); color: var(--secondary); }
.rec__object b { font-weight: 500; color: var(--fg); }
.rec__body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px 24px; padding: 14px 20px 16px; }
.rec__section { display: grid; gap: 6px; align-content: start; }
.rec__section .label { font-size: 10px; }
.rec__why { font-size: 13.5px; line-height: 1.5; color: var(--fg); }
.rec__why b { font-weight: 600; }
.conds { list-style: none; display: grid; gap: 4px; font-size: 12.5px; margin-top: 2px; }
.conds li { display: flex; gap: 8px; align-items: baseline; }
.conds__mark { width: 14px; flex: none; font-weight: 700; text-align: center; }
.cond--met { color: var(--success); }
.cond--unmet { color: var(--secondary); }
.cond--unmet .conds__mark { color: var(--muted); }
.change { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.change__from { color: var(--muted); font-weight: 500; }
.change__arrow { color: var(--accent); }
.change__to { color: var(--fg); }
.change small { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; flex-basis: 100%; }
.effect { font-size: 13.5px; line-height: 1.5; }
.effect em { font-style: normal; color: var(--muted); }
.confidence-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.rec__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 20px 18px; border-top: 1px solid var(--border); }
.rec__actions .u-right { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); }
.rec--observation { background: var(--raised); border-style: dashed; }
.rec--observation .rec__title { font-size: 15px; font-weight: 600; }
.rec__empty { padding: 14px 20px 18px; font-size: var(--fs-sm); color: var(--secondary); display: grid; gap: 6px; }

.history { list-style: none; }
.history-item { display: grid; gap: 3px; padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 12.5px; line-height: 1.4; }
.history-item:last-child { border-bottom: 0; }
.history-item__when { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.history-item__who b { font-weight: 600; }
.verb { font-weight: 600; }
.verb--approved { color: var(--success); }
.verb--rejected { color: var(--danger); }
.verb--snoozed { color: var(--warning); }
.verb--created { color: var(--info); }
.history-item__what { color: var(--fg); }
.history-item__meta { color: var(--muted); font-size: 11.5px; }
.history-item__meta .link { font-size: 11.5px; }

/* 13. Campaign draft review ----------------------------------------------- */
.draft-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2.3fr); gap: 16px; align-items: start; }
.changes { list-style: none; }
.change-row {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 11px 20px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm);
}
.change-row:last-child { border-bottom: 0; }
.change-mark {
  width: 24px; height: 24px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; line-height: 1;
}
.change-mark--add { background: var(--success-tint); color: var(--success); }
.change-mark--mod { background: var(--info-tint); color: var(--info); }
.change-mark--del { background: var(--danger-tint); color: var(--danger); }
.change-row__main { display: grid; gap: 2px; min-width: 0; }
.change-row__kind { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.change-row__name { font-weight: 500; }
.change-row__meta { color: var(--secondary); font-size: var(--fs-xs); }
.change-row--mod .change-row__name { color: var(--accent); font-weight: 600; }  /* edited after generation */
.change-row--del .change-row__name { text-decoration: line-through; color: var(--muted); }
.change-row__aside { font-size: 11.5px; color: var(--muted); white-space: nowrap; text-align: right; }
.change-row__aside .link { font-size: 11.5px; }
.changes-summary { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--secondary); }
.changes-summary b { font-weight: 600; }

.validation { list-style: none; }
.vitem { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 12px; align-items: start; padding: 11px 20px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); line-height: 1.45; }
.vitem:last-child { border-bottom: 0; }
.vitem .dot { margin-top: 6px; }
.vitem__sev { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; margin-right: 6px; }
.vitem--error .vitem__sev { color: var(--danger); }
.vitem--warn .vitem__sev { color: var(--warning); }
.vitem--ok .vitem__sev { color: var(--success); }
.vitem__meta { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.validation-summary { display: flex; gap: 6px; flex-wrap: wrap; }

.steps { display: grid; gap: 10px; padding: 16px 20px 20px; }
.step {
  position: relative; display: grid; gap: 8px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--raised);
}
.step__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step__num {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: var(--sunken); color: var(--secondary);
}
.step__title { font-size: var(--fs-body); font-weight: 600; }
.step__head > .chip { margin-left: auto; }
.step__meta { font-size: var(--fs-xs); color: var(--secondary); line-height: 1.45; }
.step__meta b { font-weight: 600; color: var(--fg); }
.step--done { border-color: var(--success-line); }
.step--done .step__num { background: var(--success-tint); color: var(--success); }
.step--current { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--signal-tint); }
.step--current .step__num { background: var(--accent); color: var(--accent-fg); }
.step__budget { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 22px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--raised); width: max-content; max-width: 100%; }
.step__budget div { display: grid; gap: 2px; }
.step__budget span { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.step__budget b { font-size: 18px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.step__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.step__warn { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-xs); color: var(--warning); }
.step__warn .dot { margin-top: 5px; }
.step-connector { height: 14px; margin: -4px 0 -4px 27px; border-left: 1px dashed var(--border-strong); }

/* 14. Leads --------------------------------------------------------------- */
.notice {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px;
  background: var(--info-tint); color: var(--info); font-size: var(--fs-sm);
}
.notice .link { color: var(--info); }
.notice .dot { margin-top: 7px; }
.notice__text { flex: 1 1 280px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.filters__group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.filters .search { min-width: 150px; flex: 0 1 200px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill); background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--secondary); cursor: pointer; white-space: nowrap;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}
.filter-chip:hover { border-color: var(--signal); }
.filter-chip[aria-pressed="true"] { background: var(--signal-tint); border-color: var(--signal); color: var(--accent); }
.filter-chip__count { font-size: 11px; color: var(--muted); }
.filter-chip[aria-pressed="true"] .filter-chip__count { color: var(--accent); }
.leads-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 16px; align-items: start; }
.panel { position: sticky; top: calc(var(--topbar-h) + 16px); box-shadow: var(--shadow-panel); }
.panel__head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel__id { font-size: 15px; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.panel__head .icon-btn { margin-left: auto; width: 30px; height: 30px; border-color: transparent; }
.panel__head .icon-btn:hover { background: var(--sunken); }
.panel__chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 18px 0; }
.panel__section { padding: 14px 18px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.panel__section:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 7px 12px; font-size: 12.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv dd b { font-weight: 500; }
.panel__hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.timeline { list-style: none; display: grid; gap: 12px; padding-left: 16px; border-left: 1px solid var(--border-strong); margin-left: 4px; }
.tl-item { position: relative; display: grid; gap: 2px; font-size: 12.5px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--muted);
}
.tl-item--ok::before { background: var(--success-dot); }
.tl-item--info::before { background: var(--info-dot); }
.tl-item--current::before { box-shadow: 0 0 0 3px var(--signal-tint); }
.tl-item__status { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.tl-item__when { font-size: 11.5px; color: var(--muted); }

/* 15. Utilities ----------------------------------------------------------- */
.u-right { margin-left: auto; }
.u-muted { color: var(--muted); }
.u-secondary { color: var(--secondary); }
.u-nowrap { white-space: nowrap; }
.u-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.u-gap-sm { gap: 6px; }
.u-sm { font-size: var(--fs-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }
.w-60 { width: 60%; }
.arrow { display: inline-block; }

/* 16. Responsive ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rec-layout, .leads-layout { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; }
}
@media (max-width: 900px) {
  :root { --page-pad: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .app-nav { display: none; }
  .app[data-nav="open"] .app-nav {
    display: block; position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40;
    box-shadow: var(--shadow-panel);
  }
  .app[data-nav="open"] .app-nav__inner { height: 100%; }
  .topbar { height: auto; min-height: var(--topbar-h); padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; row-gap: 8px; }
  .topbar .topbar__menu, .topbar .topbar__brand { display: inline-flex; }
  .topbar__spacer { display: none; }
  .switcher { flex: 1 1 auto; min-width: 0; }
  .switcher img { display: none; }  /* the Q tile already sits in the mobile top bar */
  .source-chips { order: 10; }
  .daterange { order: 11; flex: 1 1 auto; }
  .page { padding-top: 16px; }
  .page-title { font-size: 22px; }
  .banner { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .draft-layout { grid-template-columns: minmax(0, 1fr); }
  .rec__body { grid-template-columns: minmax(0, 1fr); }
  .funnel { flex-direction: column; }
  .conn--row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .conn--row .conn-item { padding: 0; border-left: 0; }
  .funnel-arrow { width: auto; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 2px 14px; text-align: left; }
  .funnel-arrow__glyph { transform: rotate(90deg); }
  .search { min-width: 0; flex: 1 1 160px; }
  .tabs__aside { display: none; }
  .step__budget { grid-template-columns: repeat(2, minmax(0, 1fr)); width: auto; }
}
@media (max-width: 480px) {
  .kpi__value { font-size: 22px; }
  .banner__actions { width: 100%; }
  .banner__actions .btn { width: 100%; }
  .rec__actions .btn { flex: 1 1 auto; }
  .rec__actions .u-right { flex-basis: 100%; margin-left: 0; }
  .change-row { grid-template-columns: 24px minmax(0, 1fr); }
  .change-row__aside { grid-column: 2; text-align: left; white-space: normal; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dt { margin-top: 6px; }
  .switcher__org, .switcher__sep { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* 17. Backend additions (Jinja templates, 08.10) ---------------------------
   Small structural rules the live templates need beyond the mockups. Same tokens. */
.leads-layout:not(.leads-layout--panel) { grid-template-columns: minmax(0, 1fr); }
.notice { margin-bottom: 16px; }
.notice--warn  { background: var(--warning-tint); color: var(--warning); }
.notice--warn .link { color: var(--warning); }
.notice--error { background: var(--danger-tint); color: var(--danger); }
.rec__actions form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec__reject .search { min-width: 200px; }
.nav-foot form { margin-top: 8px; }
.page-head .section__hint { margin-top: 12px; }
button[aria-busy="true"] { opacity: .6; cursor: progress; }

/* вход, ошибки, пустое состояние */
.login {
  max-width: 420px; margin: 12vh auto 0; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  display: flex; flex-direction: column; gap: 16px;
}
.login h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.login__brand { display: flex; align-items: center; gap: 10px; }
.login__dev { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.login__dev input { width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); font: inherit; background: var(--surface); color: var(--fg); }
.login__dev input:focus { outline: 0; border-color: var(--accent); box-shadow: var(--focus); }
.login__theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
a.chip { text-decoration: none; }
a.chip:hover { border-color: var(--signal); }
.card__body > .notice { margin: 14px 0 0; }
a.filter-chip { text-decoration: none; color: inherit; }
.table .status { white-space: nowrap; flex-wrap: nowrap; }
.login { width: calc(100% - 32px); }
.login__form { display: flex; flex-direction: column; gap: 8px; }
.login__form input { width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl); font: inherit; background: var(--surface); color: var(--fg); }
.login__form input:focus { outline: 0; border-color: var(--accent); box-shadow: var(--focus); }
.login__form .btn { margin-top: 8px; }
