/* ==========================================================================
   Lumen — design system « Alpin »
   La lumière du soir sur les Alpes : bleu lac profond, blanc glacier, rose
   alpenglow pour ce qui compte aujourd'hui. Police Hanken Grotesk
   (variable, auto-hébergée). Cartes blanches nettes, barre de navigation en
   haut, frise des échéances. Logo : deux sommets sous un soleil couchant.
   ========================================================================== */

@font-face { font-family: "Hanken Grotesk"; src: url("/static/fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; }

/* ---------- Jetons ---------- */
:root {
  --paper: #EEF2F6;       /* glacier */
  --surface: #FFFFFF;
  --surface-2: #E5EBF2;
  --ink: #14243B;         /* nuit sur le lac */
  --ink-2: #34465E;
  --muted: #586A80;
  --rule: #DCE3EA;
  --rule-strong: #C3CDD8;
  --field: #8392A5;
  --lamp: #24426B;        /* accent : bleu lac */
  --lamp-ink: #1D3557;
  --lamp-soft: #E1E9F3;
  --glow: #E8A9A0;        /* alpenglow : aujourd'hui, logo */
  --on-glow: #14243B;
  --hero: #1D3557;        /* bloc « reste à vivre » */
  --on-hero: #F1F4F7;
  --good: #2F7A5A;
  --good-soft: #E0F0E8;
  --bad: #B5473A;
  --bad-soft: #F8E6E2;
  --focus: #24426B;
  --shadow: 0 1px 2px rgb(20 36 59 / 0.06), 0 1px 1px rgb(20 36 59 / 0.03);

  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --display: var(--sans);

  --r-s: 8px;
  --r: 10px;
  --r-l: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0F1724; --surface: #162133; --surface-2: #1E2B40; --ink: #E9EEF5; --ink-2: #C3CDDA;
  --muted: #93A2B6; --rule: #243249; --rule-strong: #33445F; --field: #55657D; --lamp: #8FB0E0; --lamp-ink: #B5CBEE;
  --lamp-soft: #1C2C47; --glow: #E8A9A0; --on-glow: #14243B; --hero: #24426B; --on-hero: #F1F4F7;
  --good: #6FC59A; --good-soft: #13291F; --bad: #F09A8A; --bad-soft: #3A1E1C;
  --focus: #8FB0E0; --shadow: none; color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --paper: #0F1724; --surface: #162133; --surface-2: #1E2B40; --ink: #E9EEF5; --ink-2: #C3CDDA;
  --muted: #93A2B6; --rule: #243249; --rule-strong: #33445F; --field: #55657D; --lamp: #8FB0E0; --lamp-ink: #B5CBEE;
  --lamp-soft: #1C2C47; --glow: #E8A9A0; --on-glow: #14243B; --hero: #24426B; --on-hero: #F1F4F7;
  --good: #6FC59A; --good-soft: #13291F; --bad: #F09A8A; --bad-soft: #3A1E1C;
  --focus: #8FB0E0; --shadow: none; color-scheme: dark;
  }
}

/* Teintes d'étiquettes (20). Chaque classe ne définit que --tone. */
.tone-ochre { --tone: #C2861F; }  .tone-amber { --tone: #D9A21B; }  .tone-sand { --tone: #A88B5C; }
.tone-clay { --tone: #B5603F; }   .tone-brick { --tone: #9A3B2C; }  .tone-coral { --tone: #D9705A; }
.tone-rose { --tone: #B9506A; }   .tone-plum { --tone: #84508A; }   .tone-lilac { --tone: #9A7DC4; }
.tone-indigo { --tone: #4F5A9E; } .tone-navy { --tone: #2F4170; }   .tone-ocean { --tone: #2F6E9E; }
.tone-sky { --tone: #4B98C7; }    .tone-teal { --tone: #2E8178; }   .tone-mint { --tone: #4FA58A; }
.tone-forest { --tone: #3E6B47; } .tone-moss { --tone: #5A7F3A; }   .tone-olive { --tone: #86813A; }
.tone-slate { --tone: #687080; }  .tone-graphite { --tone: #4A4945; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 450 15px/1.55 var(--sans);
  font-feature-settings: "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--lamp); }
img, svg { display: block; }
code { font: 0.88em ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
em { font-style: normal; color: var(--muted); font-weight: 400; }
small { font-size: 0.8rem; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--lamp-soft); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.inline-icon { display: inline-block; vertical-align: -3px; width: 16px; height: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--r-s); }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pad { padding: 1rem 0; }
.is-good { color: var(--good); }
.is-bad { color: var(--bad); }
.is-lamp { color: var(--lamp-ink); }
.month-name { text-transform: capitalize; }

/* ---------- Logo ---------- */
.logo-mark { width: 28px; height: 28px; flex: none; }
/* Logo Alpin : couleurs fixes (identiques en clair et en sombre). */
.logo-bg { fill: #24426B; }
.logo-sun { fill: #E8A9A0; }
.logo-peak { fill: #F1F4F7; }
.logo-shade { fill: #C9D4E0; }

/* ---------- Coquille : barre du haut ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in oklab, var(--paper) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--rule); }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0.6rem clamp(1rem, 3vw, 2rem); display: flex; align-items: center; gap: 1.5rem; }
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; font: 750 1.2rem/1 var(--sans); letter-spacing: -0.03em; }
.nav { display: flex; gap: 0.15rem; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.8rem; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}
.nav a .icon { width: 17px; height: 17px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.nav a[aria-current="page"] .icon { color: var(--glow); }
.topbar-tools { display: flex; align-items: center; gap: 0.15rem; }

/* Menu du compte : clic sur le nom → Profil, Réglages, Admin, déconnexion. */
.account { position: relative; min-width: 0; margin-left: 0.35rem; }
.who {
  display: flex; align-items: center; gap: 0.55rem; min-width: 0;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem; border-radius: 999px; cursor: pointer; list-style: none; border: 1px solid var(--rule);
}
.who::-webkit-details-marker { display: none; }
.who:hover, .account[open] .who { background: var(--surface-2); }
.who-current .who-name { color: var(--ink); }
.who-current .avatar { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--lamp); }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 0.9rem; max-width: 14ch; }
.who-chevron { color: var(--muted); width: 16px; height: 16px; flex: none; }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--lamp); color: var(--surface); font: 700 0.8rem/1 var(--sans); }
.avatar-l { width: 52px; height: 52px; font-size: 1.4rem; }
.account-menu {
  position: absolute; z-index: 30; right: 0; top: calc(100% + 8px); min-width: 220px;
  display: flex; flex-direction: column; padding: 0.3rem;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.08);
}
.account-menu a, .menu-item {
  display: flex; align-items: center; gap: 0.65rem; width: 100%;
  padding: 0.5rem 0.6rem; border: 0; border-radius: var(--r-s);
  background: transparent; color: var(--ink-2); font: 500 0.92rem var(--sans); text-align: left; text-decoration: none; cursor: pointer;
}
.account-menu a:hover, .menu-item:hover { background: var(--surface-2); color: var(--ink); }
.account-menu a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.account-menu a[aria-current="page"] .icon { color: var(--lamp); }
.menu-sep { margin-top: 0.3rem; padding-top: 0.3rem; border-top: 1px solid var(--rule); }
.menu-prefs { display: none; }

/* Popover générique (sélecteur de langue) : <details data-menu>. */
.popover { position: relative; }
.popover > summary { list-style: none; }
.popover > summary::-webkit-details-marker { display: none; }
.popover[open] > summary { background: var(--surface-2); color: var(--ink); }
.popover-panel {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 220px;
  display: flex; flex-direction: column; padding: 0.3rem;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.08);
}
.auth-tools .popover-panel, .topbar-tools .popover-panel { left: auto; right: 0; }
.lang-option { display: grid; grid-template-columns: 1fr auto; column-gap: 0.75rem; align-items: center; }
.lang-option .lang-name { color: var(--ink); }
.lang-option .lang-check { grid-column: 2; color: var(--lamp); }
.lang-option[aria-current="true"] { background: var(--surface-2); }
.lang-row { display: flex; align-items: center; gap: 0.2rem; padding: 0.35rem 0.6rem; color: var(--ink-2); }
.lang-row .icon { margin-right: 0.45rem; }
.lang-row button { flex: 1; padding: 0.35rem 0; border: 1px solid var(--rule); border-radius: var(--r-s); background: transparent; color: var(--ink-2); font: 600 0.78rem var(--sans); cursor: pointer; }
.lang-row button[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.profile-head { display: flex; align-items: center; gap: 0.9rem; }

.main { padding: 2rem clamp(1rem, 3vw, 2rem) 3rem; max-width: 1160px; width: 100%; margin: 0 auto; outline: none; flex: 1; }
.foot { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.78rem; }

/* ---------- Typographie de page ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head-main { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; min-width: 0; }
/* Sélecteur de période : flèches immobiles, libellé à largeur fixe. */
.switch-period { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; box-shadow: var(--shadow); }
.switch-arrow { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; color: var(--ink-2); text-decoration: none; user-select: none; -webkit-user-select: none; }
.switch-arrow:hover { background: var(--surface-2); color: var(--ink); }
.switch-arrow:active { background: var(--rule); }
.switch-label { width: 12.5rem; text-align: center; font: 700 1.05rem/1 var(--sans); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none; }
.eyebrow { font-size: 0.85rem; font-weight: 500; color: var(--muted); margin-bottom: 0.3rem; }
.eyebrow a { text-decoration: none; color: var(--ink-2); }
.eyebrow a:hover { color: var(--ink); text-decoration: underline; }
.title { font: 750 clamp(1.6rem, 3vw, 2rem)/1.15 var(--sans); letter-spacing: -0.03em; }
.title::first-letter { text-transform: uppercase; }
.h2 { font: 700 1.05rem/1.3 var(--sans); letter-spacing: -0.015em; }
.h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.4rem; }
.lead { color: var(--ink-2); margin-bottom: 1.25rem; }
.hint { color: var(--muted); font-size: 0.84rem; }
.link-small { background: none; border: 0; padding: 0; font: inherit; font-size: 0.84rem; color: var(--muted); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; }
.link-small:hover { color: var(--ink); }
.link-small .icon { width: 15px; height: 15px; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.summary-line { margin-bottom: 1rem; color: var(--ink-2); }
.bullets { list-style: disc; padding-left: 1.2rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 0.35rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 40px; padding: 0.5rem 1.05rem;
  border: 1px solid var(--rule-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: 650 0.9rem/1 var(--sans); text-decoration: none; cursor: pointer; box-shadow: var(--shadow);
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-ghost-danger { color: var(--bad); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--paper); }
.btn-danger:hover { background: color-mix(in oklab, var(--bad) 85%, black); border-color: color-mix(in oklab, var(--bad) 85%, black); }
.btn-small { min-height: 32px; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-s); background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* Bascule de thème : une icône visible selon l'état ; libellé visible en mode bouton. */
[data-theme-toggle] .icon { display: none; }
.icon-btn .theme-label { display: none; }
:root[data-theme-pref="light"] [data-theme-toggle] .theme-light,
:root[data-theme-pref="dark"] [data-theme-toggle] .theme-dark,
:root[data-theme-pref="auto"] [data-theme-toggle] .theme-auto,
:root:not([data-theme-pref]) [data-theme-toggle] .theme-auto { display: block; }

/* ---------- Formulaires ---------- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.compact { gap: 0.7rem; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field > span { font-size: 0.86rem; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--muted); }
.field-medium { max-width: 260px; }
.field-narrow-date { max-width: 220px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%; min-height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--field); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; /* évite le zoom iOS */
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lamp); box-shadow: 0 0 0 3px color-mix(in oklab, var(--lamp) 22%, transparent); }
input[inputmode="decimal"], input[inputmode="numeric"] { font-variant-numeric: tabular-nums; }
input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--muted) 70%, transparent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--lamp); width: 18px; height: 18px; margin: 0; flex: none; }
input[type="file"] { font: inherit; font-size: 0.9rem; }
.input-code { font-size: 1.6rem !important; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }
.check-field { display: flex; align-items: flex-start; gap: 0.6rem; cursor: pointer; color: var(--ink-2); }
.check-field input { margin-top: 3px; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-top: 1rem; }
.inline-form .field { flex: 1 1 180px; }

/* Interrupteur (case à cocher stylée). */

/* Formulaire « feuille » à sections numérotées. */
.form-sheet { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.sheet-section { margin: 0; padding: 1.25rem 1.4rem 1.4rem; border: 1px solid var(--rule); border-radius: var(--r-l); background: var(--surface); display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.sheet-section legend { float: left; width: 100%; padding: 0; margin-bottom: 0.25rem; font: 600 1rem/1.3 var(--display); display: flex; align-items: center; gap: 0.6rem; }
.sheet-section legend + * { clear: both; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font: 600 0.75rem/1 var(--sans); }
.sticky-actions { position: sticky; bottom: 0; padding: 0.75rem 0; background: var(--paper); border-top: 1px solid var(--rule); z-index: 2; }

/* Choix segmenté (radios). */
.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; border-radius: var(--r); background: var(--surface-2); gap: 3px; align-self: flex-start; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 0.45rem 0.9rem; border-radius: 6px; font-weight: 500; font-size: 0.9rem; color: var(--ink-2); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--rule-strong); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); }

/* Panneaux révélés en CSS pur (aucun JS nécessaire). */
.split-panel, .installments-panel { display: none; }
.split:has(input[value="shared"]:checked) .split-shared,
.split:has(input[value="other"]:checked) .split-other { display: flex; flex-direction: column; gap: 0.6rem; }
.sheet-section:has(.toggle-installments:checked) .installments-panel { display: flex; flex-direction: column; gap: 0.75rem; }
.form-sheet:has(.toggle-installments:checked) [data-hide-when-installments] { opacity: 0.4; pointer-events: none; }
.share-line { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 0.75rem; padding: 0.35rem 0; border-bottom: 1px solid var(--rule); }
.share-line .person { justify-self: start; font-size: 0.85rem; padding: 0.2rem 0.7rem; }
.share-new { border-bottom: 0; }

/* Échéancier : une ligne par tranche. */
.installment-list { display: flex; flex-direction: column; gap: 0.4rem; }
.installment-row { display: grid; grid-template-columns: 2rem 180px auto; align-items: center; gap: 0.5rem; }
.installment-index { color: var(--muted); font-size: 0.85rem; text-align: right; }
.installment-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; padding-top: 0.75rem; border-top: 1px dashed var(--rule); }
.split-helper { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.88rem; }
.split-helper input:not([type="checkbox"]) { min-height: 34px; padding: 0.3rem 0.55rem; }
.installment-tools .split-helper input[data-split-total]:not([type="checkbox"]) { width: 120px; }
.installment-tools .split-helper input[data-split-count]:not([type="checkbox"]) { width: 72px; }
[data-installment-total] { width: 100%; }

/* ---------- Messages ---------- */
.flash { display: flex; align-items: center; gap: 0.55rem; padding: 0.7rem 0.95rem; margin-bottom: 1.25rem; border-radius: var(--r); font-weight: 500; animation: flash-in 0.25s ease-out; }
.flash-ok { background: var(--good-soft); color: var(--good); }
.flash-error { background: var(--bad-soft); color: var(--bad); }
@keyframes flash-in { from { opacity: 0; } }
/* Notification flottante : visible où que tu sois dans la page. */
.toast {
  position: fixed; z-index: 40; right: 1.25rem; bottom: 1.25rem; max-width: min(420px, calc(100vw - 2rem));
  display: flex; align-items: center; gap: 0.55rem; padding: 0.65rem 0.5rem 0.65rem 0.9rem;
  border-radius: var(--r); border: 1px solid currentColor; font-weight: 500;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.1);
  animation: toast-in 0.2s ease-out;
}
.toast-ok { background: var(--good-soft); color: var(--good); animation: toast-in 0.2s ease-out, toast-out 0.3s ease-in 4.5s forwards; }
.toast-error { background: var(--bad-soft); color: var(--bad); }
.toast > span { flex: 1; }
.toast-close { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-s); background: transparent; color: inherit; cursor: pointer; }
.toast-close:hover { background: rgb(0 0 0 / 0.06); }
.toast-close .icon { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; transform: translateY(8px); } }
.alert { padding: 0.8rem 1rem; margin-bottom: 1.25rem; border-radius: var(--r); background: var(--bad-soft); color: var(--bad); }
.alert ul { list-style: disc; padding-left: 1.2rem; margin-top: 0.3rem; }
.notice { padding: 0.8rem 1rem; margin-bottom: 1rem; border-radius: var(--r); background: var(--lamp-soft); color: var(--ink); font-size: 0.92rem; }

/* ---------- Étiquettes ---------- */
/* Étiquettes : fond neutre, la couleur n'est qu'un point. */
.chip, .person {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.1rem 0.5rem; border-radius: var(--r-s);
  font-size: 0.78rem; font-weight: 500; line-height: 1.45; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--muted)); }
.person::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--muted)); }
.tag { display: inline-block; padding: 0.1rem 0.45rem; border-radius: var(--r-s); border: 1px solid var(--rule); font-size: 0.74rem; font-weight: 500; line-height: 1.45; color: var(--muted); white-space: nowrap; }
.tag-bad { color: var(--bad); font-style: normal; font-weight: 500; }
.tag-good { color: var(--good); font-style: normal; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

/* ---------- Bandeau du mois ---------- */
.ledger-label { font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.ledger-value { font: 600 clamp(1.35rem, 2.3vw, 1.7rem)/1.1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.015em; }
.ledger-value small { font: 500 0.85rem var(--sans); color: var(--muted); letter-spacing: 0; }


/* ---------- Résumé du mois ---------- */
.summary { display: grid; grid-template-columns: minmax(240px, 0.8fr) minmax(0, 2fr); gap: 1rem; margin-bottom: 1.5rem; }
.summary-main { display: flex; flex-direction: column; justify-content: center; gap: 0.35rem; padding: 1.4rem 1.6rem; border-radius: var(--r-l); background: var(--hero); color: var(--on-hero); }
.summary-label { font-size: 0.88rem; font-weight: 600; opacity: 0.85; }
.summary-value { font: 750 clamp(2rem, 4vw, 2.6rem)/1.05 var(--sans); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.summary-value small { font-size: 0.9rem; font-weight: 600; letter-spacing: 0; margin-left: 0.35rem; opacity: 0.75; }
.summary-value.is-bad { color: #FFC9B8; }
.summary-sub { font-size: 0.82rem; opacity: 0.85; }
.summary-sub a { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 50%, transparent); }
.summary-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.25rem; padding: 1.2rem 1.5rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); box-shadow: var(--shadow); }
.stat { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.stat + .stat { padding-left: 1.25rem; border-left: 1px solid var(--rule); }
.stat-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.stat-value { font: 750 1.45rem/1.15 var(--sans); letter-spacing: -0.03em; }
.stat-sub { font-size: 0.8rem; color: var(--muted); }
.stat-progress { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.9rem; margin-top: 1rem; font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

progress { appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: block; }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--lamp); border-radius: 99px; transition: width 0.3s; }
progress::-moz-progress-bar { background: var(--lamp); border-radius: 99px; }
.progress-line { display: flex; align-items: center; gap: 0.9rem; margin: 0.85rem 0 2rem; font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Grilles & panneaux ---------- */
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; margin-bottom: 1.5rem; }
.grid-form { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); box-shadow: var(--shadow); padding: 1.35rem 1.5rem; margin-bottom: 1.25rem; min-width: 0; }
.grid-main > .panel, .grid-form > .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel > .h2:first-child { margin-bottom: 1rem; }
.side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.card { padding: 1.15rem 1.25rem; border: 1px solid var(--rule); border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow); }
.card-title { font-size: 0.9rem; font-weight: 700; color: var(--ink); margin-bottom: 0.75rem; }
.card-title a { text-decoration: none; }
.card-title a:hover { color: var(--ink); text-decoration: underline; }
.big { font: 750 1.55rem/1.15 var(--sans); letter-spacing: -0.03em; margin-bottom: 0.2rem; font-variant-numeric: lining-nums proportional-nums; }
.kv li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.45rem 0; border-bottom: 1px solid var(--rule); }
.kv li:last-child { border-bottom: 0; }
.empty { padding: 2rem; border: 1px dashed var(--rule-strong); border-radius: var(--r-l); display: flex; flex-direction: column; align-items: flex-start; gap: 1rem; }
.empty p { max-width: 52ch; color: var(--ink-2); }
.first-steps { display: flex; flex-direction: column; gap: 0.6rem; counter-reset: step; }
.first-steps li { counter-increment: step; display: grid; grid-template-columns: 1.75rem 1fr; gap: 0.5rem; color: var(--ink-2); }
.first-steps li::before { content: counter(step); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font: 600 0.75rem/1 var(--sans); margin-top: 1px; }
.first-steps strong { color: var(--ink); }

/* ---------- Zone sensible ---------- */
.danger-zone { border-color: color-mix(in oklab, var(--bad) 35%, var(--rule)); }
.danger-head { display: flex; gap: 0.85rem; align-items: flex-start; margin-bottom: 1rem; }
.danger-head > .icon { display: none; }
.danger-head .h2 { color: var(--bad); margin-bottom: 0.25rem; }
.danger-head p { color: var(--ink-2); max-width: 62ch; font-size: 0.92rem; }
.danger-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 1rem; border-top: 1px solid color-mix(in oklab, var(--bad) 25%, transparent); }
.danger-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; padding-top: 1rem; border-top: 1px solid color-mix(in oklab, var(--bad) 25%, transparent); }
.danger-form .field { flex: 1 1 220px; max-width: 320px; }
.toc a.toc-danger { color: var(--bad); }

/* ---------- Échéances ---------- */
/* Frise : pastille de date à gauche, échéances du jour à droite. */
.day { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 1rem; padding: 0.35rem 0; }
.day + .day { border-top: 1px solid var(--rule); }
.day-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem; width: 48px; height: 52px; margin-top: 0.55rem; border-radius: 12px; background: var(--surface-2); }
.day-num { font: 750 1.2rem/1 var(--sans); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.day-wd { font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: lowercase; }
.day.is-today .day-tile { background: var(--glow); color: var(--on-glow); }
.day.is-today .day-wd { color: var(--on-glow); opacity: 0.75; }
.occ { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.9rem; padding: 0.75rem 0; }
.occ + .occ { border-top: 1px dashed var(--rule); }
.occ-toggle { order: 3; }
.occ-name { font-weight: 650; text-decoration: none; }
.occ-name:hover { text-decoration: underline; }
.occ-title { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; }
.occ-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.occ-meta .person { font-size: 0.72rem; padding: 0 0.45rem; }
.occ-amount { font-size: 1rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.check { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 0; box-shadow: inset 0 0 0 1.5px var(--field); background: var(--surface); color: transparent; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.check .icon { width: 16px; height: 16px; stroke-width: 2.5; margin: 0; }
.check:hover { box-shadow: inset 0 0 0 1.5px var(--lamp); color: var(--lamp); }
.occ.is-paid .check { background: var(--lamp); box-shadow: none; color: var(--surface); }
.occ.is-paid .occ-name { color: var(--muted); }
.occ.is-paid .occ-amount { color: var(--muted); font-weight: 500; }
.occ.is-late .check { box-shadow: inset 0 0 0 1.5px var(--bad); }
.overdue { margin-bottom: 1.25rem; padding: 0.75rem 1rem 0.25rem; border-radius: var(--r); background: var(--bad-soft); }
.overdue-title { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--bad); }
.overdue-title .icon { width: 16px; height: 16px; }
.skipped, .archived { margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }
summary { cursor: pointer; }
.skipped summary, .archived summary { padding: 0.4rem 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.plain-list li:last-child { border-bottom: 0; }
.history li { display: grid; grid-template-columns: 90px 1fr auto; }
.goal-mini { margin-bottom: 0.85rem; }
.goal-mini:last-child { margin-bottom: 0; }
.goal-mini-head { display: flex; justify-content: space-between; gap: 0.5rem; font-weight: 500; margin-bottom: 0.3rem; }
.goal-mini .hint { margin-top: 0.25rem; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--r-l); background: var(--surface); margin-bottom: 1rem; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.8rem; font-weight: 500; color: var(--muted); padding: 0.7rem 1rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th.right, .table td.right { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 50%, transparent); }
.table tfoot td { border-top: 2px solid var(--ink); font-weight: 600; padding: 0.8rem 1rem; }
.table .is-future td { color: var(--muted); }
.table progress { min-width: 80px; margin-top: 0.5rem; }
.row-link { font-weight: 500; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.cell-sub { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; font-size: 0.8rem; color: var(--muted); align-items: center; }

/* ---------- Budget ---------- */
.equation { margin-bottom: 0.5rem; }
.eq-line { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.eq-line .num { font-variant-numeric: tabular-nums; }
.eq-line.minus span:first-child::before { content: "− "; color: var(--muted); }
.eq-total { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.9rem 0 0.2rem; border-top: 1px solid var(--ink-2); margin-top: -1px; font: 600 1.05rem/1.2 var(--display); }
.eq-total .num { font-variant-numeric: tabular-nums; font-size: 1.25rem; color: var(--lamp-ink); }
.eq-total.is-bad .num { color: var(--bad); }
.accounts { margin: 0.5rem 0; }
.accounts li { border-bottom: 1px solid var(--rule); }
.accounts summary { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.55rem 0; list-style: none; }
.accounts summary::-webkit-details-marker { display: none; }
.accounts summary > span:first-child { display: flex; flex-direction: column; }
.account-name { font-weight: 500; }
.accounts form { padding: 0.5rem 0 1rem; }
details.add summary { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink-2); font-size: 0.88rem; font-weight: 500; padding: 0.4rem 0; }
details.add form { padding-top: 0.5rem; }
.goals { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.75rem; }
.goal { padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: var(--r); display: flex; flex-direction: column; gap: 0.5rem; }
.goal.is-reached progress::-webkit-progress-value { background: var(--good); }
.goal.is-reached progress::-moz-progress-bar { background: var(--good); }
.goal-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.goal-name { font: 600 1rem/1.3 var(--display); text-decoration: none; }
.goal-amount { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.goal-facts { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.1rem; }

/* ---------- Créances ---------- */
.owed-total { display: flex; flex-direction: column; gap: 0.25rem; padding-bottom: 1.25rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.receivable { padding: 1rem 0; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 0.5rem; }
.receivable.is-late .receivable-amount { color: var(--bad); }
.receivable-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.receivable-head > div:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.receivable-title { font-weight: 500; text-decoration: none; }
.receivable-amount { font-size: 1.05rem; font-weight: 600; white-space: nowrap; }
.inline-pay { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-pay input { max-width: 160px; min-height: 32px !important; padding: 0.3rem 0.6rem !important; }

/* ---------- Réglages ---------- */
.settings { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 2rem; align-items: start; }
.toc { position: sticky; top: 1.5rem; display: flex; flex-direction: column; gap: 0.1rem; }
.toc a { padding: 0.4rem 0.65rem; border-radius: var(--r-s); text-decoration: none; color: var(--ink-2); font-size: 0.9rem; }
.toc a:hover { background: var(--surface-2); }
.settings-body .panel { scroll-margin-top: 1.5rem; }
.setting-block { padding: 1.1rem 0; border-top: 1px solid var(--rule); }
.setting-block:first-of-type { border-top: 0; padding-top: 0; }
.setting-block > .hint { margin-bottom: 0.75rem; }
.audit li { flex-wrap: wrap; }
.label-row { border-bottom: 1px solid var(--rule); }
.label-row summary { display: flex; justify-content: space-between; align-items: center; padding: 0.55rem 0; list-style: none; }
.label-row summary::-webkit-details-marker { display: none; }
.label-edit { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.25rem 0 1rem; }
.swatches { display: grid; grid-template-columns: repeat(10, 28px); gap: 0.45rem; border: 0; padding: 0; margin: 0; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--tone); cursor: pointer; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch:has(input:checked) { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.label-new { display: flex; gap: 0.5rem; margin-top: 1rem; }
.label-new input { flex: 1; }
.totp-setup .steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
.totp-setup .steps > li { display: flex; flex-direction: column; gap: 0.75rem; }
.qr { width: 200px; height: 200px; padding: 10px; background: #fff; border-radius: var(--r); border: 1px solid var(--rule); image-rendering: pixelated; }
.secret { font-size: 1.05rem; letter-spacing: 0.08em; padding: 0.6rem 0; user-select: all; font-family: ui-monospace, Menlo, monospace; }
.copy-box { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.copy-box input { font-family: ui-monospace, Menlo, monospace !important; font-size: 0.85rem !important; }
.generated { border-color: var(--lamp); }
.menu { position: relative; display: inline-block; text-align: left; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: 1.6rem; z-index: 10; min-width: 230px; padding: 0.5rem 0.75rem; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r); box-shadow: 0 12px 32px -14px rgb(0 0 0 / 0.25); display: flex; flex-direction: column; gap: 0.1rem; }
.menu-body form { padding: 0.35rem 0; }

/* ---------- Authentification ---------- */
.plain-body { min-height: 100vh; }
.auth { display: flex; flex-direction: column; min-height: 100vh; padding: 1.25rem clamp(1.25rem, 4vw, 2.5rem); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.auth-logo { display: flex; align-items: center; gap: 0.55rem; font: 650 1.15rem/1 var(--display); }
.auth-main { flex: 1; display: flex; }
.auth-tools { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: 0.8rem; }
.auth-card { width: 100%; max-width: 400px; margin: auto; padding: 2rem 2rem 2.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); }
.auth-card .title { margin-bottom: 0.4rem; }
.auth-links { margin-top: 1.25rem; text-align: center; font-size: 0.9rem; color: var(--muted); }
.or { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--muted); font-size: 0.82rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.btn-passkey { min-height: 46px; }
.error-page { max-width: 520px; margin: 0 auto; padding: 18vh 1.5rem 3rem; display: flex; flex-direction: column; gap: 1rem; }
.error-code { font: 650 4rem/1 var(--display); letter-spacing: -0.03em; color: var(--lamp); }

/* ---------- Rapports ---------- */
.report-body { background: var(--surface-2); }
.report-toolbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem clamp(1rem, 4vw, 2rem); background: var(--paper); border-bottom: 1px solid var(--rule); }
.sheet { max-width: 860px; margin: 2rem auto 4rem; padding: 3rem clamp(1.25rem, 5vw, 3.5rem); background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 2px solid var(--ink); }
.sheet-brand { display: flex; align-items: center; gap: 0.5rem; font: 650 1.15rem/1 var(--display); }
.sheet-meta { text-align: right; font-size: 0.8rem; line-height: 1.5; color: var(--muted); }
.sheet-title { font: 650 clamp(1.8rem, 4.5vw, 2.4rem)/1.1 var(--display); letter-spacing: -0.02em; margin-bottom: 1.75rem; }
.sheet-title::first-letter { text-transform: uppercase; }
.sheet-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.sheet-kpis > div { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.9rem 1rem; border-left: 1px solid var(--rule); }
.sheet-kpis > div:first-child { border-left: 0; padding-left: 0; }
.sheet-kpis .ledger-value { font-size: 1.7rem; }
.sheet-h2 { font: 600 1.05rem/1.25 var(--display); margin: 2.25rem 0 0.9rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule); }
.sheet-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem; }
.sheet-foot { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 0.75rem; color: var(--muted); }
.report-pages { margin-right: auto; font-size: 0.85rem; color: var(--muted); }
.table-print { font-size: 0.88rem; }
.table-print th, .table-print td { padding: 0.55rem 0.5rem; }
.table-print tfoot td { padding: 0.7rem 0.5rem; }
.table-print th:first-child, .table-print td:first-child { padding-left: 0; }
.hbar { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; padding: 0.3rem 0; font-size: 0.86rem; }
.hbar .num { font-variant-numeric: tabular-nums; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track svg { width: 100%; height: 8px; }
.hbar-track rect { fill: var(--tone, var(--lamp)); }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart-axis { stroke: var(--ink); stroke-width: 1.5; }
.chart-total { fill: var(--surface-2); stroke: var(--rule-strong); stroke-width: 1; }
.chart-paid { fill: var(--lamp); }
.chart-label { font: 11px var(--sans); fill: var(--muted); }
.chart figcaption { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem; font-size: 0.78rem; color: var(--muted); }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 0.6rem; }
.legend:first-child { margin-left: 0; }
.legend-paid { background: var(--lamp); }
.legend-total { background: var(--surface-2); border: 1px solid var(--rule-strong); }

/* ---------- Pages A4 (relevés paginés par lumen.js) ----------
   Mêmes dimensions à l'écran et à l'impression : ce qui est affiché est ce
   qui sort de l'imprimante. Couleurs de papier forcées, même en thème sombre. */
.pages { display: flex; flex-direction: column; align-items: center; gap: 10mm; padding: 2rem 1rem 4rem; zoom: var(--page-zoom, 1); }
.page {
  --paper: #fff; --surface: #fff; --surface-2: #EEF2F6; --ink: #14243B; --ink-2: #34465E; --muted: #586A80;
  --rule: #DCE3EA; --rule-strong: #C3CDD8; --lamp: #24426B; --lamp-ink: #1D3557; --lamp-soft: #E1E9F3;
  --good: #1D6B44; --bad: #B03426;
  color-scheme: light;
  display: flex; flex-direction: column;
  width: 210mm; height: 296.8mm; flex: none; overflow: hidden;
  padding: 15mm 16mm 0;
  background: #fff; color: var(--ink);
  font-size: 9.5pt; line-height: 1.45;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 6px 18px rgb(0 0 0 / 0.08);
}
.page-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.page-foot { display: flex; justify-content: space-between; gap: 1rem; height: 13mm; align-items: center; border-top: 0.5pt solid var(--rule); font-size: 7.5pt; color: var(--muted); }
.page-num { font-variant-numeric: tabular-nums; }
.page-run { display: flex; justify-content: space-between; align-items: center; padding-bottom: 3mm; margin-bottom: 7mm; border-bottom: 0.75pt solid var(--rule); font-size: 8pt; color: var(--muted); }
.page-run .sheet-brand { font-size: 10.5pt; color: var(--ink); }
.page-run + * { margin-top: 0; }
.page-run .sheet-brand svg { width: 14px; height: 14px; }
.page .sheet-head { padding-bottom: 4mm; margin-bottom: 6mm; border-bottom: 1.5pt solid var(--ink); }
.page .sheet-brand { font-size: 15pt; }
.page .sheet-meta { font-size: 8pt; }
.page .eyebrow { font-size: 8.5pt; margin-bottom: 1mm; }
.page .sheet-title { font-size: 26pt; margin-bottom: 4.5mm; }
.page .sheet-kpis > div { padding: 2.5mm 4mm; }
.page .sheet-kpis > div:first-child { padding-left: 0; }
.page .ledger-label { font-size: 8pt; }
.page .sheet-kpis .ledger-value { font-size: 16pt; }
.page .progress-line { margin: 3mm 0 0; font-size: 8pt; }
.page .sheet-h2 { font-size: 11.5pt; margin: 6.5mm 0 2.5mm; padding-bottom: 1.5mm; border-bottom-width: 0.75pt; }
.page .table-print { font-size: 9pt; }
.page .table-print th { font-size: 7.5pt; padding: 1.5mm 0 1.5mm 4mm; }
.page .table-print td { padding: 1.25mm 0 1.25mm 4mm; border-bottom-width: 0.5pt; vertical-align: top; }
.page .table-print tfoot td { padding: 2.5mm 0 2.5mm 4mm; }
.page .table-print th:first-child, .page .table-print td:first-child { padding-left: 0; }
.page .cell-sub { font-size: 7.5pt; margin-top: 0; line-height: 1.3; }
/* Sur papier, les catégories : pastille de couleur + texte, sans fond. */
.page .chip { background: none; padding: 0; font-size: 8.5pt; color: var(--ink-2); }
.page .sheet-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10mm; }
.page .sheet-kpis { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.page .hbar { font-size: 8.5pt; padding: 0.8mm 0; grid-template-columns: minmax(0, 34mm) minmax(0, 1fr) auto; gap: 3mm; }
.page .kv li { font-size: 8.5pt; padding: 1.3mm 0; border-bottom-width: 0.5pt; }
.page .chart { margin: 0; }
.page .chart-label { font-size: 9px; }
.page .chart figcaption { font-size: 8pt; }
.page .sheet-foot { margin-top: auto; padding-top: 3mm; border-top: 0; font-size: 7.5pt; }
.is-paged .report-toolbar .report-pages:empty { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .grid-main, .grid-form { grid-template-columns: minmax(0, 1fr); }
  .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

@media (max-width: 960px) {
  .nav a span { display: none; }
  .nav a { padding: 0.55rem; }
}

@media (max-width: 860px) {
  /* backdrop-filter crée un bloc conteneur : la barre d'onglets fixe ne serait plus en bas. */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
  .topbar-inner { gap: 0.75rem; padding: 0.5rem 1rem; }
  .topbar-tools { margin-left: auto; }
  .who-name, .who-chevron { display: none; }
  .who { padding: 0.2rem; }
  /* Navigation en barre d'onglets en bas de l'écran. */
  .nav {
    position: fixed; z-index: 20; inset: auto 0 0 0;
    justify-content: space-around; gap: 0;
    padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom));
    background: var(--paper); border-top: 1px solid var(--rule);
  }
  .nav a { flex: 1; flex-direction: column; gap: 0.2rem; padding: 0.45rem 0.2rem; border-radius: var(--r); font-size: 0.68rem; min-width: 0; }
  .nav a span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
  .nav a[aria-current="page"] .icon { color: var(--lamp); }
  .menu-prefs { display: block; margin-top: 0.3rem; padding-top: 0.3rem; border-top: 1px solid var(--rule); }
  .topbar-tools > .popover, .topbar-tools > [data-theme-toggle] { display: none; }
  .toast { left: 1rem; right: 1rem; bottom: calc(4.8rem + env(safe-area-inset-bottom)); max-width: none; }
  .main { padding: 1.25rem 1rem calc(5.75rem + env(safe-area-inset-bottom)); }
  .summary { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .summary-stats { padding: 1rem 1.1rem 0.9rem; }
  .stat + .stat { padding-left: 0.8rem; }
  .stat-value { font-size: 1.1rem; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
  .toc a { border: 1px solid var(--rule-strong); font-size: 0.8rem; }
  .totp-setup .steps { grid-template-columns: minmax(0, 1fr); }
  .swatches { grid-template-columns: repeat(auto-fill, 28px); }
}

@media (max-width: 560px) {
  .row-2, .row-3 { grid-template-columns: minmax(0, 1fr); }
  .report-pages { display: none; }
  .report-toolbar { gap: 0.5rem; padding-inline: 0.75rem; }
  .report-toolbar .actions { flex-wrap: nowrap; gap: 0.4rem; }
  .report-toolbar .btn { padding-inline: 0.7rem; }
  .sheet-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .panel { padding: 1.1rem 1rem; }
  .page-head-main { width: 100%; }
  .switch-period { flex: 1; justify-content: space-between; }
  .switch-label { width: auto; flex: 1; }
  .day { grid-template-columns: 40px minmax(0, 1fr); gap: 0.75rem; }
  .day-tile { width: 40px; height: 46px; }
  .share-line { grid-template-columns: minmax(0, 1fr) 110px; }
  .installment-row { grid-template-columns: 1.5rem minmax(0, 1fr) auto; }
  .history li { grid-template-columns: 70px 1fr auto; }
  .table th, .table td { padding: 0.65rem 0.7rem; }
  .field-medium { max-width: none; }
  .auth-card { padding: 1.5rem 1.25rem 1.75rem; }
  /* Factures : nom, prochaine échéance et ma part ; le reste est dans la fiche. */
  .table-bills th:nth-child(2), .table-bills td:nth-child(2),
  .table-bills th:nth-child(4), .table-bills td:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Impression (relevés → PDF) ---------- */
@media print {
  /* Marge nulle : chaque .page porte déjà ses marges. Les navigateurs
     n'ajoutent alors ni URL ni date en en-tête / pied de page. */
  @page { size: A4; margin: 0; }
  :root, :root[data-theme="dark"] {
    --paper: #fff; --surface: #fff; --surface-2: #EEF2F6; --ink: #14243B; --ink-2: #34465E; --muted: #586A80;
    --rule: #DCE3EA; --rule-strong: #C3CDD8; --lamp: #24426B; --lamp-ink: #1D3557; --lamp-soft: #E1E9F3;
    --good: #1D6B44; --bad: #B03426;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body, .report-body { background: #fff; }
  .report-toolbar, .topbar, .foot, .flash, .toast { display: none !important; }
  .pages { display: block; padding: 0; zoom: 1; }
  .page { box-shadow: none; break-after: page; }
  .page:last-child { break-after: auto; }
  /* Sans JS : feuille continue avec ses propres marges. */
  .sheet { margin: 0; padding: 14mm 16mm; border: 0; max-width: none; }
  .sheet-h2 { break-after: avoid; }
  .table tr, .hbar, .kv li { break-inside: avoid; }
  a { text-decoration: none; }
}

/* ---------- Client chiffré : démarrage, foyer, sécurité ---------- */
.boot-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 0.75rem; color: var(--muted); font-weight: 600; }
.boot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lamp); animation: boot-pulse 1s ease-in-out infinite alternate; }
@keyframes boot-pulse { from { opacity: 0.3; transform: scale(0.8); } to { opacity: 1; transform: scale(1.1); } }
.noscript { max-width: 520px; margin: 20vh auto; padding: 0 1.5rem; text-align: center; color: var(--ink-2); }
.input-mono { font-family: ui-monospace, Menlo, Consolas, monospace !important; letter-spacing: 0.04em; text-transform: uppercase; }
.section-gap { margin-top: 1.5rem; }
.e2ee-note { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 1rem; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 0.4rem; }
.notice-action { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.notice-action a { font-weight: 700; }
.tag-household { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--lamp-ink); border-color: color-mix(in oklab, var(--lamp) 35%, var(--rule)); }
.tag-household .icon { width: 13px; height: 13px; }

/* Clé de récupération et empreintes : chiffres faciles à lire et à comparer. */
.recovery-key { margin: 1rem 0; padding: 1rem; border: 1.5px dashed var(--rule-strong); border-radius: var(--r); background: var(--surface-2); text-align: center; }
.recovery-key code { background: none; padding: 0; font-size: 1.05rem; letter-spacing: 0.06em; word-break: break-word; color: var(--ink); }
.recovery-tips { margin: 1rem 0 1.25rem; font-size: 0.9rem; }
.fingerprint { font: 700 1.35rem/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.08em; padding: 0.75rem 1rem; border-radius: var(--r); background: var(--surface-2); display: inline-block; margin: 0.25rem 0 0.5rem; }
.fingerprint-small { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.72rem; letter-spacing: 0.04em; }
.confirm-person { max-width: 640px; }
.person-card { display: flex; align-items: center; gap: 0.85rem; padding: 0.85rem 1rem; border: 1px solid var(--rule); border-radius: var(--r); margin: 1rem 0 1.25rem; }
.members li { align-items: flex-start; }
.member { display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; }

/* Foyers */
.household-list { display: grid; gap: 0.75rem; margin-bottom: 1.25rem; }
.household-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; text-decoration: none; margin: 0; transition: border-color 0.15s; }
.household-card:hover { border-color: var(--rule-strong); }
.household-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--lamp-soft); color: var(--lamp-ink); }
.household-main { display: flex; flex-direction: column; min-width: 0; }
.household-main strong { font-size: 1.05rem; }
.household-balance { display: flex; flex-direction: column; align-items: flex-end; font-weight: 750; font-size: 1.1rem; }
.household-balance small { font-weight: 500; font-size: 0.75rem; color: var(--muted); }
.invitation { border-color: var(--lamp); }

/* Formulaire de facture : « pour moi » ou « pour le foyer ». */
.is-hidden-owner { display: none !important; }
.owner-pick { margin-bottom: 0.25rem; }
.split:has(.owner-pick input[value="me"]:checked) .owner-household { display: none; }
.split:has(.owner-pick input:not([value="me"]):checked) .owner-me { display: none; }
.owner-household { display: flex; flex-direction: column; gap: 0.75rem; }
.split-custom { display: none; flex-direction: column; gap: 0.5rem; }
.owner-household:has(input[name="split_mode"][value="custom"]:checked) .split-custom { display: flex; }

/* ---------- Page d'accueil publique : paysage alpin ---------- */
.landing { min-height: 100vh; display: flex; flex-direction: column; background: var(--paper); --sky: #F4E4DF; --sky-far: #9DB1C8; --sky-mid: #24426B; --sky-lake: #1D3557; --sky-snow: #F1F4F7; }
:root[data-theme="dark"] .landing { --sky: #17223A; --sky-far: #2A3B58; --sky-mid: #1D3557; --sky-lake: #0F1724; --sky-snow: #C9D4E0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .landing { --sky: #17223A; --sky-far: #2A3B58; --sky-mid: #1D3557; --sky-lake: #0F1724; --sky-snow: #C9D4E0; } }
.landing-top { position: relative; z-index: 2; background: var(--sky); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem clamp(1rem, 4vw, 3rem); }
.landing-top .auth-logo { text-decoration: none; }
.landing-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: start; gap: 3rem; padding: clamp(2rem, 5vw, 3.5rem) clamp(1rem, 6vw, 6rem) 300px; background: var(--sky); overflow: hidden; }
.landing-sky { position: absolute; inset: auto 0 0 0; width: 100%; height: 340px; }
.sky-1 { fill: var(--sky); }
.sky-sun { fill: #E8A9A0; }
.sky-far { fill: var(--sky-far); }
.sky-mid { fill: var(--sky-mid); }
.sky-snow { fill: var(--sky-snow); }
.sky-lake { fill: var(--sky-lake); }
.sky-glint { fill: #E8A9A0; opacity: 0.8; }
.landing-copy, .landing-preview { position: relative; z-index: 1; }
.landing-copy { max-width: 34rem; }
.landing-copy h1 { margin: 0 0 1rem; font: 800 clamp(2.2rem, 5vw, 3.6rem)/1.02 var(--sans); letter-spacing: -0.045em; color: var(--ink); text-wrap: balance; }
.landing-copy p { margin: 0 0 1.75rem; font-size: 1.12rem; line-height: 1.55; color: var(--ink-2); max-width: 30rem; }
.landing-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.btn-large { min-height: 50px; padding: 0.8rem 1.6rem; font-size: 1rem; }
.landing-note { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink-2); font-size: 0.88rem; font-weight: 600; }
.landing-preview { justify-self: end; width: min(100%, 360px); padding: 0.9rem; border-radius: 22px; background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 24px 60px -24px rgb(20 36 59 / 0.45); transform: rotate(2deg) translateY(40px); }
.preview-hero { display: flex; flex-direction: column; gap: 0.2rem; padding: 1rem 1.1rem; border-radius: 14px; background: var(--hero); color: var(--on-hero); }
.preview-hero span { font-size: 0.8rem; font-weight: 600; opacity: 0.85; }
.preview-hero strong { font: 800 2rem/1 var(--sans); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.preview-hero small { font-size: 0.8rem; font-weight: 600; opacity: 0.75; letter-spacing: 0; }
.preview-list { margin: 0.6rem 0 0; display: flex; flex-direction: column; }
.preview-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 22px; align-items: center; gap: 0.7rem; padding: 0.6rem 0.25rem; font-size: 0.9rem; }
.preview-list li + li { border-top: 1px dashed var(--rule); }
.preview-day { display: grid; place-items: center; width: 34px; height: 36px; border-radius: 10px; background: var(--surface-2); font-weight: 750; }
.preview-day.is-today { background: var(--glow); color: var(--on-glow); }
.preview-name { font-weight: 650; }
.preview-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.preview-check { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--field); }
.preview-check.is-on { background: var(--lamp); box-shadow: none; }
.landing-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; padding: 3rem clamp(1rem, 6vw, 6rem); max-width: 1240px; margin: 0 auto; width: 100%; }
.landing-points article { display: flex; flex-direction: column; gap: 0.6rem; }
.landing-points h2 { margin: 0; font: 750 1.15rem/1.25 var(--sans); letter-spacing: -0.02em; }
.landing-points p { margin: 0; color: var(--ink-2); line-height: 1.55; }
.landing-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--lamp-soft); color: var(--lamp-ink); }
.landing-foot { margin-top: auto; padding: 1.5rem; text-align: center; color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--rule); }
@media (max-width: 860px) {
  .landing-hero { grid-template-columns: minmax(0, 1fr); padding-bottom: 200px; gap: 2rem; }
  .landing-sky { height: 260px; }
  .landing-preview { justify-self: start; transform: none; }
  .landing-points { grid-template-columns: minmax(0, 1fr); }
  .landing-top .auth-tools .lang-menu span { display: none; }
}
