/*
 * ImmoWise — mode sombre de l'application (html[data-theme="dark"]).
 * Le choix est gardé dans le cookie « iw_theme », partagé avec le site www.immowise.ma.
 * 1. Couleurs (variables)  2. Corrections à la main  3. Règles générées depuis les couleurs fixes des autres feuilles.
 */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1318; --surface: #131c23; --surface-2: #18232b;
  --ink: #e5ecf0; --ink-2: #c3cfd7; --muted: #8b9ba7;
  --line: #24323b; --line-strong: #33444f;
  --accent: #14a394; --accent-hover: #19b9a8; --accent-soft: #11332f;
  --success: #4ade80; --success-soft: #11291b; --warning: #fbbf24; --warning-soft: #2e2410;
  --danger: #f87171; --danger-soft: #331718; --info: #60a5fa; --info-soft: #12253c;
  --nav-bg: #0c4440; --nav-bg-2: #072b28;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-pop: 0 14px 36px rgba(0, 0, 0, .55);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--ink-2); }
html[data-theme="dark"] .topbar { background: rgba(19, 28, 35, .94); }
html[data-theme="dark"] .brand-full, html[data-theme="dark"] .guest-brand img { content: url("immowise-sombre.png"); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background-color: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: var(--muted); }
html[data-theme="dark"] .help-bot, html[data-theme="dark"] .help-form, html[data-theme="dark"] .help-note { background: var(--surface); }
html[data-theme="dark"] .table-wrap > table thead tr > :first-child, html[data-theme="dark"] .table-wrap > table tbody tr > :first-child { background: var(--surface); }
html[data-theme="dark"] .monitoring-dialog .dialog-head { background: var(--surface); }
html[data-theme="dark"] img.chart, html[data-theme="dark"] .mfa-qr { background: #fff; }
html[data-theme="dark"] .nav-flyout { border-color: var(--line-strong); box-shadow: var(--shadow-pop); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #33444f; }
/* Bouton clair / sombre (menu du profil et écrans de connexion) */
.theme-toggle .theme-dark-label, html[data-theme="dark"] .theme-toggle .theme-light-label { display: inline-flex; }
.theme-toggle .theme-light-label, html[data-theme="dark"] .theme-toggle .theme-dark-label { display: none; }

/* ── Règles générées ── */
html[data-theme="dark"] tbody tr:hover { background: color-mix(in srgb, #fafcfc 14%, var(--surface)); }
html[data-theme="dark"] .tag { background: color-mix(in srgb, #eef2f5 14%, var(--surface)); }
html[data-theme="dark"] .alert.error, html[data-theme="dark"] .error.alert { border-color: color-mix(in srgb, #f6c9c4 30%, var(--surface)); }
html[data-theme="dark"] .alert.success, html[data-theme="dark"] .success.alert { border-color: color-mix(in srgb, #bfe5cb 30%, var(--surface)); }
html[data-theme="dark"] .alert.warning { border-color: color-mix(in srgb, #f2d7a7 30%, var(--surface)); }
html[data-theme="dark"] .sidebar-brand { background: var(--surface); }
html[data-theme="dark"] .sidebar-company { background: var(--surface); }
html[data-theme="dark"] .segmented a.active .count { background: var(--surface); }
html[data-theme="dark"] .status-table tfoot td { background: color-mix(in srgb, #eef3f2 14%, var(--surface)); }
html[data-theme="dark"] .stats-kpis > div.is-alert { border-color: color-mix(in srgb, #f6c9c4 30%, var(--surface)); }
html[data-theme="dark"] .lost-fields { border: 1px solid color-mix(in srgb, #f6c9c4 30%, var(--surface)); }
html[data-theme="dark"] .feature-item.is-on { border-color: color-mix(in srgb, #bfe5cb 30%, var(--surface)); }
html[data-theme="dark"] .feature-item.is-core { border-color: color-mix(in srgb, #b9ddd8 30%, var(--surface)); }
html[data-theme="dark"] .plan-row-core td { background: color-mix(in srgb, #f4faf9 14%, var(--surface)); }
html[data-theme="dark"] .files-layout:fullscreen { background: var(--bg, color-mix(in srgb, #f5f7f8 14%, var(--surface))); }
html[data-theme="dark"] .status-table tbody tr.is-selected td { background: var(--accent-soft, color-mix(in srgb, #d9efec 14%, var(--surface))); }
html[data-theme="dark"] .rights-table .rights-group th { background: var(--surface-2,color-mix(in srgb, #f4f5f7 14%, var(--surface))); }
html[data-theme="dark"] .rights-table select.level-0 { color: var(--danger,color-mix(in srgb, #b42318 45%, #ffffff)); }
html[data-theme="dark"] .quick-actions a::after { background: linear-gradient(var(--surface), var(--surface)) center / 12px 2px no-repeat,
    linear-gradient(var(--surface), var(--surface)) center / 2px 12px no-repeat,
    rgba(255, 255, 255, .25); }
html[data-theme="dark"] .feedback-msg.is-platform { border-color: color-mix(in srgb, #bfe0dc 30%, var(--surface)); }
html[data-theme="dark"] .feedback-pending { border: 1px solid color-mix(in srgb, #f2d7a7 30%, var(--surface)); }
html[data-theme="dark"] button.secondary.danger, html[data-theme="dark"] .button.secondary.danger { border: 1px solid color-mix(in srgb, #f6c9c4 30%, var(--surface)); }
html[data-theme="dark"] .digest-tile.status-danger { border-color: color-mix(in srgb, #f6c9c4 30%, var(--surface)); }
html[data-theme="dark"] .digest-tile.status-warning { border-color: color-mix(in srgb, #f2d7a7 30%, var(--surface)); }
html[data-theme="dark"] .portal-steps li.is-done { border-color: color-mix(in srgb, #bfe5cb 30%, var(--surface)); }
html[data-theme="dark"] .help-panel { background: var(--surface); }
html[data-theme="dark"] .help-bot { background: var(--surface); }
html[data-theme="dark"] .help-form { background: var(--surface); }
html[data-theme="dark"] .help-note { background: var(--surface); }
@media (max-width: 700px) { html[data-theme="dark"] table[data-mobile-cards] tr { background: var(--surface); } }
@media (max-width: 700px) { html[data-theme="dark"] .monitoring-dialog .dialog-head { background: var(--surface); } }
@media (max-width: 900px) { html[data-theme="dark"] .table-wrap > table thead th { background: var(--surface-2, color-mix(in srgb, #f8fafb 14%, var(--surface))); } }
@media (max-width: 900px) { html[data-theme="dark"] .table-wrap > table tbody tr > :first-child, html[data-theme="dark"] .table-wrap > table thead tr > :first-child { background: var(--surface); } }
@media (max-width: 900px) { html[data-theme="dark"] .table-wrap > table thead tr > :first-child { background: var(--surface-2, color-mix(in srgb, #f8fafb 14%, var(--surface))); } }
@media (max-width: 900px) { html[data-theme="dark"] .table-wrap.has-more-right { background: linear-gradient(to left, rgba(16, 32, 44, .10), transparent 18px) right / 18px 100% no-repeat, var(--surface); } }
html[data-theme="dark"] .reference-sheet { background: var(--surface); }
html[data-theme="dark"] .reference-sheet h3 span { background: color-mix(in srgb, #e8f3f1 14%, var(--surface)); }
html[data-theme="dark"] .reference-table td { background: var(--surface); }
html[data-theme="dark"] .reference-signature { border: 1px dashed color-mix(in srgb, #cfd7dc 30%, var(--surface)); }
html[data-theme="dark"] .crm-late { color: color-mix(in srgb, #a72d36 45%, #ffffff); }
html[data-theme="dark"] .unit-stat { background: var(--surface); }
html[data-theme="dark"] .unit-table tbody tr:hover { background: color-mix(in srgb, #f8fbfc 14%, var(--surface)); }
html[data-theme="dark"] .unit-status { background: color-mix(in srgb, #f0f4f7 14%, var(--surface)); }
html[data-theme="dark"] .unit-status.available { background: color-mix(in srgb, #e5f5ed 14%, var(--surface)); color: color-mix(in srgb, #126746 45%, #ffffff); }
html[data-theme="dark"] .unit-status.reserved { background: color-mix(in srgb, #fff2dc 14%, var(--surface)); color: color-mix(in srgb, #8a5a0b 45%, #ffffff); }
html[data-theme="dark"] .unit-status.sold { background: color-mix(in srgb, #eaf0fb 14%, var(--surface)); color: color-mix(in srgb, #345da9 45%, #ffffff); }
html[data-theme="dark"] .unit-status.blocked { background: color-mix(in srgb, #fae9eb 14%, var(--surface)); color: color-mix(in srgb, #8d3039 45%, #ffffff); }
html[data-theme="dark"] .unit-row-actions details form { background: var(--surface); }
html[data-theme="dark"] .construction-tabs a { background: var(--surface); }
html[data-theme="dark"] .construction-kpis>div { background: var(--surface); }
html[data-theme="dark"] .stock-low { background: color-mix(in srgb, #fff4e5 14%, var(--surface)); }
html[data-theme="dark"] .danger-tag { background: color-mix(in srgb, #ffe4df 14%, var(--surface)); color: color-mix(in srgb, #9a321f 45%, #ffffff); }
html[data-theme="dark"] .monitoring-hero { border: 1px solid color-mix(in srgb, #dce5e9 30%, var(--surface)); background: var(--surface); }
html[data-theme="dark"] .monitoring-kpis>div { border: 1px solid var(--line); background: var(--surface); }
html[data-theme="dark"] .monitoring-wrap { border: 1px solid color-mix(in srgb, #dfe6ea 30%, var(--surface)); background: var(--surface); }
html[data-theme="dark"] .monitoring-table th, html[data-theme="dark"] .monitoring-table td { border-right: 1px solid var(--line); }
html[data-theme="dark"] .monitoring-table thead th { background: color-mix(in srgb, #f7f9fa 14%, var(--surface)); color: color-mix(in srgb, #425461 45%, #ffffff); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(2) { background: color-mix(in srgb, #f3f8fb 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(3) { background: color-mix(in srgb, #f1faf7 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(4) { background: color-mix(in srgb, #fff5f6 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(5) { background: color-mix(in srgb, #f7f5fb 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(6) { background: color-mix(in srgb, #f6faef 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(7) { background: color-mix(in srgb, #fff8f0 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table thead th:nth-child(8) { background: color-mix(in srgb, #fff4f4 14%, var(--surface)); }
html[data-theme="dark"] .monitoring-table tbody th { background: color-mix(in srgb, #fafbfc 14%, var(--surface)); color: var(--ink); }
html[data-theme="dark"] .monitoring-table td:nth-child(3) { color: color-mix(in srgb, #197b67 45%, #ffffff); }
html[data-theme="dark"] .monitoring-table td:nth-child(4), html[data-theme="dark"] .monitoring-table td:nth-child(8) { color: color-mix(in srgb, #c94852 45%, #ffffff); }
html[data-theme="dark"] .monitoring-table td:nth-child(5) { color: color-mix(in srgb, #66569b 45%, #ffffff); }
html[data-theme="dark"] .monitoring-count.sold { color: color-mix(in srgb, #197b67 45%, #ffffff); }
html[data-theme="dark"] .monitoring-count.unsold { color: color-mix(in srgb, #c94852 45%, #ffffff); }
html[data-theme="dark"] .monitoring-total th, html[data-theme="dark"] .monitoring-total td { background: color-mix(in srgb, #eef2f4 14%, var(--surface))!important; color: var(--ink)!important; }
html[data-theme="dark"] .monitoring-percent th, html[data-theme="dark"] .monitoring-percent td { background: color-mix(in srgb, #fafbfc 14%, var(--surface))!important; }
html[data-theme="dark"] .monitoring-filters { background: color-mix(in srgb, #f7f9fa 14%, var(--surface)); }
html[data-theme="dark"] .monitor-pagination { background: var(--surface); }
html[data-theme="dark"] .dashboard-monitoring .monitoring-total { background: color-mix(in srgb, #f3f7f8 14%, var(--surface)); }
html[data-theme="dark"] .ai-steps li { background: color-mix(in srgb, #fafcfd 14%, var(--surface)); }
html[data-theme="dark"] .doc-sheet { background: var(--surface); border: 1px solid var(--line, var(--line)); }
html[data-theme="dark"] .doc-amounts .accent { background: color-mix(in srgb, var(--doc-accent) 7%, var(--surface)); }
html[data-theme="dark"] .doc-body .missing { background: color-mix(in srgb, #fff4d6 14%, var(--surface)); color: color-mix(in srgb, #8a5a00 45%, #ffffff); }
html[data-theme="dark"] .doc-body .unknown { background: color-mix(in srgb, #fdecea 14%, var(--surface)); color: color-mix(in srgb, #b42318 45%, #ffffff); }
html[data-theme="dark"] .doc-note { background: color-mix(in srgb, #fff8e6 14%, var(--surface)); color: color-mix(in srgb, #7a5300 45%, #ffffff); }
html[data-theme="dark"] .editor-toolbar { background: var(--surface, var(--surface)); }
html[data-theme="dark"] .var-chip { background: var(--surface-2, color-mix(in srgb, #f8fafb 14%, var(--surface))); color: var(--ink-2, color-mix(in srgb, #3c4c59 45%, #ffffff)); }
html[data-theme="dark"] .legend-missing { background: color-mix(in srgb, #fff4d6 14%, var(--surface)); color: color-mix(in srgb, #8a5a00 45%, #ffffff); }
html[data-theme="dark"] .legend-unknown { background: color-mix(in srgb, #fdecea 14%, var(--surface)); color: color-mix(in srgb, #b42318 45%, #ffffff); }
