/* ==========================================================================
   Wafi 3.4 - Design « Registre »
   Sobre : pas de cartes, des filets fins, un seul bleu (bouton principal,
   menu actif, donnée du moment), statuts en points de couleur, tableaux denses.
   Chargé après toutes les autres feuilles (includes/header.php) : le retirer
   suffit pour revenir à l'ancien rendu.
   ========================================================================== */

:root {
  --bg-app: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-surface-secondary: #FAFBFC;
  --bg-surface-hover: #F4F6F9;
  --bg-surface-active: #EDF1F6;
  --bg-surface-selected: #EAF0FA;
  --border-subtle: #EEF1F5;
  --border-default: #E3E8EF;
  --border-strong: #CBD3DF;
  --text-primary: #0C1A33;
  --text-secondary: #46536B;
  --text-subdued: #7A859B;
  --text-tertiary: #7A859B;
  --primary-light: #EAF0FA;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 7px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-card: none;
  --shadow-card-hover: none;
  --shadow-dropdown: 0 12px 32px -12px rgba(12, 26, 51, .22), 0 0 0 1px #E3E8EF;
  --sidebar-width: 232px;
  --header-height: 56px;
  --header-bg: #FFFFFF;
  --header-surface: #F4F6F9;
  --header-border: #E3E8EF;
  --rg-ok: #1E8A58;
  --rg-warn: #B97C10;
  --rg-bad: #C0392F;
  --rg-info: #1552A3;
  --rg-idle: #9AA4B5;
  --rg-purple: #6B4FC0;
}
html[data-theme="dark"] {
  --bg-app: #0F1725;
  --bg-surface: #0F1725;
  --bg-surface-secondary: #121C2C;
  --bg-surface-hover: #162133;
  --bg-surface-active: #1B283D;
  --bg-surface-selected: #15233B;
  --border-subtle: #182234;
  --border-default: #202B3D;
  --border-strong: #2E3C55;
  --text-primary: #E6ECF5;
  --text-secondary: #B0BBCD;
  --text-subdued: #7D899E;
  --text-tertiary: #7D899E;
  --primary: #6A9BE6;
  --primary-light: #15233B;
  --header-bg: #0F1725;
  --header-surface: #162133;
  --header-border: #202B3D;
  --shadow-card: none;
  --shadow-dropdown: 0 12px 32px -12px rgba(0, 0, 0, .6), 0 0 0 1px #202B3D;
  --rg-ok: #46B985;
  --rg-warn: #DDA640;
  --rg-bad: #E2675E;
  --rg-info: #6A9BE6;
  --rg-idle: #5E6A7E;
  --rg-purple: #A894F0;
}

body { background: var(--bg-app); }

/* ---------- Barre latérale claire ---------- */
.app-sidebar { background: var(--bg-surface); border-right: 1px solid var(--border-default); box-shadow: none; }
.app-sidebar::before { display: none; }
.nav-link { border-radius: 6px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.nav-link svg { width: 16px; height: 16px; }
.nav-link:hover { background: var(--bg-surface-hover); }
.nav-link.active, .nav-link.active:hover { background: var(--primary-light); color: var(--primary); font-weight: 500; box-shadow: none; }
.nav-link.active svg { color: var(--primary); }
.nav-link.active::before, .nav-link.active::after { display: none; }
.nav-badge { background: transparent; color: var(--text-subdued); font-family: var(--font-mono); font-weight: 400; font-size: 11px; padding: 0; }
.sidebar-footer { border-top-color: var(--border-default); }

/* ---------- En-tête ---------- */
.app-header { background: var(--header-bg); border-bottom: 1px solid var(--border-default); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.header-icon-btn { border-radius: 7px; }

/* ---------- Titres de page ---------- */
.page-header { padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--border-default); }
.page-title, .dash-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.page-subtitle, .dash-lead { font-size: 12.5px; color: var(--text-subdued); }

/* ---------- Cartes : remplacées par des filets ---------- */
.card { background: transparent; border: 0; border-top: 1px solid var(--border-default); border-radius: 0; box-shadow: none; }
.card:hover { box-shadow: none; transform: none; }
.card-header { padding: 14px 0 10px; border-bottom: 1px solid var(--border-subtle); background: transparent; }
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding-left: 0; padding-right: 0; }
.card-footer { padding-left: 0; padding-right: 0; background: transparent; border-top: 1px solid var(--border-subtle); }
.card + .card { margin-top: 22px; }
/* Les cartes dans une fenêtre modale gardent leurs marges intérieures */
.modal-dialog .card, .modal-dialog .card-body, .modal-dialog .card-header { padding-left: revert; padding-right: revert; }

/* Tuiles de statistiques : une bande de chiffres séparés par des filets */
.stat-card { background: transparent; border: 0; border-left: 1px solid var(--border-default); border-radius: 0; box-shadow: none; padding: 12px 16px; }
.stat-card:hover { box-shadow: none; transform: none; }
.stat-card-icon { display: none; }
.stat-card-label { font-size: 11.5px; font-weight: 400; color: var(--text-subdued); }
.stat-card-value { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---------- Boutons : un seul bouton bleu ---------- */
.btn { border-radius: 7px; box-shadow: none; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); box-shadow: none; }
.btn-primary:hover { box-shadow: none; transform: none; }
.btn-secondary { background: var(--bg-surface); border: 1px solid var(--border-default); color: var(--text-primary); box-shadow: none; }
.btn-secondary:hover { background: var(--bg-surface-hover); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Statuts : un point de couleur et un libellé ---------- */
.badge { background: transparent !important; border: 0 !important; padding: 0; gap: 7px; font-size: 12.5px; font-weight: 400; color: var(--text-secondary) !important; border-radius: 0; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--rg-dot, var(--rg-idle)); flex: none; }
.badge .badge-dot { display: none; }
.badge-success { --rg-dot: var(--rg-ok); }
.badge-warning { --rg-dot: var(--rg-warn); }
.badge-critical { --rg-dot: var(--rg-bad); }
.badge-info { --rg-dot: var(--rg-info); }
.badge-neutral { --rg-dot: var(--rg-idle); }
.badge-purple { --rg-dot: var(--rg-purple); }
.badge { display: inline-flex; align-items: center; }

/* ---------- Tableaux denses ---------- */
.data-table-container { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.data-table th { background: transparent; font-size: 11.5px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-subdued); padding: 0 10px 8px; border-bottom: 1px solid var(--border-default); }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 0; }
.data-table th:last-child, .data-table td:last-child { padding-right: 0; }
.data-table tr:hover td { background: var(--bg-surface-hover); }
.table-toolbar { padding-left: 0; padding-right: 0; background: transparent; border-bottom: 1px solid var(--border-subtle); }
.table-tab-btn { border-radius: 6px; }
.table-tab-btn.active { background: var(--primary-light); color: var(--primary); box-shadow: none; }

/* ---------- Formulaires ---------- */
.form-control, .form-select { border-radius: 7px; box-shadow: none; border-color: var(--border-default); background-color: var(--bg-surface); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ---------- Menus, fenêtres, notifications ---------- */
.dropdown-menu { border-radius: 8px; border: 0; box-shadow: var(--shadow-dropdown); }
.modal-dialog { border-radius: 10px; box-shadow: var(--shadow-dropdown); }
.offer-strip { border-radius: 0; border-width: 0 0 1px; padding-left: 0; padding-right: 0; background: transparent; }

/* ==========================================================================
   Tableau de bord (index.php)
   ========================================================================== */
.dash { gap: 26px; }
.dash-hero { padding-bottom: 14px; border-bottom: 1px solid var(--border-default); }
.dash-date { color: var(--text-subdued); font-weight: 400; font-size: 12.5px; }
.dash-actions .btn { height: 34px; }

/* KPI : une seule bande */
.kpis { gap: 0; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); }
.kpi, .kpi-feature { background: transparent; border: 0; border-left: 1px solid var(--border-default); border-radius: 0; box-shadow: none; padding: 14px 16px; color: var(--text-primary); }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi:hover, .kpi-feature:hover { transform: none; box-shadow: none; color: var(--text-primary); background: var(--bg-surface-hover); }
.kpi-label, .kpi-feature .kpi-label { font-size: 11.5px; font-weight: 400; color: var(--text-subdued); }
.kpi-value { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.kpi-note, .kpi-feature .kpi-note { color: var(--text-secondary); }
.kpi-trend, .kpi-feature .kpi-trend.up, .kpi-feature .kpi-trend.down { background: transparent !important; padding: 0; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.kpi-trend::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.kpi-trend.up, .kpi-feature .kpi-trend.up { color: var(--rg-ok); }
.kpi-trend.down, .kpi-feature .kpi-trend.down { color: var(--rg-bad); }

/* Panneaux : sections séparées par un filet, sans cadre */
.dash-grid { gap: 32px; }
.panel { background: transparent; border: 0; border-top: 1px solid var(--border-default); border-radius: 0; box-shadow: none; height: auto; }
.panel-alert { border-top-color: var(--rg-bad); }
.panel-head { padding: 12px 0 8px; }
.panel-title { font-size: 13.5px; font-weight: 600; }
.panel-link { padding: 0; font-weight: 500; font-size: 12px; }
.panel-link:hover { background: transparent; text-decoration: underline; }
.segmented { border-radius: 7px; background: transparent; border-color: var(--border-default); }
.segmented button { border-radius: 5px; font-weight: 500; }
.segmented button.active { background: var(--primary-light); color: var(--primary); box-shadow: none; }
.chart-wrap { padding: 4px 0 8px; }
.list { padding: 0; }
.list-row { border-radius: 0; padding: 9px 0; }
.list-row:hover { background: transparent; }
.list-row:hover .list-title { color: var(--primary); }
.list-title { font-size: 13px; font-weight: 500; }
.list-amount { font-weight: 500; font-family: var(--font-mono); font-size: 12.5px; }
.avatar { border-radius: 50%; width: 30px; height: 30px; font-size: 11px; font-weight: 600; }
.funnel { padding: 6px 0 12px; gap: 12px; }
.funnel-bar { height: 6px; }
.funnel-bar span, .funnel-row.is-won .funnel-bar span { background: var(--border-strong); }
.funnel-row.is-won .funnel-bar span { background: var(--primary); }
.feed { padding: 4px 0 12px; }
.feed-dot { width: 9px; height: 9px; border: 0; box-shadow: none; margin-top: 5px; background: var(--rg-idle); }
.feed li:not(:last-child)::before { left: 4px; top: 16px; width: 1px; }
.feed li.is-won .feed-dot { background: var(--primary); box-shadow: none; }

/* Pastilles d'échéance : en points */
.chip { background: transparent !important; padding: 0; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary) !important; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--rg-idle); }
.chip-late::before { background: var(--rg-bad); }
.chip-today::before { background: var(--rg-warn); }
.chip-soon::before { background: var(--rg-info); }
.prio { box-shadow: none; width: 7px; height: 7px; }
.prio-haute { background: var(--rg-bad); }
.prio-moyenne { background: var(--rg-warn); }
.prio-basse { background: var(--rg-idle); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; padding-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--border-default); }
}
@media (max-width: 480px) {
  .kpi { padding: 10px 12px; }
  .kpi:nth-child(odd) { padding-left: 0; }
}

/* Sens de lecture arabe */
html[dir="rtl"] .app-sidebar { border-right: 0; border-left: 1px solid var(--border-default); }
html[dir="rtl"] .stat-card, html[dir="rtl"] .kpi, html[dir="rtl"] .kpi-feature { border-left: 0; border-right: 1px solid var(--border-default); }
html[dir="rtl"] .kpi:first-child { border-right: 0; padding-left: 16px; padding-right: 0; }
html[dir="rtl"] .data-table th:first-child, html[dir="rtl"] .data-table td:first-child { padding-left: 10px; padding-right: 0; }
html[dir="rtl"] .data-table th:last-child, html[dir="rtl"] .data-table td:last-child { padding-right: 10px; padding-left: 0; }

/* ---------- Onglets de filtre (soulignés) ---------- */
.rg-tabs { display: flex; gap: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--border-default); overflow-x: auto; scrollbar-width: none; }
.rg-tab { padding: 0 0 9px; font-size: 13px; color: var(--text-subdued); white-space: nowrap; text-decoration: none; box-shadow: inset 0 -2px 0 transparent; }
.rg-tab:hover { color: var(--text-primary); }
.rg-tab.is-active { color: var(--text-primary); font-weight: 500; box-shadow: inset 0 -2px 0 var(--primary); }

/* ---------- Pages aux styles écrits en dur : cartes ramenées aux filets ---------- */
.page-container .card[style] { border: 0 !important; border-top: 1px solid var(--border-default) !important; background: transparent !important; border-radius: 0 !important; box-shadow: none !important; }
.page-container .card[style*="padding"] { padding-left: 0 !important; padding-right: 0 !important; }
/* Grilles de chiffres clés : une bande, cellules séparées par un filet vertical */
.page-container div[style*="grid-template-columns"]:has(> .card[style]) { gap: 0 !important; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); }
.page-container div[style*="grid-template-columns"] > .card[style] { border-top: 0 !important; border-left: 1px solid var(--border-default) !important; padding: 12px 16px !important; }
.page-container div[style*="grid-template-columns"] > .card[style]:first-child { border-left: 0 !important; padding-left: 0 !important; }
html[dir="rtl"] .page-container div[style*="grid-template-columns"] > .card[style] { border-left: 0 !important; border-right: 1px solid var(--border-default) !important; }
html[dir="rtl"] .page-container div[style*="grid-template-columns"] > .card[style]:first-child { border-right: 0 !important; padding-right: 0 !important; padding-left: 16px !important; }
/* Libellés en capitales : en minuscules, plus discrets */
.page-container span[style*="text-transform: uppercase"], .page-container div[style*="text-transform: uppercase"] { text-transform: none !important; font-weight: 400 !important; font-size: 11.5px !important; color: var(--text-subdued) !important; letter-spacing: 0 !important; }
/* Grands montants : couleur de texte, poids moyen (le bleu reste réservé aux actions) */
.page-container div[style*="font-size: 1.5rem"] { font-weight: 500 !important; color: var(--text-primary) !important; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
/* Numéros de documents : lien sobre */
.data-table td a[style*="font-weight"] { font-weight: 500 !important; font-family: var(--font-mono); font-size: 12.5px; }
@media (max-width: 700px) {
  /* Mobile : deux chiffres par ligne pour garder la bande compacte */
  .page-container div[style*="grid-template-columns"]:has(> .card[style]) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .page-container div[style*="grid-template-columns"] > .card[style] { padding: 10px 12px !important; }
  .page-container div[style*="grid-template-columns"] > .card[style]:nth-child(odd) { border-left: 0 !important; padding-left: 0 !important; }
  .page-container div[style*="grid-template-columns"] > .card[style]:nth-child(n+3) { border-top: 1px solid var(--border-subtle) !important; }
  .page-container div[style*="grid-template-columns"] > .card[style] div[style*="font-size: 1.5rem"] { font-size: 1.15rem !important; }
  .stat-card-value, .dz-kpi-value, .kpi-value { font-size: 18px; }
}

/* ---------- Bandes de chiffres : stat-grid (produits…) et dz-kpis (dépenses, rapports) ---------- */
.stat-grid, .dz-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--border-default); border-bottom: 1px solid var(--border-default); margin-bottom: 24px; }
.stat-grid > .stat-card:first-child, .dz-kpis > .dz-kpi:first-child { border-left: 0; padding-left: 0; }
.dz-kpis > .card.dz-kpi { background: transparent; border: 0; border-left: 1px solid var(--border-default); border-radius: 0; box-shadow: none; padding: 12px 16px; margin: 0; gap: 2px; }
.dz-kpi-label { font-size: 11.5px; font-weight: 400; color: var(--text-subdued); text-transform: none; letter-spacing: 0; }
.dz-kpi-value { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
@media (max-width: 900px) {
  .stat-grid, .dz-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid > .stat-card:nth-child(odd), .dz-kpis > .dz-kpi:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat-grid > .stat-card:nth-child(n+3), .dz-kpis > .dz-kpi:nth-child(n+3) { border-top: 1px solid var(--border-subtle); }
}
html[dir="rtl"] .stat-grid > .stat-card:first-child, html[dir="rtl"] .dz-kpis > .dz-kpi:first-child { border-right: 0; padding-right: 0; padding-left: 16px; }
html[dir="rtl"] .dz-kpis > .card.dz-kpi { border-left: 0; border-right: 1px solid var(--border-default); }

/* ---------- Annonces de la plateforme (bandeau fin, point de couleur) ---------- */
.annonce-strip { display: flex; align-items: center; gap: 10px; padding: 9px 0; margin-bottom: 14px; border-bottom: 1px solid var(--border-default); font-size: 13px; color: var(--text-secondary); }
.annonce-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--rg-info); }
.annonce-succes .annonce-dot { background: var(--rg-ok); }
.annonce-alerte .annonce-dot { background: var(--rg-warn); }
.annonce-text { flex: 1; min-width: 0; }
.annonce-text strong { color: var(--text-primary); font-weight: 500; }
.annonce-close { border: 0; background: none; color: var(--text-subdued); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.annonce-close:hover { color: var(--text-primary); }

/* ---------- Assistant IA : bouton discret (lien d'action), résultat en filet ---------- */
.ia-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.ia-btn:hover:not(:disabled) { text-decoration: underline; }
.ia-btn:disabled { color: var(--text-subdued); cursor: not-allowed; }
.ia-btn.is-loading svg { animation: ia-spin 1s linear infinite; }
@keyframes ia-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ia-btn.is-loading svg { animation: none; } }
.ia-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ia-resultat { white-space: pre-line; font-size: 13.5px; line-height: 1.6; color: var(--text-primary); border-left: 2px solid var(--primary); padding: 4px 0 4px 14px; margin-top: 10px; }
.ia-note { font-size: 11.5px; color: var(--text-subdued); margin-top: 6px; }
html[dir="rtl"] .ia-resultat { border-left: 0; border-right: 2px solid var(--primary); padding: 4px 14px 4px 0; }

/* ==========================================================================
   Tableau de bord en sections (3.4) : chaque bloc est une carte nette,
   avec un en-tête, pour retrouver vite « à faire », chiffres, ventes, équipe.
   ========================================================================== */
.dash { gap: 18px; }
.dash-hero { border-bottom: 0; padding-bottom: 0; }

/* Sommaire collant */
.dash-toc {
  position: sticky; top: var(--header-height, 56px); z-index: 5;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 0; margin: -4px 0 -6px;
  background: var(--bg-app); border-bottom: 1px solid var(--border-default);
}
.dash-toc::-webkit-scrollbar { display: none; }
.dash-toc a {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary); text-decoration: none;
  transition: background-color .15s, color .15s;
}
.dash-toc a:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.dash-toc a.is-active { background: var(--primary-light); color: var(--primary); }
.dash-toc a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.dash-toc-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 600; background: var(--primary); color: #fff;
}

/* Carte « Bien démarrer » encadrée comme les sections */
.start { border: 1px solid var(--border-default); border-radius: 10px; }

/* Une section = une carte */
.dsec {
  scroll-margin-top: calc(var(--header-height, 56px) + 60px);
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  overflow: hidden;
}
.dsec-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-default);
}
.dsec-icon {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; color: var(--primary); background: var(--primary-light);
}
.dsec-icon svg { width: 18px; height: 18px; }
.dsec-icon-jour { color: var(--rg-warn); background: color-mix(in srgb, var(--rg-warn) 12%, transparent); }
.dsec-icon-chiffres { color: var(--primary); background: var(--primary-light); }
.dsec-icon-ventes { color: var(--rg-ok); background: color-mix(in srgb, var(--rg-ok) 12%, transparent); }
.dsec-icon-equipe { color: var(--rg-info); background: color-mix(in srgb, var(--rg-info) 12%, transparent); }
.dsec-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; margin: 0; }
.dsec-sub { font-size: 12.5px; color: var(--text-subdued); margin: 2px 0 0; }
.dsec-body { padding: 4px 18px 12px; }

/* Panneaux à l'intérieur d'une section : colonnes séparées par un filet vertical */
.dsec .panel { border-top: 0; border-radius: 0; }
.dsec-cols { display: grid; gap: 0; align-items: stretch; }
.dsec-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dsec-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dsec-cols-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dsec-cols > .panel { padding: 0 20px; }
.dsec-cols > .panel:first-child { padding-left: 0; }
.dsec-cols > .panel:last-child { padding-right: 0; }
.dsec-cols > .panel + .panel { border-left: 1px solid var(--border-subtle); }
.dsec .panel-alert { border-top: 0; }
.dsec .panel-alert .panel-title { color: var(--rg-bad); }

/* Opportunités : sous le graphique, séparées par un filet */
.dsec .panel-split { margin-top: 10px; border-top: 1px solid var(--border-subtle); }
.list-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }

/* Chiffres clés dans la carte : pas de double filet */
.dsec .kpis { border-top: 0; border-bottom: 0; margin: 6px 0 0; }

/* Fil d'activité sur deux colonnes */
.feed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; padding-top: 12px; }
.feed-grid li::before { display: none; }
.feed-grid li { padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 12px; }
.feed-by { font-size: 11.5px; color: var(--text-subdued); }

@media (max-width: 1100px) {
  .dsec-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dsec-cols-3 > .panel:last-child { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--border-subtle); margin-top: 8px; }
  .dsec-cols-main { grid-template-columns: minmax(0, 1fr); }
  .dsec-cols-main > .panel { padding: 0; }
  .dsec-cols-main > .panel + .panel { border-left: 0; border-top: 1px solid var(--border-subtle); margin-top: 8px; }
}
@media (max-width: 767px) {
  .dsec-head { padding: 12px 14px; }
  .dsec-body { padding: 2px 14px 10px; }
  .dsec-cols-2, .dsec-cols-3 { grid-template-columns: minmax(0, 1fr); }
  .dsec-cols > .panel { padding: 0 !important; }
  .dsec-cols > .panel + .panel { border-left: 0; border-top: 1px solid var(--border-subtle); margin-top: 8px; grid-column: auto; }
  .list-grid, .feed-grid { grid-template-columns: minmax(0, 1fr); }
  .dsec .list, .dsec .funnel, .dsec .feed { padding-left: 0; padding-right: 0; }
}

html[data-theme="dark"] .dsec { box-shadow: none; }
html[dir="rtl"] .dsec-cols > .panel:first-child { padding-left: 20px; padding-right: 0; }
html[dir="rtl"] .dsec-cols > .panel:last-child { padding-right: 20px; padding-left: 0; }
html[dir="rtl"] .dsec-cols > .panel + .panel { border-left: 0; border-right: 1px solid var(--border-subtle); }
@media (max-width: 767px) {
  html[dir="rtl"] .dsec-cols > .panel + .panel { border-right: 0; }
}

/* ==========================================================================
   Menu de gauche regroupé (3.4) : Accueil, bouton Créer, Clients, Ventes, Gestion
   ========================================================================== */
.sidebar-nav .nav-section { margin-bottom: 14px; }
.nav-section-end { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border-default); }
.nav-create { position: relative; margin: -6px 0 16px; }
.nav-create-btn {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; border-radius: 7px; background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 600; user-select: none; transition: filter .15s;
}
.nav-create-btn::-webkit-details-marker { display: none; }
.nav-create-btn:hover { filter: brightness(1.08); }
.nav-create-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-create[open] .nav-create-btn { filter: brightness(.95); }
.nav-create-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  display: grid; padding: 6px; background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: 8px; box-shadow: var(--shadow-dropdown);
}
.nav-create-menu a { padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--text-primary); text-decoration: none; }
.nav-create-menu a:hover, .nav-create-menu a:focus-visible { background: var(--bg-surface-hover); color: var(--primary); outline: 0; }


/* Entrée « Assistant IA » du menu */
.nav-section-ia { margin-top: -6px; }
.nav-link-ia svg { color: var(--primary); }
.nav-ia-tag { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--brand-ochre, #C9952B)); }

/* ---------- Compte de démonstration public ---------- */
.demo-strip {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 18px; padding: 10px 14px;
  border-radius: 12px; color: #fff; background: linear-gradient(100deg, #0C1A33, #17305A); font-size: 13.5px;
}
.demo-strip-star { flex: none; width: 12px; height: 12px; border-radius: 2px; background: #D69A3C; transform: rotate(45deg); box-shadow: 0 0 0 4px rgba(214, 154, 60, .22); }
.demo-strip-text { flex: 1; min-width: 220px; color: rgba(255, 255, 255, .82); }
.demo-strip-text strong { color: #fff; }
.demo-strip-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.demo-strip-actions .btn { background: #D69A3C; border-color: #D69A3C; color: #0C1A33; font-weight: 650; }
.demo-strip-link { color: #FFD79A; font-weight: 600; text-decoration: none; }
.demo-strip-link:hover { text-decoration: underline; }
.demo-blocked { margin: -8px 0 18px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; background: var(--status-warning-bg, #FBF1E1); color: var(--status-warning-text, #8A5A12); border: 1px solid var(--status-warning-border, #EED3A6); }
.demo-blocked a { font-weight: 650; color: inherit; }

/* Wafi IA en maintenance */
.nav-ia-tag.is-maint { background: var(--status-warning-text, #B97C10); }
.ia-btn.is-maint:disabled { opacity: .6; }

/* Interface simplifiée : barre d'actions (document-detail) */
.ui-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ui-plus { position: relative; }
.ui-plus > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.ui-plus > summary::-webkit-details-marker { display: none; }
.ui-plus[open] > summary svg { transform: rotate(180deg); }
.ui-plus-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 60; min-width: 230px; padding: 6px; display: flex; flex-direction: column;
  background: var(--bg-surface, #fff); border: 1px solid var(--border-default); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .14); }
.ui-plus-menu > a, .ui-plus-menu > button { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; text-align: start;
  font: inherit; font-size: 13.5px; color: var(--text-primary); text-decoration: none; cursor: pointer; }
.ui-plus-menu > a:hover, .ui-plus-menu > button:hover, .ui-plus-menu > a:focus-visible, .ui-plus-menu > button:focus-visible { background: var(--bg-surface-secondary, #f3f5f8); outline: none; }
@media (max-width: 640px) { .ui-actions { position: relative; } .ui-plus { position: static; } .ui-plus-menu { inset-inline: 0; min-width: 0; } }
.ui-simple .ui-cache-simple { display: none !important; }
.ui-simple .ui-nowrap { white-space: nowrap; }
.ui-simple .ui-ligne { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
/* Contacts simplifiés : sans cases à cocher, email ni dernière interaction */
.ui-simple .ui-table-contacts th:nth-child(1), .ui-simple .ui-table-contacts td:nth-child(1):not([colspan]),
.ui-simple .ui-table-contacts th:nth-child(3), .ui-simple .ui-table-contacts td:nth-child(3),
.ui-simple .ui-table-contacts th:nth-child(7), .ui-simple .ui-table-contacts td:nth-child(7) { display: none; }
/* Fiche document simplifiée : une seule colonne sur tablette et téléphone */
@media (max-width: 900px) { .ui-simple .dd-grille { grid-template-columns: minmax(0, 1fr) !important; } }
