/* ===== Mode clair / noir (tout le site) — bouton 🌙/☀️ dans la barre du haut ; choix mémorisé ===== */
.theme-btn{width:42px;height:42px;display:grid;place-items:center;border:1px solid var(--line);border-radius:12px;background:#fff;cursor:pointer;font-size:18px;line-height:1;flex:none}
.theme-btn:hover{background:var(--ok)}

html[data-theme="dark"]{
  color-scheme:dark;
  --g:#3f8a69;--g2:#a9dcc3;--gold:#c9ab74;--bg:#111513;--surf:#1a201d;--surf2:#222a26;
  --ok:#1d3a2d;--wait:#3a2e1a;--bad:#3d2220;--t:#e6eee9;--mute:#98a9a0;--line:#2c3631;
}
html[data-theme="dark"] body{background:var(--bg)!important;color:var(--t)}
html[data-theme="dark"] .sidebar{background:linear-gradient(170deg,#1f3a2e,#12231b)}
html[data-theme="dark"] h1,html[data-theme="dark"] h2,html[data-theme="dark"] h3,html[data-theme="dark"] h4{color:var(--t)}

/* surfaces blanches -> surface sombre */
html[data-theme="dark"] .top,html[data-theme="dark"] .card,html[data-theme="dark"] .slot,html[data-theme="dark"] .out,
html[data-theme="dark"] .pst,html[data-theme="dark"] .tabs a.on,html[data-theme="dark"] .gal figure,html[data-theme="dark"] .seg a.on,
html[data-theme="dark"] .pcell,html[data-theme="dark"] .dpanel,html[data-theme="dark"] .pager li,html[data-theme="dark"] .set-tabs a,
html[data-theme="dark"] .kpi,html[data-theme="dark"] .st-tabs,html[data-theme="dark"] .st-range,html[data-theme="dark"] .pt-top,
html[data-theme="dark"] .dash>.rdv-card,html[data-theme="dark"] .dash>.quick,html[data-theme="dark"] .dash>.card,
html[data-theme="dark"] .grid>.card,html[data-theme="dark"] .theme-btn,html[data-theme="dark"] .bell summary{background:var(--surf)!important;color:var(--t)}
html[data-theme="dark"] .pager li.on,html[data-theme="dark"] .set-tabs a.on{background:var(--g)!important;color:#fff}
html[data-theme="dark"] .out:hover,html[data-theme="dark"] .set-tabs a:hover,html[data-theme="dark"] .pager li a:hover,html[data-theme="dark"] .theme-btn:hover{background:var(--surf2)!important}
html[data-theme="dark"] .pt-nav a.on,html[data-theme="dark"] .st-tabs a.on{background:linear-gradient(135deg,var(--g),var(--teal))!important;color:#fff}

/* champs de formulaire */
html[data-theme="dark"] input,html[data-theme="dark"] textarea,html[data-theme="dark"] select,
html[data-theme="dark"] .upl input[type=file],html[data-theme="dark"] .search{background-color:var(--surf2)!important;color:var(--t);border-color:var(--line)}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:var(--mute)}
html[data-theme="dark"] .search:focus,html[data-theme="dark"] .form input:focus,html[data-theme="dark"] .form select:focus,html[data-theme="dark"] .form textarea:focus{background-color:#2a332f!important}
html[data-theme="dark"] option{background:#1a201d;color:var(--t)}

/* tableaux, blocs gris clair, jauges */
html[data-theme="dark"] th,html[data-theme="dark"] td{border-color:var(--line)}
html[data-theme="dark"] .day,html[data-theme="dark"] .upl,html[data-theme="dark"] .seg,html[data-theme="dark"] .mj,html[data-theme="dark"] .ph,
html[data-theme="dark"] .sf-kpi div,html[data-theme="dark"] .sysinfo div,html[data-theme="dark"] .tl .t .sw a{background:var(--surf2)!important;color:var(--t)}
html[data-theme="dark"] .st-meter,html[data-theme="dark"] .pt-imgs img{background:var(--surf2)!important}

/* pastilles / messages */
html[data-theme="dark"] .tag{background:var(--wait);color:#f0c77f}
html[data-theme="dark"] .tag.ok{background:var(--ok)!important;color:#8fe0b3!important}
html[data-theme="dark"] .tag.bad{background:var(--bad);color:#ff9b8f}
html[data-theme="dark"] .flash{background:var(--ok)!important;color:#8fe0b3;border-left-color:#2d8a5c}
html[data-theme="dark"] .flash.bad{background:var(--bad)!important;color:#ff9b8f}

/* cartes colorées (mélange avec blanc -> mélange avec surface) */
html[data-theme="dark"] .q{background:color-mix(in srgb,var(--qc) 18%,var(--surf));border-color:color-mix(in srgb,var(--qc) 35%,var(--surf))}
html[data-theme="dark"] .evt{background:color-mix(in srgb,var(--e) 22%,var(--surf))}
html[data-theme="dark"] .chip{background:color-mix(in srgb,var(--e) 25%,var(--surf))}
html[data-theme="dark"] .stat .ic{background:color-mix(in srgb,var(--c,var(--g)) 25%,var(--surf))}
html[data-theme="dark"] .btn.ghost{background:var(--surf2);color:var(--g2)!important}
html[data-theme="dark"] .btn.ghost[style]{background:var(--surf2)!important}

/* notifications : suivent le thème du site */
html[data-theme="dark"] .bell summary{border-color:#33403a;color:#e8efe9}
html[data-theme="dark"] .bell-dot{box-shadow:0 0 0 2px #1a201d}
html[data-theme="dark"] .bell-menu{background:#161918;border-color:#33403a;box-shadow:0 12px 34px rgba(0,0,0,.6)}
html[data-theme="dark"] .bell-menu h4{color:#e8efe9}
html[data-theme="dark"] .bell-item{background:#222726;color:#e8efe9}
html[data-theme="dark"] .bell-item small,html[data-theme="dark"] .bell-none{color:#9fb0a7}
html[data-theme="dark"] .bell-item.danger{background:#3a1f1c}
html[data-theme="dark"] .bell-item.warn{background:#3a2e1a}
html[data-theme="dark"] .bell-item.info{background:#1b2f33}
html[data-theme="dark"] .rdv-toast{background:#161918;color:#e8efe9;box-shadow:0 12px 34px rgba(0,0,0,.6)}
html[data-theme="dark"] .rdv-toast b{color:#e8efe9}
html[data-theme="dark"] .rdv-toast span,html[data-theme="dark"] .rdv-toast button{color:#9fb0a7}

/* bandeau d'accueil (hero) + cartes de chiffres */
html[data-theme="dark"] .hero{background:linear-gradient(100deg,#1d2a24,#16211b 60%,#111a15)!important;border-color:rgba(255,255,255,.06);box-shadow:0 8px 28px rgba(0,0,0,.45);color:var(--g2)}
html[data-theme="dark"] .hero::after{filter:invert(1) hue-rotate(180deg) brightness(.85);opacity:.9}   /* photo + logo inversés : lisibles sur fond noir */
html[data-theme="dark"] .hero p{color:var(--mute)}
html[data-theme="dark"] .stat{background:rgba(30,40,35,.92)!important;box-shadow:0 2px 10px rgba(0,0,0,.35)}
html[data-theme="dark"] .stat:hover{box-shadow:0 10px 22px rgba(0,0,0,.5)}
html[data-theme="dark"] .stat .ic{background:color-mix(in srgb,var(--c,var(--g)) 28%,#1a201d)!important}
html[data-theme="dark"] .stat span{color:var(--mute)}

/* tableaux (liste des patients, factures…) : survol et lignes d'alerte */
html[data-theme="dark"] tbody tr:hover td,html[data-theme="dark"] table tr:hover td,
html[data-theme="dark"] .dash table tr:hover td,html[data-theme="dark"] table tr:not(:first-child):hover td{background:rgba(255,255,255,.06)!important;color:var(--t)}
html[data-theme="dark"] tr.alert td{background:#3a2e1a!important}
html[data-theme="dark"] .row:hover{background:rgba(255,255,255,.05)}
html[data-theme="dark"] td,html[data-theme="dark"] dd,html[data-theme="dark"] label,html[data-theme="dark"] p{color:inherit}

/* fiche patient : onglets, boutons, liens d'action */
html[data-theme="dark"] .tabs a:hover{color:var(--g2)}
html[data-theme="dark"] .tabs a.on{color:var(--g2)!important}
html[data-theme="dark"] .btn.ghost.danger-t{background:var(--bad)!important;color:#ff9b8f!important}
html[data-theme="dark"] td.act .ok{color:#8fe0b3}
html[data-theme="dark"] td.act .red,html[data-theme="dark"] .lnk,html[data-theme="dark"] .err{color:#ff9b8f}
html[data-theme="dark"] td.act a,html[data-theme="dark"] td.act button{color:#6fd0a4}
html[data-theme="dark"] .tl .t .sw a{color:#6fd0a4}
html[data-theme="dark"] .gal figure{border-color:var(--line)}
html[data-theme="dark"] hr{border-color:var(--line)}

/* en-têtes de tableaux, visionneuse photo, page Paramètres */
html[data-theme="dark"] th{background:linear-gradient(90deg,#22302a,#2a2c24)!important;color:var(--g2)!important}
html[data-theme="dark"] .dimg{background:#222a26}
html[data-theme="dark"] .dbtn.off{background:#3a4440;color:#b9c6bf}
html[data-theme="dark"] .yes{color:#6fd0a4}
html[data-theme="dark"] .no{color:#7c8a83}
html[data-theme="dark"] .tabs em{background:#b9566a}
