/* Mode sombre : actif quand <html data-theme="dark"> (bouton du bandeau, choix gardé dans le navigateur). */
html[data-theme=dark]{color-scheme:dark;--bg:#0f1117;--surface:#171a23;--surface-2:#1c2030;--text:#e6e8ef;--muted:#9a9fb2;--border:#2a2e3b;--ligne:#232735;--doux:color-mix(in srgb,var(--primary) 18%,var(--surface));--shadow-sm:none;--shadow-md:none}
html[data-theme=dark] body{background:var(--bg);color:var(--text)}
html[data-theme=dark] h1,html[data-theme=dark] h2,html[data-theme=dark] h3,html[data-theme=dark] strong,html[data-theme=dark] b{color:inherit}

/* Structure */
html[data-theme=dark] .sidebar,html[data-theme=dark] .workspace-top{background:var(--surface);border-color:var(--border)}
html[data-theme=dark] .sidebar nav a{color:var(--muted)}
html[data-theme=dark] .sidebar nav a:hover{background:var(--surface-2)}
html[data-theme=dark] .sidebar nav a.active{background:var(--doux);color:#fff}
html[data-theme=dark] .sidebar nav b{background:var(--primary);color:#fff}
html[data-theme=dark] .workspace-label{color:#6f7488}
html[data-theme=dark] .avatar{background:var(--doux);color:#d9d3ff}
html[data-theme=dark] .mp-logo{background:#fff}
html[data-theme=dark] .demo-pill,html[data-theme=dark] .demo-notice{background:var(--surface-2);border-color:var(--border);color:var(--muted)}
html[data-theme=dark] .skip-link:focus{background:var(--surface)}

/* Cartes, panneaux, tableaux */
html[data-theme=dark] .card,html[data-theme=dark] .panel,html[data-theme=dark] .metric,html[data-theme=dark] .pricing-card,html[data-theme=dark] .company-card,html[data-theme=dark] .period-tabs,html[data-theme=dark] .stat-card{background:var(--surface);border-color:var(--border);box-shadow:none;color:var(--text)}
html[data-theme=dark] .metric-featured,html[data-theme=dark] .stat-card--amount,html[data-theme=dark] .stat-card--month,html[data-theme=dark] .stat-card--facture,html[data-theme=dark] .stat-card--count{background:var(--doux);border-color:color-mix(in srgb,var(--primary) 35%,var(--border))}
html[data-theme=dark] .metric-featured strong{color:#cfc6ff}
html[data-theme=dark] .metric>div,html[data-theme=dark] .metric small,html[data-theme=dark] .chart-caption{color:var(--muted)}
html[data-theme=dark] .metric-icon{background:var(--doux)}
html[data-theme=dark] .metric-icon.green{background:#163328;color:#5fd0a8}
html[data-theme=dark] .metric-icon.orange{background:#3a2c14;color:#e7b468}
html[data-theme=dark] .card-h,html[data-theme=dark] .main-content .card-h,html[data-theme=dark] .company-card-h,html[data-theme=dark] .stat-card-h{background:var(--surface-2);border-color:var(--border)}
html[data-theme=dark] .card-h h2,html[data-theme=dark] .card-h h3,html[data-theme=dark] .company-card-h h2,html[data-theme=dark] .card-b label,html[data-theme=dark] .title-wrap h1,html[data-theme=dark] .title-wrap h2,html[data-theme=dark] .value,html[data-theme=dark] .kpi .v,html[data-theme=dark] .pricing-title,html[data-theme=dark] .pricing-amount .value,html[data-theme=dark] .dossier-link{color:var(--text)}
html[data-theme=dark] .subtitle,html[data-theme=dark] .hint,html[data-theme=dark] .label,html[data-theme=dark] .row .label,html[data-theme=dark] .kpi .k,html[data-theme=dark] .pricing-sub,html[data-theme=dark] .pricing-amount .unit,html[data-theme=dark] form label,html[data-theme=dark] .filter-field label,html[data-theme=dark] .muted{color:var(--muted)}
html[data-theme=dark] .value a{color:#a99bff}
html[data-theme=dark] .row{border-color:var(--ligne)}
html[data-theme=dark] .kpi,html[data-theme=dark] .logo-box{background:var(--surface-2);border-color:var(--border)}
html[data-theme=dark] hr{border-color:var(--border)}
html[data-theme=dark] table{background:var(--surface)}
html[data-theme=dark] th,html[data-theme=dark] thead th{background:var(--surface-2);color:var(--muted);border-color:var(--border)}
html[data-theme=dark] td,html[data-theme=dark] table td{color:#c4c7d4;border-color:var(--ligne)}
html[data-theme=dark] table td small{color:var(--muted)}
html[data-theme=dark] tr:hover td{background:color-mix(in srgb,var(--primary) 8%,transparent)}
html[data-theme=dark] .devis-table tbody tr{background:var(--surface);border-color:var(--border);box-shadow:none}
html[data-theme=dark] .devis-table td{color:var(--text);border-color:var(--ligne)}
html[data-theme=dark] .devis-table td:first-child,html[data-theme=dark] .devis-table td[data-label="Actions"]{background:var(--surface-2);color:var(--muted)}
html[data-theme=dark] .table-pricing td{background:var(--surface-2);border-color:var(--border);box-shadow:none}
html[data-theme=dark] .activity-chart{background:repeating-linear-gradient(to top,transparent 0,transparent 39px,var(--ligne) 39px,var(--ligne) 40px)}
html[data-theme=dark] .progress-track{background:var(--surface-2)}
html[data-theme=dark] .brand-note{border-color:var(--border)}
html[data-theme=dark] .savebar{background:color-mix(in srgb,var(--surface) 92%,transparent);border-color:var(--border)}

/* Formulaires */
html[data-theme=dark] input:not([type=checkbox]):not([type=radio]),html[data-theme=dark] select,html[data-theme=dark] textarea,html[data-theme=dark] form input,html[data-theme=dark] form select,html[data-theme=dark] form textarea,html[data-theme=dark] .card-b input,html[data-theme=dark] .card-b select,html[data-theme=dark] .card-b textarea{background:#11141c;border-color:var(--border);color:var(--text);box-shadow:none}
html[data-theme=dark] input::placeholder,html[data-theme=dark] textarea::placeholder{color:#6f7488}
html[data-theme=dark] .helptext{color:#7d8296}
html[data-theme=dark] .errorlist{color:#ff8a95}

/* Boutons */
html[data-theme=dark] .btn,html[data-theme=dark] .btn-secondary,html[data-theme=dark] .btn.ghost{background:var(--surface-2);border-color:var(--border);color:var(--text);box-shadow:none}
html[data-theme=dark] .btn-secondary:hover{background:#252a3a}
html[data-theme=dark] .btn.primary{background:var(--doux);border-color:var(--primary);color:#e1dcff}
html[data-theme=dark] .main-content .btn.primary,html[data-theme=dark] .btn-primary{color:#fff}
html[data-theme=dark] .btn.danger{background:#3a1a1e;border-color:#5a2a30;color:#ffb4b4}
html[data-theme=dark] .btn.edit{background:#172540;border-color:#24395f;color:#9cc0ff}
html[data-theme=dark] a.btn-open,html[data-theme=dark] a.btn-open:link,html[data-theme=dark] a.btn-open:visited,html[data-theme=dark] a.btn-open:hover{color:var(--text)!important}
html[data-theme=dark] .logout{color:var(--muted)}
html[data-theme=dark] .toggle-pill span{background:var(--surface-2);border-color:var(--border);color:var(--text);box-shadow:none}
html[data-theme=dark] .toggle-pill:hover span{background:#252a3a}
html[data-theme=dark] .toggle-pill input:checked+span{background:var(--doux);border-color:var(--primary);color:#e1dcff}
html[data-theme=dark] .period-tabs a.active{background:var(--doux);color:#e1dcff}

/* Étiquettes et statuts */
html[data-theme=dark] .badge,html[data-theme=dark] .pill,html[data-theme=dark] .pill.gen,html[data-theme=dark] .status{background:#232736;color:#c4c7d4;border-color:var(--border)}
html[data-theme=dark] .pill.vl,html[data-theme=dark] .pill.eco,html[data-theme=dark] .pill.ok,html[data-theme=dark] .status-accepte,html[data-theme=dark] .statut-accepte,html[data-theme=dark] .abo-actif{background:#14302a;color:#6ad8ad;border-color:#1e4a3c}
html[data-theme=dark] .pill.pl,html[data-theme=dark] .pill.ecoplus,html[data-theme=dark] .status-envoye,html[data-theme=dark] .statut-envoye,html[data-theme=dark] .abo-essai{background:#172540;color:#9cc0ff;border-color:#24395f}
html[data-theme=dark] .pill.h,html[data-theme=dark] .pill.trad,html[data-theme=dark] .status-en_cours,html[data-theme=dark] .abo-retard,html[data-theme=dark] .badge--warning{background:#3a2c14;color:#f0c27a;border-color:#57421d}
html[data-theme=dark] .statut-en_cours{background:#232736;color:#c4c7d4}
html[data-theme=dark] .pill.m3,html[data-theme=dark] .pill.pres,html[data-theme=dark] .pill.sel,html[data-theme=dark] .status-facture,html[data-theme=dark] .statut-facture{background:var(--doux);color:#cfc6ff;border-color:color-mix(in srgb,var(--primary) 40%,var(--border))}
html[data-theme=dark] .pill.no,html[data-theme=dark] .status-refuse,html[data-theme=dark] .statut-refuse,html[data-theme=dark] .abo-suspendu,html[data-theme=dark] .abo-resilie{background:#3a1a1e;color:#ffa3a3;border-color:#5a2a30}
html[data-theme=dark] .stat-badge,html[data-theme=dark] .stat-badge--green,html[data-theme=dark] .amount-value--green{color:#6ad8ad}
html[data-theme=dark] .amount-value--blue{color:#9cc0ff}
html[data-theme=dark] .amount-value--facture,html[data-theme=dark] .stat-badge--facture{color:#cfc6ff}
html[data-theme=dark] .messages .message{background:#14302a;color:#cdeee0}
html[data-theme=dark] .messages .error{background:#3a1a1e;color:#ffd0d0}
html[data-theme=dark] .card-alerte{background:#3a1a1e;border-color:#5a2a30}
html[data-theme=dark] .card-info{background:var(--doux);border-color:color-mix(in srgb,var(--primary) 40%,var(--border))}
html[data-theme=dark] .texte-retard{color:#ff8a80}
html[data-theme=dark] .texte-bientot{color:#f0c27a}

/* Page de connexion */
html[data-theme=dark] .login-story{background:#161325}
html[data-theme=dark] .login-story:after{border-color:#2c2545;box-shadow:0 0 0 50px #1b1730,0 0 0 51px #2c2545}
html[data-theme=dark] .story-main>p,html[data-theme=dark] .story-footer,html[data-theme=dark] .route-point{color:#a59dbd}
html[data-theme=dark] .route-point b{color:#d6cfee}
html[data-theme=dark] .route-line{background:#3a3158}

/* Bouton de bascule */
.theme-toggle{display:grid;place-items:center;width:34px;height:34px;padding:0;border:1px solid var(--border);border-radius:50%;background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer;box-shadow:none}
.theme-toggle:hover{color:var(--text);background:var(--surface-2,#f7f6fc);box-shadow:none;transform:none}
.theme-toggle .lune{display:inline}.theme-toggle .soleil{display:none}
html[data-theme=dark] .theme-toggle .lune{display:none}html[data-theme=dark] .theme-toggle .soleil{display:inline}
.guest .theme-toggle{position:fixed;top:16px;right:16px;z-index:50;background:var(--surface,#fff)}
html[data-theme=dark] .demarrage-etape.fait .demarrage-puce{background:#14302a;color:#6ad8ad}
html[data-theme=dark] .abo-bandeau{background:var(--doux);border-color:color-mix(in srgb,var(--primary) 35%,var(--border));color:var(--text)}
html[data-theme=dark] .abo-bandeau.alerte{background:#3a1717;border-color:#7f1d1d;color:#fecaca}html[data-theme=dark] .abo-bandeau.alerte a{color:#fecaca}
html[data-theme=dark] .main-content form label{color:#a9adc0}
html[data-theme=dark] .main-content form p:has(>input[type=checkbox])>label{color:#e4e6f0}
html[data-theme=dark] .main-content form input[type=file]{border-color:#3a3d4f;color:#c9ccd9}
html[data-theme=dark] .sidebar nav a,html[data-theme=dark] .nav-groupe summary,html[data-theme=dark] .nav-aide{color:var(--muted)}
html[data-theme=dark] .sidebar nav a:hover,html[data-theme=dark] .nav-groupe summary:hover,html[data-theme=dark] .nav-aide:hover,html[data-theme=dark] .sidebar .logout:hover{background:var(--surface-2);color:var(--text)}
html[data-theme=dark] .sidebar nav a.active,html[data-theme=dark] .nav-aide.active{background:var(--doux);color:#fff}
html[data-theme=dark] .sidebar nav a.active .ico,html[data-theme=dark] .nav-aide.active .ico{color:#fff}
html[data-theme=dark] .nav-groupe summary.dans,html[data-theme=dark] .sidebar .profile a{color:var(--text)}
html[data-theme=dark] .nav-demarrage{background:var(--surface-2);border-color:var(--border);color:var(--text)}
html[data-theme=dark] .nav-demarrage i{background:linear-gradient(to right,var(--primary) var(--fait),var(--border) var(--fait))}
html[data-theme=dark] .sidebar .ico{color:var(--muted)}
