/* Locataire+ 2.0 — structure et composants */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font: 400 var(--t-md)/1.5 var(--font-text); font-stretch: 100%;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: -.005em; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--violet-ink); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.ico { flex: 0 0 auto; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 2000; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; }
.skip:focus { top: 12px; }
[hidden] { display: none !important; }

/* ---------- Coquille ---------- */
.app { min-height: 100vh; }
.side { display: none; }
.main { min-width: 0; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s2);
  padding: calc(10px + env(safe-area-inset-top)) var(--s4) 10px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.top__spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); background: none; border: 0; padding: 4px; border-radius: 12px; }
.brand img { width: 34px; height: 34px; }
.brand__name { font: 750 1.3125rem/1 var(--font-display); font-stretch: 92%; letter-spacing: -.01em; }
.brand__name b { color: var(--violet); font-weight: 800; }
.top .top__add { display: none; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 50%; border: 0; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn__dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--paper); }
.avatar { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; border: 0; padding: 0; background: var(--violet-wash); display: grid; place-items: center; color: var(--violet-ink); font: 700 14px var(--font-text); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.view:focus, .view:focus-visible { box-shadow: none; }
.view { display: block; max-width: 1120px; margin: 0 auto; padding: var(--s2) var(--s4) calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); outline: none; }

/* Barre d’onglets (mobile) */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: start;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tabbar-h); border: 0; background: none; color: var(--muted);
  font: 600 .75rem/1 var(--font-text); letter-spacing: .01em;
}
.tab[aria-current="page"] { color: var(--violet-ink); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--violet); }
.tab__badge { position: absolute; top: 9px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font: 700 11px/18px var(--font-text); }
/* Le bouton + reprend la pastille du logo */
.tab--add { color: var(--ink-2); }
.tab--add .tab__plus {
  display: grid; place-items: center; width: 54px; height: 54px; margin-top: -20px; margin-bottom: 1px;
  border-radius: 50%; background: var(--violet); color: #fff;
  box-shadow: 0 0 0 4px var(--surface), 0 10px 22px -8px rgba(71, 72, 184, .8);
}
.tab--add:active .tab__plus { transform: scale(.95); }

/* ---------- Grand écran ---------- */
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 276px minmax(0, 1fr); }
  .side {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: var(--s5) var(--s3) var(--s4); background: var(--surface); border-right: 1px solid var(--line);
  }
  .side .brand { margin: 0 var(--s2) var(--s4); }
  .top { padding: var(--s4) var(--s10) var(--s2); background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; position: static; }
  .top .brand { display: none; }
  .top .top__add { display: inline-flex; }
  .view { padding: var(--s2) var(--s10) var(--s12); }
  .tabbar { display: none; }
}

/* Navigation latérale */
.nav__group + .nav__group { margin-top: var(--s4); }
.nav__title { padding: 0 var(--s3) 6px; font: 600 var(--t-xs)/1.2 var(--font-text); color: var(--muted); }
.nav__item {
  display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 8px var(--s3); border: 0; border-radius: var(--r-tile);
  background: none; color: var(--ink-2); font: 550 .9375rem/1.25 var(--font-text); text-align: left;
}
.nav__item:hover { background: var(--surface-2); }
.nav__item[aria-current="page"] { background: var(--violet-wash); color: var(--violet-ink); font-weight: 650; }
.nav__count { margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 999px; background: var(--red-wash); color: var(--red-text); font: 700 12px/1.3 var(--font-text); text-align: center; }
.side__foot { margin-top: auto; padding-top: var(--s4); }
.side__me { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 14px; background: var(--paper); text-align: left; }
.side__me strong { display: block; font-size: var(--t-sm); }
.side__me small { display: block; color: var(--muted); font-size: var(--t-xs); }

/* ---------- La plaque (adresse du logement) ---------- */
.plaque {
  position: relative; display: block; width: 100%; padding: 7px; border: 0; text-align: left; text-decoration: none;
  border-radius: var(--r-plaque); background: var(--plaque); color: var(--plaque-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -2px 0 rgba(0, 0, 0, .12), 0 14px 30px -18px rgba(62, 63, 168, .9);
  overflow: hidden;
}
.plaque::after { /* reflet de l’émail */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, 0) 38%);
}
.plaque__inner {
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: var(--s4);
  min-height: 104px; padding: 12px 18px; border: 2px solid var(--plaque-rule); border-radius: 12px;
}
.plaque__num {
  grid-row: span 2; font: 800 3.5rem/.85 var(--font-display); font-stretch: 75%; font-variation-settings: "opsz" 96;
  letter-spacing: -.02em; min-width: .9ch; text-align: center;
}
.plaque__num--icon { display: grid; place-items: center; }
.plaque__street { font: 700 1.5625rem/1.02 var(--font-display); font-stretch: 78%; font-variation-settings: "opsz" 48; overflow-wrap: anywhere; }
.plaque__city { margin-top: 4px; font: 500 var(--t-sm)/1.3 var(--font-text); opacity: .9; }
.plaque:hover .plaque__inner { border-color: #fff; }
.plaque--empty { background: transparent; color: var(--violet-ink); box-shadow: none; border: 2px dashed var(--violet); }
.plaque--empty::after { display: none; }
.plaque--empty .plaque__inner { border-color: transparent; }
.plaque--mini { padding: 4px; border-radius: 13px; margin-bottom: var(--s5); }
.plaque--mini .plaque__inner { min-height: 0; padding: 8px 10px; border-width: 1.5px; border-radius: 9px; column-gap: 10px; }
.plaque--mini .plaque__num { font-size: 1.75rem; }
.plaque--mini .plaque__street { font-size: 1rem; }
.plaque--mini .plaque__city { font-size: var(--t-xs); margin-top: 1px; }
.plaque-caption { margin-top: var(--s2); color: var(--muted); font-size: var(--t-sm); }

/* ---------- En-têtes ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s4); margin: var(--s2) 0 var(--s6); }
.page-title { font-size: var(--t-2xl); font-weight: 750; font-variation-settings: "opsz" 72; letter-spacing: -.015em; }
.page-lead { margin-top: 6px; max-width: 62ch; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
@media (min-width: 1024px) { .page-title { font-size: var(--t-3xl); } }

.sec { margin-top: var(--s8); }
.sec:first-child { margin-top: 0; }
.sec__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.sec__title { font-size: var(--t-lg); font-weight: 700; }
.sec__note { color: var(--muted); font-size: var(--t-sm); }

/* ---------- Mises en page ---------- */
.cols { display: grid; gap: var(--s8); }
.cols > * { min-width: 0; }
.stack > * + * { margin-top: var(--s3); }
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .cols--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.grid-auto { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: var(--r-ctl); border: 1px solid transparent; background: var(--surface-2); color: var(--ink);
  font: 650 .9375rem/1.2 var(--font-text); text-decoration: none; text-align: center; max-width: 100%;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--violet); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--violet-deep); }
.btn--soft { background: var(--violet-wash); color: var(--violet-ink); }
.btn--soft:hover:not(:disabled) { background: var(--violet-wash-2); }
.btn--quiet { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn--quiet:hover:not(:disabled) { background: var(--surface-2); }
.btn--danger { background: var(--red-text); color: #fff; }
:root.dark .btn--danger { background: #C2403F; }
.btn--danger-soft { background: var(--red-wash); color: var(--red-text); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: var(--t-sm); border-radius: 10px; }
.btn--block { width: 100%; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--violet-ink); font: 650 var(--t-sm)/1.3 var(--font-text); text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link--danger { color: var(--red-text); }

/* ---------- Puces d’état ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-chip);
  background: var(--surface-2); color: var(--ink-2); font: 650 var(--t-xs)/1.25 var(--font-text); white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip--plain::before { display: none; }
.chip--open { background: var(--orange-wash); color: var(--orange-text); }
.chip--done { background: var(--green-wash); color: var(--green-text); }
.chip--info { background: var(--violet-wash); color: var(--violet-ink); }
.chip--danger { background: var(--red-wash); color: var(--red-text); }

/* Filtres en pastilles */
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: var(--r-chip); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-2); font: 600 var(--t-sm)/1 var(--font-text);
}
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Listes groupées ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.item {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  width: 100%; padding: 14px var(--s4); border: 0; background: none; color: inherit; text-align: left; text-decoration: none;
}
.item--no-icon { grid-template-columns: minmax(0, 1fr) auto; }
.list > .item + .item::before, .list > * + .item::before { content: ""; position: absolute; top: 0; right: 0; left: 64px; border-top: 1px solid var(--line); }
.list > .item--no-icon + .item::before, .list > .item + .item--no-icon::before { left: var(--s4); }
button.item:hover, a.item:hover { background: var(--surface-2); }
.item__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-tile); background: var(--violet-wash); color: var(--violet-ink); }
.item__icon--open { background: var(--orange-wash); color: var(--orange-text); }
.item__icon--done { background: var(--green-wash); color: var(--green-text); }
.item__icon--danger { background: var(--red-wash); color: var(--red-text); }
.item__icon--plain { background: var(--surface-2); color: var(--ink-2); }
.item__title { display: block; font: 650 var(--t-md)/1.3 var(--font-text); overflow-wrap: anywhere; }
.item__meta { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-sm); line-height: 1.4; overflow-wrap: anywhere; }
.item__note { display: block; margin-top: 6px; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.45; }
.item__aside { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-sm); text-align: right; }
.item__amount { font: 700 var(--t-md)/1.2 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.item__actions { display: flex; gap: 2px; }
.item__chev { color: var(--faint); }
.list__foot { display: flex; justify-content: flex-start; padding: 12px var(--s4); border-top: 1px solid var(--line); }
.linked { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; color: var(--violet-ink); font: 600 var(--t-xs)/1.3 var(--font-text); }
@media (max-width: 520px) {
  .item--wrap { grid-template-columns: auto minmax(0, 1fr); }
  .item--wrap .item__aside { grid-column: 2; justify-content: flex-start; text-align: left; }
}

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--s5); }
.panel--wash { background: var(--violet-wash); border-color: transparent; }
.panel__title { font-size: var(--t-lg); margin-bottom: var(--s3); }
.note { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: 14px; background: var(--violet-wash); color: var(--ink-2); font-size: var(--t-sm); line-height: 1.5; }
.note .ico { color: var(--violet-ink); margin-top: 2px; }
.note--warn { background: var(--orange-wash); }
.note--warn .ico { color: var(--orange-text); }

/* Fiche de détails (dl) */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 145px), 1fr)); gap: var(--s4) var(--s5); margin: 0; }
.facts dt { color: var(--muted); font-size: var(--t-sm); }
.facts dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }

/* Chiffres clés */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.figure { padding: 14px var(--s4); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.figure__num { display: block; font: 750 var(--t-xl)/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.figure__label { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-sm); }

/* ---------- Quittance (loyer) ---------- */
.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--s5); }
.ledger__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px var(--s3); margin-bottom: var(--s4); }
.ledger__title { font-size: var(--t-lg); }
.ledger__when { color: var(--muted); font-size: var(--t-sm); }
.ledger__rows { display: grid; gap: 10px; margin: 0; }
.ledger__row { display: flex; align-items: baseline; gap: var(--s2); }
.ledger__row dt { color: var(--ink-2); }
.ledger__row::after { content: none; }
.ledger__lead { flex: 1; min-width: 16px; border-bottom: 2px dotted var(--line-strong); transform: translateY(-4px); }
.ledger__row dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.ledger__row--minus dd { color: var(--green-text); }
.ledger__total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); padding-top: var(--s3); border-top: 2px solid var(--ink); }
.ledger__total span { font-weight: 650; }
.ledger__total strong { font: 800 2rem/1 var(--font-display); font-stretch: 88%; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ledger .row-actions { margin-top: var(--s5); }

/* ---------- Raccourcis d’ajout ---------- */
.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.shortcut {
  display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: var(--s3); border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface); color: var(--ink); text-align: left; font: 650 var(--t-sm)/1.25 var(--font-text);
}
.shortcut:hover { border-color: var(--violet); }
.shortcut .item__icon { flex: 0 0 36px; }

/* ---------- États vides ---------- */
.empty { padding: var(--s6); border: 1.5px dashed var(--line-strong); border-radius: var(--r-panel); }
.empty__icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: var(--s3); border-radius: 12px; background: var(--violet-wash); color: var(--violet-ink); }
.empty h2, .empty h3 { font-size: var(--t-lg); }
.empty p { margin-top: 6px; color: var(--muted); max-width: 52ch; }
.empty--inline { padding: var(--s4) var(--s5); color: var(--muted); border-style: dashed; }

/* ---------- Recherche ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.search { position: relative; flex: 1 1 260px; }
.search .ico { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 42px; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.form-grid > * { min-width: 0; }
.dlg--wide .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dlg--wide .fld--full, .dlg--wide .fld-section, .dlg--wide .choices { grid-column: 1 / -1; }
@media (max-width: 640px) { .dlg--wide .form-grid { grid-template-columns: minmax(0, 1fr); } }
.fld { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.fld__label { font: 650 var(--t-sm)/1.3 var(--font-text); color: var(--ink-2); padding: 0; }
.fld__opt { font-weight: 400; color: var(--muted); }
.fld__hint { color: var(--muted); font-size: var(--t-xs); line-height: 1.4; }
.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink); font: 400 1rem/1.4 var(--font-text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: var(--faint); opacity: 1; }
.input:focus { outline: none; border-color: var(--violet); box-shadow: var(--focus); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { position: relative; display: block; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 40px; }
.select .ico { position: absolute; right: 14px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--muted); }
.is-invalid, .is-invalid + span { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(226, 82, 82, .22) !important; }
input[type="date"].input, input[type="time"].input {
  min-height: 46px; display: block; width: 100%; min-width: 0; max-width: 100%;
  -webkit-appearance: none; appearance: none; line-height: 44px; padding-top: 0; padding-bottom: 0;
}
/* iPhone : les champs date gardent sinon une largeur minimale qui fait déborder la fenêtre */
input[type="date"].input::-webkit-date-and-time-value, input[type="time"].input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 44px; line-height: 44px; }
input[type="date"].input::-webkit-datetime-edit, input[type="time"].input::-webkit-datetime-edit { padding: 0; }
.fld-section { grid-column: 1 / -1; padding-top: var(--s4); border-top: 1px solid var(--line); }
.fld-section:first-child { padding-top: 0; border-top: 0; }
.fld-section h3 { font-size: 1.0625rem; }
.fld-section p { margin-top: 2px; color: var(--muted); font-size: var(--t-sm); }

.file-drop {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: var(--s3) var(--s4);
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-ctl); color: var(--violet-ink); font-weight: 650; font-size: var(--t-sm);
}
.file-drop.has-file { border-style: solid; border-color: var(--violet); background: var(--violet-wash); }
.file-drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop:focus-within { box-shadow: var(--focus); }
.file-drop__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.choices__grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: var(--s2); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface);
  font: 650 var(--t-sm)/1.2 var(--font-text); text-align: center; cursor: pointer;
}
.choice input:checked + span { border-color: var(--violet); background: var(--violet-wash); color: var(--violet-ink); box-shadow: inset 0 0 0 1px var(--violet); }
.choice input:focus-visible + span { box-shadow: var(--focus); }
.choices.is-invalid .choice span { border-color: var(--red); }

/* Recherche d’adresse */
.addr { position: relative; }
.addr__status { color: var(--muted); font-size: var(--t-xs); min-height: 1em; }
.addr__list { display: grid; margin-top: 4px; border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; background: var(--surface); }
.addr__list:empty { display: none; }
.addr__opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 0; background: none; text-align: left; }
.addr__opt + .addr__opt { border-top: 1px solid var(--line); }
.addr__opt:hover, .addr__opt:focus-visible { background: var(--violet-wash); }
.addr__opt b { display: block; font-size: var(--t-sm); }
.addr__opt small { color: var(--muted); font-size: var(--t-xs); }

/* ---------- Fenêtres ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(15, 16, 22, .48); }
.dlg {
  width: min(560px, calc(100vw - 32px)); max-height: min(90vh, 920px); padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); box-shadow: var(--shadow-pop); overflow: hidden;
}
.dlg--wide { width: min(780px, calc(100vw - 32px)); }
.dlg__form { display: flex; flex-direction: column; max-height: min(90vh, 920px); }
.dlg__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s5) var(--s4) var(--s2) var(--s6); }
.dlg__title { font-size: var(--t-xl); font-weight: 750; }
.dlg__body { padding: var(--s2) var(--s6) var(--s6); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; min-width: 0; }
.dlg__lead { margin-bottom: var(--s5); color: var(--muted); }
.dlg__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s6) calc(var(--s3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.dlg__foot .btn--left { margin-right: auto; }
@media (max-width: 640px) {
  .dlg, .dlg--wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 94vh; }
  .dlg__form { max-height: 94vh; }
  .dlg__head { padding: var(--s4) var(--s3) var(--s2) var(--s5); }
  .dlg__head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--line-strong); }
  .dlg__body { padding: var(--s2) var(--s5) var(--s5); }
  .dlg__foot { padding-left: var(--s5); padding-right: var(--s5); }
  .dlg__foot .btn { flex: 1 1 auto; }
  .dlg[open] { animation: sheet-in .28s var(--ease); }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* Confirmation */
.confirm-dlg { width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-pop); }
.confirm { padding: var(--s6); }
.confirm__title { font-size: var(--t-lg); }
.confirm__text { margin-top: var(--s2); color: var(--muted); }
.confirm__actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s6); }

/* Feuilles (menu, ajouter) */
.sheet {
  width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 860px); padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); box-shadow: var(--shadow-pop); overflow: hidden;
}
.sheet__inner:focus { outline: none; box-shadow: none; }
.sheet__inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s5) var(--s3) var(--s2) var(--s5); }
.sheet__title { font-size: var(--t-xl); }
.sheet__body { overflow-y: auto; padding: var(--s2) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); }
.sheet__group + .sheet__group { margin-top: var(--s4); }
.sheet__group h3 { padding: 0 var(--s2) 6px; font: 600 var(--t-xs)/1.2 var(--font-text); color: var(--muted); }
.sheet__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.sheet__link {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink); text-align: left; font: 600 var(--t-sm)/1.2 var(--font-text);
}
.sheet__link:hover, .sheet__link[aria-current="page"] { background: var(--violet-wash); color: var(--violet-ink); }
.sheet__link .ico { color: var(--violet-ink); }
@media (max-width: 640px) {
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .sheet[open] { animation: sheet-in .28s var(--ease); }
  .sheet__head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--line-strong); }
}

/* ---------- Écran verrouillé ---------- */
.lock { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: var(--s6); background: var(--violet); color: #fff; }
.lock__card { width: min(360px, 100%); text-align: center; }
.lock__logo { width: 84px; height: 84px; margin: 0 auto var(--s5); border-radius: 22px; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .25)); }
.lock h1 { font-size: var(--t-2xl); font-weight: 750; }
.lock p { margin-top: var(--s2); opacity: .9; }
.lock__pin {
  width: 100%; margin-top: var(--s6); padding: 12px; border: 2px solid rgba(255, 255, 255, .7); border-radius: 16px;
  background: rgba(255, 255, 255, .12); color: #fff; text-align: center;
  font: 750 2rem/1 var(--font-display); letter-spacing: .5em; text-indent: .5em;
}
.lock__pin::placeholder { color: rgba(255, 255, 255, .55); }
.lock__pin:focus { outline: none; border-color: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .3); }
.lock__error { min-height: 1.5em; margin-top: var(--s3); font-weight: 650; }
.lock__btn { width: 100%; margin-top: var(--s2); background: #fff; color: var(--violet-deep); }
.lock__btn:hover { background: #F0F0FF; }
.lock__forgot { margin-top: var(--s4); padding: 8px; border: 0; background: none; color: #fff; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }

/* ---------- Message éphémère ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 1100;
  max-width: min(480px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: var(--t-sm); line-height: 1.4;
  box-shadow: var(--shadow-pop); transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.toast.is-shown { transform: translate(-50%, 0); opacity: 1; }
@media (min-width: 1024px) { .toast { bottom: 28px; } }

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { animation: none !important; transition: none !important; }

/* Pendant le verrouillage, rien n’est visible derrière l’écran violet. */
:root.is-locked .app { visibility: hidden; }

/* Choix sur téléphone : 4 options passent sur 2 colonnes pour ne pas couper les libellés */
@media (max-width: 480px) {
  .choices[style*="--cols:4"] .choices__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices[style*="--cols:7"] .choices__grid { gap: 6px; }
}
.choice span { min-width: 0; overflow-wrap: anywhere; }
.dlg, .dlg__form { max-width: 100%; overflow-x: hidden; }
