/* =============================================================
   DYWANES — feuille de style unique du back-office
   Charte : Atlantique #0C4C8B · Nuit #0A2A4A · Laiton #B08D57
   Motif signature : le double trait croisé du logo (plan d'architecte)
   ============================================================= */

/* ---------- 1. Jetons ---------- */
:root {
  /* Couleurs de base */
  --atlantique: #0C4C8B;
  --atlantique-600: #0A4178;
  --atlantique-700: #083563;
  --atlantique-50: #EEF4FA;
  --atlantique-100: #DCE8F4;
  --nuit: #0A2A4A;
  --nuit-2: #0E3459;
  --laiton: #B08D57;
  --laiton-clair: #E9DCC4;
  --calcaire: #F2F4F7;
  --blanc: #FFFFFF;
  --encre: #16212E;
  --encre-2: #45536A;
  --encre-3: #6B7889;
  --trait: #DEE3EA;
  --trait-fort: #C9D1DC;

  /* États */
  --succes: #1E7356;   --succes-bg: #E6F3EE;
  --alerte: #A3630F;   --alerte-bg: #FBF1E2;
  --danger: #B42318;   --danger-bg: #FCEBEA;
  --info:   var(--atlantique); --info-bg: var(--atlantique-50);

  /* Typo */
  --f-ui: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-display: "Bodoni Moda", "Didot", Georgia, serif;
  --t-xs: .75rem; --t-sm: .8125rem; --t-base: .9375rem; --t-md: 1.0625rem;
  --t-lg: 1.375rem; --t-xl: 1.875rem; --t-2xl: 2.5rem;

  /* Espaces (base 4) */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem;

  /* Rayons : hiérarchisés, pas un seul pour tout */
  --r-sm: 6px;   /* champs, boutons */
  --r-md: 10px;  /* panneaux */
  --r-lg: 16px;  /* écrans de connexion, modales */

  --ombre-1: 0 1px 2px rgba(10, 42, 74, .06);
  --ombre-2: 0 8px 24px -8px rgba(10, 42, 74, .18), 0 2px 4px rgba(10, 42, 74, .05);
  --ombre-3: 0 24px 48px -16px rgba(10, 42, 74, .32);

  --sidebar-w: 264px;
  --topbar-h: 72px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-ui);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--encre);
  background: var(--calcaire);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--atlantique); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { flex-shrink: 0; }

:focus-visible { outline: 2px solid var(--atlantique); outline-offset: 2px; border-radius: 4px; }
.sidebar :focus-visible { outline-color: var(--laiton-clair); }

.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 100;
  background: var(--atlantique); color: #fff; padding: var(--s2) var(--s4); border-radius: var(--r-sm);
}
.skip-link:focus { top: var(--s4); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Structure : barre latérale + contenu ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--nuit);
  color: #C9D6E5;
  /* Doubles traits du logo, en filigrane dans l'angle bas */
  background-image:
    linear-gradient(var(--nuit-2), var(--nuit-2)), linear-gradient(var(--nuit-2), var(--nuit-2)),
    linear-gradient(var(--nuit-2), var(--nuit-2)), linear-gradient(var(--nuit-2), var(--nuit-2));
  background-size: 1px 220px, 1px 220px, 220px 1px, 220px 1px;
  background-position: 36px 100%, 41px 100%, 0 calc(100% - 96px), 0 calc(100% - 91px);
  background-repeat: no-repeat;
}
.sidebar__brand { display: flex; align-items: center; justify-content: space-between; padding: var(--s5) var(--s5) var(--s4); }
.sidebar__brand img { width: 132px; height: auto; }
.sidebar .sidebar__close { display: none; color: #fff; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 0 var(--s3) var(--s4); scrollbar-width: thin; scrollbar-color: var(--nuit-2) transparent; }
.nav-group + .nav-group { margin-top: var(--s5); }
.nav-group__title { font-size: var(--t-xs); color: #7F95AE; padding: 0 var(--s3); margin-bottom: var(--s2); font-weight: 500; }
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.nav-link {
  position: relative;
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s3); border-radius: var(--r-sm);
  color: #C9D6E5; font-weight: 500; font-size: var(--t-base);
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.is-active { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--laiton);
}
.nav-link.is-active .icon { color: var(--laiton-clair); }
.nav-link--soon { color: #6E86A1; cursor: default; }
.nav-link > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link--soon em {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 500;
  color: #8EA3BA; border: 1px solid #2A4A6C; border-radius: 999px; padding: 0 7px; line-height: 18px;
}

.sidebar__foot {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3); margin: 0 var(--s3) var(--s3);
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.me-card { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border-radius: var(--r-sm); color: #fff; }
.me-card:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.me-card__text { min-width: 0; display: grid; line-height: 1.3; }
.me-card__text strong { font-weight: 600; font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-card__text small { color: #8EA3BA; font-size: var(--t-xs); }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s6);
  background: rgba(242, 244, 247, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.is-scrolled { border-bottom-color: var(--trait); }
.topbar .topbar__menu { display: none; }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: var(--t-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__back { display: inline-flex; align-items: center; gap: 2px; font-size: var(--t-sm); color: var(--encre-3); font-weight: 500; }
.topbar__back:hover { color: var(--atlantique); text-decoration: none; }
.topbar__actions { display: flex; align-items: center; gap: var(--s2); }

.content { flex: 1; padding: var(--s5) var(--s6) var(--s7); width: 100%; max-width: 1280px; outline: none; }

/* ---------- 4. Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-weight: 600; font-size: var(--t-base); line-height: 1; white-space: nowrap;
  cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--atlantique); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, var(--ombre-1); }
.btn--primary:hover { background: var(--atlantique-600); }
.btn--ghost { background: var(--blanc); color: var(--encre); border-color: var(--trait-fort); }
.btn--ghost:hover { border-color: var(--encre-3); }
.btn--quiet { background: transparent; color: var(--encre-2); }
.btn--quiet:hover { background: rgba(10, 42, 74, .06); }
.btn--danger { background: var(--blanc); color: var(--danger); border-color: #EBC3BF; }
.btn--danger:hover { background: var(--danger-bg); }
.btn--sm { min-height: 32px; padding: 0 var(--s3); font-size: var(--t-sm); }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .65; pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--encre-2); cursor: pointer;
}
.icon-btn:hover { background: rgba(10, 42, 74, .07); color: var(--encre); }
.icon-btn--sidebar { color: #8EA3BA; }
.icon-btn--sidebar:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ---------- 5. Panneaux ---------- */
.panel { background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--r-md); box-shadow: var(--ombre-1); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--trait); }
.panel__head h2 { font-size: var(--t-md); }
.panel__head p { color: var(--encre-3); font-size: var(--t-sm); margin-top: 2px; }
.panel__body { padding: var(--s5); }

/* ---------- 6. Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s5); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section + .form-section { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--trait); }
.form-section__title { font-size: var(--t-md); margin-bottom: 2px; }
.form-section__hint { color: var(--encre-3); font-size: var(--t-sm); margin-bottom: var(--s4); max-width: 60ch; }

.field { display: grid; gap: 6px; align-content: start; }
.field label, .field .label { font-weight: 600; font-size: var(--t-sm); color: var(--encre); }
.field label .optional { font-weight: 400; color: var(--encre-3); }
.field .hint { font-size: var(--t-xs); color: var(--encre-3); }
.field .error-text { font-size: var(--t-xs); color: var(--danger); display: flex; gap: 4px; align-items: center; }

.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  background: var(--blanc); border: 1px solid var(--trait-fort); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #9AA6B5; }
.input:hover, .select:hover { border-color: #AEB9C7; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--atlantique); box-shadow: 0 0 0 3px rgba(12, 76, 139, .15); }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background: var(--blanc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7889' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}

.input-group { position: relative; }
.input-group > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--encre-3); pointer-events: none; }
.input-group > .input { padding-left: 38px; }
.input-group .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-group:has(.reveal) > .input { padding-right: 44px; }

/* Interrupteur actif/inactif */
.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 40px; height: 24px; border-radius: 999px; background: var(--trait-fort); position: relative; transition: background .2s; flex-shrink: 0; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--ombre-1); transition: transform .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--atlantique); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--atlantique); outline-offset: 2px; }

.checkbox { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--t-sm); color: var(--encre-2); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--atlantique); }

/* Choix de rôle sous forme de cartes */
.role-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s2); }
.role-option { position: relative; cursor: pointer; }
.role-option input { position: absolute; opacity: 0; }
.role-option__card {
  display: grid; gap: 2px; height: 100%; padding: var(--s3) var(--s4);
  border: 1px solid var(--trait-fort); border-radius: var(--r-sm); background: var(--blanc);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.role-option__card strong { font-size: var(--t-sm); }
.role-option__card small { color: var(--encre-3); font-size: var(--t-xs); line-height: 1.4; }
.role-option:hover .role-option__card { border-color: #AEB9C7; }
.role-option input:checked + .role-option__card { border-color: var(--atlantique); background: var(--atlantique-50); box-shadow: 0 0 0 1px var(--atlantique) inset; }
.role-option input:focus-visible + .role-option__card { outline: 2px solid var(--atlantique); outline-offset: 2px; }

.form-actions { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--trait); background: #FAFBFC; border-radius: 0 0 var(--r-md) var(--r-md); }

/* ---------- 7. Tableaux ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--trait); }
.toolbar .input-group { flex: 1 1 260px; max-width: 360px; }
.toolbar .input, .toolbar .select { min-height: 38px; }
.toolbar .select { width: auto; min-width: 180px; }
.toolbar__count { margin-left: auto; color: var(--encre-3); font-size: var(--t-sm); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-base); }
.table th {
  text-align: left; font-weight: 500; font-size: var(--t-sm); color: var(--encre-3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--trait); background: #FAFBFC; white-space: nowrap;
}
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--trait); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #F7F9FB; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table tr.is-inactive td:not(.actions) { opacity: .55; }

.person { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.person__text { display: grid; line-height: 1.35; min-width: 0; }
.person__text strong { font-weight: 600; }
.person__text small { color: var(--encre-3); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--encre-3); }

/* ---------- 8. Badges, avatars ---------- */
.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--avatar, var(--atlantique)); color: #fff;
  font-size: var(--t-sm); font-weight: 600; letter-spacing: .02em;
}
.avatar--lg { width: 64px; height: 64px; font-size: var(--t-lg); }
.sidebar .avatar { box-shadow: 0 0 0 2px var(--nuit), 0 0 0 3px rgba(176, 141, 87, .6); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 600; line-height: 20px; white-space: nowrap;
  background: var(--calcaire); color: var(--encre-2);
}
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--succes { background: var(--succes-bg); color: var(--succes); }
.badge--alerte { background: var(--alerte-bg); color: var(--alerte); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info   { background: var(--atlantique-50); color: var(--atlantique); }
.badge--laiton { background: #F5EEE2; color: #7A5F33; }

/* ---------- 9. Tableau de bord ---------- */
.welcome {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: var(--s5);
  padding: var(--s6) var(--s6) var(--s5);
  border-radius: var(--r-md);
  color: #fff; background: var(--atlantique);
  margin-bottom: var(--s5);
}
.welcome::after { /* doubles traits du logo */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(233,220,196,.45), rgba(233,220,196,.45)) right 120px top 0 / 1px 100% no-repeat,
    linear-gradient(rgba(233,220,196,.45), rgba(233,220,196,.45)) right 126px top 0 / 1px 100% no-repeat,
    linear-gradient(rgba(233,220,196,.45), rgba(233,220,196,.45)) right 0 top 34px / 340px 1px no-repeat,
    linear-gradient(rgba(233,220,196,.45), rgba(233,220,196,.45)) right 0 top 40px / 340px 1px no-repeat;
}
.welcome__date { color: #BFD3E8; font-size: var(--t-sm); margin-bottom: var(--s2); }
.welcome h2 { font-family: var(--f-display); font-weight: 500; font-size: var(--t-2xl); letter-spacing: 0; line-height: 1.1; }
.welcome p { color: #D5E2F0; margin-top: var(--s2); max-width: 56ch; }
.welcome .btn--ghost { background: #fff; border-color: #fff; color: var(--atlantique); position: relative; z-index: 1; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.stat { padding: var(--s4) var(--s5); }
.stat__label { color: var(--encre-3); font-size: var(--t-sm); display: flex; align-items: center; gap: var(--s2); }
.stat__value { font-size: var(--t-xl); font-weight: 600; margin-top: var(--s1); letter-spacing: -.02em; }
.stat__foot { font-size: var(--t-xs); color: var(--encre-3); margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }

/* Feuille de route des lots */
.roadmap { list-style: none; margin: 0; padding: 0; }
.roadmap li { display: grid; grid-template-columns: 28px 1fr auto; gap: var(--s3); align-items: start; padding: var(--s3) 0; }
.roadmap li + li { border-top: 1px solid var(--trait); }
.roadmap__step {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 700; border: 1px solid var(--trait-fort); color: var(--encre-3); background: #fff;
}
.roadmap li.is-done .roadmap__step { background: var(--succes); border-color: var(--succes); color: #fff; }
.roadmap li.is-current .roadmap__step { background: var(--atlantique); border-color: var(--atlantique); color: #fff; box-shadow: 0 0 0 4px var(--atlantique-100); }
.roadmap strong { display: block; font-weight: 600; }
.roadmap small { color: var(--encre-3); font-size: var(--t-sm); }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: var(--s3); padding: var(--s3) 0; }
.activity li + li { border-top: 1px solid var(--trait); }
.activity .avatar { width: 30px; height: 30px; font-size: 11px; }
.activity p { font-size: var(--t-sm); }
.activity time { font-size: var(--t-xs); color: var(--encre-3); }

/* ---------- 10. États vides ---------- */
.empty-state { text-align: center; padding: var(--s7) var(--s5); color: var(--encre-2); display: grid; justify-items: center; gap: var(--s2); }
.empty-state > .icon { color: var(--atlantique); background: var(--atlantique-50); padding: 14px; width: 60px; height: 60px; border-radius: 50%; margin-bottom: var(--s2); }
.empty-state h2, .empty-state h3 { font-size: var(--t-md); color: var(--encre); }
.empty-state p { max-width: 44ch; color: var(--encre-3); margin-bottom: var(--s3); }
.empty-state--page { margin-top: 8vh; }

/* ---------- 11. Toasts ---------- */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 80; display: grid; gap: var(--s2); width: min(400px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s3) var(--s4); border-radius: var(--r-md);
  background: var(--encre); color: #fff; box-shadow: var(--ombre-3);
  animation: toast-in .35s var(--ease);
}
.toast p { flex: 1; font-size: var(--t-sm); padding-top: 1px; }
.toast--succes > .icon { color: #7FD1B0; }
.toast--erreur > .icon { color: #F4A39B; }
.toast--info > .icon { color: #9CC3EA; }
.toast__close { border: 0; background: none; color: #93A1B3; cursor: pointer; padding: 2px; border-radius: 4px; }
.toast__close:hover { color: #fff; }
.toast.is-leaving { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* Alerte en ligne (dans un formulaire) */
.notice { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-sm); font-size: var(--t-sm); }
.notice--erreur { background: var(--danger-bg); color: var(--danger); }
.notice--info { background: var(--atlantique-50); color: var(--atlantique-700); }
.notice--laiton { background: #F7F1E6; color: #6B5330; }

/* ---------- 12. Modale ---------- */
dialog.modal {
  width: min(480px, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: var(--r-lg);
  box-shadow: var(--ombre-3); color: var(--encre);
}
dialog.modal::backdrop { background: rgba(10, 42, 74, .45); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in .25s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal__body { padding: var(--s5) var(--s5) var(--s4); }
.modal__body h2 { font-size: var(--t-md); margin-bottom: var(--s2); }
.modal__body p { color: var(--encre-2); }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5) var(--s5); }

/* Mot de passe provisoire à transmettre */
.secret {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  margin-top: var(--s3); padding: var(--s3) var(--s4);
  border: 1px dashed var(--laiton); border-radius: var(--r-sm); background: #FBF8F2;
  font-size: var(--t-md); font-weight: 600; letter-spacing: .06em; font-feature-settings: "tnum" 1, "zero" 1;
}

/* ---------- 13. Écran de connexion ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: var(--blanc); }
.auth__visual {
  position: relative; overflow: hidden;
  background: var(--atlantique);
  color: #fff; padding: var(--s6) var(--s7);
  display: flex; flex-direction: column; gap: var(--s6);
}
.auth__visual img.logo { width: 210px; height: auto; position: relative; z-index: 2; margin-left: -18px; }
.auth__elevation { position: absolute; right: 0; bottom: 0; width: 88%; height: 60%; z-index: 1; }
.auth__elevation .trait { fill: none; stroke: var(--laiton-clair); stroke-width: 1; vector-effect: non-scaling-stroke; }
.auth__elevation .trait--fin { stroke-opacity: .35; }
.auth__elevation .trait--cote { stroke: #8FB4DA; stroke-opacity: .7; }
.auth__elevation text { fill: #A9C6E4; font-family: var(--f-ui); font-size: 11px; }
.auth__elevation .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.8s var(--ease) forwards; animation-delay: var(--d, 0s); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.auth__quote { position: relative; z-index: 2; max-width: 460px; }
.auth__quote p { font-family: var(--f-display); font-size: var(--t-xl); line-height: 1.2; font-weight: 500; }
.auth__quote small { display: block; margin-top: var(--s3); color: #BFD3E8; font-size: var(--t-sm); }

.auth__panel { display: grid; place-items: center; padding: var(--s6) var(--s5); }
.auth__form { width: min(380px, 100%); }
.auth__form h1 { font-size: var(--t-xl); letter-spacing: -.02em; }
.auth__form .lead { color: var(--encre-3); margin: var(--s2) 0 var(--s5); }
.auth__form .field + .field { margin-top: var(--s4); }
.auth__row { display: flex; justify-content: space-between; align-items: center; margin: var(--s4) 0 var(--s5); font-size: var(--t-sm); }
.auth__foot { margin-top: var(--s6); font-size: var(--t-xs); color: var(--encre-3); }
.auth__mobile-logo { display: none; }

/* Jauge de robustesse du mot de passe */
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.strength span { height: 4px; border-radius: 2px; background: var(--trait); transition: background .2s; }
.strength[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] span:nth-child(-n+2) { background: var(--alerte); }
.strength[data-level="3"] span:nth-child(-n+3) { background: #4C8C6F; }
.strength[data-level="4"] span { background: var(--succes); }

/* ---------- 14. Profil ---------- */
.profile-head { display: flex; align-items: center; gap: var(--s4); }
.profile-head h2 { font-size: var(--t-lg); }
.def-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); margin: 0; font-size: var(--t-sm); }
.def-list dt { color: var(--encre-3); }
.def-list dd { margin: 0; font-weight: 500; }

/* ---------- 15. Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: var(--ombre-3); }
  .sidebar.is-open { transform: none; }
  .sidebar .sidebar__close { display: inline-grid; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(10, 42, 74, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar.is-open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .shell { margin-left: 0; }
  .topbar { padding: var(--s3) var(--s4); }
  .topbar .topbar__menu { display: inline-grid; margin-left: -6px; }
  .content { padding: var(--s4) var(--s4) var(--s7); }
  .auth { grid-template-columns: 1fr; }
  .auth__visual { display: none; }
  .auth__mobile-logo { display: block; width: 140px; margin-bottom: var(--s6); }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .welcome { grid-template-columns: 1fr; padding: var(--s5); }
  .welcome h2 { font-size: var(--t-xl); }
  .stats { gap: var(--s2); }
  .stat { padding: var(--s3) var(--s4); }
  .stat__value { font-size: var(--t-lg); }
  .topbar__actions .btn span { display: none; }
  .topbar__actions .btn { padding: 0 var(--s3); }
  /* Tableau → fiches empilées */
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--trait); position: relative; }
  .table--stack td { border: 0; padding: 2px 0; }
  .table--stack td[data-label]:not(:first-child)::before { content: attr(data-label) " · "; color: var(--encre-3); font-size: var(--t-xs); }
  .table--stack td.actions { position: absolute; top: var(--s3); right: var(--s3); width: auto; }
  .toolbar .input-group { flex-basis: 100%; max-width: none; }
  .toolbar__count { width: 100%; margin-left: 0; }
  .toolbar .select { flex: 1; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .auth__elevation .draw { stroke-dashoffset: 0; }
}

/* Champ de fichier aux couleurs de la charte */
input[type="file"].input { padding: 6px; cursor: pointer; color: var(--encre-2); }
input[type="file"].input::file-selector-button {
  margin-right: var(--s3); padding: 6px 12px; border: 1px solid var(--trait-fort); border-radius: var(--r-sm);
  background: var(--calcaire); color: var(--encre); font: inherit; font-weight: 600; font-size: var(--t-sm); cursor: pointer;
}
input[type="file"].input:hover::file-selector-button { border-color: var(--encre-3); }

/* ---------- Impression (fiches EDL, etc.) ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .sidebar-backdrop, .topbar, .toasts, .no-print, dialog, .tabs { display: none !important; }
  .shell { margin: 0; }
  .content { padding: 0; max-width: none; }
  .print-only { display: block; }
  .panel { border: 0; box-shadow: none; }
  .table th { background: none; }
  a { color: inherit; text-decoration: none; }
  .signatures { display: grid !important; grid-template-columns: 1fr 1fr; gap: 24mm; margin-top: 16mm; }
  .signatures div { border-top: 1px solid var(--encre); padding-top: 2mm; min-height: 24mm; font-size: 10pt; }
}

/* ---------- Accès à l'application DYWANES CONNECT (fiche client) ---------- */
.app-access__state { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.secret--xl { justify-content: center; font-size: var(--t-xl); letter-spacing: .18em; padding: var(--s4); background: #fff; }
