/* ============================================================ Polices (hébergées localement) */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree.woff2") format("woff2");
  font-weight: 300 900; font-display: swap;
}

/* ============================================================ Jetons */
:root {
  --ink: #1B2638;          /* menu, logo */
  --ink-2: #26344C;
  --ink-text: #C9D2E0;
  --paper: #EEF1F5;        /* fond */
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --line: #DCE2EA;
  --text: #1B2638;
  --muted: #5F6B7C;
  --brass: #E7AE3C;        /* accent clé */
  --brass-deep: #9A6A0E;
  --brass-soft: #FBF0D6;
  --link: #2E5AAC;
  --primary-bg: #1B2638;
  --primary-fg: #FFFFFF;
  --live: #23794F;  --live-soft: #DFF1E7;
  --soon: #2E5AAC;  --soon-soft: #E3EBF8;
  --ended: #5F6B7C; --ended-soft: #E7EBF0;
  --danger: #B5432F; --danger-soft: #F8E4E0;
  --focus: 0 0 0 3px rgba(231, 174, 60, .55);
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #0E141E; --ink-2: #1A2333; --ink-text: #B8C3D4;
    --paper: #121822; --surface: #1A2230; --surface-2: #1F2837;
    --line: #2B3647; --text: #E6EAF0; --muted: #95A1B3;
    --brass-deep: #E7AE3C; --brass-soft: #3A2F17; --link: #8DB0F0;
    --primary-bg: #E7AE3C; --primary-fg: #1B2638;
    --live: #6CCB9A; --live-soft: #1C3328;
    --soon: #8DB0F0; --soon-soft: #1E2A42;
    --ended: #A3AEBF; --ended-soft: #252F3F;
    --danger: #F08A76; --danger-soft: #3A221E;
    color-scheme: dark;
  }
}

/* ============================================================ Transitions entre pages */
@view-transition { navigation: auto; }
/* Appli installée sur l'écran d'accueil : iOS repeint la barre d'état en blanc pendant
   une transition de page. On la remplace par un simple fondu du contenu. */
@media (display-mode: standalone) {
  @view-transition { navigation: none; }
  html.navigated .page { animation: page-in .28s var(--ease) both; }
}
html.standalone.navigated .page { animation: page-in .28s var(--ease) both; }
.sidebar { view-transition-name: sidebar; }
.mobilebar { view-transition-name: mobilebar; }
.page { view-transition-name: page; }
.auth-card { view-transition-name: auth-card; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(page) { animation: page-out .18s var(--ease) both; }
::view-transition-new(page) { animation: page-in .32s var(--ease) both; }
@keyframes page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }

/* ============================================================ Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
@media (max-width: 900px) { html:not(:has(body.auth)) { background: linear-gradient(var(--ink) 0 50%, var(--paper) 50%); } }
html:has(body.auth) { background: var(--ink); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 16px/1.55 var(--body); font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.015em; margin: 0; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.35rem); line-height: 1.1; }
h2 { font-size: 1.15rem; line-height: 1.3; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 3px; }
strong { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
svg.ico { width: 20px; height: 20px; flex: none; }

/* ============================================================ Structure : menu à gauche */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 300px; z-index: 30;
  display: flex; flex-direction: column; gap: 22px;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background: var(--ink); color: var(--ink-text);
}
.main { margin-left: 300px; min-width: 0; }
.page { max-width: 980px; margin: 0 auto; padding: 44px 48px 72px; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand img { border-radius: 10px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.08rem; color: #fff; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: .8rem; color: var(--ink-text); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a, .me {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--ink-text); text-decoration: none; font-weight: 550;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.side-nav a:hover, .me:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--brass);
  transform: scaleY(0); transition: transform .35s var(--ease);
}
.side-nav a.active { background: var(--ink-2); color: #fff; }
.side-nav a.active::before { transform: scaleY(1); }
.side-nav a.active svg { color: var(--brass); }

.side-foot { display: flex; align-items: center; gap: 6px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.me { flex: 1; min-width: 0; padding: 8px 10px; }
.me.active { background: var(--ink-2); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: .8rem; font-weight: 450; opacity: .75; }
.sidebar .icon-btn { color: var(--ink-text); }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar .side-close, .mobilebar, .scrim { display: none; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brass); color: var(--ink);
  font: 700 .85rem/1 var(--display); letter-spacing: .02em;
}
.avatar.sm { width: 30px; height: 30px; font-size: .72rem; border: 2px solid var(--surface); }
.avatar.sm + .avatar.sm { margin-left: -8px; }

/* ---- mobile : menu escamotable */
@media (max-width: 900px) {
  .sidebar {
    width: min(86vw, 320px); transform: translateX(-102%);
    transition: transform .38s var(--ease), box-shadow .38s;
  }
  body.menu-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 25; background: rgba(14, 20, 30, .45);
    opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
  }
  body.menu-open .scrim { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
  .sidebar .side-close { display: inline-grid; }
  .main { margin-left: 0; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
    background: var(--ink); color: var(--ink-text);
  }
  .mobilebar .brand-name { font-size: 1rem; }
  .mobilebar .icon-btn { color: #fff; }
  .page { padding: 26px calc(16px + env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
}

/* ============================================================ Apparition de la page (un seul moment) */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
html:not(.navigated) .page > * { animation: rise .55s var(--ease) both; }
html:not(.navigated) .page > *:nth-child(2) { animation-delay: .05s; }
html:not(.navigated) .page > *:nth-child(3) { animation-delay: .1s; }
html:not(.navigated) .page > *:nth-child(4) { animation-delay: .15s; }
html:not(.navigated) .page > *:nth-child(5) { animation-delay: .2s; }
html:not(.navigated) .page > *:nth-child(n+6) { animation-delay: .25s; }

/* ============================================================ En-têtes et blocs */
.page-head { margin-bottom: 30px; }
.page-head .lead { margin-top: 8px; }
.page-head.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lead { color: var(--muted); max-width: 62ch; }
.back {
  display: inline-flex; align-items: center; gap: 4px; margin: -8px 0 14px -6px; padding: 4px 8px 4px 2px;
  color: var(--muted); text-decoration: none; font-weight: 550; font-size: .92rem; border-radius: 8px;
}
.back:hover { color: var(--text); }
.back svg { transition: transform .25s var(--ease); }
.back:hover svg { transform: translateX(-3px); }
.block { margin-top: 34px; }
.block > h2 { margin-bottom: 14px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.block-head .lead { flex: 1 1 320px; }
.empty {
  padding: 26px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-align: center; list-style: none;
}
.note { font-size: .875rem; color: var(--muted); }
.top-gap { margin-top: 14px; }

/* ============================================================ Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 .93rem/1 var(--body); padding: 11px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .2s, border-color .2s, transform .12s var(--ease), box-shadow .2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.btn.primary:hover { box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--primary-bg) 80%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:not(.ghost) { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .2s, color .2s, transform .12s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }

/* ============================================================ Formulaires */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
.hint { font-weight: 450; color: var(--muted); font-size: .82rem; }
.field input + .hint { margin-top: -1px; }
.center { display: flex; justify-content: center; }
input:not([type=checkbox]):not([type=radio]):not([type=file]) {
  font: 450 1rem/1.3 var(--body); color: var(--text);
  padding: 11px 13px; width: 100%; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]):focus {
  outline: none; border-color: var(--brass); background: var(--surface); box-shadow: var(--focus);
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.panel.narrow { max-width: 520px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { flex: 1 1 200px; width: auto !important; }

/* interrupteurs */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; font-size: .9rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 40px; height: 24px; border-radius: 999px; flex: none;
  background: var(--line); transition: background .25s var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s var(--ease);
}
.switch input:checked + .switch-track { background: var(--live); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.switch input:disabled + .switch-track { opacity: .4; }
.switch input:disabled ~ .switch-label { opacity: .5; }
.switch-row { display: flex; gap: 22px; flex-wrap: wrap; }

.choice { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; padding: 0; }
@media (max-width: 560px) { .choice { grid-template-columns: 1fr; } }
.radio-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); transition: border-color .2s, background .2s;
}
.radio-card > span { display: flex; flex-direction: column; gap: 2px; }
.radio-card input { accent-color: var(--ink); margin-top: 3px; }
.radio-card:has(input:checked) { border-color: var(--brass); background: var(--brass-soft); }

/* ============================================================ Panneaux dépliables */
.reveal {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows .4s var(--ease), opacity .3s var(--ease), margin .4s var(--ease);
}
.reveal > * { overflow: hidden; min-height: 0; }
.reveal.is-open { grid-template-rows: 1fr; opacity: 1; }
.page > .reveal.is-open, .block > .reveal.is-open, .tab-body > .reveal.is-open { margin-bottom: 22px; }
.reveal > .panel { overflow: hidden; }

/* ============================================================ Pastilles d'état */
.pill {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap;
  background: var(--ended-soft); color: var(--ended);
}
.pill svg { width: 14px; height: 14px; }
.pill.big { font-size: .88rem; padding: 6px 14px; }
.pill.live { background: var(--live-soft); color: var(--live); }
.pill.soon { background: var(--soon-soft); color: var(--soon); }
.pill.closed { background: var(--danger-soft); color: var(--danger); }
.pill.brass { background: var(--brass-soft); color: var(--brass-deep); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2.4s ease-in-out infinite; }
.pill.live:has(svg)::before { display: none; }
@keyframes pulse { 50% { opacity: .35; } }
.sep { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; margin: 0 8px; vertical-align: middle; }

/* ============================================================ Dossiers */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.folder {
  display: flex; align-items: flex-start; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: border-color .25s var(--ease);
}
.folder:hover { border-color: color-mix(in srgb, var(--text) 35%, var(--line)); }
.folder-ico {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); transition: transform .35s var(--ease), background .25s;
}
.folder-ico svg { width: 23px; height: 23px; }
.folder:hover .folder-ico { transform: rotate(-6deg) scale(1.06); }
.folder.droppable .folder-ico { background: var(--brass-soft); color: var(--brass-deep); }
.folder { align-items: center; }
.folder-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.folder-name, .folder-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-name { font-weight: 650; font-size: 1.02rem; }
.folder-meta { font-size: .84rem; color: var(--muted); }
.flag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; font-size: .76rem; font-weight: 650; vertical-align: 1px; }
.flag.awaited { background: var(--brass-soft); color: var(--brass-deep); }
.flag.closed { background: var(--danger-soft); color: var(--danger); }
.flag.unseen { background: var(--soon-soft); color: var(--soon); }
.folder.has-unseen .folder-ico { position: relative; }
.folder.has-unseen .folder-ico::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--soon); border: 2px solid var(--surface); animation: pop .4s .4s var(--ease) both;
}
.file.unseen { background: linear-gradient(90deg, color-mix(in srgb, var(--soon) 7%, transparent), transparent 60%); }
.file.unseen .file-name { font-weight: 700; }
.file:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.file:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.file:only-child { border-radius: var(--radius); }
.file-name .flag { margin-right: 8px; }
.seen-by { display: inline-flex; align-items: center; gap: 4px; color: var(--live); cursor: help; }
.seen-by svg { width: 14px; height: 14px; }

/* ============================================================ Locations */
.leases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lease {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px;
  padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; position: relative; overflow: hidden;
  transition: border-color .25s var(--ease), transform .25s var(--ease);
}
.lease::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.lease.live::before { background: var(--live); }
.lease.soon::before { background: var(--soon); }
.lease.closed { opacity: .72; }
.lease:hover { border-color: color-mix(in srgb, var(--text) 35%, var(--line)); transform: translateX(3px); }
.lease-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lease-name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.lease-dates { display: flex; align-items: center; gap: 7px; font-size: .88rem; color: var(--muted); flex-wrap: nowrap; min-width: 0; white-space: nowrap; }
.lease-dates > span:first-of-type { overflow: hidden; text-overflow: ellipsis; }
.lease-dates .flag { margin: 0 0 0 4px; flex: none; }
.lease-dates svg { width: 16px; height: 16px; }
.people { display: flex; align-items: center; }
.lease .pill { align-self: center; }
@media (max-width: 600px) {
  .lease { grid-template-columns: 1fr auto; row-gap: 10px; }
  .lease .people { grid-row: 2; }
}

/* occupants / propriétaires */
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.person-row { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; flex-wrap: wrap; }
.person-text { display: flex; flex-direction: column; flex: 1; min-width: 140px; line-height: 1.35; }
.person-name { font-weight: 650; }
.person-tools { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 16px; border-top: 1px solid var(--line); }

/* ============================================================ Fichiers */
.drop { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.drop-zone {
  position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 20px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface);
  transition: border-color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease);
}
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-zone:hover, .drop.dragging .drop-zone { border-color: var(--brass); background: var(--brass-soft); }
.drop.dragging .drop-zone { transform: scale(1.01); }
.drop-zone:focus-within { box-shadow: var(--focus); }
.drop-ico {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: var(--brass-soft); color: var(--brass-deep); transition: transform .35s var(--ease);
}
.drop.dragging .drop-ico, .drop-zone:hover .drop-ico { transform: translateY(-4px); }
.drop-hint { font-size: .8rem; color: var(--muted); max-width: 46ch; }
.drop-files { font-size: .88rem; font-weight: 600; color: var(--text); }

.files { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.file { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 16px; }
.file + .file { border-top: 1px solid var(--line); }
.file-ico { position: relative; display: grid; place-items: center; color: var(--muted); flex: none; }
.file-ico svg { width: 34px; height: 34px; stroke-width: 1.4; }
.file-ext {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  font: 800 .52rem/1 var(--body); text-transform: uppercase; padding: 2px 3px; border-radius: 3px;
  background: var(--ended); color: var(--surface);
}
.file-ico[data-ext=pdf] .file-ext { background: var(--danger); }
.file-ico[data-ext=jpg] .file-ext, .file-ico[data-ext=jpeg] .file-ext, .file-ico[data-ext=png] .file-ext,
.file-ico[data-ext=heic] .file-ext, .file-ico[data-ext=webp] .file-ext { background: var(--live); }
.file-ico[data-ext=doc] .file-ext, .file-ico[data-ext=docx] .file-ext, .file-ico[data-ext=odt] .file-ext { background: var(--soon); }
.file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-meta { font-size: .82rem; color: var(--muted); }
.file-actions { display: flex; gap: 2px; flex: none; }
.file-actions form { margin: 0; }

/* ============================================================ Réglages */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 30px; width: fit-content; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto;
}
.tabs a {
  padding: 9px 16px; border-radius: 9px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .92rem; white-space: nowrap; transition: background .25s var(--ease), color .2s;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--primary-bg); color: var(--primary-fg); }
.tab-body > .block:first-of-type { margin-top: 10px; }

.settings-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.setting { display: grid; grid-template-columns: 1fr minmax(200px, 300px); gap: 24px; align-items: center; padding: 22px 24px; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting-title { font-weight: 650; font-size: 1rem; }
.setting-desc { margin-top: 4px; font-size: .88rem; color: var(--muted); max-width: 58ch; }
.settings-actions { padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; }
@media (max-width: 680px) { .setting { grid-template-columns: 1fr; gap: 12px; padding: 18px; } }
.suffix-input { position: relative; }
.suffix-input input { padding-right: 64px !important; }
.suffix-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }

.frows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.frow + .frow { border-top: 1px solid var(--line); }
.frow-main { display: grid; grid-template-columns: 1fr auto auto auto; gap: 22px; align-items: center; padding: 14px 12px 14px 18px; margin: 0; }
.frow-name { display: flex; flex-direction: column; min-width: 0; }
.switch-spacer { width: 92px; }
.frow-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 4px 18px 16px; }
.frow-tools form { margin: 0; }
.frow-tools .inline-form { flex: 1 1 280px; }
@media (max-width: 600px) {
  .frow-main { grid-template-columns: 1fr auto; row-gap: 12px; column-gap: 16px; }
  .frow-main .frow-name { grid-column: 1 / -1; }
  .frow-main .icon-btn { grid-row: 1; grid-column: 2; justify-self: end; }
  .frow-main .frow-name { grid-column: 1; }
  .switch-spacer { display: none; }
}

.danger-zone {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 12px; padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
}

/* ============================================================ Pages de connexion */
body.auth {
  min-height: 100vh; background: var(--ink);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(231, 174, 60, .14), transparent 40%),
    radial-gradient(circle at 90% 85%, rgba(46, 90, 172, .25), transparent 45%);
}
.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 40px 16px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; animation: rise .6s var(--ease) both; }
.auth-brand img { border-radius: 18px; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5); animation: settle .9s var(--ease) both; }
@keyframes settle { from { transform: translateY(-14px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.auth-title { font: 700 1.5rem/1.1 var(--display); color: #fff; letter-spacing: -.015em; }
.auth-sub { color: var(--ink-text); font-size: .95rem; }
.auth-card {
  width: 100%; max-width: 420px; padding: 30px; border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .55);
  display: flex; flex-direction: column; gap: 16px; animation: rise .6s .1s var(--ease) both;
}
.auth-card h1 { font-size: 1.6rem; }
.code-input {
  text-align: center; font: 700 1.6rem/1 var(--display) !important; letter-spacing: .4em;
  padding: 14px 10px 14px calc(10px + .4em) !important;
}
.code-input.sm { font-size: 1.1rem !important; letter-spacing: .25em; max-width: 160px; flex: 0 0 160px !important; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-size: .95rem; }
.steps li::marker { font-weight: 700; color: var(--brass-deep); }
.qr { margin: 12px 0 4px; display: flex; justify-content: center; }
.qr img { border-radius: 12px; background: #fff; padding: 6px; border: 1px solid var(--line); animation: pop .5s .3s var(--ease) both; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.manual summary { cursor: pointer; color: var(--link); font-size: .9rem; font-weight: 550; }
.manual p { margin-top: 8px; }
.secret { display: block; margin-top: 6px; padding: 10px; border-radius: 8px; background: var(--surface-2); font-size: .95rem; letter-spacing: .06em; word-break: break-all; }
.codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.codes code { display: block; text-align: center; padding: 10px 6px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 1rem; font-weight: 600; letter-spacing: .05em; }
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ============================================================ Notifications */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px 12px 16px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .35); font-weight: 550; font-size: .93rem;
  animation: toast-in .5s var(--ease) both;
}
.toast > span:nth-child(2) { flex: 1; }
.toast-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); flex: none; }
.toast.error .toast-dot { background: var(--danger); }
.toast-x { border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; }
.toast-x svg { width: 16px; height: 16px; }
.toast-x:hover { background: var(--surface-2); }
.toast.leaving { animation: toast-out .35s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@media (max-width: 600px) { .toasts { top: auto; bottom: 16px; right: 16px; left: 16px; max-width: none; } }

/* ============================================================ Documents attendus */
.pill.awaited { background: var(--brass-soft); color: var(--brass-deep); }
.pill.awaited::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brass); animation: pulse 1.8s ease-in-out infinite; }
.pill.quiet { background: transparent; color: var(--muted); padding-left: 0; font-weight: 550; }
.folder.awaited { border-color: color-mix(in srgb, var(--brass) 55%, var(--line)); }
.folder.awaited .folder-ico { background: var(--brass-soft); color: var(--brass-deep); }
.lease-main .pill { margin-top: 4px; }
.awaited-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
  padding: 16px 18px; border-radius: var(--radius); background: var(--brass-soft);
  border: 1px solid color-mix(in srgb, var(--brass) 45%, transparent);
}
.awaited-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--brass); color: var(--ink); flex: none; animation: nudge 2.6s var(--ease) infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 78% { transform: translateY(-3px); } 86% { transform: none; } 92% { transform: translateY(-1.5px); } }
.awaited-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 200px; }
.awaited-banner form { margin: 0; }
.request-line { margin-bottom: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.request-line .reveal { width: 100%; }
.request-line .reveal.is-open { margin-top: 12px; }

/* ============================================================ Erreurs de formulaire */
.form-error {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: .92rem;
  animation: rise .35s var(--ease) both;
}
.form-error svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.auth-card.has-error { animation: rise .6s .1s var(--ease) both, shake .45s .5s var(--ease); }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
input[aria-invalid=true] { border-color: color-mix(in srgb, var(--danger) 60%, var(--line)) !important; }

/* ============================================================ Popup de confirmation */
.modal {
  border: 0; padding: 28px 28px 22px; width: min(440px, calc(100vw - 32px)); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgba(10, 16, 28, .55);
  opacity: 0; transform: translateY(14px) scale(.96);
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.modal.show { opacity: 1; transform: none; }
.modal::backdrop { background: rgba(14, 20, 30, 0); backdrop-filter: blur(0); transition: background .3s, backdrop-filter .3s; }
.modal.show::backdrop { background: rgba(14, 20, 30, .5); backdrop-filter: blur(3px); }
.modal-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; }
.modal.show .modal-ico { animation: pop .45s .1s var(--ease) both; }
.modal-ico svg { width: 24px; height: 24px; }
.modal h2 { font-size: 1.3rem; margin-bottom: 8px; }
.modal p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:hover { box-shadow: 0 6px 18px -8px var(--danger); }
.sub-actions { padding-top: 12px; border-top: 1px dashed var(--line); }
.section-sub { margin: -8px 0 12px; }

/* ============================================================ Journal */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.select { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); flex: 1 1 180px; max-width: 260px; }
.select select {
  font: 500 .95rem/1.2 var(--body); color: var(--text); padding: 10px 34px 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F6B7C' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  appearance: none; cursor: pointer;
}
.select select:focus { outline: none; border-color: var(--brass); box-shadow: var(--focus); }
.log-day { font-size: .95rem; color: var(--muted); font-weight: 650; margin: 26px 0 10px; font-family: var(--body); letter-spacing: 0; }
.log-day:first-child { margin-top: 0; }
.log-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.log-row { display: grid; grid-template-columns: 46px 30px 1fr auto; gap: 12px; align-items: center; padding: 11px 16px; }
.log-row + .log-row { border-top: 1px solid var(--line); }
.log-time { font-variant-numeric: tabular-nums; font-size: .88rem; color: var(--muted); font-weight: 600; }
.log-row .avatar.sm { border: 0; }
.avatar.owner { background: var(--ink); color: var(--brass); }
.avatar.ghost { background: var(--ended-soft); color: var(--muted); }
@media (prefers-color-scheme: dark) { .avatar.owner { background: var(--ink-2); } }
.log-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-what { font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.log-what > span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; margin: 0 7px; vertical-align: middle; }
.log-file { color: var(--text); font-weight: 550; }
.log-device { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.log-device svg { width: 16px; height: 16px; }
.tag { font-size: .74rem; font-weight: 650; padding: 2px 8px; border-radius: 6px; background: var(--ended-soft); color: var(--ended); }
.tag.consultations { background: var(--soon-soft); color: var(--soon); }
.tag.depots { background: var(--live-soft); color: var(--live); }
.tag.suppressions, .tag.warn { background: var(--danger-soft); color: var(--danger); }
.tag.administration { background: var(--brass-soft); color: var(--brass-deep); }
@media (max-width: 600px) {
  .log-row { grid-template-columns: 30px 1fr; row-gap: 4px; padding: 12px 14px; }
  .log-time { grid-column: 2; grid-row: 2; font-size: .78rem; }
  .log-row .avatar { grid-row: 1 / span 2; align-self: start; }
  .log-device { grid-column: 2; grid-row: 2; justify-self: end; }
  .filters { gap: 8px; margin-bottom: 20px; }
  .select { max-width: none; flex-basis: 100%; }
  .select > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 22px; }

/* ============================================================ Mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(page), ::view-transition-new(page) { animation: none; }
}
