/* Thème sombre de l'espace connecté (src/theme-mode.js pose html[data-theme=dark] sur /app/*).
   Chargée en dernier. Palette : pierre bleue de nuit pour les fonds, chaux pour le texte,
   brique et sauge éclaircies pour garder un contraste AA. Le site public n'est jamais concerné. */
:root{color-scheme:light}
html[data-theme=dark]{
  color-scheme:dark;
  --paper:#0f171b;--paper-2:#1a262c;--surface:#172227;
  --ink:#eef2f3;--ink-2:#dfe6e8;--ink-3:#c9d4d7;--text:#cfd8db;--muted:#9aa9ae;
  --brick:#e0794d;--brick-strong:#f2a27e;--brick-soft:#3a2219;--brick-light:#f2a579;--brick-glow:rgba(242,165,121,.12);
  --oak:#d7ae7a;--sage:#7fa58a;--sage-soft:#1d2d24;
  --line:#2a383e;--line-strong:#3a4b52;--line-hover:#566a72;--line-ink:rgba(255,255,255,.08);
  --blue:#7db3d8;--blue-strong:#a6cbe6;--blue-soft:#17293a;
  --green:#4cc497;--green-soft:#15302a;
  --amber:#e4b25c;--amber-soft:#33281a;
  --red:#ef7b70;--red-soft:#3a1d1b;
  --on-ink:#b4c2c4;--on-ink-strong:#d3dcdc;
  --canvas:var(--paper);
  --app-bg:#0f171b;--app-card:#172227;--app-line:#26343a;--app-soft:#1c2a30;
  --app-shadow:0 1px 2px rgba(0,0,0,.35),0 6px 20px -10px rgba(0,0,0,.6);
  --shadow-1:0 1px 2px rgba(0,0,0,.35);--shadow-2:0 24px 48px -20px rgba(0,0,0,.7),0 4px 12px rgba(0,0,0,.35);--shadow-3:0 40px 80px -32px rgba(0,0,0,.8);
  /* Surfaces « encre » (bandeaux, bulles, aperçus) : un cran plus clair que le fond. */
  --night-panel:#22323a;--night-panel-text:#eef2f3;
}
html[data-theme=dark],html[data-theme=dark] body{background:var(--app-bg)!important;color:var(--text)}
html[data-theme=dark] ::selection{background:#2d4f6e;color:#fff}

/* ---------- Coque : menu, en-tête, bandeau ---------- */
html[data-theme=dark] body .sidebar{background:#121c21!important;border-right-color:var(--app-line)!important;color:var(--ink)!important}
html[data-theme=dark] body .sidebar nav a.active,html[data-theme=dark] body .sidebar nav a[aria-current=page],html[data-theme=dark] body .sidebar .module-home.active,html[data-theme=dark] body .sidebar .module-group.has-current>.module-trigger,html[data-theme=dark] body .module-group.is-open>.module-trigger{background:var(--brick-soft)!important;color:var(--brick-strong)!important}
html[data-theme=dark] body .app-header,html[data-theme=dark] body .app-main>header{background:rgba(15,23,27,.88)!important;border-bottom-color:var(--app-line)!important;color:var(--ink)}
html[data-theme=dark] body .demo-banner{background:var(--brick-soft)!important;color:var(--brick-strong)!important;border-bottom-color:#4a2c20!important}
html[data-theme=dark] .search-trigger,html[data-theme=dark] .language-trigger{background:var(--app-soft)!important;border-color:var(--app-line)!important;color:var(--text)!important}
html[data-theme=dark] .search-trigger kbd{background:var(--paper-2);color:var(--muted);border-color:var(--line)}
html[data-theme=dark] .icon-btn{color:var(--muted)}html[data-theme=dark] .icon-btn:hover{background:var(--app-soft);color:var(--ink)}
html[data-theme=dark] .theme-toggle[data-mode=dark],html[data-theme=dark] .theme-toggle[data-mode=auto]{color:var(--brick-light)}
html[data-theme=dark] .app-foot{color:var(--muted);border-top-color:var(--app-line)}

/* ---------- Cartes, panneaux, tableaux ---------- */
html[data-theme=dark] :is(.panel,.card,.stat,.stat-card,.kpi,.metric,.quick-action,.pf-section,.pf-stepcard,.pf-pick,.pf-hero,.ap-card,.ap-stage,.ap-scan-fields li,.ap-review,.tutorial-dashboard,.empty,.dashed,.list-card,.property-card,.contact-card,.lease-card,.task-card,.document-card,.module-card,.feature-card,.settings-card,.connector,.connector-card,.integration-card,.receipt,.calendar,.timeline,.modal,dialog,.dropdown,.menu,.popover){background-color:var(--app-card)!important;border-color:var(--app-line)!important;color:var(--text)}
html[data-theme=dark] .app-main :is(h1,h2,h3,h4,b,strong,th,dt,legend,summary){color:var(--ink)}
html[data-theme=dark] .app-main :is(p,li,td,dd,label,small,span){border-color:var(--app-line)}
html[data-theme=dark] table{background:transparent}
html[data-theme=dark] :is(thead th,tr:hover>td){background:var(--app-soft)!important}
html[data-theme=dark] :is(td,th){border-color:var(--app-line)!important}
html[data-theme=dark] .pf-stepcard.done{background:linear-gradient(90deg,var(--sage-soft),var(--app-card) 40%)!important}
html[data-theme=dark] .pf-ring{background:radial-gradient(closest-side,var(--app-card) 78%,transparent 79% 100%),conic-gradient(var(--sage) calc(var(--pct,0)*1%),var(--app-line) 0)!important}
html[data-theme=dark] .pf-hero{background:radial-gradient(600px 300px at 100% 0,rgba(224,121,77,.14),transparent 60%),var(--app-card)!important}
html[data-theme=dark] :is(.pf-flowbar li span,.pf-toggle span,.pf-toggle span:before){background:var(--app-soft)!important;border-color:var(--line-strong)!important;color:var(--text)}
html[data-theme=dark] .pf-flowbar li.current{background:var(--brick-soft)!important;border-color:#5a3424!important;color:var(--brick-strong)!important}
html[data-theme=dark] :is(.pf-flowbar li.current span,.pf-stepcard.current .pf-num){background:var(--brick)!important;color:#1a0f0a!important}
html[data-theme=dark] :is(.pf-flowbar li.done span,.pf-stepcard.done .pf-num){background:var(--sage)!important;color:#0f1a14!important}

/* ---------- Champs ---------- */
html[data-theme=dark] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),select,textarea){background-color:#111b20!important;border-color:var(--line-strong)!important;color:var(--ink)!important}
html[data-theme=dark] :is(input,textarea)::placeholder{color:#6f8086}
html[data-theme=dark] :is(input,select,textarea):focus{border-color:var(--brick)!important;box-shadow:0 0 0 3px rgba(224,121,77,.22)!important}
html[data-theme=dark] input[type=checkbox],html[data-theme=dark] input[type=radio]{accent-color:var(--brick)}

/* ---------- Boutons ---------- */
/* Bouton principal : le bleu ardoise du thème clair, éclairci (texte blanc, contraste ≥ 4,5). */
html[data-theme=dark] .btn:not(.secondary):not(.text):not(.white):not(.danger){background:#2f6f9c!important;border-color:#2f6f9c!important;color:#fff!important}
html[data-theme=dark] .btn:not(.secondary):not(.text):not(.white):not(.danger):hover{background:#3a80b0!important;border-color:#3a80b0!important}
html[data-theme=dark] .btn.secondary{background:var(--app-soft)!important;border-color:var(--line-strong)!important;color:var(--ink)!important}
html[data-theme=dark] .btn.secondary:hover{background:#24343b!important;border-color:var(--line-hover)!important}
html[data-theme=dark] .btn.danger{background:#c0362c!important;border-color:#c0362c!important;color:#fff!important}
html[data-theme=dark] .btn[disabled],html[data-theme=dark] button[disabled]{opacity:.5}

/* ---------- Badges et alertes ---------- */
html[data-theme=dark] .badge.green{background:var(--green-soft)!important;color:var(--green)!important}
html[data-theme=dark] .badge.orange{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme=dark] .badge.purple{background:#2a2140!important;color:#c3a9f5!important}
html[data-theme=dark] .badge.neutral,html[data-theme=dark] .badge:not(.green):not(.orange):not(.purple){background:var(--paper-2)!important;color:var(--text)!important}
html[data-theme=dark] :is(.warn,.immo-warning,.form-error){color:#f0a37a}
html[data-theme=dark] :is(.info-note,.notice,.callout,.hint,.tip){background:var(--blue-soft)!important;border-color:#24425a!important;color:var(--text)!important}

/* ---------- Surfaces « encre » : un cran au-dessus du fond, texte clair ---------- */
html[data-theme=dark] :is(#toast,.paulie-hero,.is-user .paulie-bubble,.paulie-launcher,.paulie-panel-head,.index-result-card,.index-library-feature,.pf-step,.bar span,.tutorial-video-frame,.immo-hero,.immo-preview-card,.workspace){background:var(--night-panel)!important;color:var(--night-panel-text)!important;border-color:#33464f!important}
html[data-theme=dark] .paulie-launcher:hover{background:#2b3e47!important}
html[data-theme=dark] :is(.paulie-hero,.immo-hero) :is(h1,h2,h3,p,b,span){color:inherit}

/* ---------- Fenêtres et liste d'import (src/autopilot.css) ---------- */
html[data-theme=dark] :is(.ap-progress,.ap-confirm,.modal){background:var(--app-card)!important;color:var(--text)!important;border:1px solid var(--app-line)!important}
html[data-theme=dark] :is(.ap-progress,.ap-confirm,.modal)::backdrop{background:rgba(0,0,0,.6)!important}
html[data-theme=dark] .ap-stage{background:#141e23!important}
html[data-theme=dark] .ap-scan-fields li.found{background:var(--green-soft)!important;border-color:#2b5544!important}
html[data-theme=dark] .ap-scan-fields li.searching{animation-name:ap-chip-dark}
@keyframes ap-chip-dark{0%,100%{border-color:var(--app-line);background:var(--app-card)}15%,35%{border-color:var(--green);background:var(--green-soft);color:var(--green)}}
html[data-theme=dark] :is(.ap-progress-bar,.ap-card-scan){background:var(--paper-2)!important}
html[data-theme=dark] .ap-progress-list li.active{background:var(--app-soft)!important}
html[data-theme=dark] :is(.ap-mini,.ap-scan-doc){border-color:var(--line-strong)!important}
html[data-theme=dark] .autopilot .dropzone{background:#13212a!important;border-color:#2e4a5e!important}
html[data-theme=dark] .ap-queue-link{background:var(--amber-soft)!important;border-color:#5a4422!important}
html[data-theme=dark] .autopilot .ap-delete{background:var(--app-soft)!important;border-color:var(--app-line)!important}
html[data-theme=dark] .autopilot .ap-delete:hover{background:var(--red-soft)!important;color:var(--red)!important}
html[data-theme=dark] .ap-card.open{border-color:var(--blue)!important;box-shadow:0 0 0 3px rgba(125,179,216,.18)!important}
html[data-theme=dark] :is(.ap-ocr,.ap-mail pre,pre,code){background:#111b20!important;color:var(--text)!important;border-color:var(--app-line)!important}
html[data-theme=dark] .autopilot .autopilot-tabs a.active{color:var(--brick-strong);border-bottom-color:var(--brick)}

/* ---------- Choix du thème (Mon espace) ---------- */
.theme-choices{display:flex;flex-wrap:wrap;gap:12px;margin-top:12px}
.theme-choice{position:relative;display:grid;gap:8px;justify-items:center;padding:12px;border:1px solid var(--line);border-radius:14px;cursor:pointer;min-width:120px;background:var(--surface)}
.theme-choice input{position:absolute;opacity:0;pointer-events:none}
.theme-choice:has(input:checked){border-color:var(--brick);box-shadow:0 0 0 3px var(--brick-glow)}
.theme-choice:has(input:focus-visible){outline:2px solid var(--brick);outline-offset:2px}
.theme-swatch{width:88px;height:56px;border-radius:9px;border:1px solid var(--line-strong);background:linear-gradient(90deg,#fff 0 30%,#f4efe7 30%)}
.theme-dark .theme-swatch{background:linear-gradient(90deg,#121c21 0 30%,#0f171b 30%)}
.theme-auto .theme-swatch{background:linear-gradient(135deg,#f4efe7 0 50%,#0f171b 50%)}
@media (prefers-reduced-motion:reduce){html[data-theme=dark] *{scroll-behavior:auto}}

/* ---------- Blocs repérés page par page (analyse des fonds clairs, décembre 2026) ---------- */
html[data-theme=dark] :is(.advanced-module #advanced-content,.advanced-module #assembly-content,.advanced-module #collaboration-content,.drive-import #drive-import-content){background:var(--app-card)!important;border-color:var(--app-line)!important;color:var(--text)!important}
html[data-theme=dark] :is(.advanced-module #advanced-content,.advanced-module #assembly-content,.advanced-module #collaboration-content)>a{background:var(--app-soft)!important;color:var(--ink)!important;border-color:var(--line-strong)!important}
html[data-theme=dark] :is(.payment-summary,.month-control,.table-search,.eid-downloads article,.eid-mobile-note){background:var(--app-card)!important;border-color:var(--app-line)!important;color:var(--text)!important}
html[data-theme=dark] .payment-summary strong{color:var(--ink)!important}html[data-theme=dark] .payment-summary .green-text{color:var(--green)!important}
html[data-theme=dark] :is(.month-control input,.table-search input){background:transparent!important;border:0!important;box-shadow:none!important;color:var(--text)!important}
html[data-theme=dark] .autopilot-invite{background:linear-gradient(120deg,#16283a,#132029)!important;border-color:#24425a!important;color:var(--text)!important}
html[data-theme=dark] .autopilot-invite b{color:var(--blue-strong)!important}html[data-theme=dark] .autopilot-invite span{color:var(--text)!important}
html[data-theme=dark] .priority-icon{background:var(--blue-soft)!important;color:var(--blue)!important}html[data-theme=dark] .priority-icon.amber{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme=dark] .property-tag{background:rgba(15,23,27,.85)!important;color:var(--ink)!important}
html[data-theme=dark] .property-card .icon-btn,html[data-theme=dark] .property-quick .icon-btn{background:var(--app-soft)!important;color:var(--text)!important;border-color:var(--line-strong)!important}
html[data-theme=dark] .property-quick .icon-btn.danger:hover{background:var(--red)!important;color:#1a0b09!important}
html[data-theme=dark] .index-warning{background:var(--amber-soft)!important;border-color:#5a4422!important;color:#f0cf95!important}
html[data-theme=dark] .index-source-status{background:var(--blue-soft)!important;border-color:#24425a!important;color:var(--blue-strong)!important}
html[data-theme=dark] .rent-indexation label,html[data-theme=dark] .rent-indexation .index-lease-choice,html[data-theme=dark] .rent-indexation span{color:var(--text)}
html[data-theme=dark] .letter-mail-button,html[data-theme=dark] .rent-indexation button:not(.btn){background:var(--app-soft)!important;color:var(--ink)!important;border-color:var(--line-strong)!important}
html[data-theme=dark] :is(.workspace-icon){background:var(--brick-light)!important;color:#1a0f0a!important}
html[data-theme=dark] .avatar.pastel{background:var(--brick-soft)!important;color:var(--brick-strong)!important}
html[data-theme=dark] :is(.site-intro,.tutorial-intro){background:radial-gradient(900px 400px at 90% -10%,rgba(224,121,77,.16),transparent 60%),linear-gradient(180deg,#16232a,#121c21)!important;color:var(--text)!important}
html[data-theme=dark] .tutorial-intro :is(h1,strong){color:var(--ink)!important}html[data-theme=dark] .tutorial-intro :is(p,span,small){color:var(--text)!important}html[data-theme=dark] .tutorial-intro .eyebrow{color:var(--brick-light)!important}
html[data-theme=dark] .app-main .tutorial-page button:not(.btn),html[data-theme=dark] .app-main .tutorial-card,html[data-theme=dark] .app-main .tutorial-list button{background:var(--app-card)!important;color:var(--text)!important;border-color:var(--app-line)!important}
html[data-theme=dark] .paulie-hero li{background:rgba(255,255,255,.07)!important;color:var(--night-panel-text)!important;border-color:rgba(255,255,255,.12)!important}
/* Aperçu d'un courrier : la page reste blanche, comme le papier imprimé. */
html[data-theme=dark] .app-main .document-paper{background:#fff!important;color:#1f2a30!important;box-shadow:0 18px 40px -20px rgba(0,0,0,.8)!important}
html[data-theme=dark] .app-main .document-paper :is(h1,h2,h3,h4,p,li,td,th,b,strong,span,small,dt,dd){color:#1f2a30!important}
html[data-theme=dark] .app-main .document-paper :is(td,th){border-color:#d9d2c6!important}
/* Texte blanc sur couleur d'accent : teintes pleines plus profondes (contraste ≥ 4,5). */
html[data-theme=dark] :is(.tutorial-lesson.is-active,.paulie-action.is-primary,.paulie-send,.tour-visual>span,.tour-dots button.active){background:#2f6f9c!important;border-color:#2f6f9c!important;color:#fff!important}
html[data-theme=dark] .tutorial-lesson.is-active :is(span,b,small){color:#fff!important}
html[data-theme=dark] :is(.module-link:hover .module-feature-icon,.module-link:focus-visible .module-feature-icon,.module-link.active .module-feature-icon,.pm-item:hover .module-feature-icon,.pm-item:focus-visible .module-feature-icon){background:#b9562b!important;color:#fff!important}
html[data-theme=dark] .app-main .tutorial-lesson:not(.is-active){background:transparent!important;color:var(--text)!important}
html[data-theme=dark] .app-main .tutorial-lesson:not(.is-active) :is(b,span,small){color:inherit!important}
html[data-theme=dark] .app-main .tutorial-lesson:not(.is-active):hover{background:var(--app-soft)!important}
/* Petits restes : icône de l'espace, champs de fichier, barres du graphique, mentions grisées. */
html[data-theme=dark] body .sidebar .workspace-icon,html[data-theme=dark] body .workspace .workspace-icon{background:var(--brick-light)!important;color:#1a0f0a!important}
html[data-theme=dark] input[type=file]{color:var(--text)}
html[data-theme=dark] input[type=file]::file-selector-button{background:var(--app-soft);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:6px 12px;margin-right:10px}
html[data-theme=dark] .bar.expected{background:#2a3c45!important}
html[data-theme=dark] :is(.yield-disclaimer,.form-note,.muted,.cell-sub){color:var(--muted)!important}
html[data-theme=dark] .ap-queue-link span{color:var(--amber)!important}
html[data-theme=dark] .live-dot{background:var(--blue)}
/* Vérification d'un bail importé */
html[data-theme=dark] .autopilot .ap-matches{background:var(--blue-soft)!important;color:var(--text)!important}
html[data-theme=dark] .autopilot .ap-agenda{background:var(--app-soft)!important;color:var(--text)!important}
html[data-theme=dark] .autopilot :is(.ap-matches,.ap-agenda) :is(b,summary){color:var(--ink)!important}
html[data-theme=dark] .autopilot .ap-proof.ok{background:var(--green-soft)!important;color:var(--green)!important}
html[data-theme=dark] .autopilot .ap-proof.check{background:var(--amber-soft)!important;color:var(--amber)!important}
html[data-theme=dark] .autopilot .ap-proof.none{background:var(--paper-2)!important;color:var(--muted)!important}
html[data-theme=dark] .autopilot .ap-field{color:var(--ink)!important}
/* Menus du panneau latéral et guide de démarrage */
html[data-theme=dark] :is(.module-panel,.module-flyout,.module-menu){background:var(--app-card)!important;border-color:var(--app-line)!important;color:var(--text)!important}
html[data-theme=dark] .module-panel-icon{background:var(--brick-soft)!important;color:var(--brick-strong)!important}
html[data-theme=dark] .module-go{color:var(--muted)!important}
html[data-theme=dark] .floating-check{background:var(--app-card)!important;color:var(--text)!important;border-color:var(--app-line)!important}
