/* ══════════════════════════════════════════════════════════════════════
   LIDIA Design Tokens — single source of truth
   ══════════════════════════════════════════════════════════════════════
   Loaded by all layouts (admin, agency, lidia, lidia_auth).

   Architecture (2026-04-25 dual-mode refactor) :
   ─────────────────────────────────────────────
   - `:root` contient les BRAND tokens (cyan/accent + accents sémantiques
     constants peu importe le mode : pink, green, orange, etc.)
   - `body[data-mode="dark"]` (= défaut, aussi appliqué quand body n'a
     pas d'attribut data-mode) définit la palette sombre
   - `body[data-mode="light"]` redéfinit `--bg`, `--card`, `--text`, etc.
     pour le light mode
   - Une agence white-label choisit son `mode` + 2 couleurs (primary/accent)
     dans /agency/branding. Pas plus de pickers --bg arbitraires (qui
     créaient des contrastes catastrophiques quand les hardcoded color:#fff
     se retrouvaient sur fond clair).
   - Per-user toggle ☀️/🌙 (Phase D) override le choix agence via
     localStorage + sync DB.

   Si tu ajoutes un nouveau composant : utilise TOUJOURS les tokens
   sémantiques (`var(--text)`, `var(--card)`, `var(--text-on-primary)`).
   N'écris JAMAIS `color:#fff` ou `background:#0c1220` en dur — ça pète
   en light mode.
   ══════════════════════════════════════════════════════════════════════ */

:root {
  /* ─── Brand accents (overridable per agency) — Console slate-blue default ─── */
  --cyan:    #4f7cf0;          /* primary (agency-overridable) */
  --cyan2:   #6d8bf5;          /* accent2 */
  --brand-primary: var(--cyan);
  --brand-accent:  var(--cyan2);

  /* ─── Semantic accents (muted « Console » — calme, jamais néon) ─── */
  --orange:  #cf8a48;
  --green:   #46976f;
  --pink:    #c07298;
  --yellow:  #cba140;
  --blue:    #4f86c9;
  --accent:  #6f63c0;
}

/* ══════════════════════════════════════════════════════════════════════
   DARK MODE (default — applies to body without data-mode AND data-mode="dark")
   ══════════════════════════════════════════════════════════════════════
   Le selector `body, body[data-mode="dark"]` garantit que les pages qui
   n'ont pas encore migré vers data-mode (transition Phase A→B) bénéficient
   quand même de la palette dark. Pas de breakage.
   ══════════════════════════════════════════════════════════════════════ */
body,
body[data-mode="dark"] {
  /* Surfaces */
  --bg:        #0e1218;
  --surface:   #141a22;
  --card:      #171e28;
  --card-solid: #171e28;       /* Console : cartes solides (plus de gradient) */
  --card2:     #1c2530;
  --input-bg:  #10161f;        /* champ de saisie : inset sous la carte (Console) */

  /* Borders — Console : hairline froide */
  --border:    rgba(150, 170, 200, 0.13);
  --border2:   rgba(150, 170, 200, 0.08);

  /* Text scale */
  --text:           #d7deea;   /* texte principal */
  --text-strong:    #f4f7fb;   /* titres */
  --text-on-card:   #d7deea;
  --text-on-primary: #ffffff;  /* texte sur boutons accent (slate-blue → blanc) */
  --muted:          #7f8b9b;
  --muted2:         #586471;

  /* Shadows — Console : discrètes (les bordures portent la hiérarchie) */
  --shadow-card:    0 2px 10px rgba(0, 0, 0, .35);
  --shadow-modal:   0 18px 50px rgba(0, 0, 0, .55);

  /* Hover/active overlays — neutres (calme) */
  --overlay-hover:  rgba(255, 255, 255, .04);
  --overlay-active: rgba(255, 255, 255, .08);
}

/* ══════════════════════════════════════════════════════════════════════
   S5 FIX (2026-05-16 PM) — force body bg+color to re-resolve on data-mode flip
   ══════════════════════════════════════════════════════════════════════
   Chromium bug: when a rule like `body { background: var(--bg) }` has a
   selector that doesn't reference the attribute being changed (data-mode),
   the engine optimizes by NOT re-evaluating the rule when only the var
   changes — even though var() resolution SHOULD make the property dirty.
   Result: body's computed background-color stays at the old value (dark)
   even after `<body data-mode="light">` swaps --bg to #f5f7fa.

   Fix: an explicit rule whose selector DOES match the data-mode attribute.
   Now when data-mode flips, Chromium re-evaluates the rule, var(--bg)
   resolves to the new value, and body's bg follows. Same for color.

   Verified live via Chrome MCP (lidia/agent) before + after — visual
   light/dark/light cycle confirmed via screenshots.
   ══════════════════════════════════════════════════════════════════════ */
body[data-mode="dark"],
body[data-mode="light"] {
  background-color: var(--bg);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════════════════
   LIGHT MODE
   ══════════════════════════════════════════════════════════════════════
   Activé par <body data-mode="light"> émis par les layouts quand l'agence
   a choisi le light mode (brand_theme_json.mode === "light") OU quand
   l'utilisateur a forcé le toggle via localStorage.
   ══════════════════════════════════════════════════════════════════════ */
body[data-mode="light"] {
  /* Surfaces */
  --bg:        #e4e7ed;
  --surface:   #eceff4;
  --card:      #f4f6f9;
  --card-solid: #f4f6f9;
  --card2:     #e7eaf1;
  --input-bg:  #eef1f6;        /* champ de saisie sur carte claire */

  /* Borders — hairline froide sur fond clair */
  --border:    rgba(24, 34, 54, 0.13);
  --border2:   rgba(24, 34, 54, 0.08);

  /* Text scale */
  --text:           #2b3543;   /* texte principal */
  --text-strong:    #101722;   /* titres */
  --text-on-card:   #2b3543;
  --text-on-primary: #ffffff;  /* texte sur boutons accent */
  --muted:          #5f6b7b;
  --muted2:         #939eae;

  /* Shadows — subtiles en light (Console dim, pas de blanc pur) */
  --shadow-card:    0 1px 3px rgba(20, 30, 50, .06), 0 1px 2px rgba(20, 30, 50, .04);
  --shadow-modal:   0 10px 40px rgba(20, 30, 50, .14);

  /* Hover/active overlays */
  --overlay-hover:  rgba(24, 34, 54, .05);
  --overlay-active: rgba(24, 34, 54, .09);
}

/* ─── Utility classes (loaded with tokens, available everywhere) ─── */
/* Screen-reader-only labels — used by auth forms for a11y compliance */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Spinning icon (used with mdi-loading) */
.mdi-spin { animation: lidia-spin 1.2s linear infinite; display: inline-block; }
@keyframes lidia-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ─── Empty state component (Round 1.9) ─── */
.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state-icon {
  font-size: 2.6rem;
  opacity: .25;
  color: var(--cyan);
  line-height: 1;
}
.empty-state-title {
  font-family:var(--font-title, 'Rajdhani', sans-serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: .04em;
}
.empty-state-help {
  max-width: 340px;
  line-height: 1.55;
  font-size: .8rem;
  color: var(--muted);
}
/* CTA wrapper. Supports a single button (margin-top only) OR a row of
   actions (flex+wrap+gap). The flex behaviour kicks in only when used as a
   container around multiple <a>/<button> children — single-child blocks render
   the same as before so existing single-CTA empty states aren't disturbed. */
.empty-state-cta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
/* Conversational lead text shown above the CTAs ("3 façons de faire …"). */
.empty-state-lead {
  font-size: .8rem;
  color: var(--text);
  font-weight: 600;
  margin-top: 4px;
}

/* Loading skeleton — utilise les tokens pour s'adapter au mode */
.loading-skeleton {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--text) 4%, transparent) 25%,
    color-mix(in srgb, var(--text) 8%, transparent) 37%,
    color-mix(in srgb, var(--text) 4%, transparent) 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: skeleton-shimmer 1.4s ease infinite;
  min-height: 14px;
}
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ══════════════════════════════════════════════════════════════════════
   body[data-mode="light"] overrides (Phase A — dual-mode refactor)
   ══════════════════════════════════════════════════════════════════════
   Ces rules s'appliquent quand body[data-mode="light"] est défini par
   le layout (à partir de brand_theme_json.mode ou pref user). Elles
   couvrent les cas où la cascade var(--text) ne suffit pas — par
   exemple les couleurs hardcodées qu'on ne peut pas éliminer dans
   l'immédiat (Phase B se chargera de la sweep).

   Différence avec body.theme-light ci-dessus : ces rules sont plus
   ciblées ET utilisent les NOUVEAUX tokens sémantiques
   (--text-on-card, --shadow-card, etc.) qui sont eux-mêmes
   automatiquement light-aware via la cascade body[data-mode="light"].
   ══════════════════════════════════════════════════════════════════════ */

/* Sidebar nav active item en light : on laisse les rules inline des layouts
   (admin/lidia/agency) gérer (color: var(--text-strong) !important). On NE
   force PAS var(--cyan) ici parce que le brand primary peut être très sombre
   (ex. CEA #241B33 dark purple) et serait alors invisible sur sidebar light.
   --text-strong = #0a0e1a en light → contraste garanti. */

/* Logo LIDIA — Console (2026-07-10): the rail is dark in BOTH modes, so the
   logo is styled light-on-dark in sidebar.css (.lidia-logo-text #f4f7fb + flat
   slate arc) and needs NO light-mode override here. The old block forced the
   wordmark dark (weight 600 + var(--text)), which vanishes on the dark rail. */

/* Stat cards — les ombres profondes du dark deviennent invisibles sur
   fond clair, on les remplace par des bordures subtiles.
   2026-05-25 (Part L Phase C) — .lidia-card removed from this list; it now
   has its own mode-paired treatment in the COMPONENT TREATMENTS section
   below (search ".lidia-card ─ Primary surface card"). Future component
   refactors should similarly migrate out of this legacy override. */
body[data-mode="light"] .stat-card,
body[data-mode="light"] .kpi-card {
  box-shadow: var(--shadow-card) !important;
}

/* Topbar chips */
body[data-mode="light"] .topbar-chat-chip,
body[data-mode="light"] .bug-rep-chip {
  border-width: 1.5px !important;
}

/* Sentient widget overlay — l'overlay sombre derrière le panel doit
   rester un voile sombre pour que le panel light se détache. */
body[data-mode="light"] .lidia-sentient-overlay {
  background: rgba(20, 24, 32, .35) !important;
}

/* Color picker swatches — bordures plus contrastées sur fond clair */
body[data-mode="light"] .theme-picker-swatch-wrap {
  border-color: rgba(0, 0, 0, 0.18) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8) !important;
}
body[data-mode="light"] .theme-picker-row {
  background: rgba(0, 0, 0, 0.02) !important;
}
body[data-mode="light"] .theme-picker-hex {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}

/* Sidebar gradient — le gradient noir → transparent → noir devient
   invisible sur fond light. On override avec un gradient subtil
   utilisant border2. */
body[data-mode="light"] #sidebar-desktop {
  /* Console (2026-07-10): dark rail in light mode too. Fallback matches
     sidebar.css's #sidebar-desktop — #141a22 default, agency --menu-bg wins.
     Consumer-fallback only (never declare --menu-bg in a body[data-mode] block)
     so a top-level agency :root{--menu-bg} override is not silently outranked. */
  background: var(--menu-bg, #141a22) !important;
  border-right: 1px solid var(--border2) !important;
}

/* Topbar — bg du topbar utilise --card qui est un gradient en dark.
   En light, --card devient solide blanc — pas besoin d'override. */

/* ══════════════════════════════════════════════════════════════════════
   Mass override : titres/labels hardcoded color:#fff dans view/* files
   (Phase B sweep n'a pas pu attraper toutes les vues — trop de surface).
   On force var(--text) pour toutes ces classes connues. Si un nouveau
   composant ship du color:#fff, l'idéal est qu'il use --text-strong
   directement, mais ce filet de sécurité couvre les cas existants.
   ══════════════════════════════════════════════════════════════════════ */
/* 2026-07-10 (Console) — SPLIT: the rail-chrome selectors (.lidia-logo-text,
   .agency-badge-name, .nav-link-lidia, .nav-text) were REMOVED — the rail is now
   dark in both modes, so those are styled light-on-dark in sidebar.css and this
   light-mode dark-text force would make them vanish. Also dropped .page-title /
   .page-sub / .cfg-lbl / .cv-modal-title (already double-covered by their own
   non-!important mode-paired treatments lower in this file). The rest stay as
   the light-mode safety net until each view is swept in Phase 2/3. */
body[data-mode="light"] .stat-big,
body[data-mode="light"] .topbar-title,
body[data-mode="light"] .ag-hero-title,
body[data-mode="light"] .kpi-lbl,
body[data-mode="light"] .action-title,
body[data-mode="light"] .opp-rail-tab,
body[data-mode="light"] .crm-kcard-name,
body[data-mode="light"] .bug-rep-head-title,
body[data-mode="light"] .cv-profile-name,
body[data-mode="light"] .modal-title,
body[data-mode="light"] .em-result-title,
body[data-mode="light"] .lsp-head-title,
body[data-mode="light"] .lsp-empty-title,
body[data-mode="light"] .lsp-insight-title,
body[data-mode="light"] .sup-head-title,
body[data-mode="light"] .modal-content.modal-lidia .modal-title,
body[data-mode="light"] .onboarding-card-title,
body[data-mode="light"] .onboarding-step-title,
body[data-mode="light"] .stat-row-val,
body[data-mode="light"] .stat-label,
body[data-mode="light"] .lead-name,
body[data-mode="light"] .opp-section-title,
body[data-mode="light"] .chart-title,
body[data-mode="light"] .action-client,
body[data-mode="light"] .ag-report-md h3,
body[data-mode="light"] h1, body[data-mode="light"] h2, body[data-mode="light"] h3,
body[data-mode="light"] h4, body[data-mode="light"] h5, body[data-mode="light"] h6 {
  color: var(--text) !important;
}

/* ══════════════════════════════════════════════════════════════════════
   Chrome autofill — without this, autofilled inputs render with the
   browser's default light-blue background (rgb(232,240,254)) + black text,
   which is glaring on top of dark mode and sticks for several seconds before
   the user types. The 5000s transition is the canonical hack to defeat
   Chromium's autofill repaint. (Bug #119, 2026-04-27.)
   ══════════════════════════════════════════════════════════════════════ */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text) !important;
  transition: background-color 5000s ease-in-out 0s, color 5000s ease-in-out 0s !important;
}

/* ══════════════════════════════════════════════════════════════════════
   Admin .cp-stat in light mode — the inline gradients use accent colors
   at .15 alpha which become near-invisible against #f5f7fa. The .val
   number colored with the same accent then disappears. We strengthen the
   gradient (alpha .15 → .22) and force the .lbl to lose its .65 opacity.
   (Bugs #123, #127, #137, 2026-04-27.)
   ══════════════════════════════════════════════════════════════════════ */
body[data-mode="light"] .cp-stat {
  background-color: var(--surface) !important;
  border-color: color-mix(in srgb, currentColor 22%, transparent) !important;
}
body[data-mode="light"] .cp-stat .lbl,
body[data-mode="light"] .stat-card .stat-lbl,
body[data-mode="light"] .stat-card .stat-sub,
body[data-mode="light"] .kpi-card .kpi-lbl {
  opacity: 1 !important;
  color: var(--muted) !important;
}

/* Stat cards en light — les ombres profondes deviennent invisibles, on
   les remplace par bordures subtiles.
   2026-05-25 (Part L Phase C) — .lidia-card removed (now has its own
   mode-paired treatment below). Others kept until their refactor. */
body[data-mode="light"] .stat-card,
body[data-mode="light"] .kpi-card,
body[data-mode="light"] .chart-card {
  box-shadow: var(--shadow-card) !important;
}

/* dash-insights-widget : le gradient hardcodé en cyan-faible peut
   disparaître en light. On force un fond plus visible. */
body[data-mode="light"] .dash-insights-widget {
  background: var(--card) !important;
  border-color: var(--border2) !important;
}
body[data-mode="light"] .dash-insight-card {
  background: var(--card) !important;   /* Console: soft-white, not retina-white */
  border-color: color-mix(in srgb, var(--text) 12%, transparent) !important;
}
body[data-mode="light"] .lsp-insight {
  background: var(--card) !important;   /* Console: soft-white */
  border-color: color-mix(in srgb, var(--text) 10%, transparent) !important;
}
body[data-mode="light"] .lsp-head {
  border-bottom-color: color-mix(in srgb, var(--text) 10%, transparent) !important;
}

/* ══════════════════════════════════════════════════════════════════════
   DataTable headers + outline-primary buttons in light mode (Phase F).
   Admin layout hardcodes color:color-mix(brand-primary 70%, transparent)
   on table headers and btn-outline-primary, which renders as cyan
   #00d4ff/.7 — a 1.6:1 contrast ratio against white. The element-class
   selector beats the global .table thead th { color: var(--text) }
   override, so we need an equally-or-more specific light-mode rule.
   (Bugs #125, #126, #136, 2026-04-27.)
   ══════════════════════════════════════════════════════════════════════ */
body[data-mode="light"] table.dataTable thead th,
body[data-mode="light"] .table thead th,
body[data-mode="light"] .table th {
  color: var(--text) !important;
}
body[data-mode="light"] .btn-outline-primary {
  color: #0e7490 !important;
  border-color: rgba(14, 116, 144, .35) !important;
}
body[data-mode="light"] .btn-outline-primary:hover {
  background: rgba(14, 116, 144, .08) !important;
  color: #0e7490 !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   STUDIO CONSOLE TOKENS (2026-05-25 — Part L Phase A consolidation)
   ══════════════════════════════════════════════════════════════════════════
   Tokens for the Studio Console design system, migrated FROM /css/sc.css
   into this canonical tokens file. Two naming systems coexist:

   • Legacy LIDIA names (--cyan, --bg, --text, --muted) — original system
   • Design system names (--primary, --card-bg, --text-mid, --indigo) — added

   The two are wired via aliases so a Brand::cssVars override of --cyan
   automatically cascades to --primary (and all derived soft tints), and
   surface-tier tokens (--rail-bg, --card-bg) work for new sc-* surfaces
   without disturbing legacy --bg / --card consumers.

   Selectors honor BOTH .sc-root[data-theme="dark|light"] (explicit opt-in)
   AND body[data-mode="dark|light"] (legacy LIDIA mode flag) so a single
   page can mix legacy + new surfaces.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Type */
  --font-sans: 'Gotham', 'Montserrat', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  /* Console (2026-07-09): kill the condensed Rajdhani display font app-wide.
     Titles fall back to Rajdhani ONLY when --font-title is undefined; defining
     it here flips every `var(--font-title, 'Rajdhani', …)` consumer to a clean
     grotesk. Agency font pick still overrides via Brand::cssVars :root emit. */
  --font-title: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:  'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 10px;
  --r-2xl: 14px;
  --r-full: 999px;

  /* Brand — alias to existing LIDIA --cyan so Brand::cssVars cascades.
     Fallback to a clean design-system cyan if --cyan isn't loaded yet. */
  --primary:        var(--cyan, #4f7cf0);
  --primary-hover:  #5c85f2;
  --primary-on:     #ffffff;

  /* Semantic accents — muted « Console » palette */
  --success:        #46976f;
  --warn:           #cf9a48;
  --danger:         #c96a63;
  --indigo:         #6f63c0;

  /* Soft tints — color-mix suit la marque / le sémantique. */
  --primary-soft:   color-mix(in srgb, var(--cyan, #4f7cf0) 14%, transparent);
  --success-soft:   color-mix(in srgb, #46976f 15%, transparent);
  --warn-soft:      color-mix(in srgb, #cf9a48 16%, transparent);
  --danger-soft:    color-mix(in srgb, #c96a63 15%, transparent);
  --indigo-soft:    color-mix(in srgb, #6f63c0 16%, transparent);

  /* Stage palette — Console muted (gris→sarcelle→violet→ambre→vert),
     indépendante de l'accent agence. */
  --stage-prospect:    #8a94a6;
  --stage-contact:     #4fa0b4;
  --stage-qualified:   #8a6fc0;
  --stage-negotiation: #c99248;
  --stage-won:         #48986f;
}

/* ── Console numerals (2026-07-10) ──────────────────────────────────────────
   Metric figures render in the mono face with tabular (fixed-width) digits so
   dashboard numbers line up and read like a console readout. --font-mono is
   platform-fixed (not in the agency font whitelist), so this is orthogonal to
   white-label. Value cells only — never applied to names/emails/body copy.
   The `.num` utility is opt-in for table figure columns (add to <td>/<th>). */
.stat-big,
.cp-stat .val,
.cp-stat-n,
.stat-row-val,
.wallet-amount,
.savings-big,
.num,
td.num, th.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ── DARK MODE — 3-tier surface system ───────────────────────────────────
   Applies in 3 contexts:
     1. .sc-root[data-theme="dark"]    explicit opt-in
     2. body[data-mode="dark"]          legacy LIDIA mode flag
     3. :root default                   defensive fallback (no mode flag set)
   ───────────────────────────────────────────────────────────────────────── */
.sc-root[data-theme="dark"],
body[data-mode="dark"],
:root {
  --rail-bg:    #141a22;
  --topbar-bg:  #10161d;
  --card-bg:    #171e28;
  --card-bg-2:  #1c2530;
  --card-bg-3:  #232d3a;
  --inset-bg:   #0b0f15;
  --border-hi:  rgba(150,170,200,0.16);
  --divider:    rgba(150,170,200,0.07);

  --text-mid:   #9aa4b6;
  --text-dim:   #7f8b9b;
  --text-faint: #586471;

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.35);
  --shadow:      0 2px 6px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.28);
  --shadow-md:   0 8px 22px rgba(0,0,0,0.42);
  --shadow-rail: 1px 0 0 rgba(150,170,200,0.05);
}

/* ── LIGHT MODE — same tokens, different values ─────────────────────────── */
.sc-root[data-theme="light"],
body[data-mode="light"],
body[data-mode="light"] .sc-root {
  --rail-bg:    #eceff4;
  --topbar-bg:  #eceff4;
  --card-bg:    #f4f6f9;
  --card-bg-2:  #e7eaf1;
  --card-bg-3:  #dde2ea;
  --inset-bg:   #e4e7ed;
  --border-hi:  rgba(24,34,54,0.15);
  --divider:    rgba(24,34,54,0.07);

  --text-mid:   #3b4657;
  --text-dim:   #5f6b7b;
  --text-faint: #939eae;

  --shadow-sm:   0 1px 2px rgba(20,30,50,0.05);
  --shadow:      0 1px 3px rgba(20,30,50,0.06), 0 1px 2px rgba(20,30,50,0.04);
  --shadow-md:   0 8px 22px rgba(20,30,50,0.08);
  --shadow-rail: 1px 0 0 rgba(20,30,50,0.05);
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPONENT TREATMENTS — mode-paired
   2026-05-25 — Part L Phase B / Phase C convention establishment
   ══════════════════════════════════════════════════════════════════════════

   ARCHITECTURE CONVENTION (read before editing):

   Every visual property that should look DIFFERENT in dark vs light mode
   MUST have its own explicit per-mode rule. Do NOT rely on tokens alone to
   produce a good result in both modes — tokens give you values, but the
   COMPOSITION of border + shadow + background often needs distinct treatment
   per mode (dark = subtle border + deep shadow; light = explicit border +
   subtle shadow).

   Pattern for any component (.X):
     .X { mode-agnostic structure: padding, radius, font, layout }
     body[data-mode="dark"] .X { dark-mode visual treatment }
     body[data-mode="light"] .X { light-mode visual treatment }

   Each mode block can be edited INDEPENDENTLY without affecting the other.
   Specificity (0,0,1,1) beats bare component selectors (0,0,1,0) so no
   `!important` needed.

   When agency white-label kicks in (Brand::cssVars override of --cyan etc.),
   tokens cascade; component visual rules stay intact. Brand color shows
   through the rule that references it (e.g. var(--cyan) in a button bg).

   Components below are the platform's surface vocabulary. Add new entries
   when refactoring legacy hardcoded-color rules out of style.css.

   ══════════════════════════════════════════════════════════════════════════ */

/* ── .lidia-card ─ Primary surface card ─────────────────────────────────── */
.lidia-card {
  border-radius: 14px;
  padding: 22px;
  position: relative;
}
body[data-mode="dark"] .lidia-card {
  background: var(--card);
  border: 1px solid var(--border2);
}
body[data-mode="light"] .lidia-card {
  background: var(--card);
  border: 1px solid var(--border2);
}
body[data-mode="light"] .lidia-card:hover {
  border-color: var(--border);
}

/* ── .btn-lidia ─ Primary action button ────────────────────────────────── */
.btn-lidia {
  border-radius: 8px;
  padding: 9px 18px;
  font-family:var(--font-body, 'DM Sans', sans-serif);
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .03em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  text-decoration: none;
  transition: background .16s, border-color .16s, transform .16s, box-shadow .16s;
}
body[data-mode="dark"] .btn-lidia {
  background: var(--cyan);
  color: #05080f;
  border: 1px solid var(--cyan);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
body[data-mode="dark"] .btn-lidia:hover {
  background: var(--cyan2);
  border-color: var(--cyan2);
  color: #05080f;
  transform: translateY(-1px);
}
body[data-mode="light"] .btn-lidia {
  background: var(--cyan);
  color: #ffffff;
  border: 1px solid color-mix(in srgb, var(--cyan) 80%, #000);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
body[data-mode="light"] .btn-lidia:hover {
  background: color-mix(in srgb, var(--cyan) 88%, #000);
  border-color: color-mix(in srgb, var(--cyan) 65%, #000);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ── .btn-ghost-d ─ Secondary / ghost button ──────────────────────────── */
.btn-ghost-d {
  border-radius: 8px;
  padding: 7px 14px;
  font-family:var(--font-body, 'DM Sans', sans-serif);
  font-weight: 600;
  font-size: .77rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  transition: background .16s, border-color .16s, color .16s;
}
body[data-mode="dark"] .btn-ghost-d {
  background: color-mix(in srgb, var(--cyan) 8%, transparent);
  color: var(--cyan);
  border: 1px solid color-mix(in srgb, var(--cyan) 18%, transparent);
}
body[data-mode="dark"] .btn-ghost-d:hover {
  background: color-mix(in srgb, var(--cyan) 15%, transparent);
  border-color: color-mix(in srgb, var(--cyan) 32%, transparent);
  color: var(--cyan);
}
body[data-mode="light"] .btn-ghost-d {
  background: #ffffff;
  color: color-mix(in srgb, var(--cyan) 70%, #000);
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
body[data-mode="light"] .btn-ghost-d:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: color-mix(in srgb, var(--cyan) 80%, #000);
}

/* ── .lidia-field ─ Form input / select / textarea ─────────────────────── */
.lidia-field {
  width: 100%;
  border-radius: 8px;
  padding: 9px 13px;
  font-family:var(--font-body, 'DM Sans', sans-serif);
  font-size: .86rem;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
body[data-mode="dark"] .lidia-field {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
}
body[data-mode="dark"] .lidia-field:focus {
  border-color: color-mix(in srgb, var(--cyan) 70%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 10%, transparent);
}
body[data-mode="light"] .lidia-field {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text);
}
body[data-mode="light"] .lidia-field:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 18%, transparent);
}
body[data-mode="light"] .lidia-field::placeholder { color: #94a3b8; }

/* ── .cfg-lbl ─ Section header label (the "ESSENTIELS" / "PRESETS" caps) ─ */
body[data-mode="dark"] .cfg-lbl  { color: var(--cyan); }
body[data-mode="light"] .cfg-lbl { color: color-mix(in srgb, var(--cyan) 70%, #000); }

/* ── .br-* — Branding admin page surfaces (Part L Phase B rebuild) ────── */
/* Mode preview tile "Clair" needs darker, more opaque lines for visibility. */
body[data-mode="light"] .br-ess-card .dm-pv-light .dm-pv-line,
.dm-pv-light .dm-pv-line { background: #475569; opacity: 0.9; }
body[data-mode="light"] .br-ess-card .dm-pv-light .dm-pv-card,
.dm-pv-light .dm-pv-card { background: #ffffff; border: 1px solid #cbd5e1; }

/* Light-mode treatment for the Branding page's preset cards (visibility). */
body[data-mode="light"] .br-preset {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
}
body[data-mode="light"] .br-preset:hover {
  background: #f8fafc;
  border-color: color-mix(in srgb, var(--cyan) 40%, #cbd5e1);
}
body[data-mode="light"] .br-preset.sel {
  background: color-mix(in srgb, var(--cyan) 6%, white);
  border-color: var(--cyan);
}
body[data-mode="light"] .br-preset-name { color: #0f172a; }

/* Auto-derived chip row in light mode — visible bg + border. */
body[data-mode="light"] .br-derived-row {
  background: #f8fafc;
  border-color: #e2e8f0;
}
body[data-mode="light"] .br-derived-label { color: #64748b; }
body[data-mode="light"] .br-chip {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Advanced section <details> — light-mode treatment matches card. */
body[data-mode="light"] .br-advanced > summary::after { color: #64748b; }
body[data-mode="light"] .br-advanced[open] > summary { border-bottom-color: #e2e8f0; }

/* dm-mode-opt (mode picker tile selection states) — light-mode visibility */
body[data-mode="light"] .dm-mode-opt {
  background: #ffffff;
  border-color: #e2e8f0;
}
body[data-mode="light"] .dm-mode-opt:hover {
  border-color: color-mix(in srgb, var(--cyan) 50%, #cbd5e1);
  background: #f8fafc;
}
body[data-mode="light"] .dm-mode-opt.sel {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 6%, white);
}

/* ── .br-tab ─ Tab nav (Marque / Profil / Versements) ──────────────────── */
body[data-mode="light"] .br-tab { color: #64748b; }
body[data-mode="light"] .br-tab:hover { color: #0f172a; }
body[data-mode="light"] .br-tab.active { color: var(--cyan); }

/* ── .page-title + .page-sub ─ Page headers ────────────────────────────── */
body[data-mode="light"] .page-title { color: #0f172a; font-weight: 700; }
body[data-mode="light"] .page-sub   { color: #475569; }

/* ── Conversations page (cv-*) ────────────────────────────────────────── */
/* Source has hardcoded dark values (#060a10 textarea, rgba(0,0,0,.15)
   thread-head bg, dark modal bg) — these break in light mode. Mode-paired
   treatments below override them. Dark-mode rules left empty because the
   inline source values already produce a coherent dark look. */

/* Sidebar shell (the conversation list panel) */
body[data-mode="light"] .cv-sidebar {
  background: var(--card);   /* Console: soft-white panel */
  border-color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}
body[data-mode="light"] .cv-sidebar-head { border-bottom-color: #e2e8f0; }
body[data-mode="light"] .cv-search       { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }
body[data-mode="light"] .cv-search:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 18%, transparent); }
body[data-mode="light"] .cv-select       { background: #ffffff; border-color: #cbd5e1; color: #0f172a; }
body[data-mode="light"] .cv-select:hover { border-color: color-mix(in srgb, var(--cyan) 40%, #cbd5e1); }
body[data-mode="light"] .cv-item         { border-bottom-color: #eef2f6; }
body[data-mode="light"] .cv-item:hover   { background: #f8fafc; }
body[data-mode="light"] .cv-item.active  { background: color-mix(in srgb, var(--cyan) 6%, white); border-left-color: var(--cyan); }
body[data-mode="light"] .cv-item.is-unread { background: color-mix(in srgb, #ec4899 6%, white); }
body[data-mode="light"] .cv-item-title   { color: #0f172a; }
body[data-mode="light"] .cv-item-time    { color: #64748b; }
body[data-mode="light"] .cv-item-preview { color: #475569; }

/* Thread header banner (was rgba(0,0,0,.15) — invisible/washed in light) */
body[data-mode="light"] .cv-thread-head {
  background: var(--card);   /* Console: soft-white banner */
  border-bottom-color: #e2e8f0;
}
body[data-mode="light"] .cv-thread-title { color: #0f172a; }
body[data-mode="light"] .cv-thread-meta  { color: #475569; }

/* Thread body — main message scroll area */
body[data-mode="light"] .cv-thread-body { background: #f8fafc; }

/* Reply textarea — was hardcoded #060a10 (dark blob on white page) */
body[data-mode="light"] .cv-reply textarea {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}
body[data-mode="light"] .cv-reply textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 18%, transparent);
}
body[data-mode="light"] .cv-reply textarea::placeholder { color: #94a3b8; }

/* Note-mode (yellow tint) variant */
body[data-mode="light"] .cv-reply.mode-note textarea {
  background: color-mix(in srgb, #f59e0b 4%, white);
  border-color: rgba(245,158,11,0.4);
}

/* Compose tabs (Réponse / Note interne) */
body[data-mode="light"] .cv-compose-tab        { color: #64748b; }
body[data-mode="light"] .cv-compose-tab:hover  { color: #0f172a; }
body[data-mode="light"] .cv-compose-tab.active { color: var(--cyan); }

/* Pause AI banner (orange/warn) */
body[data-mode="light"] .cv-pause-banner {
  background: color-mix(in srgb, #f59e0b 8%, white);
  border-color: rgba(245,158,11,0.3);
  color: #92400e;
}
body[data-mode="light"] .cv-pause-link { color: #92400e; }
body[data-mode="light"] .cv-resume-btn { /* uses .btn-lidia mode-paired rules above */ }

/* Modal overlays — were hardcoded dark (#060a10 input, #fff title, etc.) */
body[data-mode="light"] .cv-modal-backdrop { background: rgba(15, 23, 42, 0.4); }
body[data-mode="light"] .cv-modal-card     { background: var(--card); border-color: #e2e8f0; box-shadow: 0 24px 80px rgba(15,23,42,0.18); }
body[data-mode="light"] .cv-modal-head     { border-bottom-color: #e2e8f0; }
body[data-mode="light"] .cv-modal-title    { color: #0f172a; }
body[data-mode="light"] .cv-modal-close    { color: #64748b; }
body[data-mode="light"] .cv-modal-close:hover { background: #f1f5f9; color: #0f172a; }
body[data-mode="light"] .cv-modal-label    { color: #475569; }
body[data-mode="light"] .cv-modal-input    { background: #ffffff; border-color: #cbd5e1; color: #0f172a; }
body[data-mode="light"] .cv-modal-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 18%, transparent); }
body[data-mode="light"] .cv-modal-footer   { border-top-color: #e2e8f0; }
body[data-mode="light"] .cv-modal-btn-ghost { color: #0f172a; border-color: #cbd5e1; }
body[data-mode="light"] .cv-modal-btn-ghost:hover { background: #f1f5f9; }
