/* ============================================================
   ImmoGest - Couche de design centralisee
   Chemin : assets/css/ui.css   (chargee APRES le <style> de index.html)

   REGLE : tout changement transverse (couleurs, animations, arrondis,
   responsive, accessibilite) se fait ICI, a un seul endroit.
   Principes : Apple HIG (reponse immediate, mouvement interruptible,
   materiaux translucides, retenue) + UI/UX Pro Max (contraste 4.5:1,
   cibles 44px, focus visible, reduced-motion).
   ============================================================ */

/* ---------- 1. Jetons de design ---------------------------------- */
:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0f0f13;
  --surface: #17171e;
  --surface2: #1e1e28;
  --surface3: #272735;
  --border: #2e2e3f;
  --border-strong: #44445a;

  /* Texte : --muted releve (4.3:1 -> 5.7:1 sur --surface) */
  --text: #ececf4;
  --muted: #9494b0;

  /* Marque et etats */
  --accent: #c9a84c;
  --accent2: #e8c97a;
  --accent-ink: #14110a;          /* texte sur fond --accent (9:1) */
  --green: #4caf82;
  --red: #f26d6d;                 /* 5.2:1 sur --surface2 (etait 4.3:1) */
  --blue: #6e9bff;

  /* Forme */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* Elevation (echelle unique) */
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 6px 20px rgba(0,0,0,.35);
  --shadow-3: 0 24px 64px rgba(0,0,0,.55);

  /* Mouvement : ressorts amortis (pas de rebond sauf geste a elan) */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
  --dur-press: 100ms;
  --dur-fast: 160ms;
  --dur: 240ms;
  --dur-slow: 340ms;

  /* Focus */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Espacement (pas de 4px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  --sidebar-w: 248px;
  --touch: 44px;
}

/* ---------- 2. Base et typographie ------------------------------- */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Chiffres a chasse fixe : les montants s'alignent et ne "sautent" pas */
td, th, .stat-value, .pay-amount, .recap-val, .badge, input[type="number"], input[type="month"], input[type="date"] {
  font-variant-numeric: tabular-nums;
}
/* Pistage optique : serre sur les grands titres, ouvre sur les petits libelles */
.page-title   { font-size: 20px; letter-spacing: -.012em; line-height: 1.2; }
.section-title{ letter-spacing: -.008em; }
.stat-value   { letter-spacing: -.02em; line-height: 1.1; }
.logo h1      { letter-spacing: -.01em; }
.stat-label, th, .nav-section, .form-group label, .recap-label, .login-field label { letter-spacing: .06em; }

a { color: var(--accent); text-underline-offset: 3px; }
::selection { background: rgba(201,168,76,.35); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -64px; z-index: 20000;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  padding: 10px 16px; border-radius: var(--radius-sm);
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus { top: 12px; }

/* Actions d'ecriture masquees pour les profils lecture seule (le serveur les refuse de toute facon) */
body[data-role="demo"] [data-requires="write"],
body[data-role="consultation"] [data-requires="write"] { display: none !important; }

/* ---------- 3. Focus visible (jamais supprime) -------------------- */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 8px; }
/* Cibles de focus programmatique (titre de page, fenetre) : pas d'anneau, le lecteur d'ecran suffit */
[tabindex="-1"]:focus-visible, .page-title:focus-visible, main:focus-visible { box-shadow: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(201,168,76,.28);
  border-color: var(--accent) !important;
}

/* ---------- 4. Barre laterale ------------------------------------ */
.sidebar { width: var(--sidebar-w); transition: transform var(--dur-slow) var(--ease-sheet); }
.main { margin-left: var(--sidebar-w); }
.logo { padding: 24px 22px 18px; }

.nav-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 24px); margin: 14px 12px 4px; min-height: 42px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: var(--radius-sm);
  font: 600 14px/1 'DM Sans', system-ui, sans-serif; cursor: pointer;
  box-shadow: 0 4px 14px rgba(201,168,76,.22);
  transition: transform var(--dur-press) var(--ease-out), background var(--dur-fast), box-shadow var(--dur-fast);
}
.nav-cta:hover  { background: var(--accent2); }
.nav-cta:active { transform: scale(.97); }
.nav-cta svg { width: 16px; height: 16px; }

.nav { padding: 8px 12px 16px; }
.nav-item {
  position: relative; min-height: 40px; padding: 9px 12px;
  border-radius: var(--radius-sm); font-size: 14px; user-select: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast), transform var(--dur-press) var(--ease-out);
}
.nav-item:active { transform: scale(.98); }
.nav-item.active { background: rgba(201,168,76,.14); color: var(--accent2); }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item .icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; font-size: 16px; }
.nav-item .icon svg, .nav-cta svg, .quick-action .qa-icon svg, .btn svg {
  width: 18px; height: 18px; stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.nav-section { padding: 18px 12px 6px; font-size: 10px; font-weight: 600; }
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--red); color: #1b0707; font-size: 11px; font-weight: 700; text-align: center;
}
.sidebar-footer { padding: 12px; }
.user-pill { background: var(--surface2); }

/* ---------- 5. Barre superieure : materiau translucide ------------- */
.topbar {
  padding: 14px 32px; min-height: 64px; gap: 12px;
  background: rgba(23,23,30,.72);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
          backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 28px 32px 56px; max-width: 1480px; }
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: var(--touch); height: var(--touch); flex: none;
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.nav-scrim {
  position: fixed; inset: 0; z-index: 90; background: rgba(6,6,10,.6);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease-out);
}
.nav-scrim.show { opacity: 1; pointer-events: auto; }

/* ---------- 6. Boutons ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; line-height: 1.1; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform var(--dur-press) var(--ease-out), background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast), opacity var(--dur-fast);
}
.btn:active, .action-btn:active, .quick-action:active, .stat-card[onclick]:active, .prop-card:active, .doc-item:active { transform: scale(.97); }
.btn-primary { color: var(--accent-ink); box-shadow: 0 2px 10px rgba(201,168,76,.18); }
.btn-ghost:hover { background: rgba(201,168,76,.08); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(242,109,109,.45); }
.btn-danger:hover { background: rgba(242,109,109,.12); border-color: var(--red); }
.btn:disabled, .btn[disabled], .login-btn:disabled {
  opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none;
}
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.25); border-top-color: currentColor; color: var(--accent-ink);
  animation: ui-spin .7s linear infinite;
}
.btn-ghost.is-loading::after { color: var(--accent); border-color: rgba(201,168,76,.25); border-top-color: var(--accent); }
@keyframes ui-spin { to { transform: rotate(360deg); } }

.action-btn {
  min-height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; touch-action: manipulation;
  transition: transform var(--dur-press) var(--ease-out), border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.action-btn:hover { background: rgba(201,168,76,.08); }

/* ---------- 7. Cartes, tableaux, badges ---------------------------- */
.stat-card, .payment-card, .calendar-card, .table-wrap, .prop-card, .doc-item {
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.stat-card { transition: border-color var(--dur-fast), transform var(--dur-press) var(--ease-out), box-shadow var(--dur-fast); }
.stat-card[onclick], .prop-card[onclick], .doc-item, [onclick][style*="cursor:pointer"] { cursor: pointer; }
.stat-card:hover, .prop-card:hover { box-shadow: var(--shadow-2); }
.prop-card { transition: border-color var(--dur-fast), transform var(--dur) var(--ease-out), box-shadow var(--dur-fast); }
.prop-card:hover { transform: translateY(-3px); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
th { font-size: 11px; font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--surface2); z-index: 1; }
td { vertical-align: middle; }
tbody tr { transition: background var(--dur-fast); }
.badge { font-weight: 600; white-space: nowrap; }
.badge-red  { background: rgba(242,109,109,.16); }
.step-item.done .step-circle { color: #06210f; }  /* contraste (blanc sur vert = 2.7:1) */

.tabs { border-radius: var(--radius-sm); }
.tab { min-height: 32px; display: inline-flex; align-items: center; padding: 6px 14px; transition: background var(--dur-fast), color var(--dur-fast); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface3); box-shadow: var(--shadow-1); }

.alert { border-radius: var(--radius-sm); line-height: 1.45; }

/* ---------- 8. Formulaires --------------------------------------- */
.form-group input, .form-group select, .form-group textarea,
.search-bar input, #loyers-mois, #contrats-filtre {
  min-height: 40px; border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.form-group textarea { resize: vertical; min-height: 84px; }
.form-group input::placeholder, .form-group textarea::placeholder, .search-bar input::placeholder { color: var(--muted); opacity: .75; }
.form-group input:hover, .form-group select:hover, .form-group textarea:hover { border-color: var(--border-strong); }
.form-group input:user-invalid, .form-group select:user-invalid, .form-group textarea:user-invalid { border-color: var(--red) !important; }
.form-group input:disabled, .form-group select:disabled { opacity: .55; cursor: not-allowed; }
.form-error { color: var(--red); font-size: 12px; margin-top: 6px; }
.form-hint  { color: var(--muted); font-size: 12px; margin-top: 6px; }
.login-field label, .form-group label { font-weight: 600; }

/* ---------- 9. Fenetres modales : feuille ancree + scrim ----------- */
.modal-overlay {
  background: rgba(6,6,10,.62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 16px; overscroll-behavior: contain;
}
.modal-overlay.open .modal { animation: ui-modal-in var(--dur-slow) var(--ease-sheet); }
.modal-overlay.closing .modal { animation: ui-modal-out 140ms ease-in forwards; }
.modal-overlay.closing { opacity: 0; transition: opacity 140ms ease-in; }
.modal { max-width: 100%; border-radius: 18px; box-shadow: var(--shadow-3); }
.modal-header { position: sticky; top: 0; background: var(--surface); z-index: 2; padding: 20px 24px 14px; }
.modal-footer { position: sticky; bottom: 0; background: var(--surface); z-index: 2; }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-press);
}
.modal-close:hover { background: var(--surface2); }
.modal-close:active { transform: scale(.92); }
@keyframes ui-modal-in  { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ui-modal-out { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- 10. Transitions de page ------------------------------- */
.page.active { animation: ui-page-in var(--dur-slow) var(--ease-out); }
@keyframes ui-page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 11. Notifications (toasts) ----------------------------- */
#toast-region {
  position: fixed; right: 20px; bottom: 20px; z-index: 10050;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none; max-width: min(420px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  background: rgba(30,30,40,.92); color: var(--text);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--tone, var(--green));
  border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow-2);
  font-size: 14px; line-height: 1.4;
  animation: ui-toast-in var(--dur-slow) var(--ease-sheet);
}
.toast.out { animation: ui-toast-out 160ms ease-in forwards; }
.toast .toast-ico { flex: none; width: 18px; height: 18px; margin-top: 1px; stroke: var(--tone, var(--green)); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast.error   { --tone: var(--red); }
.toast.warning { --tone: var(--accent); }
.toast.info    { --tone: var(--blue); }
.toast .toast-x { margin-left: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
@keyframes ui-toast-in  { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ui-toast-out { to   { opacity: 0; transform: translateY(6px); } }

/* ---------- 12. Recherche globale ---------------------------------- */
.search-bar { position: relative; }
.search-bar::before { display: none; }          /* l'emoji est remplace par une icone SVG */
.search-bar .search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; pointer-events: none;
}
.search-bar input { padding-left: 36px; width: 240px; transition: width var(--dur) var(--ease-out), border-color var(--dur-fast), box-shadow var(--dur-fast); }
.gsearch-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(420px, calc(100vw - 32px)); z-index: 300;
  background: rgba(30,30,40,.96); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-3); padding: 6px; max-height: 60vh; overflow-y: auto;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  animation: ui-toast-in var(--dur) var(--ease-sheet);
}
.gsearch-group { padding: 8px 10px 4px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.gsearch-item {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.gsearch-item[aria-selected="true"], .gsearch-item:hover { background: rgba(201,168,76,.14); }
.gsearch-item .gs-main { font-size: 14px; font-weight: 600; }
.gsearch-item .gs-sub  { font-size: 12px; color: var(--muted); }
.gsearch-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 13. Actions rapides du tableau de bord ----------------- */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.quick-action {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  min-height: 68px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; cursor: pointer; box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-press) var(--ease-out);
}
.quick-action:hover { border-color: var(--accent); background: rgba(201,168,76,.06); }
.quick-action .qa-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(201,168,76,.14); color: var(--accent);
}
.quick-action .qa-icon svg { width: 20px; height: 20px; }
.quick-action .qa-title { font-size: 14px; font-weight: 600; line-height: 1.2; }
.quick-action .qa-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.quick-action.is-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.quick-action.is-primary .qa-icon { background: rgba(20,17,10,.14); color: var(--accent-ink); }
.quick-action.is-primary .qa-sub { color: rgba(20,17,10,.72); }
.quick-action.is-primary:hover { background: var(--accent2); }

/* Etats vides et chargement */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .es-title { color: var(--text); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 37%, var(--surface2) 63%); background-size: 400% 100%; animation: ui-shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes ui-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 14. Connexion ------------------------------------------ */
.login-wrap { border-radius: 22px; }
.login-form-panel h2 { letter-spacing: -.015em; }
.login-input-wrap input { font-size: 16px; min-height: 48px; }
.login-btn { min-height: 48px; transition: transform var(--dur-press) var(--ease-out), background var(--dur-fast), box-shadow var(--dur-fast); color: var(--accent-ink); }
.login-btn:hover { transform: none; }
.login-btn:active { transform: scale(.98); }
.login-error-msg { line-height: 1.4; }
.input-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; right: 6px !important; border-radius: 8px; }
.login-forgot { min-height: 32px; display: inline-flex; align-items: center; background: none; border: 0; font-family: inherit; }

/* ---------- 15. Responsive ------------------------------------------ */
@media (max-width: 1200px) {
  .stats-grid, .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .prop-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 288px; }
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-3); z-index: 100; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; min-height: 60px; padding-top: max(10px, env(safe-area-inset-top)); flex-wrap: wrap; }
  .topbar .page-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
  .topbar-actions { gap: 8px; }
  .content { padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
  .search-bar input, .search-bar input:focus { width: 100%; min-width: 150px; }
  .search-bar { flex: 1 1 100%; order: 5; }
  .topbar-actions { flex: 1 1 100%; order: 6; justify-content: stretch; }
  .topbar-actions > * { flex: 1 1 auto; }
  .topbar-actions .search-bar { flex: 1 1 100%; }
  .form-row, [style*="grid-template-columns:1fr 1fr"], [style*="grid-template-columns:2fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr 1fr !important; }
  .doc-list { grid-template-columns: 1fr; }
  table { min-width: 680px; }

  /* Modales : feuille qui monte du bas, geste de retour par le bouton visible */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100% !important; max-width: 100% !important; max-height: 92dvh !important; border-radius: 20px 20px 0 0; border-bottom: 0; }
  .modal-overlay.open .modal { animation: ui-sheet-in var(--dur-slow) var(--ease-sheet); }
  .modal-overlay.closing .modal { animation: ui-sheet-out 180ms ease-in forwards; }
  .modal-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 140px; }

  /* Assistant en etapes : defilement horizontal plutot que debordement */
  #page-location [style*="display:flex"][style*="align-items:center"]:has(.step-item) { overflow-x: auto; padding-bottom: 6px; }

  /* Connexion : une seule colonne */
  .login-wrap { grid-template-columns: 1fr; width: 100%; max-width: 440px; min-height: 0; border-radius: 20px; }
  .login-visual { display: none; }
  .login-form-panel { padding: 32px 24px; }
}

@media (max-width: 600px) {
  .stats-grid, .quick-actions, [style*="grid-template-columns:repeat(4,1fr)"], [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 22px; }
  .prop-grid { grid-template-columns: 1fr; }
  .quick-action { min-height: 60px; padding: 12px; gap: 10px; }
  .quick-action .qa-sub { display: none; }
  #toast-region { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); align-items: stretch; max-width: none; }
}

@keyframes ui-sheet-in  { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ui-sheet-out { to   { transform: translateY(100%); } }

/* Ecrans tactiles : cibles de 44px minimum, champs a 16px (pas de zoom iOS) */
@media (pointer: coarse) {
  .btn, .tab, .nav-item, .quick-action, .modal-close, .login-forgot { min-height: var(--touch); }
  .action-btn { min-height: var(--touch); min-width: var(--touch); }
  .form-group input, .form-group select, .form-group textarea, .search-bar input, #loyers-mois, #contrats-filtre { min-height: var(--touch); font-size: 16px; }
  .nav-item { padding: 11px 12px; }
}

/* ---------- 16. Accessibilite et preferences systeme ---------------- */
/* Mouvement reduit : on garde un fondu doux, on retire translations, ressorts et echelles */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .page.active { animation: ui-fade 150ms linear !important; }
  .modal-overlay.open .modal, .toast, .gsearch-panel { animation: ui-fade 150ms linear !important; }
  .btn:active, .action-btn:active, .quick-action:active, .nav-item:active, .prop-card:hover { transform: none !important; }
  .skeleton { animation: none; }
}
@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }

/* Transparence reduite : materiaux pleins */
@media (prefers-reduced-transparency: reduce) {
  .topbar, .toast, .gsearch-panel { background: var(--surface2); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .modal-overlay { background: rgba(0,0,0,.82); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Navigateurs sans backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--surface); }
  .toast, .gsearch-panel { background: var(--surface2); }
}
/* Contraste renforce */
@media (prefers-contrast: more) {
  :root { --border: #5a5a74; --muted: #b4b4cc; }
  .badge, .btn-ghost, .action-btn { border: 1px solid currentColor; }
}
@media print {
  .sidebar, .topbar-actions, .nav-toggle, #toast-region, .quick-actions { display: none !important; }
  .main { margin-left: 0; }
}
