/* =====================================================
   GESTION IMMO MR — v10 redesign
   Inspiré Game Xperience Overview (light)
   Palette : cream warm + indigo soft + pastels
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* ===== Palette base ===== */
  --bg:               #F1ECE2;           /* cream warm */
  --bg-soft:          #EAE4D7;           /* cream un cran plus chaud */
  --surface:          #FFFFFF;           /* cards */
  --surface-2:        #FAF7F1;           /* alt subtle */
  --ink:              #14141C;           /* texte principal */
  --ink-2:            #5B5E6E;           /* texte secondaire */
  --ink-3:            #9A9DAD;           /* tertiaire */
  --line:             rgba(20,20,28,0.07);
  --line-strong:      rgba(20,20,28,0.12);

  /* ===== Accents ===== */
  --primary:          #5B5FE0;           /* indigo */
  --primary-soft:     #ECEDFE;
  --primary-dark:     #3B3FB8;
  --accent-mint:      #2BB68A;
  --accent-mint-soft: #D7F0E5;
  --accent-coral:     #F2674A;
  --accent-coral-soft:#FFE0D5;
  --accent-amber:     #E89C2A;
  --accent-amber-soft:#FFE9C2;
  --accent-rose:      #E45D80;
  --accent-rose-soft: #FBDDE5;
  --accent-sky:       #2E8AE5;
  --accent-sky-soft:  #D9ECFD;
  --accent-violet:    #8B66E3;
  --accent-violet-soft:#EBE0FA;

  /* Aliases compat ascendante (anciens var iOS appelés ailleurs) */
  --ios-bg:               var(--bg);
  --ios-bg-elevated:      var(--surface);
  --ios-bg-grouped:       var(--surface);
  --ios-bg-input:         #EFE9DD;
  --ios-separator:        var(--line);
  --ios-label:            var(--ink);
  --ios-label-secondary:  var(--ink-2);
  --ios-label-tertiary:   var(--ink-3);
  --ios-blue:             var(--primary);
  --ios-green:            var(--accent-mint);
  --ios-orange:           var(--accent-amber);
  --ios-red:              var(--accent-coral);
  --ios-yellow:           #F2C94C;
  --ios-nav-bg:           rgba(241,236,226,0.85);
  --ios-tab-bg:           rgba(255,255,255,0.92);

  --safe-top:    env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --nav-height:  52px;
  --tab-height:  68px;

  --radius-card:   24px;
  --radius-card-sm: 18px;
  --radius-pill:   999px;
  --radius-btn:    14px;

  --shadow-soft:    0 2px 10px rgba(20,20,30,0.04), 0 1px 2px rgba(20,20,30,0.03);
  --shadow-card:    0 6px 24px rgba(20,20,30,0.06), 0 1px 2px rgba(20,20,30,0.03);
  --shadow-elev:    0 14px 40px rgba(20,20,30,0.12);
  --shadow-tab:     0 -2px 24px rgba(20,20,30,0.05);
  --shadow-fab:     0 12px 30px rgba(91,95,224,0.35), 0 4px 8px rgba(20,20,30,0.15);
}

/* v13.0 — Design system avec thème manuel via data-theme sur <html>.
   3 modes : "light" (défaut) | "dark" | "system" (suit prefers-color-scheme).
   Un mini-script en tête d'index.html applique data-theme AVANT le premier rendu. */

/* Dark thème manuel : appliqué quand html[data-theme="dark"] */
html[data-theme="dark"] {
  --bg:               #0E0E14;
  --bg-soft:          #16161E;
  --surface:          #1B1C26;
  --surface-2:        #20212D;
  --ink:              #F4F4F8;
  --ink-2:            #A6A9BB;
  --ink-3:            #6F7283;
  --line:             rgba(255,255,255,0.08);
  --line-strong:      rgba(255,255,255,0.14);
  --primary-soft:     #2A2D4F;
  --accent-mint-soft: #1F3A2F;
  --accent-coral-soft:#3F261F;
  --accent-amber-soft:#3D2F18;
  --accent-rose-soft: #3A1F28;
  --accent-sky-soft:  #1A2D45;
  --accent-violet-soft:#2A1F44;
  --ios-bg-input:     #2A2B36;
  --ios-nav-bg:       rgba(14,14,20,0.82);
  --ios-tab-bg:       rgba(27,28,38,0.92);
  --shadow-soft:    0 2px 10px rgba(0,0,0,0.4);
  --shadow-card:    0 6px 24px rgba(0,0,0,0.45);
  --shadow-elev:    0 14px 40px rgba(0,0,0,0.6);
  --shadow-fab:     0 12px 30px rgba(91,95,224,0.45);
}

/* Mode système : suit prefers-color-scheme uniquement si data-theme="system" (ou absent) */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"], html:not([data-theme]) {
    --bg:               #0E0E14;
    --bg-soft:          #16161E;
    --surface:          #1B1C26;
    --surface-2:        #20212D;
    --ink:              #F4F4F8;
    --ink-2:            #A6A9BB;
    --ink-3:            #6F7283;
    --line:             rgba(255,255,255,0.08);
    --line-strong:      rgba(255,255,255,0.14);
    --primary-soft:     #2A2D4F;
    --accent-mint-soft: #1F3A2F;
    --accent-coral-soft:#3F261F;
    --accent-amber-soft:#3D2F18;
    --accent-rose-soft: #3A1F28;
    --accent-sky-soft:  #1A2D45;
    --accent-violet-soft:#2A1F44;
    --ios-bg-input:     #2A2B36;
    --ios-nav-bg:       rgba(14,14,20,0.82);
    --ios-tab-bg:       rgba(27,28,38,0.92);
    --shadow-soft:    0 2px 10px rgba(0,0,0,0.4);
    --shadow-card:    0 6px 24px rgba(0,0,0,0.45);
    --shadow-elev:    0 14px 40px rgba(0,0,0,0.6);
    --shadow-fab:     0 12px 30px rgba(91,95,224,0.45);
  }
}

html { overflow-y: auto; overflow-x: hidden; height: 100%; }

/* ===== Dynamic Island & Safari URL bar cover =====
   Hauteur : safe-area-inset-top (iOS donne ~59px sur écrans à encoche, 0 sur Mac)
   Le 62px iOS PWA est appliqué via --ios-pwa-safe (set en JS uniquement sur iOS standalone) */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top, 0px);
  background: #000;
  z-index: 9999;
  pointer-events: none;
}
/* En PWA installée : on utilise --ios-pwa-safe si défini (62px sur iOS), sinon safe-area */
@media (display-mode: standalone), (display-mode: fullscreen) {
  body::before { height: max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)); }
}

body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100%;
  letter-spacing: -0.01em;
}
@media (pointer: coarse) { body { overscroll-behavior-y: contain; } }

button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* =====================================================
   NAV BAR (sous-pages)
   ===================================================== */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--ios-nav-bg);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--line);
  z-index: 100;
  padding-top: var(--safe-top);
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .nav-bar { padding-top: max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)); }
}
.nav-content {
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
}
.nav-title {
  font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.4px;
  flex: 1; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 8px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink);
}
.nav-btn {
  min-width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); border-radius: 50%; padding: 0 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s, background 0.2s;
}
.nav-btn:active { transform: scale(0.92); background: var(--surface-2); }
.nav-back { color: var(--ink); }
.nav-back.hidden { display: none; }

/* Sync dot */
.sync-dot-inline {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-3);
  flex-shrink: 0;
}
.sync-indicator.connected .sync-dot-inline,
.sync-dot-inline.connected { background: var(--accent-mint); }
.sync-indicator.syncing .sync-dot-inline,
.sync-dot-inline.syncing { background: var(--accent-mint); animation: pulse-green 1.4s infinite; }
.sync-indicator.error .sync-dot-inline,
.sync-dot-inline.error { background: var(--accent-coral); }
.sync-indicator.disconnected .sync-dot-inline,
.sync-dot-inline.disconnected { background: var(--ink-3); }
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(43,182,138,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(43,182,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(43,182,138,0); }
}

/* =====================================================
   MAIN / TYPOGRAPHIE
   ===================================================== */
.screen {
  min-height: 100vh;
  padding-top: calc(var(--nav-height) + var(--safe-top));
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 36px);
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .screen { padding-top: calc(var(--nav-height) + max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px))); }
}
.page { padding: 0 0 28px; }

.large-title {
  font-size: 32px; font-weight: 800; letter-spacing: -1px;
  margin: 22px 20px 4px; color: var(--ink);
}
.subtitle {
  font-size: 14px; color: var(--ink-2);
  margin: 0 20px 22px;
  font-weight: 500;
}
.section-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--ink-3);
  margin: 32px 20px 12px;
}

/* =====================================================
   HOME — Hero skyline remplacé par un hero card moderne
   ===================================================== */
body.home-active .nav-bar { display: none; }
body.home-active .screen { padding-top: 0; }

.hero-skyline {
  position: relative;
  margin: 0 16px 4px;
  height: auto;
  min-height: 220px;
  padding: calc(var(--safe-top) + 18px) 22px 22px;
  border-radius: 0 0 32px 32px;
  overflow: hidden;
  background: linear-gradient(140deg, #1B1D2B 0%, #2B2E48 55%, #3A3E63 100%);
  display: flex; flex-direction: column; justify-content: flex-end;
  box-shadow: var(--shadow-card);
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .hero-skyline { padding-top: calc(max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)) + 18px); }
}
.hero-skyline > svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0.18;
  z-index: 0;
}
/* deco circles */
.hero-skyline::before {
  content: ""; position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle at center, rgba(91,95,224,0.55) 0%, rgba(91,95,224,0) 70%);
  z-index: 0;
}
.hero-skyline::after {
  content: ""; position: absolute;
  bottom: -40px; left: -30px;
  width: 180px; height: 180px;
  background: radial-gradient(circle at center, rgba(43,182,138,0.4) 0%, rgba(43,182,138,0) 70%);
  z-index: 0;
}
.hero-skyline-overlay {
  position: absolute; top: 0; left: 0; right: 0;
  padding-top: var(--safe-top);
  height: calc(48px + var(--safe-top));
  display: flex; align-items: center; justify-content: flex-end;
  padding-left: 16px; padding-right: 16px;
  z-index: 3;
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .hero-skyline-overlay { padding-top: max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)); }
}
.hero-skyline-overlay .sync-dot-inline {
  width: 10px; height: 10px;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.10);
}
.hero-skyline-text {
  position: relative; z-index: 2;
  color: #fff;
}
.hero-skyline-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
  margin-bottom: 10px;
}
.hero-skyline-title {
  font-size: 30px; font-weight: 800; letter-spacing: -0.8px;
  line-height: 1.15;
  color: #fff;
}
.hero-skyline-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  margin-top: 12px;
  letter-spacing: -0.1px;
  font-weight: 500;
}

/* =====================================================
   PROPERTIES LIST (home) — cards modernes
   ===================================================== */
.properties-list {
  display: flex; flex-direction: column;
  gap: 14px;
  padding: 4px 16px 4px;
}
.property-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s, box-shadow 0.2s;
  border: 1px solid var(--line);
}
.property-card:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: var(--shadow-soft);
}
.property-card-hero {
  height: 150px;
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px 18px;
  color: white;
  overflow: hidden;
}
.property-card-hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--prop-color, #5B5FE0) 0%, var(--prop-color-dark, #3B3FB8) 100%);
  z-index: 0;
}
.property-card-hero img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  z-index: 0;
}
.property-card-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.7) 100%);
  z-index: 1;
}
.property-card-hero > * { position: relative; z-index: 2; }
.property-card-type {
  display: inline-block;
  font-size: 10px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 5px 11px; border-radius: var(--radius-pill);
  align-self: flex-start;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.15);
}
.property-card-name {
  font-size: 19px; font-weight: 800; letter-spacing: -0.4px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
  line-height: 1.15;
}
.property-card-addr {
  font-size: 12px; opacity: 0.92; margin-top: 3px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  font-weight: 500;
}
.property-card-body {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
}
.property-card-status {
  font-size: 13px; color: var(--ink-2);
  font-weight: 500;
}
.property-card-status strong {
  color: var(--ink); font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
}
.property-card-chevron {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 18px; font-weight: 600;
}
.property-card-photo-btn {
  position: absolute; top: 12px; right: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: white;
  display: flex; align-items: center; justify-content: center;
  z-index: 3;
  border: 1px solid rgba(255,255,255,0.15);
}
.property-card-photo-btn:active { background: rgba(0,0,0,0.7); }

/* =====================================================
   HEADER PHOTO (sous-pages bien)
   ===================================================== */
.header-photo {
  position: relative;
  width: calc(100% - 32px);
  margin: 16px 16px 18px;
  height: 220px;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: var(--shadow-card);
}
.header-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.header-photo-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 20px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
  color: white;
}
.header-photo-title {
  font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.header-photo-sub {
  font-size: 13px; opacity: 0.95; margin-top: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.45);
  font-weight: 500;
}
.header-photo-edit {
  position: absolute; top: 12px; right: 12px;
  width: 38px; height: 38px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.15);
}
.header-photo-edit:active { background: rgba(0,0,0,0.65); }

/* =====================================================
   HERO CARD (montant principal sur fiche bien)
   ===================================================== */
.hero-card {
  margin: 0 16px 22px;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 26px 24px;
  text-align: left;
  box-shadow: var(--shadow-card);
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
}
.hero-card::after {
  content: ""; position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle at center, var(--primary-soft) 0%, transparent 70%);
  pointer-events: none;
}
.hero-label {
  font-size: 11px; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 1.4px;
  margin-bottom: 10px; font-weight: 700;
}
.hero-amount {
  font-size: 46px; font-weight: 800; letter-spacing: -2px;
  line-height: 1; color: var(--ink);
}
.hero-amount.small { font-size: 34px; letter-spacing: -1.2px; }
.hero-cents {
  font-size: 22px; font-weight: 700;
  color: var(--ink-2); letter-spacing: -0.5px;
}
.hero-status {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px;
  font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--primary);
  letter-spacing: 0.2px;
}
.hero-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.hero-status.paid    { background: var(--accent-mint-soft);  color: var(--accent-mint); }
.hero-status.warn    { background: var(--accent-amber-soft); color: var(--accent-amber); }
.hero-status.danger  { background: var(--accent-coral-soft); color: var(--accent-coral); }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; }

/* =====================================================
   STEP CARDS (process guidé étape 1/2)
   ===================================================== */
.step-card {
  margin: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
}
.step-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.step-badge {
  font-size: 10px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 11px; border-radius: var(--radius-pill);
}
.step-title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--ink);
}
.step-desc {
  font-size: 14px; color: var(--ink-2); line-height: 1.55;
  margin: 0 0 18px;
}
.step-desc b { color: var(--ink); font-weight: 700; }
.step-btn {
  width: 100%; min-height: 54px;
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius-btn);
  font-size: 15px; font-weight: 700; letter-spacing: -0.2px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.2s;
  border: 1px solid var(--line);
}
.step-btn:active { opacity: 0.8; transform: scale(0.98); }
.step-btn.primary {
  background: var(--ink); color: var(--bg);
  border-color: var(--ink);
  box-shadow: 0 8px 22px rgba(20,20,28,0.18);
}
.step-btn.primary:active { opacity: 0.9; }
.step-btn.success {
  background: var(--accent-mint); color: white;
  border-color: var(--accent-mint);
  box-shadow: 0 8px 22px rgba(43,182,138,0.3);
}
.step-done {
  background: var(--accent-mint-soft);
  border-radius: var(--radius-btn);
  padding: 12px 14px;
  font-size: 14px; color: var(--ink);
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  font-weight: 600;
  min-height: 52px;
}
.step-done-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-mint); color: white;
  font-weight: 800; font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}
.step-done-text {
  font-size: 14px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.2px;
  margin-right: auto; /* pousse les boutons à droite quand il y a de la place */
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}

/* Sur mobile : texte sur ligne complète, boutons groupés en dessous */
@media (max-width: 600px) {
  .step-done {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 12px;
  }
  .step-done-icon { order: 1; }
  .step-done-text {
    order: 2;
    flex: 1 1 auto;
    margin-right: 0;
    white-space: normal;
  }
  /* Tous les step-link prennent la même rangée en flex-row sous le texte */
  .step-done .step-link {
    order: 3;
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
    text-align: center;
    justify-content: center;
  }
}
.step-undo {
  margin-left: auto;
  font-size: 13px; color: var(--ink-2);
  text-decoration: underline;
}
.step-link {
  background: var(--bg);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--line);
}
.step-link:active { opacity: 0.7; }
.step-card.disabled { opacity: 0.5; pointer-events: none; }

.hero-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.hero-action {
  height: 66px;
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius-btn);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  transition: opacity 0.15s, transform 0.1s;
  border: 1px solid var(--line);
}
.hero-action:active:not(:disabled) { opacity: 0.7; transform: scale(0.97); }
.hero-action:disabled { opacity: 0.4; pointer-events: none; }
.hero-action.primary {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.hero-action-icon { display: flex; align-items: center; justify-content: center; height: 22px; }
.hero-action-label { font-size: 12px; font-weight: 700; letter-spacing: -0.1px; line-height: 1; }

.history-row { display: flex; align-items: center; }
.history-pdf-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  margin-left: 10px;
  border: 1px solid var(--line);
}
.history-pdf-btn:active { opacity: 0.7; }

/* =====================================================
   BUTTONS génériques
   ===================================================== */
.btn-primary, .btn-secondary {
  flex: 1; height: 48px; border-radius: var(--radius-btn);
  font-size: 15px; font-weight: 700; letter-spacing: -0.2px;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.2s;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary {
  background: var(--ink); color: var(--bg);
  box-shadow: 0 8px 18px rgba(20,20,28,0.18);
}
.btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.btn-secondary {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:active { background: var(--bg); transform: scale(0.97); }
.btn-primary.full, .btn-secondary.full { width: 100%; }
.btn-danger { background: var(--accent-coral); color: white; }

/* =====================================================
   KPI cards — 2x2 grid avec icônes pastels
   ===================================================== */
.kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 0 16px;
}
.kpi {
  background: var(--surface);
  border-radius: var(--radius-card-sm);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  background: var(--kpi-color, var(--primary-soft));
  border-radius: 50%;
  opacity: 0.6;
}
.kpi:nth-child(1) { --kpi-color: var(--primary-soft); }
.kpi:nth-child(2) { --kpi-color: var(--accent-mint-soft); }
.kpi:nth-child(3) { --kpi-color: var(--accent-amber-soft); }
.kpi:nth-child(4) { --kpi-color: var(--accent-violet-soft); }
.kpi-label {
  font-size: 11px; color: var(--ink-2); margin-bottom: 8px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px;
  position: relative; z-index: 1;
}
.kpi-value {
  font-size: 22px; font-weight: 800; letter-spacing: -0.8px;
  color: var(--ink);
  position: relative; z-index: 1;
  line-height: 1.1;
}

/* =====================================================
   LIST GROUPS — modernisés
   ===================================================== */
.list-group {
  margin: 0 16px 10px;
  background: var(--surface);
  border-radius: var(--radius-card-sm);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
}
.list-row {
  width: 100%;
  display: flex; align-items: center;
  padding: 14px 18px; text-align: left;
  border: none; background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 48px;
  transition: background 0.15s;
}
.list-row:last-child { border-bottom: none; }
.list-row:active:not(.static) { background: var(--bg); }
.list-row.empty {
  padding: 22px 18px; min-height: 0;
  color: var(--ink-2);
  font-size: 14px;
}
.row-icon {
  width: 36px; height: 36px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; margin-right: 14px; flex-shrink: 0;
}
.row-content { flex: 1; min-width: 0; }
.row-title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.2px;
  color: var(--ink);
}
.row-sub {
  font-size: 13px; color: var(--ink-2); margin-top: 3px;
  word-wrap: break-word; font-weight: 500;
}
.row-value {
  font-size: 14px; color: var(--ink-2);
  margin-right: 8px; font-weight: 500;
}
.row-chevron {
  color: var(--ink-3); font-size: 22px; margin-left: 6px;
  font-weight: 300; line-height: 1;
}

/* Settings editable row */
.list-row.editable {
  padding: 12px 18px;
  flex-direction: column;
  align-items: stretch;
}
.list-row.editable .row-title {
  font-size: 11px; color: var(--ink-2); font-weight: 700;
  margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.list-row.editable input, .list-row.editable textarea {
  width: 100%; border: none; background: transparent; padding: 0;
  font-size: 15px; color: var(--ink); outline: none;
  resize: none; font-weight: 500;
}
.list-row.editable textarea { min-height: 44px; font-family: inherit; }

/* Date picker stylé (charter app) */
.list-row.editable input.date-picker,
.list-row.editable input[type="date"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  appearance: none; -webkit-appearance: none;
  min-height: 40px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.list-row.editable input.date-picker:focus,
.list-row.editable input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.list-row.editable input.date-picker::-webkit-calendar-picker-indicator,
.list-row.editable input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(35%) sepia(82%) saturate(2245%) hue-rotate(225deg) brightness(91%) contrast(89%);
  opacity: 0.85;
  margin-left: 6px;
}
/* Dark mode : inverse le picto calendrier natif pour qu'il reste visible sur fond sombre */
html[data-theme="dark"] .list-row.editable input.date-picker::-webkit-calendar-picker-indicator,
html[data-theme="dark"] .list-row.editable input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="system"] .list-row.editable input.date-picker::-webkit-calendar-picker-indicator,
html[data-theme="system"] .list-row.editable input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}
@media (prefers-color-scheme: light) {
  html[data-theme="system"] .list-row.editable input.date-picker::-webkit-calendar-picker-indicator,
  html[data-theme="system"] .list-row.editable input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(35%) sepia(82%) saturate(2245%) hue-rotate(225deg) brightness(91%) contrast(89%);
  }
}

/* Check box */
.check-box {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid var(--ink-3);
  margin-right: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.check-box.checked { background: var(--accent-mint); border-color: var(--accent-mint); }
.check-box.checked::after { content: "✓"; color: white; font-size: 14px; font-weight: 800; }

/* Pills */
.pill {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--bg); color: var(--ink-2);
  letter-spacing: 0.2px;
}
.pill.paid    { background: var(--accent-mint-soft);  color: var(--accent-mint); }
.pill.warn    { background: var(--accent-amber-soft); color: var(--accent-amber); }
.pill.danger  { background: var(--accent-coral-soft); color: var(--accent-coral); }

/* =====================================================
   TAB BAR — flottante en capsule, design moderne
   ===================================================== */
.tab-bar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--safe-bottom) + 10px);
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-radius: var(--radius-pill);
  display: flex; height: 64px;
  padding: 6px;
  z-index: 100;
  box-shadow: var(--shadow-tab), 0 -2px 32px rgba(20,20,30,0.08);
  border: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--ink-3); gap: 2px;
  border-radius: var(--radius-pill);
  transition: color 0.2s, background 0.2s;
  position: relative;
}
.tab svg { width: 22px; height: 22px; transition: transform 0.2s; }
.tab span {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.2px;
}
.tab.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.tab.active svg { transform: translateY(-1px); }
.tab:active { transform: scale(0.94); }

/* =====================================================
   SHEET (bottom sheet)
   ===================================================== */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,28,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
  z-index: 200;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  max-height: 92vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 201;
  padding-bottom: var(--safe-bottom);
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(20,20,30,0.15);
}
.sheet.show { transform: translateY(0); }
.sheet-handle {
  width: 42px; height: 5px; border-radius: 3px;
  background: var(--ink-3);
  margin: 8px auto 6px;
  opacity: 0.6;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-title { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.sheet-cancel, .sheet-close {
  color: var(--primary); font-size: 15px; font-weight: 600; min-width: 60px;
}
.sheet-cancel { text-align: left; font-weight: 500; color: var(--ink-2); }
.sheet-close { font-weight: 700; text-align: right; }
.sheet-body {
  padding: 18px 20px 28px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.template-pre {
  background: var(--surface);
  border-radius: var(--radius-card-sm);
  padding: 16px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  margin: 0 0 16px;
  border: 1px solid var(--line);
}
.action-row { display: flex; gap: 10px; margin-top: 10px; }

/* =====================================================
   FULLSCREEN VIEWER (PDF/IMG)
   ===================================================== */
.viewer {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .viewer { padding-top: max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)); }
}
.viewer-nav {
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.viewer-close, .viewer-share {
  min-width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: 15px; font-weight: 600;
}
.viewer-close { padding: 0 8px; }
.viewer-title {
  font-size: 16px; font-weight: 700; flex: 1; text-align: center;
  padding: 0 12px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink);
}
.viewer-body {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-soft);
}
.viewer-body iframe, .viewer-body embed, .viewer-body object {
  width: 100%; height: 100%; border: 0; display: block;
}
.viewer-body img { width: 100%; height: auto; display: block; }

/* =====================================================
   INSIGHTS AI — Cards de suggestions
   ===================================================== */
.insight-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin: 0 16px 10px;
  box-shadow: var(--shadow-soft);
}
.insight-card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.insight-card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.insight-card-meta { flex: 1; min-width: 0; }
.insight-card-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.2px;
}
.insight-card-sub {
  font-size: 11px; color: var(--ink-2);
  margin-top: 2px; font-weight: 500;
}
.insight-card-desc {
  font-size: 13px; color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 10px;
}
.insight-card-changes {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 10px;
}
.insight-card-actions {
  display: flex; gap: 8px;
}
.insight-card-actions .step-btn {
  flex: 1;
  min-height: 38px;
  font-size: 13px;
}

/* =====================================================
   EDL — État des lieux
   ===================================================== */
.edl-room-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
}
.edl-etat-btn {
  padding: 8px 4px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink-2);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.edl-etat-btn:active { transform: scale(0.97); }
.edl-etat-btn.active {
  background: var(--etat-color);
  border-color: var(--etat-color);
  color: white;
}
.edl-room-notes {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  resize: vertical;
  min-height: 50px;
  outline: none;
}
.edl-room-notes:focus { border-color: var(--primary); }
.edl-photo-thumb {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.edl-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.edl-photo-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(20,20,28,0.8);
  color: white;
  font-size: 16px; line-height: 1; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.edl-add-photo {
  width: 80px; height: 80px;
  border-radius: 10px;
  border: 2px dashed var(--line-strong);
  background: var(--bg);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.edl-add-photo:hover { border-color: var(--primary); background: var(--primary-soft); }
.edl-sign-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 600px) {
  .edl-sign-row { grid-template-columns: 1fr; }
}
.edl-sign-block { text-align: center; }
.edl-sign-label {
  font-size: 11px; font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 6px;
}
.edl-sign-canvas {
  width: 100%; height: 120px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  cursor: crosshair;
  touch-action: none;
  display: block;
  margin-bottom: 6px;
}

/* =====================================================
   SHARE SHEET — grille des canaux (SMS / WhatsApp / Mail / +)
   ===================================================== */
.share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}
.share-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: transform 0.1s, border-color 0.15s;
}
.share-card:active {
  transform: scale(0.96);
  border-color: var(--primary);
}
.share-card-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.share-card-label {
  font-size: 12px; font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.1px;
}

/* =====================================================
   MODAL CONFIRM (remplace alert/confirm natifs)
   ===================================================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,28,0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  z-index: 450;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: calc(100% - 48px);
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px 20px;
  text-align: center;
  z-index: 451;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: var(--shadow-elev);
}
.modal.show {
  opacity: 1; pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.modal-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 24px; font-weight: 800;
}
.modal.warn .modal-icon { background: var(--accent-amber-soft); color: var(--accent-amber); }
.modal.danger .modal-icon { background: var(--accent-coral-soft); color: var(--accent-coral); }
.modal.success .modal-icon { background: var(--accent-mint-soft); color: var(--accent-mint); }
.modal-title {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--ink);
  margin-bottom: 8px;
}
.modal-message {
  font-size: 14px; color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 22px;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-btn {
  height: 46px;
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 700;
  letter-spacing: -0.2px;
  transition: transform 0.1s, opacity 0.15s;
}
.modal-btn:active { transform: scale(0.97); opacity: 0.9; }
.modal-cancel {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
}
.modal-confirm {
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
}
.modal.danger .modal-confirm {
  background: var(--accent-coral);
  color: white;
  border-color: var(--accent-coral);
}

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed; top: calc(var(--safe-top) + 70px);
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: var(--ink); color: var(--bg);
  padding: 14px 22px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600;
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s, visibility 0.25s;
  backdrop-filter: blur(12px);
  max-width: 86vw; text-align: center;
  box-shadow: 0 14px 38px rgba(20,20,28,0.32);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .toast { top: calc(max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)) + 14px); }
}

/* =====================================================
   ADD DOC ZONE / DROPZONE / DOC ROW
   ===================================================== */
.add-doc-zone { margin: 0 16px 16px; }

.dropzone {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 16px 16px;
  padding: 36px 24px 32px;
  background: var(--surface);
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-card);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  box-shadow: var(--shadow-soft);
  -webkit-user-select: none; user-select: none;
}
.dropzone:hover { border-color: var(--primary); background: var(--surface-2); }
.dropzone:active { transform: scale(0.99); }
.dropzone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.01);
}
.dropzone input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
  overflow: hidden;
}
.dropzone-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.dropzone-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.dropzone-sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; font-weight: 500; }
.dropzone-formats {
  font-size: 11px; color: var(--ink-3);
  margin-top: 12px;
  letter-spacing: 1px; text-transform: uppercase;
  font-weight: 600;
}
.doc-row { display: flex; align-items: center; }
.doc-icon {
  width: 38px; height: 46px; flex-shrink: 0;
  background: var(--primary); border-radius: 7px;
  margin-right: 14px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 9px; font-weight: 800;
  letter-spacing: -0.2px;
  box-shadow: 0 4px 10px rgba(91,95,224,0.25);
}
.doc-icon.pdf { background: var(--accent-coral); box-shadow: 0 4px 10px rgba(242,103,74,0.25); }
.doc-icon.img { background: var(--accent-violet); box-shadow: 0 4px 10px rgba(139,102,227,0.25); }
.doc-actions { display: flex; gap: 6px; }
.doc-action-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line);
}
.doc-action-btn:active { opacity: 0.7; }
.doc-action-btn.danger { color: var(--accent-coral); }

/* Email history row */
.email-row { display: flex; align-items: flex-start; padding: 14px 18px; }
.email-row .row-icon-circle {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  margin-right: 14px; flex-shrink: 0;
  font-weight: 700;
}
.email-row .row-icon-circle.warn   { background: var(--accent-amber); }
.email-row .row-icon-circle.danger { background: var(--accent-coral); }
.email-row .row-icon-circle.info   { background: var(--primary); }

/* =====================================================
   SIGN-IN SCREEN — refonte
   ===================================================== */
.signin-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-top: calc(var(--safe-top) + 24px);
  padding-bottom: calc(var(--safe-bottom) + 24px);
  z-index: 500;
  background-image:
    radial-gradient(circle at 15% 0%, var(--primary-soft) 0%, transparent 45%),
    radial-gradient(circle at 85% 100%, var(--accent-mint-soft) 0%, transparent 45%);
}
.signin-content { max-width: 380px; width: 100%; text-align: center; }
.signin-icon {
  width: 96px; height: 96px;
  background: var(--surface);
  border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
}
.signin-icon svg { stroke: var(--primary); }
.signin-content h1 {
  font-size: 30px; font-weight: 800;
  letter-spacing: -0.8px; margin: 0 0 10px;
  color: var(--ink);
}
.signin-sub {
  font-size: 15px; color: var(--ink-2); margin: 0 0 22px;
  line-height: 1.5; font-weight: 500;
}
.signin-info {
  font-size: 13px; color: var(--ink-3); margin: 0 0 32px;
  line-height: 1.55;
}
.btn-google {
  width: 100%; height: 54px;
  background: var(--ink); color: var(--bg);
  border: none;
  border-radius: var(--radius-pill);
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 12px 30px rgba(20,20,28,0.25);
  transition: transform 0.12s, opacity 0.15s;
}
.btn-google:active { transform: scale(0.98); opacity: 0.92; }
.btn-google svg { background: white; border-radius: 50%; padding: 2px; }
.signin-error {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-card-sm);
  background: var(--accent-coral-soft);
  color: var(--accent-coral);
  font-size: 13px;
  text-align: left;
  font-weight: 600;
}

/* Sync indicator legacy */
.sync-indicator {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.sync-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-3);
  transition: background 0.2s;
}
.sync-indicator.connected .sync-dot    { background: var(--accent-mint); }
.sync-indicator.syncing   .sync-dot    { background: var(--accent-mint); animation: pulse-green 1.2s infinite; }
.sync-indicator.error     .sync-dot    { background: var(--accent-coral); }
.sync-indicator.disconnected .sync-dot { background: var(--ink-3); }

/* =====================================================
   FAB CHAT
   ===================================================== */
.fab-chat {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 24px);
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-fab);
  z-index: 90;
  transition: transform 0.15s, bottom 0.2s, box-shadow 0.2s;
}
.fab-chat:active {
  transform: scale(0.92);
  box-shadow: 0 6px 16px rgba(91,95,224,0.4);
}
body.home-active .fab-chat { bottom: calc(var(--safe-bottom) + 22px); }

/* =====================================================
   CHAT OVERLAY
   ===================================================== */
.chat-overlay {
  position: fixed; inset: 0;
  z-index: 350;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .chat-overlay { padding-top: max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)); }
}
.chat-header {
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--ios-nav-bg);
  backdrop-filter: saturate(180%) blur(22px);
}
.chat-close { color: var(--primary); font-size: 15px; font-weight: 600; min-width: 60px; padding: 0 8px; }
.chat-title-wrap { flex: 1; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 0 8px; }
.chat-title {
  font-size: 15px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.2px;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-agent-badge {
  font-size: 11px; font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 10px; border-radius: var(--radius-pill);
  line-height: 1.4;
  display: inline-flex; align-items: center; gap: 5px;
}
.agent-badge-ico { display: inline-flex; align-items: center; }
.agent-badge-ico svg { display: block; }

/* Chat attach button + preview */
.chat-attach-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.chat-attach-btn:active { color: var(--primary); border-color: var(--primary); }
.chat-attach-preview {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.chat-attach-preview.hidden { display: none; }
.chat-attach-item {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
}
.chat-attach-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-attach-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(20,20,28,0.85);
  color: white;
  display: flex; align-items: center; justify-content: center;
}
.chat-attach-remove svg { display: block; }
.chat-attach-remove:active { background: var(--accent-coral); }

/* Image attachée dans une bulle */
.bubble-image {
  max-width: 100%;
  max-height: 280px;
  border-radius: 14px;
  display: block;
  margin: 0 0 6px;
  background: rgba(0,0,0,0.05);
}
.bubble-text { margin-top: 4px; }
.chat-agent-badge.hidden { display: none; }
.chat-icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); border-radius: 50%;
}
.chat-icon-btn:active { background: var(--bg); }
.chat-clear { display: none; } /* legacy */

/* =====================================================
   CHAT — Sidebar historique
   ===================================================== */
.chat-history-backdrop {
  position: absolute; inset: 0;
  background: rgba(20,20,28,0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  z-index: 360;
}
.chat-history-backdrop.show { opacity: 1; pointer-events: auto; }

.chat-history-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 86%; max-width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 361;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  box-shadow: -10px 0 40px rgba(20,20,30,0.18);
}
.chat-history-panel.show { transform: translateX(0); }
@media (display-mode: standalone), (display-mode: fullscreen) {
  .chat-history-panel { padding-top: max(env(safe-area-inset-top, 0px), var(--ios-pwa-safe, 0px)); }
}
.chat-history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-history-title {
  font-size: 17px; font-weight: 800; letter-spacing: -0.3px;
  color: var(--ink);
}
.chat-history-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  color: var(--ink);
  border-radius: 50%;
  font-size: 20px; font-weight: 600;
}
.chat-history-close:active { background: var(--line); }
.chat-new-btn {
  margin: 14px 18px;
  height: 48px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px rgba(91,95,224,0.3);
}
.chat-new-btn:active { transform: scale(0.97); }
.chat-history-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 12px 18px;
}
.chat-history-empty {
  padding: 40px 24px; text-align: center;
  color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.chat-history-item {
  display: flex; align-items: stretch;
  background: var(--bg);
  border-radius: 14px;
  margin-bottom: 6px;
  overflow: hidden;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.chat-history-item.active { border-color: var(--primary); background: var(--primary-soft); }
.chat-history-pick {
  flex: 1; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; text-align: left;
  background: transparent;
  min-width: 0;
}
.chat-history-pick:active { background: var(--surface-2); }
.chat-history-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border-radius: 10px;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-history-meta { flex: 1; min-width: 0; }
.chat-history-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.2px;
}
.chat-history-sub {
  font-size: 11px; color: var(--ink-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.chat-history-del {
  width: 40px;
  background: transparent;
  color: var(--ink-3);
  font-size: 22px; font-weight: 300;
}
.chat-history-del:active { background: var(--accent-coral-soft); color: var(--accent-coral); }

/* =====================================================
   CHAT — Agent picker (bottom sheet)
   ===================================================== */
.agent-picker-backdrop {
  position: absolute; inset: 0;
  background: rgba(20,20,28,0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  z-index: 370;
}
.agent-picker-backdrop.show { opacity: 1; pointer-events: auto; }
.agent-picker-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 371;
  padding-bottom: var(--safe-bottom);
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(20,20,30,0.18);
}
.agent-picker-panel.show { transform: translateY(0); }
.agent-picker-handle {
  width: 42px; height: 5px; border-radius: 3px;
  background: var(--ink-3); opacity: 0.5;
  margin: 8px auto 0;
}
.agent-picker-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
}
.agent-picker-title {
  font-size: 18px; font-weight: 800; letter-spacing: -0.3px;
  color: var(--ink);
}
.agent-picker-close {
  color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.agent-picker-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 16px 20px;
}
.agent-card {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s;
}
.agent-card:active { border-color: var(--primary); transform: scale(0.99); }
.agent-card-icon {
  width: 48px; height: 48px;
  background: var(--primary-soft);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.agent-card-meta { flex: 1; min-width: 0; }
.agent-card-name {
  font-size: 15px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.2px;
}
.agent-card-desc {
  font-size: 12px; color: var(--ink-2); margin-top: 3px;
  font-weight: 500; line-height: 1.4;
}
.agent-card-chevron {
  color: var(--ink-3); font-size: 22px; font-weight: 300;
}
.chat-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-messages {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 8px;
}

.chat-empty { padding: 60px 24px; text-align: center; color: var(--ink-2); }
.chat-empty-icon {
  width: 76px; height: 76px;
  background: var(--surface);
  border-radius: 24px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
}
.chat-empty h3 {
  font-size: 22px; font-weight: 800;
  color: var(--ink); margin: 0 0 6px; letter-spacing: -0.4px;
}
.chat-empty p { font-size: 14px; margin: 0 0 24px; line-height: 1.5; }
.chat-suggestions { display: flex; flex-direction: column; gap: 8px; max-width: 320px; margin: 0 auto; }
.chat-suggestion {
  background: var(--surface);
  color: var(--ink);
  padding: 14px 18px;
  border-radius: var(--radius-card-sm);
  font-size: 14px;
  text-align: left;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  font-weight: 500;
}
.chat-suggestion:active { background: var(--surface-2); transform: scale(0.98); }

.chat-bubble { display: flex; max-width: 80%; align-items: flex-end; }
.chat-bubble.user { align-self: flex-end; }
.chat-bubble.assistant { align-self: flex-start; }
.chat-bubble.error { align-self: center; max-width: 92%; }
.bubble-content {
  padding: 11px 16px;
  border-radius: 22px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.chat-bubble.user .bubble-content {
  background: var(--ink); color: var(--bg);
  border-bottom-right-radius: 6px;
}
.chat-bubble.assistant .bubble-content {
  background: var(--surface); color: var(--ink);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
}
.chat-bubble.error .bubble-content {
  background: var(--accent-coral-soft); color: var(--accent-coral);
}
.bubble-content b { font-weight: 700; }
.bubble-content code {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 13px; background: rgba(0,0,0,0.06);
  padding: 1px 6px; border-radius: 5px;
}
.chat-bubble.user .bubble-content code { background: rgba(255,255,255,0.2); }

.chat-bubble.typing .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  margin: 0 2px;
  animation: typing 1.2s infinite;
}
.chat-bubble.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.chat-bubble.typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--ios-nav-bg);
  backdrop-filter: saturate(180%) blur(22px);
}
.chat-input-bar textarea {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  outline: none;
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  resize: none;
  max-height: 120px;
  min-height: 40px;
  line-height: 20px;
}
.chat-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(91,95,224,0.3);
  padding: 0;
}
/* L'icône paper-plane est visuellement haut-droite dans son viewbox 24x24.
   On compense optiquement pour la centrer dans le rond. */
.chat-send svg {
  transform: translate(-1px, 1px);
  display: block;
}
.chat-send:disabled { opacity: 0.4; box-shadow: none; }
.chat-send:active:not(:disabled) { transform: scale(0.92); }

/* =====================================================
   SEARCH BAR (page documents)
   ===================================================== */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-bar svg { color: var(--ink-3); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--ink); font-weight: 500;
  min-width: 0;
}
.search-bar input::placeholder { color: var(--ink-3); }
.search-clear {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.search-clear:active { background: var(--line); }

/* =====================================================
   MAIL CARDS (historique emails expandable)
   ===================================================== */
.mail-card {
  background: var(--surface);
  border-radius: var(--radius-card-sm);
  margin: 0 16px 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.mail-card-header {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  text-align: left;
  background: transparent;
  transition: background 0.15s;
}
.mail-card-header:active { background: var(--bg); }
.mail-card-meta { flex: 1; min-width: 0; }
.mail-card-type {
  font-size: 10px; font-weight: 800;
  color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 3px;
}
.mail-card-subject {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.2px;
}
.mail-card-sub {
  font-size: 12px; color: var(--ink-2);
  margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.mail-card-chevron {
  color: var(--ink-3); font-size: 22px;
  transition: transform 0.2s;
  margin-left: 4px;
}
.mail-card-header.expanded .mail-card-chevron {
  transform: rotate(90deg);
}
.mail-card-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
  margin-top: -1px;
}
.mail-detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  gap: 14px;
}
.mail-detail-row:last-of-type { border-bottom: none; }
.mail-detail-label {
  font-size: 11px; font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.8px;
  flex-shrink: 0; min-width: 90px;
}
.mail-detail-val {
  font-size: 13px; color: var(--ink);
  word-break: break-word;
  flex: 1;
}
.mail-attachs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mail-attach-chip {
  font-size: 12px; font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
}
.mail-attach-chip:active { background: var(--surface); border-color: var(--primary); }
.mail-no-attach {
  font-size: 12px; color: var(--ink-3); font-style: italic;
}
.mail-body-pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px; line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
  margin: 6px 0 0;
  max-height: 320px; overflow-y: auto;
}

/* =====================================================
   SETTINGS — Indicateur "Enregistré"
   ===================================================== */
.save-indicator {
  position: fixed;
  top: calc(var(--safe-top) + 18px);
  right: 18px;
  z-index: 350;
  display: flex; align-items: center; gap: 6px;
  background: var(--accent-mint);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(43,182,138,0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
  transition: opacity 0.2s, transform 0.25s;
}
.save-indicator.show {
  opacity: 1;
  transform: translateY(0);
}

/* =====================================================
   MAIL list (existant)
   ===================================================== */
.mail-row { display: flex; align-items: flex-start; padding: 14px 18px; }
.mail-row .mail-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
  margin-right: 14px; flex-shrink: 0;
}
.mail-row .mail-content { flex: 1; min-width: 0; }
.mail-row .mail-sender { font-size: 14px; font-weight: 700; color: var(--ink); }
.mail-row .mail-date {
  font-size: 12px; color: var(--ink-3);
  font-weight: 500; float: right;
}
.mail-row .mail-subject {
  font-size: 14px; color: var(--ink);
  margin-top: 2px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mail-row .mail-snippet {
  font-size: 13px; color: var(--ink-2);
  margin-top: 3px; line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mail-row .mail-attach {
  display: inline-block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  padding: 3px 9px;
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
}

/* ===== v10.12 — Refonte charte : Credits / Dashboard / Agenda / Fiscal / Tracking / Dedup ===== */

/* ---- Jauges emprunts (home) ---- */
#creditGauges {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px;
  margin-bottom: 24px;
}
.credit-gauge {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card-sm);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  position: relative; overflow: hidden;
}
.credit-gauge::before {
  content: ""; position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: var(--gauge-color-soft, var(--primary-soft));
  border-radius: 50%;
  opacity: 0.45; pointer-events: none;
}
.credit-gauge-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  position: relative; z-index: 1;
}
.credit-gauge-color {
  width: 12px; height: 12px; border-radius: 50%;
  box-shadow: 0 0 0 3px var(--surface);
}
.credit-gauge-title {
  flex: 1; font-weight: 800; font-size: 16px;
  color: var(--ink); letter-spacing: -0.3px;
}
.credit-gauge-edit {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--ink-2); padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.credit-gauge-edit:active { transform: scale(0.95); }
.credit-gauge-empty {
  font-size: 13px; color: var(--ink-2);
  text-align: center; padding: 12px 0;
}
.credit-gauge-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; color: var(--ink-2);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
  position: relative; z-index: 1;
}
.credit-gauge-value { color: var(--ink); font-weight: 700; font-size: 13px; letter-spacing: 0; text-transform: none; }
.credit-gauge-bar {
  height: 10px; background: var(--bg-soft);
  border-radius: var(--radius-pill); overflow: hidden;
  position: relative; z-index: 1;
}
.credit-gauge-bar-fill {
  height: 100%; border-radius: var(--radius-pill);
  transition: width .5s ease;
  background: linear-gradient(90deg, var(--gauge-color, var(--primary)) 0%, var(--gauge-color-2, var(--primary-dark)) 100%);
}
.credit-gauge-meta {
  font-size: 12px; color: var(--ink-2); margin-top: 8px;
  position: relative; z-index: 1;
}
.credit-gauge-meta strong { color: var(--ink); font-weight: 700; }
.credit-gauge-footer {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-2);
  display: flex; gap: 8px; flex-wrap: wrap;
  position: relative; z-index: 1;
}
.credit-gauge-footer strong { color: var(--ink); font-weight: 700; }
.credit-gauge-footer .pill {
  background: var(--bg-soft); padding: 3px 9px;
  border-radius: var(--radius-pill); font-size: 11px;
}

/* ---- Agenda ---- */
#agendaFilters {
  display: flex; gap: 8px;
  margin: 0 16px 16px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.agenda-filter {
  background: var(--surface); border: 1px solid var(--line);
  padding: 8px 16px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.agenda-filter.active {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(20,20,28,0.18);
}
.agenda-filter:active { transform: scale(0.95); }
.agenda-month {
  margin: 18px 20px 10px; font-size: 12px;
  font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.agenda-card {
  display: flex; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card-sm);
  padding: 14px 16px; margin: 0 16px 10px;
  box-shadow: var(--shadow-soft);
  border-left-width: 4px;
}
.agenda-card-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  background: var(--bg-soft); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.agenda-card-body { flex: 1; min-width: 0; }
.agenda-card-head {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 6px;
}
.agenda-card-type {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.agenda-card-prop {
  font-size: 11px; padding: 3px 10px; border-radius: var(--radius-pill); font-weight: 700;
}
.agenda-badge {
  font-size: 10px; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--bg-soft); color: var(--ink-2); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.agenda-badge-today { background: var(--accent-amber-soft); color: var(--accent-amber); }
.agenda-badge-soon  { background: var(--accent-sky-soft); color: var(--accent-sky); }
.agenda-badge-past  { background: var(--accent-coral-soft); color: var(--accent-coral); }
.agenda-card-title { font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--ink); }
.agenda-card-desc  { font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.4; }
.agenda-card-date  { font-size: 12px; color: var(--ink-3); margin-top: 6px; font-weight: 500; }
.agenda-card-actions { display: flex; flex-direction: column; gap: 4px; align-self: center; }

/* ---- Section cards (Fiscal / Tracking / EDL / Insights wrap) ---- */
.section-card {
  margin: 0 16px 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card-sm);
  box-shadow: var(--shadow-soft);
}
.section-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.section-card-head h3 {
  margin: 0; font-size: 15px; font-weight: 800;
  color: var(--ink); letter-spacing: -0.3px;
}

/* ---- Fiscal ---- */
.fiscal-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.fiscal-cell {
  padding: 12px 14px; background: var(--bg-soft);
  border-radius: var(--radius-btn);
}
.fiscal-label {
  font-size: 10px; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
}
.fiscal-value { font-size: 16px; font-weight: 800; margin-top: 4px; color: var(--ink); letter-spacing: -0.4px; }
.fiscal-result {
  padding: 14px 16px; background: var(--bg-soft);
  border-radius: var(--radius-btn); font-size: 14px; color: var(--ink);
  border-left: 4px solid var(--accent-mint);
}
.fiscal-result.warn { border-left-color: var(--accent-amber); }
.fiscal-result strong { font-weight: 800; letter-spacing: -0.3px; }

/* ---- Tracking annuel ---- */
.tracking-table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: var(--surface);
}
.tracking-table {
  width: 100%; border-collapse: collapse; font-size: 13px; min-width: 540px;
}
.tracking-table th, .tracking-table td {
  text-align: right; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.tracking-table th:first-child, .tracking-table td:first-child {
  text-align: left;
}
.tracking-table th {
  background: var(--bg-soft);
  font-weight: 700; font-size: 10px;
  color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.6px;
  white-space: nowrap;
}
.tracking-table td { color: var(--ink); }
.tracking-table .muted { color: var(--ink-3); font-size: 11px; }
.tracking-current { background: var(--primary-soft); }
.tracking-totals { background: var(--bg-soft); font-weight: 800; }
.tracking-pos { color: var(--accent-mint); }
.tracking-neg { color: var(--accent-coral); }
.tracking-chart {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-btn);
}
.tracking-chart-legend {
  display: flex; gap: 16px; font-size: 12px; margin-bottom: 12px;
  flex-wrap: wrap; color: var(--ink-2); font-weight: 600;
}
.tcl { display: inline-flex; align-items: center; }
.tcl::before {
  content: ""; display: inline-block;
  width: 12px; height: 12px; border-radius: 3px; margin-right: 6px;
}
.tcl-loy::before { background: var(--primary); }
.tcl-ch::before  { background: var(--accent-coral); }
.tracking-bar-row {
  display: flex; gap: 12px; align-items: center; margin-bottom: 10px;
}
.tracking-bar-year {
  width: 48px; font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.tracking-bars { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tracking-bar { height: 10px; border-radius: var(--radius-pill); min-width: 6px; transition: width .4s ease; }
.tracking-bar-loy { background: var(--primary); }
.tracking-bar-ch  { background: var(--accent-coral); }

/* ---- Dedup banner ---- */
.dup-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; margin: 0 16px 12px;
  background: var(--accent-amber-soft); border: 1px solid var(--accent-amber);
  color: var(--ink);
  border-radius: var(--radius-card-sm);
}
.dup-banner svg { color: var(--accent-amber); flex-shrink: 0; }
.dup-banner-text { flex: 1; font-size: 13px; color: var(--ink); }
.dup-banner .app-btn-link { color: var(--accent-amber); font-weight: 800; }
.dup-group h4 { margin: 16px 0 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.6px; }
.dup-item {
  display: flex; gap: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  margin-bottom: 8px; cursor: pointer; background: var(--surface);
}
.dup-item:active { background: var(--bg); }
.dup-item input[type=radio] { margin-top: 4px; accent-color: var(--primary); }
.dup-item-body { flex: 1; min-width: 0; }
.dup-item-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.dup-item-meta { font-size: 12px; color: var(--ink-2); margin-top: 3px; word-break: break-all; }

/* ===== Modal app (charte cream) ===== */
.app-modal-backdrop {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(20,20,28,0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: appModalFadeIn 0.2s ease;
}
@keyframes appModalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.app-modal {
  background: var(--bg);
  width: 100%; max-width: 560px; max-height: 92vh;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-elev);
  animation: appModalSlideUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes appModalSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (min-width: 700px) {
  .app-modal-backdrop { align-items: center; padding: 24px; }
  .app-modal { border-radius: var(--radius-card); max-height: 86vh; padding-bottom: 0; }
}
.app-modal::before {
  content: "";
  display: block; margin: 8px auto 0;
  width: 38px; height: 4px;
  background: var(--ink-3); opacity: 0.35;
  border-radius: var(--radius-pill);
}
@media (min-width: 700px) { .app-modal::before { display: none; } }
.app-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px 8px;
}
.app-modal-head h3 {
  margin: 0; font-size: 19px; font-weight: 800;
  color: var(--ink); letter-spacing: -0.5px;
}
.app-modal-close {
  background: var(--surface); border: 1px solid var(--line);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2);
  font-size: 18px; line-height: 1; padding: 0;
}
.app-modal-close:active { transform: scale(0.92); }
.app-modal-body {
  padding: 8px 20px 16px; overflow-y: auto; flex: 1;
  -webkit-overflow-scrolling: touch;
}
.app-modal-body .app-field {
  display: block; margin-bottom: 14px;
}
.app-modal-body .app-field-label {
  font-size: 11px; color: var(--ink-2);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 6px; display: block;
}
.app-modal-body input[type="text"],
.app-modal-body input[type="email"],
.app-modal-body input[type="password"],
.app-modal-body input[type="number"],
.app-modal-body input[type="tel"],
.app-modal-body input[type="date"],
.app-modal-body input[type="url"],
.app-modal-body select,
.app-modal-body textarea {
  display: block; width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  background: var(--surface); color: var(--ink);
  font-size: 15px; font-family: inherit;
  font-weight: 500; letter-spacing: -0.2px;
  -webkit-appearance: none; appearance: none;
}
.app-modal-body input:focus,
.app-modal-body select:focus,
.app-modal-body textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.app-modal-body textarea { min-height: 70px; resize: vertical; }
.app-modal-body select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B5E6E' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
.app-modal-foot {
  display: flex; gap: 10px;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.app-modal-foot .btn-primary,
.app-modal-foot .btn-secondary { flex: 1; height: 46px; }

/* Boutons texte (lien) cohérents avec la charte */
.app-btn-link {
  background: transparent; border: none;
  color: var(--primary); cursor: pointer;
  font-size: 13px; font-weight: 700;
  padding: 6px 10px; border-radius: var(--radius-pill);
}
.app-btn-link:active { background: var(--primary-soft); transform: scale(0.96); }
.app-btn-link.danger { color: var(--accent-coral); }
.app-btn-link.danger:active { background: var(--accent-coral-soft); }

.app-empty {
  padding: 36px 20px; text-align: center;
  color: var(--ink-2); font-size: 14px;
}
.app-muted { color: var(--ink-2); }

/* Table d'édition (charges, fiscal composants) */
.app-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.app-table th {
  text-align: left; padding: 8px 10px;
  font-size: 10px; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.6px;
  border-bottom: 1px solid var(--line);
}
.app-table th.num, .app-table td.num { text-align: right; }
.app-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.app-table input[type="text"],
.app-table input[type="number"] {
  background: transparent; border: 1px solid transparent;
  padding: 8px 10px; border-radius: 8px;
  width: 100%; font-size: 14px; color: var(--ink);
  font-family: inherit;
}
.app-table input:focus {
  background: var(--surface); border-color: var(--primary);
  outline: none; box-shadow: 0 0 0 2px var(--primary-soft);
}
.app-table input.num { text-align: right; }
.app-table select {
  background: transparent; border: 1px solid transparent;
  padding: 8px 6px; border-radius: 8px;
  font-size: 13px; color: var(--ink); font-family: inherit;
}
.app-table select:focus { background: var(--surface); border-color: var(--primary); outline: none; }
.app-table .row-del {
  background: transparent; border: none; cursor: pointer;
  color: var(--accent-coral); font-size: 16px; padding: 6px;
  width: 30px; height: 30px; border-radius: 50%;
}
.app-table .row-del:active { background: var(--accent-coral-soft); }

/* Section pour grouper plusieurs sous-blocs dans la modal (charges par bien) */
.app-modal-subsection {
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 12px 14px;
}
.app-modal-subsection-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; color: var(--ink);
  margin-bottom: 8px;
}
.app-modal-subsection-title .swatch {
  width: 10px; height: 10px; border-radius: 50%;
}

/* Mini-aperçu (fiscal preview) */
.app-preview {
  margin-top: 14px; padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  font-size: 13px; color: var(--ink); line-height: 1.6;
}
.app-preview hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.app-preview .row-flex { display: flex; justify-content: space-between; gap: 10px; }

/* Compat ancien — alias modal-overlay vers app-modal-backdrop si encore appelé */
.modal-overlay { display: none !important; }

/* ===== Date picker custom — charte cream/indigo ===== */
.app-dp-backdrop {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(20,20,28,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: appModalFadeIn 0.18s ease;
}
.app-dp {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-elev);
  width: 320px; max-width: 100%;
  padding: 16px;
  transform-origin: center;
  animation: dpPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes dpPop { from { transform: scale(0.94) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.app-dp-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.app-dp-title {
  display: flex; gap: 4px; flex: 1; justify-content: center;
}
.app-dp-title-btn {
  background: transparent; border: none;
  font-size: 15px; font-weight: 800; color: var(--ink);
  padding: 6px 10px; border-radius: var(--radius-btn);
  cursor: pointer; letter-spacing: -0.3px;
  text-transform: capitalize;
}
.app-dp-title-btn:hover { background: var(--bg-soft); }
.app-dp-nav {
  background: var(--bg-soft); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink);
}
.app-dp-nav:active { transform: scale(0.92); }
.app-dp-dows {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.app-dp-dow {
  text-align: center; font-size: 11px; font-weight: 700;
  color: var(--ink-2); padding: 6px 0;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.app-dp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.app-dp-day {
  aspect-ratio: 1 / 1;
  background: transparent; border: none;
  font-size: 14px; font-weight: 500; color: var(--ink);
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.app-dp-day:hover { background: var(--bg-soft); }
.app-dp-day.other-month { color: var(--ink-3); opacity: 0.5; }
.app-dp-day.today {
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.app-dp-day.selected {
  background: var(--ink) !important; color: var(--bg) !important; font-weight: 700;
}
.app-dp-footer {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.app-dp-action {
  background: transparent; border: none;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-pill);
  cursor: pointer;
}
.app-dp-action:hover { background: var(--bg-soft); color: var(--ink); }
.app-dp-action.primary { color: var(--primary); }
.app-dp-action.primary:hover { background: var(--primary-soft); }
.app-dp-list {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; max-height: 280px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.app-dp-list-years { grid-template-columns: repeat(4, 1fr); }
.app-dp-list-item {
  background: var(--bg-soft); border: none;
  padding: 10px 8px; border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; text-transform: capitalize;
}
.app-dp-list-item:hover { background: var(--primary-soft); color: var(--primary); }
.app-dp-list-item.selected { background: var(--ink); color: var(--bg); }

/* ===== Calendrier mensuel (home) ===== */
.cal-card {
  margin: 0 16px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card-sm);
  padding: 18px 16px;
  box-shadow: var(--shadow-soft);
}
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cal-title {
  font-size: 16px; font-weight: 800; color: var(--ink);
  letter-spacing: -0.3px; text-transform: capitalize;
}
.cal-nav-group { display: flex; gap: 6px; }
.cal-nav {
  background: var(--bg-soft); border: none;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink);
}
.cal-nav:active { transform: scale(0.92); }
.cal-today-btn {
  background: var(--bg-soft); border: none;
  padding: 0 14px; height: 34px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; color: var(--ink);
  cursor: pointer;
}
.cal-dows {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-dow {
  text-align: center; font-size: 10px; font-weight: 700;
  color: var(--ink-2); padding: 6px 0;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1 / 1;
  background: var(--bg-soft); border: 1px solid transparent;
  border-radius: 10px; cursor: pointer;
  padding: 6px 4px 4px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.cal-day:active:not(.empty) { transform: scale(0.95); }
.cal-day.other-month { opacity: 0.4; }
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.empty:active { transform: none; }
.cal-day.today {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.cal-day.has-events { background: var(--surface); border-color: var(--line-strong); }
.cal-day.has-events.today { background: var(--primary-soft); }
.cal-day-num {
  font-size: 12px; font-weight: 700; color: var(--ink);
  text-align: right; line-height: 1;
  padding-right: 2px;
}
.cal-day.today .cal-day-num { color: var(--primary); }
.cal-day.other-month .cal-day-num { color: var(--ink-3); }
.cal-day-dots {
  display: flex; gap: 2px; flex-wrap: wrap;
  justify-content: center; align-items: flex-end;
  padding: 0 2px 2px;
  min-height: 8px;
}
.cal-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
.cal-day-count {
  position: absolute; top: 2px; left: 4px;
  font-size: 9px; font-weight: 800; color: var(--ink-2);
}

.cal-legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-2);
}
.cal-legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 600;
}
.cal-legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
}

/* Modal détail jour */
.day-events-list { display: flex; flex-direction: column; gap: 10px; }
.day-event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius-btn);
  padding: 14px;
}
.day-event-head {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 6px;
}
.day-event-type {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.day-event-title {
  font-size: 15px; font-weight: 700; color: var(--ink);
  line-height: 1.3;
}
.day-event-desc {
  font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.4;
}
.day-event-meta {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.day-event-meta-row { display: flex; gap: 6px; align-items: flex-start; color: var(--ink-2); }
.day-event-meta-row svg { flex-shrink: 0; margin-top: 2px; color: var(--ink-3); }
.day-event-meta-row strong { color: var(--ink); font-weight: 600; }

/* Badge statut d'occupation sur card propriété */
.property-card-vacancy {
  position: absolute; top: 12px; right: 50px;
  background: var(--accent-coral); color: white;
  font-size: 10px; font-weight: 800;
  padding: 4px 10px; border-radius: var(--radius-pill);
  text-transform: uppercase; letter-spacing: 0.6px;
  box-shadow: 0 4px 12px rgba(20,20,28,0.18);
  z-index: 2;
}
.property-card-vacancy.occupied { background: var(--accent-mint); }

/* Bouton + badge PDF dans la liste EDL */
.edl-pdf-btn {
  background: var(--primary-soft); color: var(--primary);
  border: none; width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  margin-left: 6px;
}
.edl-pdf-btn:active { transform: scale(0.92); }
.edl-pdf-badge {
  display: inline-block; margin-left: 4px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.4px;
  background: var(--primary-soft); color: var(--primary);
  padding: 1px 6px; border-radius: var(--radius-pill);
}

/* ===== RP Dashboard ===== */
.rp-statut {
  margin: 0 16px 14px; padding: 10px 14px;
  background: var(--accent-amber-soft); color: var(--accent-amber);
  border-radius: var(--radius-btn); font-size: 13px; font-weight: 700;
  text-align: center;
}
.rp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-btn);
}
.rp-item-title { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.rp-item-meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.rp-item-amount { font-size: 15px; font-weight: 800; color: var(--ink); white-space: nowrap; }

/* ===== Chantier ===== */
.chantier-list { display: flex; flex-direction: column; }
.chantier-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 6px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.chantier-row:last-child { border-bottom: none; }
.chantier-row:active { background: var(--bg-soft); }
.chantier-row-main { flex: 1; min-width: 0; }
.chantier-row-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.chantier-row-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; }

.chantier-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.chantier-tab {
  background: var(--bg-soft); border: none;
  padding: 8px 16px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
}
.chantier-tab.active { background: var(--ink); color: var(--bg); }

.chantier-drop {
  display: block; padding: 24px; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: var(--radius-card-sm);
  cursor: pointer; background: var(--surface); transition: all 0.2s;
}
.chantier-drop:hover { border-color: var(--primary); background: var(--primary-soft); }

.chantier-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin-top: 12px;
}
.chantier-media-cell {
  position: relative; aspect-ratio: 1; cursor: pointer;
  border-radius: var(--radius-btn); overflow: hidden;
  background: var(--bg-soft);
}
.chantier-media-cell img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.chantier-media-cell:active { transform: scale(0.97); }
.chantier-media-loading, .chantier-media-video {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--ink-2); font-size: 12px;
}
.chantier-media-video {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; font-weight: 700;
}
.chantier-media-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 8px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  color: white;
}
.chantier-media-date { font-size: 10px; font-weight: 700; }
.chantier-media-comment { font-size: 10px; margin-top: 2px; opacity: 0.9; }

.etape-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-btn);
}
.etape-check {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.etape-main { flex: 1; }
.etape-label { font-weight: 600; font-size: 14px; color: var(--ink); }
.etape-sub { font-size: 12px; margin-top: 2px; color: var(--ink-2); }

/* User management rows */
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-btn);
}
.audit-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px; margin-bottom: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  font-size: 13px;
}

/* ===== Home top-bar : avatar + gear ===== */
.home-topbar {
  position: absolute;
  top: max(env(safe-area-inset-top, 0), var(--ios-pwa-safe, 0));
  left: 0; right: 0;
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 10;
  pointer-events: none;
}
.home-topbar-btn {
  pointer-events: auto;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.home-topbar-btn:active { transform: scale(0.92); }
.home-topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
  color: white; background: var(--primary);
}

/* ===== Global settings modal sections ===== */
.global-settings-section {
  margin-bottom: 18px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
}
.global-settings-section h4 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.global-user-info {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-btn);
}

/* ===== v11.5 — Menu utilisateur unifié (avatar dropdown) ===== */
.user-menu-header {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.user-menu-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  flex-shrink: 0;
}
.user-menu-info { flex: 1; min-width: 0; }
.user-menu-name {
  font-size: 15px; font-weight: 800; color: var(--ink);
  letter-spacing: -0.2px; line-height: 1.2;
}
.user-menu-email {
  font-size: 12px; color: var(--ink-2); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-role {
  display: inline-block; margin-top: 6px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.user-menu-list { display: flex; flex-direction: column; gap: 2px; }
.user-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px;
  background: transparent; border: none; border-radius: var(--radius-btn);
  color: var(--ink); font-size: 15px; font-weight: 600;
  cursor: pointer; text-align: left;
  transition: background 0.12s;
  width: 100%;
}
.user-menu-item svg:not(.chev) { color: var(--ink-2); flex-shrink: 0; }
.user-menu-item span { flex: 1; }
.user-menu-item .chev { color: var(--ink-3); flex-shrink: 0; }
.user-menu-item:hover, .user-menu-item:active { background: var(--bg-soft); }
.user-menu-item.danger { color: var(--accent-coral); }
.user-menu-item.danger svg:not(.chev) { color: var(--accent-coral); }
.user-menu-item.primary { color: var(--primary); font-weight: 800; }
.user-menu-item.primary svg:not(.chev) { color: var(--primary); }
.user-menu-divider {
  height: 1px; background: var(--line);
  margin: 8px 0;
}

/* ===== v11.5 — Settings modal (charte cream/indigo) ===== */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card-sm);
  padding: 16px;
  margin-bottom: 14px;
}
.settings-section-title {
  font-size: 11px; font-weight: 800;
  color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.7px;
  margin-bottom: 12px;
}
.settings-row {
  margin-bottom: 12px;
}
.settings-row:last-child { margin-bottom: 0; }
.settings-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink); margin-bottom: 6px;
}
.settings-input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  font-size: 14px; color: var(--ink);
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.settings-input:focus {
  outline: none; border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.settings-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 4px;
  cursor: pointer;
  font-size: 14px; color: var(--ink); font-weight: 500;
}
.settings-toggle span { flex: 1; }
.settings-switch {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 26px;
  background: var(--line-strong); border-radius: 13px;
  position: relative; cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.settings-switch::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  background: white; border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.settings-switch:checked { background: var(--accent-mint); }
.settings-switch:checked::after { transform: translateX(18px); }

.settings-item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft); border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font-size: 14px; font-weight: 600; color: var(--ink);
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.12s, border-color 0.15s;
}
.settings-item:last-child { margin-bottom: 0; }
.settings-item:hover, .settings-item:active {
  background: var(--surface);
  border-color: var(--line);
}
.settings-item svg:not(.chev) { color: var(--primary); flex-shrink: 0; }
.settings-item span { flex: 1; text-align: left; }
.settings-item .chev { color: var(--ink-3); flex-shrink: 0; }

.settings-about {
  padding: 16px;
  background: var(--bg-soft);
  border-radius: var(--radius-btn);
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.7;
  text-align: center;
}
.settings-about strong { color: var(--ink); font-weight: 800; }

/* ===== Insights cards — refonte charte ===== */
.insights-list { display: flex; flex-direction: column; gap: 10px; }
.insight-card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 14px;
}
.insight-card-head {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 8px;
}
.insight-card-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.insight-card-meta { flex: 1; min-width: 0; }
.insight-card-title { font-weight: 700; font-size: 14px; color: var(--ink); line-height: 1.3; }
.insight-card-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; font-weight: 500; }
.insight-card-desc { font-size: 13px; color: var(--ink-2); line-height: 1.45; margin-bottom: 10px; }
.insight-card-changes {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 10px;
}
.insight-change-pill {
  font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 2px 7px; border-radius: var(--radius-pill);
  word-break: break-all;
}
.insight-card-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ins-act {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); padding: 7px 12px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.ins-act:active { transform: scale(0.96); }
.ins-act.primary {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.ins-act.ghost {
  background: transparent; border-color: transparent; color: var(--ink-2);
}
.ins-act.ghost:hover { background: var(--bg); }

/* ===== To-do lists ===== */
.todo-row {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 4px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.todo-row:last-child { border-bottom: none; }
.todo-row:active { background: var(--bg); }
.todo-row-main { flex: 1; min-width: 0; }
.todo-row-title { font-weight: 700; font-size: 14px; color: var(--ink); line-height: 1.3; }
.todo-row-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.todo-row-bar {
  flex: 0 0 60px; height: 6px;
  background: var(--bg-soft); border-radius: var(--radius-pill);
  overflow: hidden;
}
.todo-row-bar-fill {
  height: 100%; background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width .3s ease;
}

.todo-items-list { display: flex; flex-direction: column; gap: 4px; }
.todo-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  cursor: default;
  transition: opacity .15s;
}
.todo-item.done { opacity: 0.6; }
.todo-item.done .todo-item-label { text-decoration: line-through; color: var(--ink-2); }
.todo-check {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--surface); border: 1.5px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; color: white;
  transition: background .15s, border-color .15s;
}
.todo-item.done .todo-check {
  background: var(--accent-mint); border-color: var(--accent-mint);
}
.todo-check:hover { border-color: var(--primary); }
.todo-item-main { flex: 1; min-width: 0; cursor: pointer; }
.todo-item-label { font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.35; }
.todo-item-notes { font-size: 12px; color: var(--ink-2); margin-top: 3px; }



/* ===== Dropzone IA (modal crédit) ===== */
.credit-dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-card-sm);
  padding: 20px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all .2s ease;
  margin-bottom: 10px;
}
.credit-dropzone:hover, .credit-dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.credit-dropzone-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  margin-top: 8px; letter-spacing: -0.2px;
}
.credit-dropzone-sub {
  font-size: 12px; color: var(--ink-2);
  margin-top: 4px;
}
.credit-dz-loading {
  margin-top: 12px; padding: 10px 14px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600;
  text-align: left;
}
.credit-dz-success {
  margin-top: 12px; padding: 10px 14px;
  background: var(--accent-mint-soft); color: var(--accent-mint);
  border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600;
}
.credit-dz-error {
  margin-top: 12px; padding: 10px 14px;
  background: var(--accent-coral-soft); color: var(--accent-coral);
  border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600;
}

/* ============================================================
   v13.0 — Theme picker (3 vignettes clair/sombre/système)
   ============================================================ */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.theme-opt {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 10px 10px 12px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
  font-family: inherit;
}
.theme-opt:hover { border-color: var(--primary-soft); }
.theme-opt:active { transform: scale(0.98); }
.theme-opt.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.theme-preview {
  height: 62px;
  border-radius: 10px;
  padding: 10px;
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
}
.theme-preview-light { background: #F1ECE2; }
.theme-preview-light .theme-preview-bar { background: #14141C; }
.theme-preview-dark { background: #0E0E14; }
.theme-preview-dark .theme-preview-bar { background: #F4F4F8; }
.theme-preview-system {
  background: linear-gradient(135deg, #F1ECE2 0 50%, #0E0E14 50% 100%);
}
.theme-preview-system .theme-preview-bar {
  background: linear-gradient(90deg, #14141C 0 50%, #F4F4F8 50% 100%);
}
.theme-preview-dot {
  width: 10px; height: 10px; border-radius: 50%;
  align-self: flex-start;
}
.theme-preview-bar {
  height: 4px;
  border-radius: 2px;
  opacity: 0.6;
  width: 90%;
}
.theme-preview-bar.short { width: 55%; opacity: 0.4; }
.theme-opt-label {
  font-size: 13px; font-weight: 700;
  color: var(--ink);
  text-align: center;
}
.theme-opt.active .theme-opt-label { color: var(--primary); }

/* ============================================================
   v11.7 — Sidebar brand + user : mobile = cachés (n'existent qu'en desktop)
   ============================================================ */
.sidebar-brand, .sidebar-user { display: none; }

/* v12.1 — Bouton d'action rapide dans le hero de la home */
.hero-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.2s, transform 0.15s;
}
.hero-quick-btn:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }
.hero-quick-btn:active { transform: scale(0.97); }

/* ============================================================
   v11.7 — Docs 2-pane mobile stacking (dropzone above list)
   ============================================================ */
@media (max-width: 1023px) {
  .docs-layout { display: flex; flex-direction: column; }
  .docs-pane-right { order: 0; }
  .docs-pane-left { order: 1; }
  .docs-viewer { display: none; }
}

/* ============================================================
   v12.0.2 — Mails mobile stacking : boutons + liste alignés
   ============================================================ */
@media (max-width: 1023px) {
  .mails-layout { display: flex; flex-direction: column; }
  .mails-pane-right { display: none; }
  /* Boutons et liste alignés sur le padding standard 16px */
  .mails-pane-left .large-title,
  .mails-pane-left .subtitle,
  .mails-pane-left .add-doc-zone,
  .mails-pane-left .list-group,
  .mails-pane-left #importProgress {
    margin-left: 16px !important;
    margin-right: 16px !important;
  }
}

/* ============================================================
   v11.6 — Home user bar (bottom), Charte checkbox, Responsive
   ============================================================ */

/* Home : barre utilisateur en bas — padding symétrique aligné avec les autres cards */
.home-user-bar {
  margin: 22px 16px 0;
  padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
}
.home-user-bar-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card, 18px);
  box-shadow: 0 6px 22px -12px rgba(0,0,0,0.18), 0 1px 0 rgba(0,0,0,0.02);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-align: left;
  font-family: inherit;
}
.home-user-bar-btn:hover {
  border-color: var(--primary-soft);
  box-shadow: 0 12px 30px -12px rgba(88, 101, 242, 0.24);
}
.home-user-bar-btn:active { transform: scale(0.98); }
.home-user-bar-avatar {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.home-user-bar-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.home-user-bar-name {
  font-weight: 700; font-size: 15px;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-user-bar-role {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.home-user-bar-chev {
  color: var(--ink-2);
  flex-shrink: 0;
}

/* Charte checkbox (case à cocher stylée : cream / indigo) */
.charte-check {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.charte-check:hover { border-color: var(--primary); }
.charte-check:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.charte-check:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 6px; height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.charte-check-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.charte-check-row:hover { border-color: var(--primary-soft); background: var(--bg-soft); }
.charte-check-row .dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.charte-check-row .label {
  flex: 1; font-weight: 600; font-size: 14px; color: var(--ink);
}
.charte-check-row select {
  padding: 6px 10px !important;
  font-size: 12px !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: var(--bg-soft) !important;
  color: var(--ink) !important;
  font-weight: 600;
  cursor: pointer;
  width: auto !important;
}

/* Ligne user compacte (gestion utilisateurs) */
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
}

/* ============================================================
   Responsive : tablette et desktop
   ============================================================ */

/* Tablette (768px+) — cards agrandies, KPI en 4 colonnes */
@media (min-width: 768px) {
  :root {
    --pad-x: 32px;
  }
  .screen {
    max-width: 900px;
    margin: 0 auto;
  }
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .properties-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .properties-list .property-card,
  .properties-list > * {
    margin-bottom: 0;
  }
  .hero-skyline {
    border-radius: 20px;
    margin: 0 0 20px;
    overflow: hidden;
  }
  .home-user-bar {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
  /* Modals plus larges */
  .app-modal { max-width: min(720px, 92vw); }
}

/* Desktop (1024px+) — Sidebar à gauche, grid dense, list-groups en 2 col */
@media (min-width: 1024px) {
  :root { --pad-x: 32px; --sidebar-w: 240px; --sidebar-brand-h: 72px; --sidebar-user-h: 84px; }
  body { background: var(--bg-soft); }

  /* -------- Sidebar : brand haut + tabs milieu + user bas -------- */
  /* v12.2 : fond noir pour matcher le nouveau logo MR IMMO (fond noir intégré) */
  .sidebar-brand {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: var(--sidebar-brand-h);
    display: flex; align-items: center; justify-content: center;
    padding: 6px;
    background: #121216;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    z-index: 110;
    text-decoration: none;
    transition: filter 0.2s;
    overflow: hidden;
  }
  .sidebar-brand:hover { filter: brightness(1.08); }
  .sidebar-brand img {
    max-height: 60px;
    max-width: 100%;
    width: auto;
    display: block;
    object-fit: contain;
  }
  .sidebar-user {
    position: fixed;
    left: 0; bottom: 0;
    width: var(--sidebar-w);
    padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-right: 1px solid var(--line);
    z-index: 110;
  }
  .sidebar-user-btn {
    width: 100%;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
  }
  .sidebar-user-btn:hover { border-color: var(--primary-soft); background: var(--surface); }
  .sidebar-user-btn:active { transform: scale(0.98); }
  .sidebar-user-avatar {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
  }
  .sidebar-user-info {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 1px;
  }
  .sidebar-user-name {
    font-weight: 700; font-size: 13px;
    color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sidebar-user-role {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* v13.3 : sidebar toujours visible (y compris sur la home) pour cohérence du shell */

  /* -------- Sidebar : la tab-bar devient un rail vertical à gauche -------- */
  body:not(.home-active) .tab-bar {
    position: fixed;
    top: var(--sidebar-brand-h); left: 0; right: auto;
    bottom: var(--sidebar-user-h);
    width: var(--sidebar-w);
    height: auto;
    flex-direction: column;
    padding: 18px 14px 14px;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 4px 0 30px -22px rgba(20,20,30,0.12);
    gap: 4px;
    justify-content: flex-start;
    align-items: stretch;
    transform: none !important;
    max-width: none;
    overflow-y: auto;
  }
  body:not(.home-active) .tab-bar .tab {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 14px;
    height: auto; min-height: 44px;
    gap: 12px;
    border-radius: var(--radius-btn);
  }
  body:not(.home-active) .tab-bar .tab span {
    font-size: 14px;
    text-transform: none;
    letter-spacing: -0.1px;
    font-weight: 600;
  }
  body:not(.home-active) .tab-bar .tab svg { width: 20px; height: 20px; }

  /* Décale la nav-bar et le contenu pour laisser place à la sidebar */
  body:not(.home-active) .nav-bar { left: var(--sidebar-w); }
  body:not(.home-active) .screen { padding-left: var(--sidebar-w); padding-bottom: 40px; }
  body:not(.home-active) .page {
    /* v12.1 : full width sur desktop pour utiliser tout l'espace disponible */
    max-width: none;
    padding: 24px 40px 40px;
    margin: 0;
  }
  /* Contenu bien encore lisible sur très grand écran (~1600px+) : centrer avec max-width */
  @media (min-width: 1600px) {
    body:not(.home-active) .page {
      max-width: 1440px;
      margin: 0 auto;
    }
  }
  /* v12.1 : fix Pinel overview — pas de step-cards, hero-card ne doit PAS span 2 rows */
  #page-pinel-overview > .hero-card {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }

  /* -------- Home reste centré (pas de sidebar sur la home) -------- */
  body.home-active .screen {
    max-width: 1200px;
    padding-left: 24px;
    padding-right: 24px;
    margin: 0 auto;
  }
  .properties-list { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .kpi { padding: 18px 20px; border-radius: 18px; }
  .kpi-value { font-size: 26px; }
  .hero-skyline { border-radius: 24px; min-height: 220px; }
  .hero-skyline-title { font-size: 32px; line-height: 1.15; }
  .hero-skyline-sub { font-size: 15px; }
  .property-card { display: flex; flex-direction: column; border-radius: 20px; overflow: hidden; }

  /* -------- Aperçu bien : grille 2 col, hero-card fill height -------- */
  #page-overview, #page-pinel-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: stretch;
  }
  #page-overview > .header-photo,
  #page-pinel-overview > .header-photo {
    grid-column: 1 / -1;
    border-radius: 22px;
    margin: 0;
  }
  #page-overview > .hero-card, #page-pinel-overview > .hero-card {
    grid-column: 1 / 2;
    grid-row: span 2;
    margin: 0;
    display: flex; flex-direction: column; justify-content: center;
    min-height: 0;
  }
  #page-overview > #step1Card { grid-column: 2 / 3; grid-row: auto; margin: 0; }
  #page-overview > #step2Card { grid-column: 2 / 3; grid-row: auto; margin: 0; }

  /* KPI grid, section-title et list-groups gérés en full-width sur la grille */
  #page-overview > .kpi-grid, #page-pinel-overview > .kpi-grid { grid-column: 1 / -1; }
  #page-overview > .section-title, #page-pinel-overview > .section-title {
    grid-column: 1 / -1;
    margin-top: 10px; margin-bottom: 4px;
    margin-left: 0; margin-right: 0;
  }
  /* list-groups : full width par défaut dans overview (sinon création de trous visuels) */
  #page-overview > .list-group, #page-pinel-overview > .list-group {
    grid-column: 1 / -1;
    margin: 0;
  }

  /* -------- Aperçu : force les enfants directs à même largeur / marge nulle ------- */
  #page-overview > *, #page-pinel-overview > * {
    margin-left: 0 !important; margin-right: 0 !important;
    box-sizing: border-box;
  }
  /* Conteneurs dynamiques (Suggestions IA, To-do, chantier, EDL, fiscal, tracking)
     et sur SCI/Pinel : on les met en 2 colonnes égalisées via grille */
  #pinelInsightsContainer, #pinelTodosContainer, #pinelChantierContainer,
  #pinelEdlContainer, #pinelFiscalContainer, #pinelTrackingContainer {
    margin: 0 !important;
    min-width: 0;
  }
  /* Force les .section-card à l'intérieur des containers à occuper toute la largeur du cell,
     donc à s'aligner avec les .list-group du dessus (padding 20px symétrique intégré) */
  #page-overview .section-card, #page-pinel-overview .section-card,
  #pinelInsightsContainer .section-card, #pinelTodosContainer .section-card,
  #pinelChantierContainer .section-card, #pinelEdlContainer .section-card,
  #pinelFiscalContainer .section-card, #pinelTrackingContainer .section-card {
    margin: 0 !important;
    padding: 20px 24px !important;
    height: 100%;
    box-sizing: border-box;
  }
  /* Idem pour les headers "État des lieux" hors section-card qui utilisent d'autres wrappers */
  #pinelEdlContainer > *, #pinelChantierContainer > *,
  #pinelFiscalContainer > *, #pinelTrackingContainer > * {
    margin-left: 0 !important; margin-right: 0 !important;
  }
  /* Egalise les hauteurs des cartes dynamiques */
  #page-overview > div:not(.header-photo):not(.hero-card):not(.step-card):not(.kpi-grid):not(.list-group),
  #page-pinel-overview > div:not(.header-photo):not(.hero-card):not(.kpi-grid):not(.list-group) {
    align-self: stretch;
  }
  /* Les .list-group dans l'aperçu adoptent aussi 20px 24px pour matcher les section-card */
  #page-overview > .list-group, #page-pinel-overview > .list-group { padding: 0; }

  /* -------- Pages "settings" style : 2 colonnes CSS (paquets titre+list) ------- */
  #page-settings, #page-history, #page-rp-dashboard {
    column-count: 2;
    column-gap: 24px;
  }
  #page-settings .section-title, #page-settings .list-group,
  #page-history .section-title, #page-history .list-group,
  #page-rp-dashboard .section-title, #page-rp-dashboard .list-group {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin-left: 0; margin-right: 0;
  }
  #page-settings .section-title, #page-history .section-title,
  #page-rp-dashboard .section-title { margin-top: 8px; }

  /* -------- Mails : layout 2 volets (liste gauche + preview droite) ------- */
  #page-mails { padding: 24px 32px 40px !important; }
  .mails-layout {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) 1.4fr;
    gap: 28px;
    height: calc(100vh - var(--nav-height) - var(--safe-top) - 60px);
    min-height: 0;
  }
  .mails-pane { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
  .mails-pane-left .large-title { margin: 0 0 4px; flex-shrink: 0; }
  .mails-pane-left .subtitle { margin: 0 0 16px; flex-shrink: 0; }
  .mails-pane-left .add-doc-zone { flex-shrink: 0; margin: 0 0 16px !important; }
  .mails-pane-left #importProgress { flex-shrink: 0; }
  .mails-pane-left .list-group {
    margin: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
  }
  .mails-pane-left .list-row.mail-row {
    cursor: pointer; transition: background 0.15s, border-color 0.15s;
  }
  .mails-pane-left .list-row.mail-row:hover { background: var(--bg-soft); }
  .mails-pane-left .list-row.mail-row.active {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
  }
  .mails-viewer {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card, 18px);
    overflow: hidden;
    display: flex; flex-direction: column;
    min-height: 380px;
  }
  .mails-viewer-head {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
    flex-shrink: 0;
  }
  .mails-viewer-subject {
    font-weight: 800; font-size: 16px; color: var(--ink);
    margin: 0 0 6px;
  }
  .mails-viewer-meta {
    font-size: 12px; color: var(--ink-2);
    display: flex; flex-wrap: wrap; gap: 12px;
  }
  .mails-viewer-meta strong { color: var(--ink); font-weight: 700; }
  .mails-viewer-body {
    flex: 1; overflow-y: auto;
    padding: 20px 22px;
    font-size: 14px; line-height: 1.6; color: var(--ink);
    white-space: pre-wrap; word-wrap: break-word;
  }
  .mails-viewer-attachments {
    border-top: 1px solid var(--line);
    padding: 14px 20px;
    background: var(--bg-soft);
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 8px;
  }
  .mails-viewer-attach-title {
    font-size: 11px; font-weight: 700; color: var(--ink-2);
    text-transform: uppercase; letter-spacing: 0.6px;
  }
  .mails-viewer-attach {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    font-size: 13px;
    transition: border-color 0.15s;
    cursor: pointer;
  }
  .mails-viewer-attach:hover { border-color: var(--primary); }
  .mails-viewer-attach-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .mails-viewer-attach-info { flex: 1; min-width: 0; }
  .mails-viewer-attach-name {
    font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mails-viewer-attach-meta { font-size: 11px; color: var(--ink-2); }

  /* -------- Agenda (page-todo) : layout dédié 2 colonnes équilibrées ------- */
  #page-todo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
  }
  #page-todo > .large-title, #page-todo > .subtitle { grid-column: 1 / -1; margin: 0; }
  #page-todo > .large-title { margin-top: 8px; }
  #page-todo > .subtitle { margin-bottom: 8px; color: var(--ink-2); }
  #page-todo > .section-title { grid-column: 1 / -1; margin: 12px 0 4px; }
  #page-todo > .list-group, #page-todo > #agendaCalendar,
  #page-todo > #agendaContainer, #page-todo > div { margin: 0; }
  /* agendaCalendar full width, todo list dessous en 2 col si nombreux */
  #page-todo > #agendaCalendar { grid-column: 1 / -1; }

  /* -------- Documents : layout 2 volets (liste + viewer) ------- */
  #page-docs {
    padding: 24px 32px 40px !important;
  }
  .docs-layout {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 1.4fr;
    gap: 28px;
    height: calc(100vh - var(--nav-height) - var(--safe-top) - 60px);
    min-height: 0;
  }
  .docs-pane { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
  .docs-pane-left .large-title { margin: 0 0 4px; flex-shrink: 0; }
  .docs-pane-left .subtitle { margin: 0 0 16px; flex-shrink: 0; }
  .docs-pane-left .search-bar { margin: 0 0 16px; flex-shrink: 0; }
  #dupBannerContainer { flex-shrink: 0; }
  /* La liste seule scrolle, header + recherche restent fixés en haut */
  .docs-pane-left .list-group {
    margin: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
  }
  .docs-pane-left .list-row.doc-row {
    cursor: pointer; transition: background 0.15s, border-color 0.15s;
  }
  .docs-pane-left .list-row.doc-row:hover { background: var(--bg-soft); }
  .docs-pane-left .list-row.doc-row.active {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
  }
  .docs-pane-right { gap: 16px; }
  .docs-pane-right .dropzone { margin: 0; padding: 24px; }
  .docs-viewer {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card, 18px);
    overflow: hidden;
    display: flex; flex-direction: column;
    min-height: 380px;
  }
  .docs-viewer-empty {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--ink-3);
    padding: 32px;
    gap: 14px;
    text-align: center;
  }
  .docs-viewer-empty-text { font-size: 14px; font-weight: 500; }
  .docs-viewer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-soft);
  }
  .docs-viewer-title {
    font-weight: 700; font-size: 14px;
    color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
  }
  .docs-viewer-dl {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--surface);
    color: var(--primary);
    text-decoration: none;
    border: 1px solid var(--line);
    transition: background 0.15s;
  }
  .docs-viewer-dl:hover { background: var(--primary-soft); }
  .docs-viewer-body { flex: 1; overflow: hidden; }
  .docs-viewer-body embed, .docs-viewer-body iframe { display: block; width: 100%; height: 100%; }
  .docs-viewer-img-wrap {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-soft);
    padding: 20px;
  }
  .docs-viewer-img-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }

  /* -------- Tab bar : plus de barre en bas quand on est dans un bien -------- */
  body:not(.home-active) .tab-bar {
    /* déjà stylé ci-dessus en sidebar */
  }

  /* -------- Modals plus larges -------- */
  .app-modal { max-width: min(760px, 90vw); }

  /* -------- User bar hover accentué -------- */
  .home-user-bar-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px -14px rgba(88, 101, 242, 0.35);
  }

  /* -------- Typo générale plus posée -------- */
  .large-title { font-size: 40px; }
  .subtitle { font-size: 15px; }
  .section-title { font-size: 13px; margin-top: 24px; margin-bottom: 10px; }

  /* -------- Header photo : hauteur limitée pour ne pas manger l'écran -------- */
  body:not(.home-active) .header-photo { max-height: 260px; }
}

/* Large desktop (1440px+) — utilise l'espace pour un vrai dashboard 4 colonnes */
@media (min-width: 1440px) {
  .screen { max-width: 1360px; }
  .properties-list { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================================
   v13.3 — DASHBOARD SAAS SHELL (desktop ≥ 1024px)
   Nav rail 88px icônes only + Top toolbar full-width + Home cards + Bien hero
   ============================================================================ */
@media (min-width: 1024px) {
  :root {
    --sidebar-w: 88px;     /* rail compact icônes-only */
    --sidebar-brand-h: 72px;
    --sidebar-user-h: 82px;
    --toolbar-h: 68px;     /* top toolbar persistante */
  }

  /* --- Sidebar : rail fin, icônes centrées, labels masqués (tooltip au hover) --- */
  body:not(.home-active) .tab-bar,
  body.home-active .tab-bar {
    display: flex !important;
    position: fixed;
    top: var(--sidebar-brand-h); left: 0; right: auto;
    bottom: var(--sidebar-user-h);
    width: var(--sidebar-w);
    height: auto;
    flex-direction: column;
    padding: 14px 12px;
    background: var(--surface);
    border: none;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    gap: 6px;
    align-items: stretch;
    max-width: none;
    overflow-y: auto;
  }
  /* Sur la home, tab-bar cachée par défaut par le JS (.hidden). On la re-affiche
     pour montrer un lien "Home" au moins visible (icône maison) */
  body.home-active .tab-bar.hidden { display: none !important; }

  body:not(.home-active) .tab-bar .tab,
  .tab-bar .tab {
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 12px 0 !important;
    height: auto;
    min-height: 56px;
    gap: 4px;
    border-radius: var(--radius-btn);
    position: relative;
  }
  .tab-bar .tab span {
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px !important;
    text-transform: uppercase;
    opacity: 0.75;
  }
  .tab-bar .tab svg { width: 22px !important; height: 22px !important; }
  .tab-bar .tab.active {
    background: var(--primary-soft);
    color: var(--primary);
  }
  .tab-bar .tab.active span { opacity: 1; }

  /* Sidebar brand + user compact */
  .sidebar-brand { width: var(--sidebar-w); padding: 8px; }
  .sidebar-brand img { max-height: 52px; }
  .sidebar-user { width: var(--sidebar-w); padding: 10px 8px calc(env(safe-area-inset-bottom, 0px) + 10px); }
  .sidebar-user-btn {
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px;
    text-align: center;
  }
  .sidebar-user-avatar { width: 40px; height: 40px; font-size: 13px; }
  .sidebar-user-info { align-items: center; gap: 0; }
  .sidebar-user-name { font-size: 10px; max-width: 68px; }
  .sidebar-user-role { font-size: 9px; letter-spacing: 0.4px; }

  /* --- Top toolbar : nav-bar full-width toujours visible sur desktop --- */
  body .nav-bar {
    left: var(--sidebar-w) !important;
    right: 0;
    height: var(--toolbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: block !important;   /* force visible même sur home */
  }
  body.home-active .nav-bar { display: block !important; }
  body .nav-content { height: var(--toolbar-h); padding: 0 32px; gap: 16px; }
  body .nav-title {
    font-size: 22px !important;
    font-weight: 800 !important;
    letter-spacing: -0.4px !important;
    text-align: left !important;
    color: var(--ink) !important;
    justify-content: flex-start !important;
    flex: 1;
  }
  body .nav-btn.nav-back {
    background: var(--bg-soft);
    box-shadow: none;
    color: var(--ink);
  }

  /* Content pousse sous la toolbar */
  body:not(.home-active) .screen,
  body.home-active .screen {
    padding-left: var(--sidebar-w) !important;
    padding-top: var(--toolbar-h) !important;
  }
  body .page { padding: 28px 32px 48px; }

  /* --- HOME : dashboard SaaS avec KPI ring cards + property grid --- */
  body.home-active #page-properties .hero-skyline {
    display: none;   /* remplacé par toolbar + KPI cards ci-dessous */
  }
  body.home-active #page-properties .large-title {
    font-size: 32px !important;
    font-weight: 800 !important;
    letter-spacing: -0.6px !important;
    margin: 8px 0 4px !important;
    color: var(--ink);
  }
  body.home-active #page-properties .subtitle {
    font-size: 14px !important;
    color: var(--ink-2) !important;
    margin: 0 0 24px !important;
  }
  body.home-active #page-properties .section-title {
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-3);
    margin: 24px 0 14px !important;
    font-weight: 700;
  }

  /* KPI card style dashboard (fond blanc, ombre douce, radius 20px, padding généreux) */
  body.home-active .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
  body.home-active .kpi {
    padding: 22px 24px !important;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px !important;
    box-shadow: 0 1px 3px rgba(20,20,30,0.03), 0 8px 24px -14px rgba(20,20,30,0.08);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
  }
  body.home-active .kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20,20,30,0.05), 0 14px 32px -16px rgba(91,95,224,0.2);
  }
  body.home-active .kpi::before {
    content: "";
    position: absolute;
    top: -30px; right: -30px;
    width: 90px; height: 90px;
    background: radial-gradient(circle, var(--primary-soft) 0%, transparent 70%);
    opacity: 0.6;
    pointer-events: none;
  }
  body.home-active .kpi-label {
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: var(--ink-3) !important;
    margin-bottom: 8px !important;
  }
  body.home-active .kpi-value {
    font-size: 26px !important;
    font-weight: 800 !important;
    letter-spacing: -0.6px !important;
    color: var(--ink) !important;
    line-height: 1.1;
  }
  body.home-active .kpi:nth-child(2)::before { background: radial-gradient(circle, var(--accent-mint-soft) 0%, transparent 70%); }
  body.home-active .kpi:nth-child(3)::before { background: radial-gradient(circle, var(--accent-coral-soft) 0%, transparent 70%); }
  body.home-active .kpi:nth-child(4)::before { background: radial-gradient(circle, var(--accent-amber-soft) 0%, transparent 70%); }

  /* Properties list : grille 3-4 colonnes, cards épurées */
  body.home-active .properties-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
  body.home-active .property-card {
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(20,20,30,0.03), 0 8px 24px -14px rgba(20,20,30,0.08);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
  }
  body.home-active .property-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(20,20,30,0.05), 0 20px 40px -16px rgba(91,95,224,0.25);
  }

  /* --- FICHE BIEN : hero cover + info row --- */
  body:not(.home-active) .header-photo {
    max-height: 220px !important;
    margin: 0 0 20px !important;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(20,20,30,0.04), 0 12px 30px -18px rgba(20,20,30,0.15);
  }
  body:not(.home-active) .header-photo-title {
    font-size: 24px !important;
    font-weight: 800;
    letter-spacing: -0.4px;
  }
  body:not(.home-active) .header-photo-sub {
    font-size: 13px;
    opacity: 0.9;
  }

  /* Hero-card (aperçu) : style dashboard KPI */
  body:not(.home-active) .hero-card {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    border-radius: 20px !important;
    padding: 24px 28px !important;
    box-shadow: 0 1px 3px rgba(20,20,30,0.03), 0 8px 24px -14px rgba(20,20,30,0.08);
  }
  body:not(.home-active) .hero-label {
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    color: var(--ink-3) !important;
    font-weight: 700 !important;
  }
  body:not(.home-active) .hero-amount {
    font-size: 40px !important;
    font-weight: 800 !important;
    letter-spacing: -1px !important;
    color: var(--ink) !important;
    margin: 6px 0 !important;
    line-height: 1.05;
  }
  body:not(.home-active) .hero-status {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    background: var(--primary-soft);
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }

  /* Step cards (LMNP) : plus doux */
  body:not(.home-active) .step-card {
    background: var(--surface) !important;
    border-radius: 20px !important;
    padding: 22px 24px !important;
    box-shadow: 0 1px 3px rgba(20,20,30,0.03), 0 8px 24px -14px rgba(20,20,30,0.08);
  }

  /* Section titles compactes dans fiche bien */
  body:not(.home-active) .section-title {
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-3);
    font-weight: 700;
    margin: 14px 0 10px !important;
  }
}

/* Dark mode : ajustements ombres pour le shell dashboard */
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .hero-card,
html[data-theme="dark"] .step-card,
html[data-theme="dark"] .property-card,
html[data-theme="dark"] .header-photo,
html[data-theme="dark"] .section-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px -14px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] .nav-bar {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--line);
}

/* ============================================================================
   v13.3 — POLISH transversal (toutes tailles écran)
   ============================================================================ */

/* Ligne "danger" dans list-group (ex: "Effacer la conversation", "Supprimer") :
   apparence pilule discrète au lieu d'un lien texte rouge nu */
.list-group .list-row[style*="var(--ios-red)"],
.list-group button.list-row .row-title[style*="var(--ios-red)"] {
  color: var(--accent-coral) !important;
}
.list-group button.list-row:has(.row-title[style*="var(--ios-red)"]):hover {
  background: var(--accent-coral-soft) !important;
}

/* Section-title uppercase style dashboard partout */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* list-group : bordure + fond surface (pas de bord tranchant blanc en dark) */
.list-group {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(20,20,30,0.03);
}
html[data-theme="dark"] .list-group,
html[data-theme="system"] .list-group {
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
@media (prefers-color-scheme: light) {
  html[data-theme="system"] .list-group {
    box-shadow: 0 1px 3px rgba(20,20,30,0.03);
  }
}

/* Native inputs (date, email, password, tel, url) : fond cohérent avec la charte */
.list-row input[type="date"],
.list-row input[type="email"],
.list-row input[type="password"],
.list-row input[type="tel"],
.list-row input[type="url"],
.list-row input[type="number"],
.list-row input[type="text"],
.list-row select {
  color-scheme: light dark;
}

/* Focus visible cohérent partout (indigo soft ring) */
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* v13.5 — Inputs éditables dans list-row : subtle background pour révéler l'input */
.list-row.editable input:not([type="date"]):not(.date-picker),
.list-row.editable textarea {
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.list-row.editable input:not([type="date"]):not(.date-picker):hover,
.list-row.editable textarea:hover {
  border-color: var(--line);
}
.list-row.editable input:not([type="date"]):not(.date-picker):focus,
.list-row.editable textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Empty states élégants (list-row.static.empty) */
.list-row.static.empty {
  padding: 32px 20px !important;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-btn);
  background: transparent;
}
.list-row.static.empty .row-sub {
  color: var(--ink-3) !important;
  font-size: 13px;
  font-weight: 500;
}

/* Home desktop : mini welcome banner compact remplaçant l'ancien hero-skyline */
@media (min-width: 1024px) {
  body.home-active #page-properties::before {
    content: attr(data-welcome);
    display: block;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--primary);
    margin-bottom: 4px;
  }
  /* Ajuste la première section-title pour ne pas être trop collée au haut */
  body.home-active #page-properties > .section-title:first-of-type {
    margin-top: 0 !important;
  }
  /* Column-count des Réglages : gap plus généreux et pas de casse au milieu d'une card */
  #page-settings, #page-history, #page-rp-dashboard {
    column-gap: 32px !important;
  }
  #page-settings .list-group, #page-history .list-group, #page-rp-dashboard .list-group,
  #page-settings .section-card, #page-history .section-card, #page-rp-dashboard .section-card {
    margin-bottom: 20px !important;
  }
}

/* Subtitle : tighter */
.subtitle {
  color: var(--ink-2);
  font-weight: 500;
  line-height: 1.5;
}

/* section-card : cohérence complète (padding, radius, ombre) */
.section-card {
  transition: box-shadow 0.15s;
}
.section-card:hover {
  box-shadow: 0 4px 12px rgba(20,20,30,0.06);
}
html[data-theme="dark"] .section-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Boutons secondaires dans les cards : plus de contraste en dark */
html[data-theme="dark"] .btn-secondary {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}
