/* ═══════════════ CRM Auto — styles ═══════════════ */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --border: #e3e7ee;
  --border-strong: #cfd6e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8391a7;
  --primary: #2563eb;
  --primary-soft: #e8efff;
  --primary-text: #1d4ed8;
  --green: #16a34a; --green-soft: #e7f7ed;
  --red: #dc2626; --red-soft: #fdecec;
  --orange: #d97706; --orange-soft: #fdf3e2;
  --purple: #7c3aed; --purple-soft: #f1ebff;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #16213a; --border: #22304b; --border-strong: #2f4063;
    --text: #e6ebf4; --text-2: #aab6ca; --text-3: #71809b;
    --primary: #4f86ff; --primary-soft: #1a2a4f; --primary-text: #8fb1ff;
    --green: #34c26b; --green-soft: #12301f; --red: #f26060; --red-soft: #3a1717;
    --orange: #f0a43a; --orange-soft: #37280f; --purple: #a78bfa; --purple-soft: #2a2145;
    --sidebar: #080d1a; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #16213a; --border: #22304b; --border-strong: #2f4063;
  --text: #e6ebf4; --text-2: #aab6ca; --text-3: #71809b;
  --primary: #4f86ff; --primary-soft: #1a2a4f; --primary-text: #8fb1ff;
  --green: #34c26b; --green-soft: #12301f; --red: #f26060; --red-soft: #3a1717;
  --orange: #f0a43a; --orange-soft: #37280f; --purple: #a78bfa; --purple-soft: #2a2145;
  --sidebar: #080d1a; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-text); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }
#sidebar { width: 236px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; display: grid; place-items: center; font-weight: 800; overflow: hidden; flex-shrink: 0; }
.brand-logo img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #8391a7; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin: 14px 8px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-text); margin-bottom: 1px; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.active { background: rgba(59,130,246,.18); color: #fff; }
.nav a .ico { width: 20px; text-align: center; }
.nav a .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.1); padding: 1px 7px; border-radius: 10px; }
.nav a .count.alert { background: var(--red); color: #fff; }
.sidebar-foot { padding: 12px 16px calc(12px + var(--safe-b)); font-size: 12px; color: #8391a7; display: flex; align-items: center; gap: 8px; border-top: 1px solid rgba(255,255,255,.06); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.sync-dot.busy { background: #f59e0b; } .sync-dot.off { background: #ef4444; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar { position: sticky; top: 0; z-index: 30; display: flex; gap: 12px; align-items: center; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
#view { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }
.search-box { position: relative; flex: 1; max-width: 560px; }
.search-box input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); padding: 0 12px 0 34px; outline: none; }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-ico { position: absolute; left: 11px; top: 9px; color: var(--text-3); font-size: 17px; }
#search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(15,23,42,.18); max-height: 70vh; overflow-y: auto; padding: 6px; }
.sr-item { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.sr-item:hover, .sr-item.active { background: var(--surface-2); }
.sr-type { font-size: 10px; text-transform: uppercase; color: var(--text-3); width: 62px; flex-shrink: 0; }

#bottom-nav { display: none; }
.only-mobile { display: none !important; }

/* ── Titres de page ── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 750; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--text-3); margin-top: 3px; }
.back-link { display: inline-flex; gap: 6px; color: var(--text-2); margin-bottom: 10px; font-size: 13px; }

/* ── Boutons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-text); border-color: var(--primary-text); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ai { background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; border: 0; }
.btn-ai:hover { filter: brightness(1.08); background: linear-gradient(135deg, #7c3aed, #2563eb); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 18px; display: grid; place-items: center; }

/* ── Cartes ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-title { font-weight: 700; font-size: 15px; margin: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.stat { padding: 16px 18px; }
.stat-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.stat-value { font-size: 28px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; }
.stat-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.blur-money .money { filter: blur(7px); }

.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.qa { display: flex; gap: 12px; align-items: center; padding: 14px; cursor: pointer; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
.qa:hover { border-color: var(--primary); }
.qa-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; background: var(--primary-soft); flex-shrink: 0; }
.qa-ico.ai { background: linear-gradient(135deg, #ede4ff, #dfe9ff); }
.qa b { display: block; font-size: 13.5px; }
.qa span { font-size: 12px; color: var(--text-3); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.b-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.b-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.b-orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.b-blue { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.b-purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }
.plate { display: inline-block; font-family: var(--mono); font-weight: 700; letter-spacing: .06em; font-size: 12.5px; padding: 2px 8px; border: 1.5px solid var(--text-2); border-radius: 5px; background: var(--surface); white-space: nowrap; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.toolbar { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.toolbar .input { max-width: 320px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-ico { font-size: 34px; margin-bottom: 8px; }

/* Liste en cartes (mobile) */
.list-cards { display: none; }
.lc { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); align-items: center; color: var(--text); }
.lc:last-child { border-bottom: 0; }
.lc-thumb { width: 64px; height: 48px; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; flex-shrink: 0; display: grid; place-items: center; color: var(--text-3); font-size: 20px; }
.lc-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.lc-right { text-align: right; flex-shrink: 0; }

/* ── Vignettes véhicule (grille stock) ── */
.thumb { width: 54px; height: 40px; border-radius: 7px; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--text-3); }

/* ── Formulaires ── */
.form-section { margin-bottom: 20px; }
.form-section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin: 0 0 10px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.fgrid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; position: relative; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea { width: 100%; height: 40px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); padding: 0 11px; outline: none; font-size: 14.5px; }
.textarea { height: auto; min-height: 84px; padding: 10px 11px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.filled-ai { background: var(--purple-soft); border-color: var(--purple); }
.input-lg { height: 46px; font-size: 17px; font-weight: 700; }
.check { display: flex; gap: 9px; align-items: center; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.suggest { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(15,23,42,.16); z-index: 20; max-height: 220px; overflow-y: auto; margin-top: 4px; }
.suggest div { padding: 8px 11px; cursor: pointer; }
.suggest div:hover, .suggest div.active { background: var(--primary-soft); }
.help { font-size: 12px; color: var(--text-3); }

.ai-banner { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 12px; background: linear-gradient(135deg, #f3edff, #e9f0ff); border: 1px solid #d9ccff; margin-bottom: 18px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ai-banner { background: linear-gradient(135deg, #231b3d, #172647); border-color: #3b2f66; } }
:root[data-theme="dark"] .ai-banner { background: linear-gradient(135deg, #231b3d, #172647); border-color: #3b2f66; }
.ai-banner .ai-ico { font-size: 26px; }
.ai-banner b { display: block; }
.ai-banner span { font-size: 12.5px; color: var(--text-2); }
.ai-status { font-size: 12.5px; margin-top: 8px; }

/* ── Photos / fichiers ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2) center/cover no-repeat; border: 1px solid var(--border); cursor: zoom-in; }
.photo .photo-del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(15,23,42,.72); color: #fff; cursor: pointer; font-size: 12px; }
.photo .photo-main { position: absolute; left: 6px; bottom: 6px; font-size: 10.5px; background: rgba(15,23,42,.72); color: #fff; padding: 2px 7px; border-radius: 6px; }
.add-tile { aspect-ratio: 4 / 3; border: 2px dashed var(--border-strong); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--text-3); background: var(--surface-2); font-size: 12px; }
.add-tile:hover { border-color: var(--primary); color: var(--primary-text); }
.add-tile big { font-size: 24px; }
.gallery-hero { aspect-ratio: 16 / 10; border-radius: 12px; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--text-3); font-size: 44px; cursor: zoom-in; }
.gallery-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; }
.gallery-strip div { width: 74px; height: 56px; flex-shrink: 0; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; cursor: pointer; border: 2px solid transparent; }
.gallery-strip div.active { border-color: var(--primary); }

.doc-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: 0; }
.doc-thumb { width: 46px; height: 46px; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; flex-shrink: 0; font-size: 20px; border: 1px solid var(--border); cursor: pointer; }
.checklist { display: flex; flex-direction: column; }
.ck { display: flex; gap: 10px; align-items: flex-start; padding: 9px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.ck:last-child { border-bottom: 0; }
.ck-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; font-weight: 800; }
.ck.ok .ck-ico { background: var(--green-soft); color: var(--green); }
.ck.ko .ck-ico { background: var(--red-soft); color: var(--red); }
.ck.warn .ck-ico { background: var(--orange-soft); color: var(--orange); }

/* ── Alertes ── */
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.alert-item:last-child { border-bottom: 0; }
.alert-item:hover { background: var(--surface-2); }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.lvl-danger .alert-dot { background: var(--red); }
.lvl-warn .alert-dot { background: var(--orange); }
.lvl-info .alert-dot { background: var(--primary); }
.alert-title { font-weight: 600; }
.alert-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* ── Onglets ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary-text); border-bottom-color: var(--primary); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
.kv > div { padding: 10px 16px; border-bottom: 1px solid var(--border); min-width: 0; }
.kv dt { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.kv dd { margin: 3px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.money-box { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--border); border-radius: 10px; overflow: hidden; }
.money-box > div { background: var(--surface); padding: 12px 14px; }
.money-box .l { font-size: 11px; color: var(--text-3); text-transform: uppercase; font-weight: 650; }
.money-box .v { font-size: 17px; font-weight: 750; margin-top: 3px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 760px; box-shadow: 0 24px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; animation: pop .16s; }
.modal.sm { max-width: 460px; } .modal.lg { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); border-radius: 16px 16px 0 0; z-index: 2; }
.modal-title { font-size: 17px; font-weight: 700; margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 96vw; max-height: 90vh; object-fit: contain; }
.lightbox iframe { width: 92vw; height: 88vh; border: 0; background: #fff; border-radius: 8px; }
.lb-btn { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255,255,255,.14); border: 0; width: 42px; height: 42px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; background: rgba(255,255,255,.14); border: 0; width: 46px; height: 46px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lb-prev { left: 14px; } .lb-next { right: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }

/* ── Toasts ── */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 13.5px; max-width: 380px; animation: pop .2s; }
.toast.error { background: #b91c1c; }
.toast.ok::before { content: "✓  "; color: #4ade80; font-weight: 800; }

/* ── Connexion ── */
#auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, #1e3a8a 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #4c1d95 0%, transparent 55%), #0b1120; }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border-radius: 18px; padding: 30px 26px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 800; margin-bottom: 16px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p { margin: 0 0 20px; color: var(--text-3); }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-3); }
.auth-err { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; }

.progress { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .3s; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.counter { font-size: 11.5px; color: var(--text-3); text-align: right; }
.counter.over { color: var(--red); font-weight: 700; }
.preview-cerfa { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; font-size: 13px; }

/* ═══════════════ Mobile ═══════════════ */
@media (max-width: 900px) {
  .only-mobile { display: grid !important; }
  .only-desktop { display: none !important; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform .22s ease; width: 270px; }
  #app.menu-open #sidebar { transform: none; }
  #app.menu-open #sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  #topbar { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  #view { padding: 16px 12px calc(96px + var(--safe-b)); }
  .page-title { font-size: 21px; }
  .grid-2, .grid-3, .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .qa { flex-direction: column; align-items: flex-start; gap: 8px; }
  .fgrid, .fgrid-3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .money-box { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-value { font-size: 23px; }
  .hide-mobile { display: none !important; }
  .table-desktop { display: none; }
  .list-cards { display: block; }
  /* Fenêtres plein écran : fond opaque, aucun défilement ni transparence vers la page de derrière */
  .modal-overlay { padding: 0; align-items: stretch; background: var(--surface); overscroll-behavior: contain; height: 100dvh; animation: none; }
  .modal, .modal.sm, .modal.lg { max-width: none; min-height: 100dvh; border-radius: 0; box-shadow: none; animation: none; }
  body.modal-open { position: fixed; left: 0; right: 0; overflow: hidden; }
  body.modal-open #bottom-nav { display: none; }
  .modal-head { border-radius: 0; padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .modal-foot { border-radius: 0; padding-bottom: calc(14px + var(--safe-b)); }
  .modal-foot .btn { flex: 1; }
  .toolbar .input { max-width: none; }
  #toasts { left: 12px; right: 12px; bottom: calc(84px + var(--safe-b)); align-items: stretch; }
  .toast { max-width: none; }
  #bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + var(--safe-b)); justify-content: space-around; align-items: center; }
  #bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--text-3); padding: 4px 8px; position: relative; min-width: 58px; }
  #bottom-nav a span { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: .7; }
  #bottom-nav a.active { color: var(--primary-text); font-weight: 650; }
  #bottom-nav a.active span { filter: none; opacity: 1; }
  #bottom-nav .fab { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 26px; box-shadow: 0 6px 18px rgba(37,99,235,.45); margin-top: -18px; cursor: pointer; }
  .nav-badge { position: absolute; top: 0; right: 10px; background: var(--red); color: #fff; font-size: 10px; border-radius: 10px; padding: 0 5px; }
  .input, .select, .textarea { font-size: 16px; } /* évite le zoom iOS */
}

@media print {
  #sidebar, #topbar, #bottom-nav, .no-print { display: none !important; }
  #view { padding: 0; }
  .card { box-shadow: none; }
}
