/* Budget — feuille de style unique, sans dépendance externe. CSP stricte : aucun style en ligne. */

:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #e9efed;
  --ink: #142322;
  --muted: #5b6c6a;
  --line: #dbe3e1;
  --primary: #0d6b66;
  --primary-2: #12877f;
  --primary-soft: #e2f1ee;
  --primary-ink: #ffffff;
  --danger: #c2412d;
  --danger-soft: #fbe9e5;
  --ok: #1e7650;      /* assez foncés pour du petit texte (badges, titres de conseils) : ≥ 4,5:1 sur blanc et sur les fonds pâles */
  --ok-soft: #e3f3ea;
  --warn: #8a5a10;
  --warn-soft: #f8eedc;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 40, 38, 0.06);
  --shadow: 0 1px 2px rgba(16, 40, 38, 0.05), 0 6px 20px rgba(16, 40, 38, 0.07);
  --shadow-lg: 0 10px 40px rgba(16, 40, 38, 0.18);
  --bar-bg: rgba(255, 255, 255, 0.86);
  /* Couleurs propres à quelques composants, redéfinies en sombre */
  --feature-bg: linear-gradient(140deg, var(--primary) 0%, var(--primary-2) 100%);
  --feature-shadow: 0 12px 30px rgba(13, 107, 102, 0.28);
  --share-bg: #efe7fb;
  --share-ink: #6b3fb0;
  --teal-fill: #0D6B66;
  --invest-fill: #1F5F99;
  --sun-bg: #ffe9ae;      /* carte de la prime à placer (Accueil) */
  --sun-ink: #4a3500;
  --undo-ink: #ffd76a;    /* « Annuler » sur le message (fond foncé en clair, clair en sombre) */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --display: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

/* Mode sombre : comme l'appareil (data-theme="auto", ou absent sur la page hors ligne), sauf si le clair est choisi,
   ou imposé par le réglage (Web/Theme.cs, <html data-theme>). Les deux blocs doivent rester identiques. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1514;
    --surface: #152120;
    --surface-2: #1d2c2a;
    --ink: #e3ecea;
    --muted: #93a6a3;
    --line: #263634;
    --primary: #45b8b0;
    --primary-2: #2f9d95;
    --primary-soft: #17312e;
    --primary-ink: #0b1615;
    --danger: #f07a64;
    --danger-soft: #3a1f1a;
    --ok: #5cc48e;
    --ok-soft: #16301f;
    --warn: #e0a84a;
    --warn-soft: #33271a;
    --shadow-sm: none;
    --shadow: 0 0 0 1px var(--line);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --bar-bg: rgba(21, 33, 32, 0.88);
    --feature-bg: linear-gradient(140deg, #0f4f4b 0%, #13706a 100%);
    --feature-shadow: 0 0 0 1px #1e4744;
    --share-bg: #2d2340;
    --share-ink: #c9a8f5;
    --teal-fill: #45b8b0;
    --invest-fill: #5b9bd5;
    --sun-bg: #3b2f12;
    --sun-ink: #ffe3a0;
    --undo-ink: #0d6b66;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
    --bg: #0d1514;
    --surface: #152120;
    --surface-2: #1d2c2a;
    --ink: #e3ecea;
    --muted: #93a6a3;
    --line: #263634;
    --primary: #45b8b0;
    --primary-2: #2f9d95;
    --primary-soft: #17312e;
    --primary-ink: #0b1615;
    --danger: #f07a64;
    --danger-soft: #3a1f1a;
    --ok: #5cc48e;
    --ok-soft: #16301f;
    --warn: #e0a84a;
    --warn-soft: #33271a;
    --shadow-sm: none;
    --shadow: 0 0 0 1px var(--line);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --bar-bg: rgba(21, 33, 32, 0.88);
    --feature-bg: linear-gradient(140deg, #0f4f4b 0%, #13706a 100%);
    --feature-shadow: 0 0 0 1px #1e4744;
    --share-bg: #2d2340;
    --share-ink: #c9a8f5;
    --teal-fill: #45b8b0;
    --invest-fill: #5b9bd5;
    --sun-bg: #3b2f12;
    --sun-ink: #ffe3a0;
    --undo-ink: #0d6b66;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  font-variant-numeric: tabular-nums;
}

a { color: var(--primary); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.015em; }
h2 { font-size: 1.15rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 650; }

p { margin: 0 0 0.75rem; }

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

/* ---------- En-tête et navigation ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand svg { display: block; }

.nav { display: flex; gap: 2px; background: var(--surface); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); }

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }

/* Bouton clair / sombre : lune en clair, soleil en sombre (automatique compris). */
.theme-toggle { margin: 0 0 0 auto; }
.top .nav { margin-left: auto; }
.top .nav + .theme-toggle { margin-left: 0; }
.theme-toggle button {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow); cursor: pointer;
}
.theme-toggle button:hover { color: var(--ink); }
.theme-toggle svg { width: 20px; height: 20px; }
[data-theme-toggle] .sun { display: none; }
:root[data-theme="dark"] [data-theme-toggle] .sun { display: block; }
:root[data-theme="dark"] [data-theme-toggle] .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-theme-toggle] .sun { display: block; }
  :root:not([data-theme="light"]) [data-theme-toggle] .moon { display: none; }
}

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.discreet-toggle .ic { width: 20px; height: 20px; }
:root[data-discret="on"] .discreet-toggle button { color: var(--primary); background: var(--primary-soft); }

/* Mode discret : les champs de montant gardent leur valeur mais s'affichent en points, comme un mot de passe. */
:root[data-discret="on"] :is(input.amount-input, input[inputmode="decimal"], .unit-input input) { -webkit-text-security: disc; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover, .icon-btn[aria-current="page"] { color: var(--primary); }

.tabbar { display: none; }
.sidebar { display: none; }

/* ---------- Téléphone : barre d'onglets flottante, « + » au centre ---------- */
@media (max-width: 700px) {
  .nav { display: none; }
  .top { padding: 12px 0 6px; }
  body.has-tabbar { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    background: var(--bar-bg);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 6px 4px;
    z-index: 20;
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 2px 0 4px;
    font-size: 0.7rem;
    font-weight: 650;
    color: var(--muted);
    text-decoration: none;
  }
  .tabbar svg {
    width: 44px;
    height: 28px;
    padding: 3px 11px;
    border-radius: 999px;
    transition: background 0.25s var(--ease), color 0.25s;
  }
  .tabbar a[aria-current="page"] { color: var(--primary); }
  .tabbar a[aria-current="page"] svg { background: var(--primary-soft); }
  .tab-add {
    justify-self: center;
    width: 54px;
    height: 54px;
    border: 0;
    border-radius: 19px;
    background: linear-gradient(140deg, var(--primary), var(--primary-2));
    color: var(--primary-ink);
    box-shadow: 0 6px 18px rgba(13, 107, 102, 0.35);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.15s var(--ease);
  }
  .tab-add:active { transform: scale(0.92); }
  .tabbar .tab-add svg { width: 26px; height: 26px; padding: 0; border-radius: 0; }
}

/* ---------- Ordinateur et tablette : menu latéral ---------- */
@media (min-width: 701px) {
  body.has-tabbar { display: grid; grid-template-columns: 236px minmax(0, 1fr); align-items: start; }
  body.has-tabbar .top, body.has-tabbar .app-version { display: none; }
  body.has-tabbar .wrap { width: 100%; padding-top: 28px; padding-left: 32px; padding-right: 32px; }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 22px 14px 16px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0 8px; }
  .sidebar .brand > span { display: flex; flex-direction: column; line-height: 1.15; }
  .sidebar .brand small { font-family: var(--text); font-weight: 500; font-size: 0.78rem; color: var(--muted); }
  .side-add svg { width: 18px; height: 18px; }
  .side-nav { display: flex; flex-direction: column; gap: 3px; }
  .side-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    color: var(--ink);
    font-weight: 650;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
  }
  .side-nav a svg { flex: none; width: 20px; height: 20px; }
  .side-nav a:hover { background: var(--surface-2); }
  .side-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  .side-nav a.is-loading svg { color: transparent; }
  .side-nav a.is-loading::before {
    content: "";
    position: absolute;
    left: 13px;
    width: 18px;
    height: 18px;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
  }
  .side-title { display: block; padding: 0 12px 4px; font-size: 0.8rem; font-weight: 700; color: var(--muted); text-decoration: none; }
  .side-title:hover, .side-title[aria-current="page"] { color: var(--primary); }
  .side-links { display: flex; flex-direction: column; gap: 1px; }
  .side-links a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--ink);
    font-size: 0.92rem;
    text-decoration: none;
  }
  .side-links a:hover { background: var(--surface-2); }
  .side-links a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
  .side-theme { margin-top: auto; }
  .side-theme button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
  }
  .side-theme button:hover { background: var(--surface-2); color: var(--ink); }
  .side-theme svg { width: 18px; height: 18px; }
  .side-theme.side-discreet { margin-top: 0; }
  :root[data-discret="on"] .side-discreet button { color: var(--primary); }
  .side-version { padding: 0 12px; font-size: 0.75rem; color: var(--muted); }
}
.wrap.wide { max-width: 1180px; }
.btn.block { width: 100%; }

main { padding-bottom: 48px; }
main:has(.fab) { padding-bottom: 96px; } /* le bouton « + » ne cache pas la dernière ligne */

/* ---------- Messages (toasts) ---------- */

.flash {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  width: max-content;
  max-width: min(92vw, 520px);
  margin: 0;
  padding: 12px 16px 12px 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-weight: 550;
  cursor: pointer;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

.flash::before {
  content: "✓";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
}

.flash.error::before { content: "!"; background: var(--danger); font-weight: 800; }
.flash.hide { opacity: 0; transform: translate(-50%, 16px); pointer-events: none; }
@media (max-width: 700px) {
  .flash { bottom: calc(96px + env(safe-area-inset-bottom)); } /* au-dessus de la barre d'onglets flottante */
}
/* Message après une dépense notée : bouton « Annuler » à droite. */
.flash.with-undo { display: flex; align-items: center; gap: 14px; padding-right: 8px; }
.flash-undo { margin: 0; }
.flash-undo button {
  min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent;
  color: var(--undo-ink); font: inherit; font-weight: 750; cursor: pointer;
}

.errors {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  margin: 0 0 16px;
  padding: 10px 14px 10px 32px;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.badge.current { background: var(--primary-soft); color: var(--primary); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.todo { background: var(--warn-soft); color: var(--warn); }

/* ---------- Le mois : en-tête et synthèse ---------- */

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 16px;
}

.month-nav .title { flex: 1; text-align: center; display: grid; gap: 4px; justify-items: center; }
.month-nav h1 { text-align: center; flex: 1; }
.month-nav .badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.month-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 1.3rem;
  transition: transform 0.15s;
}

.month-nav a:active { transform: scale(0.92); }

/* Lien « Revenir au mois en cours » sous le titre (pas un bouton rond comme les flèches). */
.month-nav .title a.today {
  width: auto;
  height: auto;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--primary);
  background: transparent;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hero { margin-bottom: 24px; }

/* Gros montant, puis son texte d'accompagnement en dessous (jamais à côté). */
.hero-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 12px;
}

.hero-figure .amount {
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
}

.hero-figure .caption { color: var(--muted); }

/* Carte de synthèse du mois, en dégradé. */
.feature {
  position: relative;
  overflow: hidden;
  padding: 20px 18px 16px;
  border-radius: var(--radius-lg);
  background: var(--feature-bg);
  color: #fff;
  box-shadow: var(--feature-shadow);
}

.feature::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}


.feature .eyebrow { display: block; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.85; }
.feature .hero-figure { display: block; margin: 4px 0 14px; }
.feature .hero-figure .amount { display: block; font-size: 2.9rem; color: #fff; }
.feature .hero-figure .caption { display: block; margin-top: 6px; color: rgba(255, 255, 255, 0.85); }
.feature .split-track { fill: rgba(255, 255, 255, 0.18); }
.feature .legend { color: rgba(255, 255, 255, 0.92); }
.feature .legend .value { color: #fff; }

.feature .kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 520px) { .feature .kpis { grid-template-columns: repeat(2, 1fr); } }

/* Voile sombre (et non clair) sous les KPI : le petit texte blanc garde un contraste d'au moins 4,5:1. */
.feature .kpi { background: rgba(0, 0, 0, 0.14); border-radius: 12px; padding: 8px 10px; }
.feature .kpi .k { display: block; font-size: 0.75rem; color: rgba(255, 255, 255, 0.92); }
.feature .kpi .v { display: block; font-family: var(--display); font-weight: 800; font-size: 1.05rem; }
.feature .kpi .hint { display: block; font-size: 0.72rem; color: rgba(255, 255, 255, 0.9); }

svg.split { display: block; width: 100%; height: 30px; }
.split-track { fill: var(--surface-2); }

/* Barre du plan : non affecté, zone du bonus hachurée (or), dépassement au-delà du bonus. */
.split-free { fill: #c3d0cd; }
.split-over { fill: var(--danger); }
.bonus-bg { fill: rgba(242, 193, 78, 0.22); }
.bonus-stripe { fill: rgba(242, 193, 78, 0.55); }
.feature .split-free { fill: rgba(255, 255, 255, 0.45); }
.feature .split-over { fill: #ff8a73; }
.feature .bonus-bg { fill: rgba(255, 214, 102, 0.18); }
.feature .bonus-stripe { fill: rgba(255, 214, 102, 0.6); }
svg.dot.key-free circle { fill: #c3d0cd; }
svg.dot.key-bonus circle { fill: #f2c14e; }
.feature svg.dot.key-free circle { fill: rgba(255, 255, 255, 0.45); }
.feature svg.dot.key-bonus circle { fill: #ffd666; }

.plan-bar-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.8;
}

.feature .hero-figure .bonus-line {
  display: block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
  color: #ffe8a3;
  font-size: 0.9rem;
  font-weight: 650;
}
.feature .hero-figure .bonus-line.warn { color: #fff; background: rgba(194, 65, 45, 0.55); }
.feature .overrun-line {
  margin: 0 0 12px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(194, 65, 45, 0.55);
  color: #fff;
  font-size: 0.9rem;
}
.feature .bonus-legend { margin-top: 6px; color: #ffe8a3; }
.feature .bonus-legend .value { color: #ffe8a3; }

.legend {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.86rem;
}

.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .value { font-weight: 700; }

svg.dot { flex: none; display: inline-block; vertical-align: middle; }

.callout {
  margin: 16px 0; /* marge basse : l'encadré ne touche pas le panneau qui suit */
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--primary-soft);
}
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }

/* Rituel du jour de paie : étapes */
.ritual-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; counter-reset: step; }
.ritual-steps li { flex: 1; min-width: 0; text-align: center; font-size: 0.78rem; color: var(--muted); padding-top: 8px; border-top: 4px solid var(--line); counter-increment: step; }
.ritual-steps li::before { content: counter(step) ". "; }
.ritual-steps li.done { border-color: var(--ok); color: var(--ok); }
.ritual-steps li.current { border-color: var(--primary); color: var(--ink); font-weight: 750; }

/* Cap : jalons et objectifs projetés */
.milestones { list-style: none; margin: 0; padding: 0; }
.milestones li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 2px 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.milestones li:first-child { border-top: 0; }
.milestones .when { grid-row: span 2; font-weight: 800; font-family: var(--display); color: var(--primary); font-size: 0.9rem; }
.milestones .what { font-weight: 700; }
.milestones .detail { color: var(--muted); font-size: 0.86rem; }
.milestones li.credit .when, .milestones li.zero-dette .when { color: var(--ok); }
.late { color: var(--danger); font-weight: 650; }
.hypotheses { margin: 0; padding-left: 18px; }
.hypotheses li { margin: 5px 0; }
.early { color: var(--ok); font-weight: 650; }

/* Crédits suivis (patrimoine) */
.loan { display: grid; gap: 8px; padding: 14px; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.list > .loan:first-child { border-top: 0; }
.loan:target { background: var(--primary-soft); }
.loan p, .loan .callout { margin: 0; }
.loan-head { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.loan-head .name { flex: 1; min-width: 0; }
.loan-head .value { font-family: var(--display); font-weight: 800; }
.loan .sub { color: var(--muted); font-size: 0.86rem; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-fields select { flex: 1 1 140px; min-width: 0; }
.loan-settings > summary { color: var(--primary); font-size: 0.9rem; }
.loan-settings form { margin-top: 8px; }

/* Actions rapides (défilement horizontal sur téléphone). */
.quick-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 16px -16px 20px;
  padding: 2px 16px 6px;
}

.quick-actions::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.chip:active { transform: scale(0.96); }
.chip.primary { background: var(--ink); color: var(--bg); }
.chip.selected { background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.chip.selected span { font-size: 0.8em; opacity: 0.8; }
.chip svg { width: 16px; height: 16px; }

/* Notes compactes (revenus variables, partages, échéances). */
.notes { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }

.notes li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
}

.notes .ico {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  background: var(--primary-soft);
  color: var(--primary);
}

.notes .ico.warn { background: var(--warn-soft); color: var(--warn); }
.notes .ico.share { background: var(--share-bg); color: var(--share-ink); }

/* ---------- Sections et lignes ---------- */

.section { margin: 0 0 24px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head .total { font-weight: 800; font-family: var(--display); }

/* Titre nu dans une section ou un panneau : même écart que .section-head. */
.section > h2, .panel > h2 { margin-bottom: 10px; }

/* Section repliable : l'en-tête fait office de bouton. */
details.fold > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 2px 0;
  cursor: pointer;
}

details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { flex: 1; }
/* Cap, « Vers l'épargne » : une section repliable par année, chaque mois avec ses comptes et ses projets. */
details.save-year > summary h3 { flex: 1; margin: 0; font-size: 1rem; }
#vers-epargne > :is(p, details) + :is(.panel, details) { margin-top: 16px; }
.save-month { align-items: flex-start; }
.save-month .save-goals { color: var(--primary); }
.save-month .amounts .planned { color: var(--ok); }
.save-month.is-empty .amounts .planned { color: var(--muted); }
.save-month .amounts .actual { color: var(--muted); }
details.fold > summary .total { font-weight: 800; font-family: var(--display); }

details.fold > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.25s var(--ease);
  margin: 0 4px 0 2px;
}

details.fold:not([open]) > summary::after { transform: rotate(-45deg); }
details.fold:not([open]) { margin-bottom: 12px; }

/* Liste repliable (ex. destinataires dans Réglages) : .row met le titre en flex, ce qui retire le triangle natif.
   Même chevron que les sections repliables, à droite. */
details.list > summary.row { list-style: none; cursor: pointer; }
details.list > summary.row::-webkit-details-marker { display: none; }
details.list > summary.row:hover { background: var(--surface-2); }
details.list > summary.row::after {
  content: "";
  flex-shrink: 0;
  margin: 0 4px 0 auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.25s var(--ease);
}
details.list[open] > summary.row::after { transform: rotate(45deg) translate(-2px, -2px); }

.list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 6px;
  border-top: 1px solid var(--line);
}

.list > .group-head:first-child { border-top: 0; }

.group-head .name { font-weight: 750; flex: 1; }
.group-head .sum { font-weight: 750; }

.group-gauge { padding: 0 14px 6px; }

svg.gauge { display: block; width: 100%; height: 6px; }
.gauge-track { fill: var(--surface-2); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: inherit;
  text-decoration: none;
  border-top: 1px solid var(--line);
  min-height: 54px;
  transition: background 0.15s;
}

.list > .row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-2); }
a.row:active { background: var(--primary-soft); }

.row .main { flex: 1; min-width: 0; }
a.main { color: inherit; text-decoration: none; }
.provision-help { margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); }
/* Part d'une provision : le bouton « Pas mis de côté » / « Annuler » passe sous le libellé, sinon il écrase le libellé
   dans une colonne étroite (bloc Épargne du mois sur ordinateur). */
.row.provision-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 6px; }
.provision-row .inline-form { grid-column: 2 / -1; justify-self: start; }
.row .label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.row .sub { display: block; color: var(--muted); font-size: 0.84rem; }
.row .amounts { text-align: right; white-space: nowrap; }
.row .amounts .planned { font-weight: 700; }
.row .amounts .actual { display: block; font-size: 0.84rem; }

a.panel.row { border-top: 0; margin-bottom: 16px; padding: 14px 16px; }

/* Projets dans l'ordre de priorité (page Épargne) : numéro à gauche, flèches à droite pour changer l'ordre. */
.goal-row .rank {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 750; font-size: 0.9rem;
}
.goal-row .reorder { flex: none; display: flex; flex-direction: column; gap: 4px; }
.goal-row .reorder .btn { min-height: 30px; min-width: 38px; padding: 2px 8px; }
.goal-row .reorder .btn:disabled { opacity: 0.3; }

/* Solder un crédit (page /remboursement) */
.payoff-result .headline { margin: 0; }
.payoff-result .headline strong { font-family: var(--display); font-size: 1.7rem; }
.payoff-result h3 { margin: 6px 0 0; font-size: 1rem; }
.facts { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.facts .neg { color: var(--danger); }
.payoff-path summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.payoff-path .table-wrap { margin-top: 8px; }
a.panel.row .amounts { font-size: 1.4rem; color: var(--muted); }

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: 1px;
}

.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-weight: 650;
  text-decoration: none;
}

/* « + » dessiné par deux traits centrés (un caractère « + » ne se centre jamais dans sa pastille). */
.add-row::before {
  content: "";
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--primary-soft);
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor);
  background-size: 12px 2px, 2px 12px;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-color 0.15s, color 0.15s;
}

@media (hover: hover) {
  .add-row:hover::before { background-color: var(--primary); color: var(--primary-ink); }
}

.empty { padding: 18px 14px; color: var(--muted); }

/* ---------- Chiffres clés ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

/* Séparateurs dessinés par chaque case : une ligne incomplète ne laisse pas de trou grisé. */
.stat { padding: 12px 14px; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.stat .k { display: block; color: var(--muted); font-size: 0.82rem; }
.stat .v { display: block; font-family: var(--display); font-weight: 800; font-size: 1.3rem; }
.stat .hint { display: block; color: var(--muted); font-size: 0.78rem; }

/* ---------- Formulaires ---------- */

form.stack { display: grid; gap: 14px; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-weight: 650; font-size: 0.9rem; }
.field .help { color: var(--muted); font-size: 0.82rem; font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
/* Les éléments de grille ne doivent pas imposer la largeur de leur contenu (champs « mois » de Safari). */
.grid-2 > *, form.stack > *, .stack > * { min-width: 0; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Safari iOS : les champs date/mois et les listes ont une largeur et un style imposés qui débordent. */
input[type="month"], input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  line-height: 1.3;
  text-align: left;
}
input[type="month"]::-webkit-date-and-time-value, input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235b6c6a' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

input[type="color"] { padding: 4px; width: 52px; flex: none; }
.order-input { width: 60px; flex: none; }
input[type="checkbox"], input[type="radio"] { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.amount-input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s, filter 0.2s, background 0.2s;
}

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 13px; font-size: 0.88rem; border-radius: 10px; }
.btn.link { background: none; border: 0; color: var(--primary); padding: 0; min-height: 0; font-weight: 650; }

.inline-form { display: inline; }

/* Lignes éditables (Réglages, Patrimoine) : passent à la ligne au lieu de déborder. */
form.row { flex-wrap: wrap; row-gap: 8px; }
form.row .main { flex: 1 1 150px; min-width: 0; }
form.row select { width: auto; flex: 0 0 auto; }
form.row .check { flex: 0 0 auto; }
form.row .btn { margin-left: auto; flex: 0 0 auto; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Les cartes (panneau, liste, tableau) n'ont pas de marge : c'est ce qui les suit qui prend l'écart.
   Autre carte, bouton, titre : 16 px ; note sous la carte : 10 px ; nouvelle section : 24 px.
   Dans une grille ou une colonne qui espace déjà ses blocs (gap), pas de marge en plus (sinon une colonne descendrait). */
:is(.panel, .list, .table-wrap) + * { margin-top: 16px; }
:is(.panel, .list, .table-wrap) + p { margin-top: 10px; }
:is(.panel, .list, .table-wrap) + .section { margin-top: 24px; }
:is(.stack, .cap-layout, .cap-side, .proj-layout, .proj-side, .page-panes, .house-main, .house-cards, .home-top, .home-cols,
    .tiles, .noter, .payday-split, .loan, .secret-box, .year-list) > :is(.panel, .list, .table-wrap) + * { margin-top: 0; }
/* Bouton seul après une carte (« Supprimer le scénario ») : un formulaire en ligne ignorerait la marge. */
:is(.panel, .list, .table-wrap) + .inline-form { display: block; }

/* ---------- Tableaux ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 650; font-size: 0.82rem; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---------- Graphiques ---------- */

/* overflow visible : une graduation plus longue que prévu déborde dans le padding du panneau au lieu d'être coupée. */
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font: 11px var(--text); }
svg.chart .line-planned { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
svg.chart .line-planned-dot { fill: var(--primary); }
svg.chart .line-actual { fill: none; stroke: var(--warn); stroke-width: 2; stroke-dasharray: 5 4; }
svg.chart .line-actual-dot { fill: var(--warn); }
svg.chart .picked { stroke: var(--ink); stroke-width: 2; }
/* Catégories (Réglages) : liste lisible, flèches d'ordre sur la ligne ; fiche avec palette de couleurs. */
.category-row { align-items: center; }
.category-row .label { display: inline-flex; align-items: center; gap: 8px; }
.category-row .reorder { flex: none; display: flex; gap: 4px; }
.category-row .reorder form { margin: 0; }
.category-row .reorder .btn { min-height: 34px; min-width: 34px; padding: 0; }
.category-row .reorder .btn:disabled { opacity: 0.3; }
.category-archived { margin-top: 12px; }
.category-archived > summary { cursor: pointer; color: var(--muted); font-weight: 650; padding: 6px 2px; }
.category-archived .label { display: inline-flex; align-items: center; gap: 8px; }
.category-form legend { font-weight: 650; font-size: 0.9rem; margin-bottom: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.swatch input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.swatch .dot { width: 32px; height: 32px; }
.swatch:has(input[type="radio"]:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch:has(input[type="radio"]:focus-visible) { outline: 2px solid var(--primary); outline-offset: 3px; }
.swatch.other input[type="color"] {
  -webkit-appearance: none; appearance: none;
  display: block; box-sizing: border-box; width: 32px; height: 32px; min-width: 0; min-height: 0; padding: 0;
  border: 2px dashed var(--line); border-radius: 50%; background: none; cursor: pointer; overflow: hidden;
}
.swatch.other input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatch.other input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatch.other input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }
.switch-line > span { display: grid; gap: 2px; }
.switch-line .help { color: var(--muted); font-size: 0.85rem; font-weight: 400; line-height: 1.45; }

/* Interrupteur (lissage des courbes du patrimoine). */
.smooth-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 12px 2px 0; }
.smooth-toggle .small { flex: 1 1 220px; }
.switch { display: inline-flex; align-items: center; gap: 10px; padding: 4px 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 650; cursor: pointer; }
.switch-track { position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); transition: background 0.15s; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s var(--ease); }
.switch.on .switch-track { background: var(--primary); }
.switch.on .switch-knob { transform: translateX(16px); }
.switch:focus-visible .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-knob { transition: none; } }

/* Patrimoine par élément : une courbe par élément (couleur de l'élément, attribut stroke). */
svg.chart .series { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
@media (max-width: 700px) { svg.chart .series { stroke-width: 4; } }
.element-legend { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.86rem; }
.element-legend a, .element-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; }
.element-legend a:hover { text-decoration: underline; }
.loan-head a.name { color: inherit; text-decoration: none; }
.loan-head a.name:hover { text-decoration: underline; }
/* Trajectoire (page Cap) : fourchette prudent–favorable, courbe réaliste, zéro, jalons ; points visibles une fois touchés. */
svg.chart .traj-band { fill: var(--primary-soft); }
svg.chart .traj-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
svg.chart .traj-zero { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 4; }
svg.chart .traj-mark { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 4; }
svg.chart .traj-pt, svg.chart.many circle { opacity: 0; }
svg.chart.many circle.picked { opacity: 1; }
svg.chart .traj-pt.picked { opacity: 1; }
svg.dot.key-band circle { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 1; }
svg.dot.key-mark circle { fill: var(--warn); }

/* Le graphique (viewBox de 640 de large) est réduit à la largeur de l'écran : les tailles ci-dessous sont en unités
   du viewBox. On grossit texte et traits pour garder environ 11 px réels (≈ 11,2 px sur un iPhone de 390 px). */
@media (max-width: 700px) {
  svg.chart .axis { font-size: 16px; }
  svg.chart .axis.alt { display: none; } /* un mois sur deux : les étiquettes grossies ne se chevauchent pas */
  svg.chart .line-planned { stroke-width: 3.5; }
  svg.chart .line-actual { stroke-width: 3; stroke-dasharray: 8 6; }
  svg.chart .traj-line { stroke-width: 3.5; }
  svg.chart .traj-mark, svg.chart .traj-zero { stroke-width: 2.5; }
}
@media (max-width: 520px) {
  svg.chart .axis { font-size: 20px; }
  svg.chart .line-planned { stroke-width: 4.5; }
  svg.chart .line-actual { stroke-width: 4; stroke-dasharray: 10 8; }
  svg.chart circle { r: 6px; } /* points plus gros là où le navigateur le permet (sinon r = 3.5) */
  svg.chart .picked { stroke-width: 3; }
}
@media (max-width: 430px) { svg.chart .axis { font-size: 22px; } }

/* Pastilles de légende des courbes (Charts.Key) : mêmes couleurs que les courbes, en clair comme en sombre. */
svg.dot.key-planned circle { fill: var(--primary); }
svg.dot.key-actual circle { fill: var(--warn); }

/* Couleurs fixes écrites par certaines pages (jauge d'objectif, barres « Investi », couleur de compte) : trop sombres
   sur fond sombre. Le style l'emporte sur l'attribut fill ; « i » ignore la casse. Rien ne change en mode clair. */
svg:is(.dot, .gauge, .split, .chart) [fill="#0D6B66" i] { fill: var(--teal-fill); }
svg:is(.dot, .gauge, .split, .chart) [fill="#1F5F99" i] { fill: var(--invest-fill); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Valeurs de la colonne touchée (site.js) : les infobulles n'apparaissent pas au toucher. */
.chart-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
.chart-readout:empty { display: none; }
.chart-readout strong { color: var(--ink); }
.chart-readout span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }

/* ---------- Connexion / installation ---------- */

.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 6px; }
.auth .lead { color: var(--muted); margin-bottom: 20px; }

.qr { display: block; width: 220px; height: 220px; margin: 8px auto; border-radius: 8px; background: #fff; padding: 8px; }

.secret {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1rem;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
}

.codes {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.codes li { background: var(--surface-2); padding: 6px 8px; border-radius: 6px; text-align: center; }

details > summary { cursor: pointer; font-weight: 650; padding: 6px 0; }

/* ---------- Partages ---------- */

.tag.shared { background: var(--share-bg); color: var(--share-ink); }
.tag.exceptional { background: var(--warn-soft); color: var(--warn); }

/* Date de prélèvement passée sans être cochée : liseré orange à gauche, badge et rappel (à vérifier sur le compte). */
.tag.late { background: var(--warn); color: var(--surface); }
.row.is-late, .check-row.is-late { box-shadow: inset 4px 0 0 var(--warn); }
.cal-item.is-late .cal-amount { color: var(--warn); }
.late-note { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.late-note a { color: inherit; }
.tag.tracked { background: var(--primary-soft); color: var(--primary); }

/* Texte lu seulement par les lecteurs d'écran. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Calendrier des prélèvements */
.low-card { display: grid; gap: 4px; }
.low-card .k { font-size: 0.85rem; color: var(--muted); font-weight: 650; }
.low-card .amount { font-family: var(--display); font-size: 1.9rem; font-weight: 800; letter-spacing: -0.01em; }
.low-card svg.spark { margin: 8px 0 4px; flex: none; }
.low-card.negative { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--danger); }
.cal-day { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.cal-day:first-child { border-top: 0; }
.cal-day.past { opacity: 0.6; }
.cal-date { display: grid; justify-items: center; align-content: start; gap: 2px; }
.cal-date strong { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); font-size: 1rem; }
.cal-date span { font-size: 0.75rem; color: var(--muted); }
.cal-day.today .cal-date strong { background: var(--primary); color: var(--primary-ink); }
.cal-items { display: grid; gap: 8px; min-width: 0; align-content: start; }
.cal-item, .due-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; }
.cal-item .main, .due-list .main { display: grid; min-width: 0; }
.cal-item .label, .due-list .label { font-weight: 600; }
.cal-item .sub, .due-list .sub { font-size: 0.82rem; color: var(--muted); }
.cal-amount, .due-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-balance { font-size: 0.8rem; color: var(--muted); }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 12px; }
.year-list { display: grid; gap: 12px; }
@media (min-width: 701px) { .year-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .year-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.year-month h3 { margin-bottom: 10px; }
.year-month.empty h3 { margin-bottom: 4px; color: var(--muted); }
.due-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tag.due-fin { background: var(--ok-soft); color: var(--ok); }
.tag.due-contrat, .tag.due-tarif { background: var(--warn-soft); color: var(--warn); }
.tag.due-provision, .tag.due-cadeaux, .tag.due-projet { background: var(--primary-soft); color: var(--primary); }
/* Échéance d'une dépense annuelle lissée : part déjà mise de côté (étiquette et barre). */
.tag.part-progress { background: var(--surface-2); color: var(--ink); }
.tag.part-progress.done { background: var(--ok-soft); color: var(--ok); }
.due-list svg.goal-bar { display: block; width: 100%; height: 6px; margin-top: 6px; }
/* Parts des dépenses annuelles de chaque mois : une ligne chacune, statut au milieu, montant à droite. */
.year-parts { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.year-month h3 + .year-parts { margin-top: 0; padding-top: 0; border-top: 0; }
.year-parts-head { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 6px; font-size: 0.82rem; color: var(--muted); }
.year-parts-head strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.part-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.part-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-size: 0.86rem; }
.part-list .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-amount { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.part-missed .part-amount { color: var(--muted); }
.tag.part-saved { background: var(--ok-soft); color: var(--ok); }
.tag.part-partial, .tag.part-missed { background: var(--warn-soft); color: var(--warn); }
.tag.part-planned { background: var(--surface-2); color: var(--muted); }

/* Comptes (super admin) */
.account-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; font-size: 1.02rem; }
.account-head .tag:first-of-type { margin-left: 8px; }
.account-card > p { margin: 6px 0 0; }
.account-card > .actions { margin-top: 12px; }
.invite-link { width: 100%; margin-top: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
details.share { border-top: 1px dashed var(--line); padding-top: 8px; }
details.share > summary { margin-bottom: 8px; }

/* Projets archivés (page Projets) : désarchiver ou supprimer définitivement. */
.archived-goal .archived-actions { display: flex; gap: 6px; flex: none; }
@media (max-width: 420px) {
  .row.archived-goal { flex-wrap: wrap; }
  .archived-goal .archived-actions { width: 100%; justify-content: flex-end; }
}

/* Nom secret (partiel _SecretFields) : le nom affiché à la place n'apparaît qu'une fois la case cochée ; le vrai nom
   d'un élément secret reste replié sous « Plus d'options ». */
.secret-box { display: grid; gap: 10px; }
.secret-box:not(:has(.secret-toggle input:checked)) .secret-cover { display: none; }
details.secret-more > summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }
details.secret-more[open] > summary { margin-bottom: 10px; }
.person .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.person .name { font-weight: 750; font-size: 1.1rem; }
.person .balance { font-family: var(--display); font-weight: 800; font-size: 1.35rem; white-space: nowrap; }
.person form.repay { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 10px; }
@media (max-width: 480px) { .person form.repay { grid-template-columns: 1fr 1fr; } .person form.repay .btn { grid-column: 1 / -1; } }

.app-version { color: var(--muted); font-size: 0.75rem; text-align: center; padding: 0 0 24px; }

/* ---------- Points d'attention ---------- */

.insights { list-style: none; margin: 0; padding: 0; }
/* Le bouton passe sous le texte quand il lui laisserait moins de 220 px (téléphone, colonne étroite). */
.insight { border-left: 4px solid var(--primary); align-items: center; flex-wrap: wrap; }
.insight .main { flex: 1 1 220px; }
.insight.alert { border-left-color: var(--danger); }
.insight.tip { border-left-color: var(--warn); }
.insight.good { border-left-color: var(--ok); }
.insight .label { white-space: normal; font-weight: 700; }
.insight .principle { display: block; font-size: 0.7rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.insight.alert .principle { color: var(--danger); }
.insight.tip .principle { color: var(--warn); }
.insight.good .principle { color: var(--ok); }
.insight .btn { flex-shrink: 0; }
@media (max-width: 480px) { .insight { flex-wrap: wrap; } .insight .btn { margin-left: auto; } }
.insights + p { margin-top: 8px; }
details.more > summary { color: var(--primary); font-size: 0.9rem; padding: 10px 2px 0; }
details.more .insights { margin-top: 8px; }

/* ---------- Suivi rapide, liste d'envies ---------- */

/* Enveloppe suivie (page du mois, #suivi) : nom et « + Noter », le reste en grand, la jauge, puis ses dépenses
   notées en lignes qui ouvrent leur fiche (partiel _SpendRow), les plus anciennes repliées. */
.env-block { padding: 14px 14px 12px; border-top: 1px solid var(--line); }
.list > .env-block:first-child { border-top: 0; }
.env-head { display: flex; align-items: center; gap: 10px; }
.env-head .name { flex: 1; min-width: 0; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-head .btn { flex: none; }
.env-figure { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; margin: 6px 0 10px; color: var(--muted); font-size: 0.9rem; }
.env-figure strong { font-family: var(--display); font-weight: 900; font-size: 1.6rem; line-height: 1.15; color: var(--ink); }
.env-figure strong.neg { color: var(--danger); }
.env-gauge svg.gauge { height: 10px; }
.env-meta { display: flex; justify-content: space-between; gap: 10px; margin: 6px 0 0; color: var(--muted); font-size: 0.84rem; }
.spend-row .label.untitled { color: var(--muted); font-style: italic; font-weight: 500; }
.spend-row .amounts .planned { font-weight: 650; }
.list .spend-row { min-height: 52px; }
#suivi .spend-row { padding-left: 36px; }
details.spend-more > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 12px 36px; border-top: 1px solid var(--line);
  color: var(--primary); font-size: 0.9rem; font-weight: 650; cursor: pointer; list-style: none;
}
details.spend-more > summary::-webkit-details-marker { display: none; }
details.spend-more > summary::after {
  content: ""; width: 7px; height: 7px; margin-left: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.25s var(--ease);
}
details.spend-more[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
details.spend-more > summary:hover { background: var(--surface-2); }
/* Fiche d'une dépense notée : les champs du panneau Noter dans un panneau. */
.spend-form > fieldset.noter { border: 0; margin: 0; padding: 0; min-width: 0; }
.spend-form > fieldset:disabled .noter-amount { border-color: var(--line); }
.spend-form > fieldset:disabled .cat-chip span { cursor: default; }
.wish .actions { margin-top: 8px; }

/* ---------- Liste de cadeaux : mois → occasion → personne ---------- */

.gifts-month { margin-bottom: 28px; }
.gifts-month > .section-head { padding-bottom: 6px; border-bottom: 2px solid var(--ink); margin-bottom: 12px; }
.gifts-month > .section-head h2, .gifts-month > .section-head h3 { margin: 0; }
.gift-card { margin-bottom: 14px; }

/* Occasion : bandeau coloré en tête de carte. */
.gift-occasion-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--primary-soft);
  color: var(--primary);
}
.gift-occasion-head svg { flex: none; width: 18px; height: 18px; }
.gift-occasion-head h3 { flex: 1; margin: 0; font-size: 0.98rem; font-weight: 800; letter-spacing: 0.01em; }
/* Déjà payé / total : le payé en couleur, vert quand tout est acheté. */
.gift-sum { white-space: nowrap; font-weight: 700; color: var(--muted); }
.gift-sum .paid { color: var(--ink); font-weight: 800; }
.gift-sum .paid.all { color: var(--ok); }
.gift-occasion-head .gift-sum { color: var(--primary); opacity: 0.85; }
.gift-occasion-head .gift-sum .paid { color: var(--primary); }
.gift-occasion-head .gift-sum .paid.all { color: var(--ok); }
.gift-person .meta .gift-sum { font-weight: 600; }
.gift-person .meta .gift-sum .paid { font-weight: 700; }

/* Personne : bandeau gris avec pastille ; ses cadeaux en retrait, alignés sur le prénom. */
.gift-person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.gift-person .name { flex: 1; min-width: 0; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gift-person .meta { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
}
.av-0 { background: #0d6b66; }
.av-1 { background: #b4462f; }
.av-2 { background: #6a4fb3; }
.av-3 { background: #9a6410; }
.av-4 { background: #2e64a8; }
.av-5 { background: #a3406f; }
.av-none { background: var(--muted); }
.row.gift { padding-left: 52px; min-height: 50px; }
/* Pas encore d'idée : ligne mise en avant jusqu'à la saisie de l'idée. */
.row.gift.no-idea { background: var(--warn-soft); }
.row.gift.no-idea .label { display: flex; align-items: center; gap: 6px; color: var(--warn); font-weight: 750; font-style: italic; }
.row.gift.no-idea .label svg { flex: none; width: 17px; height: 17px; }
.row.gift.no-idea .sub { color: var(--warn); opacity: 0.85; }
.no-idea-list ul { margin: 6px 0 0; padding-left: 18px; }
.no-idea-list li { margin: 2px 0; }
.no-idea-list a { color: inherit; font-weight: 600; }
.row.gift .label { font-weight: 500; }
.row.gift.bought .label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.gift-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}
.gift-check svg { width: 18px; height: 18px; }
.gift-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.gift-copy .btn { margin-top: 24px; } /* aligné sur le champ, sous son libellé */
.gift-check:hover { border-color: var(--ok); color: var(--ok); }
.gift-check.on { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.gift-check:active { transform: scale(0.9); }
/* Occasion couverte par le cadeau d'une autre occasion : coche en lecture seule (elle suit le cadeau principal). */
.gift-check.static { cursor: default; opacity: 0.55; }
.gift-check.static:hover { border-color: var(--line); color: transparent; }
.gift-check.static.on:hover { border-color: var(--ok); color: var(--bg); }
.gift-check.static:active { transform: none; }
.row.gift.joint .label { font-style: italic; }

/* ---------- Page « Plus » ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }

.tile {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s;
}

.tile:hover { box-shadow: var(--shadow-lg); }
.tile:active { transform: scale(0.97); }
.tile svg { width: 34px; height: 34px; padding: 7px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); margin-bottom: 6px; }
.tile strong { font-family: var(--display); font-size: 1rem; }
.tile span { color: var(--muted); font-size: 0.82rem; line-height: 1.35; }

/* ---------- Ajout rapide : bouton flottant et panneau ---------- */

.fab {
  position: fixed;
  right: max(16px, calc((100vw - 780px) / 2 + 16px));
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 25;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(140deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(13, 107, 102, 0.4);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}

.fab:active { transform: scale(0.92); }
.fab svg { width: 26px; height: 26px; }
@media (max-width: 700px) { .fab { bottom: calc(88px + env(safe-area-inset-bottom)); } }

dialog.sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain; /* en butée du contenu, le défilement ne passe pas à la page dessous */
}

/* Panneau ouvert : la page dessous ne défile plus (glissé sur le fond grisé). Tactile seulement : sur PC,
   la barre de défilement disparaîtrait et décalerait la page. */
@media (pointer: coarse) { html:has(dialog.sheet[open]) { overflow: hidden; } }

@media (min-width: 701px) { dialog.sheet { margin: auto; border-radius: 22px; padding-bottom: 20px; } }

dialog.sheet::backdrop { background: rgba(8, 20, 19, 0.45); }
dialog.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
dialog.sheet .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
dialog.sheet .sheet-head button { border: 0; background: var(--surface-2); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; }
dialog.sheet h3 { margin: 18px 0 10px; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
dialog.sheet .sheet-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Panneau latéral sur ordinateur (Noter une dépense) : glisse depuis la droite, toute la hauteur. */
@media (min-width: 701px) {
  dialog.sheet.side {
    margin: 0 0 0 auto;
    width: 440px;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 22px 0 0 22px;
    padding: 18px 26px 26px;
  }
  dialog.sheet.side .grabber { display: none; }
}
@media (prefers-reduced-motion: no-preference) and (min-width: 701px) {
  dialog.sheet.side[open] { animation: drawer-in 0.24s var(--ease) both; }
}
@keyframes drawer-in { from { transform: translateX(48px); opacity: 0; } }

/* ---------- Noter une dépense ---------- */

.noter { display: flex; flex-direction: column; gap: 14px; }
.noter-label { font-size: 0.85rem; font-weight: 650; color: var(--muted); margin-bottom: -8px; }
.noter-amount {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border: 2px solid var(--primary);
  border-radius: 18px;
  padding: 0 18px;
  background: var(--surface);
}
.noter-amount:focus-within { box-shadow: 0 0 0 4px var(--primary-soft); }
.noter-amount input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.7rem;
  line-height: 1.3;
  padding: 0;
  text-align: right;
}
.noter-amount span { font-family: var(--display); font-weight: 900; font-size: 2rem; color: var(--muted); }
.noter-impact { min-height: 1.4em; margin: -6px 0 0; font-size: 0.95rem; font-weight: 650; color: var(--primary); }
.noter-impact.neg { color: var(--danger); }
.noter-cats { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.noter-cats legend { padding: 0; margin-bottom: 8px; font-size: 0.85rem; font-weight: 650; color: var(--muted); }
.cat-chip { position: relative; }
.cat-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cat-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cat-chip input:checked + span { background: var(--primary); color: var(--primary-ink); }
.cat-chip input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.numpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.numpad[hidden] { display: none; }
.numpad button {
  height: 54px;
  border: 0;
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  cursor: pointer;
  touch-action: manipulation;
}
.numpad button:active { background: var(--primary-soft); }

/* ---------- Accueil ---------- */

.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.home-date { display: block; color: var(--muted); font-size: 0.9rem; }
.home-head h1 { font-size: 2rem; font-weight: 900; }
.home-when { color: var(--muted); font-size: 0.9rem; }

.home-top { display: flex; flex-wrap: wrap; gap: 18px; align-items: stretch; margin-bottom: 26px; }
.home-hero {
  flex: 7 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--feature-bg);
  color: #fff;
  border-radius: 26px;
  padding: 22px 20px 18px;
  box-shadow: var(--feature-shadow);
}
.hero-line { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.home-hero .eyebrow { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255, 255, 255, 0.92); }
.hero-pace { font-size: 0.82rem; color: rgba(255, 255, 255, 0.88); }
.home-figure { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 14px; }
.home-figure .amount { font-family: var(--display); font-weight: 900; font-size: 3.3rem; line-height: 1.08; letter-spacing: -0.02em; }
.home-hero .per-day { color: rgba(255, 255, 255, 0.92); }
.home-hero .per-day strong { color: #ffd76a; }
.home-hero a.on-feature { color: #fff; text-decoration: underline; }
svg.pace { display: block; width: 100%; height: 22px; }
.pace-track { fill: rgba(255, 255, 255, 0.18); }
.pace-fill { fill: #7fd6cf; }
.pace-mark { fill: #fff; }
.hero-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: auto; padding-top: 16px; }
.hero-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 14px;
  padding: 9px 11px;
  color: #fff;
  text-decoration: none;
}
a.hero-tile:hover { background: rgba(0, 0, 0, 0.24); }
.hero-tile .k { font-size: 0.75rem; color: rgba(255, 255, 255, 0.92); }
.hero-tile .v { font-family: var(--display); font-weight: 800; font-size: 1.12rem; white-space: nowrap; }
.hero-tile .hint { font-size: 0.72rem; color: rgba(255, 255, 255, 0.88); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-tile.warn .v { color: #ffd0c4; }
@media (min-width: 701px) {
  .home-hero { padding: 26px 28px 22px; }
  .home-figure { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px 18px; }
  .home-figure .amount { font-size: 4.2rem; }
  .hero-tile { padding: 11px 14px; }
  .hero-tile .v { font-size: 1.3rem; }
}

.home-side { flex: 5 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.prime-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sun-bg);
  color: var(--sun-ink);
  border-radius: 20px;
  padding: 14px 14px 14px 18px;
}
.prime-card .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.prime-card .main span { font-size: 0.88rem; }
.prime-card .btn { flex: none; background: var(--sun-ink); color: var(--sun-bg); }
.home-side .cap-mini { flex: 1; display: flex; flex-direction: column; gap: 8px; margin: 0; border-radius: 22px; padding: 18px 20px; }
.cap-mini-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cap-mini-value { margin: 0; color: var(--muted); }
.cap-mini-value strong { font-family: var(--display); font-weight: 900; font-size: 1.6rem; color: var(--ink); margin-right: 4px; }
.cap-mini p.small { margin: 0; }
svg.spark { display: block; width: 100%; height: 64px; flex: 1; min-height: 56px; }
.spark-area { fill: var(--primary-soft); }
.spark-line { stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.home-envs { margin-bottom: 26px; }
.env-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  margin: 0 -16px;
  padding: 4px 16px 10px;
  scrollbar-width: none;
}
.env-cards::-webkit-scrollbar { display: none; }
.env-card {
  flex: 0 0 142px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 14px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.env-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.env-card:active { transform: scale(0.97); }
.env-top { display: flex; justify-content: space-between; align-items: flex-start; }
.env-ring { position: relative; width: 56px; height: 56px; }
.env-ring svg { display: block; }
.env-ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.72rem; font-weight: 750; }
.env-plus { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); transition: background 0.15s, color 0.15s; }
.env-plus svg { width: 15px; height: 15px; }
.env-card:hover .env-plus { background: var(--primary); color: var(--primary-ink); }
.env-name { margin-top: 10px; font-weight: 650; }
.env-left { font-family: var(--display); font-weight: 800; font-size: 1.35rem; line-height: 1.2; }
.env-left.neg { color: var(--danger); }
.env-hint { font-size: 0.78rem; color: var(--muted); }
.ring-track { stroke: var(--surface-2); }
.ring-fill.over { stroke: var(--danger); }
@media (min-width: 701px) {
  .env-cards { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .env-card { flex: 1 1 160px; max-width: 250px; } /* peu d'enveloppes : des cartes, pas des bandeaux */
}

.home-cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: stretch; }
.home-cols > .panel { flex: 1 1 340px; min-width: 0; margin: 0; border-radius: 22px; padding: 16px 16px 12px; }
.home-list .list { margin: 0 -16px; border-radius: 0; box-shadow: none; background: transparent; }
.home-list .section-head { flex-wrap: wrap; row-gap: 2px; }
@media (max-width: 520px) { .hero-tile .hint { display: none; } }
.home-list .more-link { display: inline-block; margin-top: 8px; font-size: 0.88rem; }
.home-list .more-links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; }
.home-list .more-links .more-link { margin-top: 0; }
.home-low { margin-bottom: 0; }

@media (prefers-reduced-motion: no-preference) {
  .ring-fill { animation: ring-in 0.7s var(--ease) both; }
  svg.pace .pace-fill { transform-box: fill-box; transform-origin: left center; animation: grow-x 0.5s var(--ease) both; }
}
@keyframes ring-in { from { stroke-dashoffset: 100; } }

/* ---------- Indicateurs de chargement ---------- */

/* Bouton d'un formulaire en cours d'envoi : spinner devant le libellé, plus de second clic. */
.is-busy { pointer-events: none; opacity: 0.85; }
.is-busy::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Barre de progression en haut de l'écran pendant un changement de page lent. */
.progress {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 60;
  pointer-events: none;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  transition: opacity 0.2s;
}
.progress.on { opacity: 1; animation: progress 8s cubic-bezier(0.1, 0.7, 0.2, 1) forwards; }

.tabbar a.is-pressed svg { background: var(--primary-soft); }

/* Onglet touché pendant le chargement : l'icône laisse place à un indicateur qui tourne. */
.tabbar a, .month-nav a { position: relative; }
.tabbar a.is-loading svg { color: transparent; transition: none; }
.tabbar a.is-loading::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Barre de chargement le long du haut de la barre d'onglets, sous le pouce. */
.tabbar.loading::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 35%;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  animation: slide 1s ease-in-out infinite;
}

/* Flèches de mois : la flèche laisse place à l'indicateur. */
.month-nav a.is-loading { color: transparent; }
.month-nav a.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--primary);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.month-nav a.is-pressed, a.row.is-pressed, .tile.is-pressed, .chip.is-pressed { opacity: 0.7; }

/* Ligne qui vient d'être ajoutée ou modifiée : brève surbrillance. */
.row:target { scroll-margin-top: 90px; }

@media (prefers-reduced-motion: reduce) {
  .is-busy::before { animation: pulse 1s ease-in-out infinite; }
  .progress.on { animation: none; transform: scaleX(0.6); }
  .row:target { background: var(--primary-soft); }
  .tabbar a.is-loading::before, .month-nav a.is-loading::after { animation: pulse 1s ease-in-out infinite; }
  .tabbar.loading::after { width: 100%; animation: pulse 1s ease-in-out infinite; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(0.92); } }
@keyframes highlight { from { background: var(--primary-soft); } }

/* ---------- Page du mois : onglets sur téléphone, colonnes sur ordinateur ---------- */

.pane { margin: 0 0 24px; min-width: 0; }
/* Colonnes étroites : le libellé passe à la ligne plutôt que d'être coupé par ses étiquettes (variable, partagé…). */
.pane .row .label { white-space: normal; overflow-wrap: anywhere; }
.pane-sub {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin: 18px 2px 8px; font-size: 0.95rem; color: var(--muted);
}
.section-head + .pane-sub { margin-top: 0; }
.pane-sub span { font-family: var(--display); font-weight: 800; color: var(--ink); }
.pane-help { margin: 8px 4px 0; }

.month-tabs {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(var(--tab-count, 4), minmax(0, 1fr));
  padding: 4px; margin: 0 0 14px;
  background: var(--surface-2); border-radius: 16px;
  box-shadow: 0 0 0 6px var(--bg); /* fond de la page autour de la barre quand elle colle en haut */
}
.month-tabs[hidden] { display: none; }
/* Ancre visée (#ligne-N, #retraits…) : pas cachée sous la barre d'onglets collée en haut. */
.month-panes [id] { scroll-margin-top: 80px; }
.month-tabs .tab-ind {
  position: absolute; top: 4px; left: 4px;
  width: calc((100% - 8px) / var(--tab-count, 4)); height: calc(100% - 8px);
  border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease);
}
.month-tabs[data-active="1"] .tab-ind { transform: translateX(100%); }
.month-tabs[data-active="2"] .tab-ind { transform: translateX(200%); }
.month-tabs[data-active="3"] .tab-ind { transform: translateX(300%); }
.month-tabs button {
  position: relative; min-height: 44px; padding: 0 2px;
  border: 0; border-radius: 12px; background: none;
  font: inherit; font-size: 0.92rem; font-weight: 650; color: var(--muted);
  cursor: pointer; transition: color 0.15s;
}
.month-tabs button[aria-selected="true"] { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .month-tabs .tab-ind { transition: none; } }

@media (max-width: 700px) {
  .month-panes.tabbed > .pane:not(.active) { display: none; }
}
@media (min-width: 701px) {
  .month-tabs:not([hidden]) { display: none; }
  .month-panes {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px; align-items: start; margin-bottom: 28px;
  }
  .month-panes > .pane { margin: 0; }
}

/* Onglets d'une page à toutes les largeurs (Projet maison : Résultat, Hypothèses) : un seul bloc visible. */
.page-tabs { --tab-count: 2; }
@media (min-width: 701px) { .month-tabs.page-tabs:not([hidden]) { display: grid; max-width: 440px; } }
.page-panes { display: grid; gap: 16px; margin-bottom: 24px; }
.page-panes > * { min-width: 0; }
.page-panes.tabbed > :not(.active) { display: none; }
.page-panes [id] { scroll-margin-top: 80px; }

/* Frais fixe pointé sur place : coche à gauche, fiche de la ligne au toucher du libellé ou du montant. */
.row.tick-line { padding: 0 14px 0 4px; gap: 4px; }
.tick-form { margin: 0; flex: none; }
.tick-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 12px; background: none; color: inherit; cursor: pointer;
}
.tick-btn .tick {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tick-btn .tick svg { width: 15px; height: 15px; }
.tick-btn:hover .tick { border-color: var(--primary); }
.tick-btn.is-checked .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick-btn[aria-busy="true"] .tick { opacity: 0.6; }
.tick-line .main, .tick-line .amounts {
  align-self: stretch; display: flex; flex-direction: column; justify-content: center;
  padding: 8px 0; color: inherit; text-decoration: none;
}
.tick-line:has(.tick-btn.is-checked) .label { color: var(--muted); }
.tick-line:has(a:hover) { background: var(--surface-2); }
@media (prefers-reduced-motion: reduce) { .tick-btn .tick { transition: none; } }

/* ---------- Projets : réservoirs des comptes et projets dans l'ordre de priorité ---------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin: 4px 0 16px; }
.page-head p { margin: 2px 0 0; }

.proj-layout { display: grid; gap: 16px; margin-bottom: 28px; }
.proj-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.proj-main { min-width: 0; }
@media (min-width: 900px) {
  .proj-layout { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; align-items: start; }
  .proj-main { grid-column: 1; grid-row: 1; }
  .proj-side { grid-column: 2; grid-row: 1; }
}

.tank { display: flex; flex-direction: column; gap: 4px; }
.tank .eyebrow { color: rgba(255, 255, 255, 0.92); opacity: 1; }
.tank-amount { font-family: var(--display); font-weight: 900; font-size: 2.6rem; line-height: 1.1; letter-spacing: -0.01em; margin-bottom: 10px; }
svg.tank-bar { height: 18px; }
.tank-slot { fill: rgba(255, 255, 255, 0.18); }
.tank-free { fill: rgba(255, 255, 255, 0.45); }
.tank-legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; position: relative; z-index: 1; }
.tank-legend li { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.tank-legend .name { flex: 1; min-width: 0; color: rgba(255, 255, 255, 0.92); overflow-wrap: anywhere; }
.tank-legend strong { white-space: nowrap; }
.tank-line { margin: 8px 0 0; font-size: 0.86rem; color: rgba(255, 255, 255, 0.88); }

.goals { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.goal-card {
  position: relative; display: flex; align-items: center; gap: 4px; padding-right: 16px;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
}
.goal-handle {
  flex: none; align-self: stretch; width: 56px; min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 0; border: 0; border-radius: 20px 0 0 20px; background: none; color: var(--muted);
  font: inherit; cursor: grab; touch-action: none;
}
.goal-handle.static { cursor: default; }
.goal-handle .rank {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 0.95rem;
}
.goal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 14px 0; color: inherit; text-decoration: none; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.goal-name { font-weight: 750; overflow-wrap: anywhere; }
.goal-eta { flex: none; font-size: 0.88rem; font-weight: 700; white-space: nowrap; }
.goal-eta.early { color: var(--ok); }
.goal-eta.late { color: var(--warn); }
svg.goal-bar { height: 10px; }
.goal-sub { font-size: 0.86rem; color: var(--muted); }
.goal-body:hover .goal-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.goal-card .reorder { flex: none; display: flex; flex-direction: column; gap: 4px; }
.goal-card .reorder .btn { min-height: 30px; min-width: 38px; padding: 2px 8px; }
.goal-card .reorder .btn:disabled { opacity: 0.3; }
.goals.js-drag .reorder { display: none; }
.goals-add { margin-top: 2px; }
.goals-add .add-row { border-top: 0; }
.accounts-split { margin-bottom: 12px; }
.accounts-split p { margin: 8px 0 0; }

/* Glisser-déposer (site.js) : la carte tenue suit le doigt, les autres s'écartent. */
.goals.sorting { user-select: none; -webkit-user-select: none; }
.goals.sorting > .goal-card:not(.dragging) { transition: transform 0.2s var(--ease); }
.goal-card.dragging { z-index: 3; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18); cursor: grabbing; }
.goal-card.dragging .goal-handle { cursor: grabbing; }
.goal-card.settling { transition: transform 0.18s var(--ease); }
.goals[aria-busy="true"] .goal-eta, .goals[aria-busy="true"] .goal-sub { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) {
  .goals.sorting > .goal-card:not(.dragging), .goal-card.settling { transition: none; }
}

/* ---------- Cap : horizon, courbe parcourue au doigt, « Et si je mettais… », jalons ---------- */

.seg { display: inline-flex; gap: 3px; padding: 3px; border-radius: 14px; background: var(--surface-2); }
.seg[hidden] { display: none; }
.seg > a, .seg > button {
  min-height: 40px; min-width: 56px; padding: 0 12px; display: inline-grid; place-items: center;
  border: 0; border-radius: 11px; background: none; color: var(--muted);
  font: inherit; font-size: 0.9rem; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg > [aria-current="true"], .seg > [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.cap-layout { display: grid; gap: 16px; margin-bottom: 24px; }
.cap-main, .cap-side { min-width: 0; }
.cap-side { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 900px) {
  .cap-layout { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 24px; align-items: start; }
}
/* Projet maison : onglets Résultat et Hypothèses (.page-panes) ; le formulaire ne s'étire pas sur toute la largeur. */
.house-main { display: flex; flex-direction: column; gap: 16px; }
.house-main > .section { margin: 0; }
.page-panes > .house-form { max-width: 720px; }
.house-when { position: relative; margin: 2px 0 4px; font-family: var(--display); font-weight: 900; font-size: 2.4rem; line-height: 1.1; }
.house-checks { position: relative; list-style: none; margin: 14px 0 10px; padding: 0; display: grid; gap: 8px; }
.house-checks li { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.11); }
.house-checks li::before { content: "✓"; grid-row: span 2; font-weight: 800; color: #7fd6cf; }
.house-checks li.wait::before { content: "…"; color: #ffd76a; }
.house-checks li.binding { outline: 2px solid #ffd76a; outline-offset: -2px; }
.house-checks li span { grid-column: 2; font-size: 0.82rem; opacity: 0.85; }
.house-binding { position: relative; margin: 0 0 12px; color: rgba(255, 255, 255, 0.92); }
.feature.house-moment .btn.soft { position: relative; }
tr.hl td { background: var(--surface-2); font-weight: 650; }
.calc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.calc-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.calc-list strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc-list li.total { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 750; }
.calc-list li.sub-line { padding-left: 14px; color: var(--muted); font-size: 0.86rem; }
.calc-list li.sub-line strong { font-weight: 650; }

/* Projet maison : écart à la date visée, frise des conditions, raisons, blocs chiffrés. */
.house-delay { position: relative; margin: 6px 0 0; font-weight: 700; }
.house-delay.late { color: #ffd76a; }
.house-delay.early { color: #7fd6cf; }
.ready-grid { position: relative; display: grid; gap: 6px; margin: 14px 0 6px; }
.ready-scale { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 0 6px; font-size: 0.72rem; opacity: 0.8; }
.ready-scale span:nth-child(2) { text-align: center; }
.ready-scale span:last-child { text-align: right; }
/* Nom et date sur une ligne, barre pleine largeur dessous : lisible à toutes les largeurs. */
.ready-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; padding: 6px; border-radius: 10px; }
.ready-row svg.ready { grid-column: 1 / -1; grid-row: 2; }
.ready-row .ready-name { grid-column: 1; grid-row: 1; }
.ready-row .ready-when { grid-column: 2; grid-row: 1; }
.ready-row.binding { background: rgba(255, 215, 106, 0.16); }
.ready-name { font-size: 0.88rem; font-weight: 700; }
.ready-when { font-size: 0.84rem; text-align: right; }
.ready-row.never .ready-when { color: #ffd76a; }
svg.ready { display: block; width: 100%; height: 14px; }
.ready-wait { fill: rgba(255, 255, 255, 0.16); }
.ready-ok { fill: #7fd6cf; }
.ready-mark { stroke: #ffd76a; stroke-width: 2; }
.ready-target { stroke: #fff; stroke-width: 1.5; stroke-dasharray: 2 2; }
.house-legend { position: relative; margin: 4px 0 0; opacity: 0.85; }
.house-legend .key-ok, .house-legend .key-wait { display: inline-block; width: 12px; height: 8px; border-radius: 2px; vertical-align: 0; }
.house-legend .key-ok { background: #7fd6cf; }
.house-legend .key-wait { background: rgba(255, 255, 255, 0.25); }
.why-list .row.why { align-items: flex-start; }
.why-list .row.why .label { white-space: normal; }
.why-list .row.why .sub { white-space: normal; line-height: 1.45; }
.why-list .row.why.binding { box-shadow: inset 3px 0 0 var(--warn); }
.house-cards { display: grid; gap: 16px; }
@media (min-width: 1100px) { .house-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.house-cards .panel h3 { margin: 0 0 10px; }
.house-cards .panel > p.small { margin: 10px 0 0; }
table.house-table th, table.house-table td { padding: 6px 4px; font-size: 0.9rem; }
table.house-table tr.total td { font-weight: 750; border-top: 1px solid var(--line); border-bottom: 0; }
/* Résumé des hypothèses en haut de page. */
.house-recap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.house-recap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.house-recap-list li { padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 0.82rem; font-weight: 600; }
.house-recap-list li.edit { padding: 0; background: none; }
.house-recap-list li.edit a { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--primary); font-weight: 700; text-decoration: none; }
@media (max-width: 520px) { .house-when { font-size: 2rem; } }

/* Formulaire des hypothèses : blocs titrés, unités dans les champs, champs conditionnels. */
.house-form { display: grid; gap: 0; }
.house-form > h2 { margin: 0 0 4px; }
.hf-group { display: grid; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.hf-group:first-of-type { border-top: 0; padding-top: 6px; }
.hf-group h3 { margin: 0; font-size: 0.95rem; display: flex; align-items: baseline; gap: 8px; }
.house-form .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.house-form .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.house-form .grid-3 > * { min-width: 0; }
.house-form > .btn { margin-top: 6px; }
.unit-input, .field > .unit-input { position: relative; display: block; font-weight: 400; font-size: 1rem; }
.unit-input input { width: 100%; padding-right: 3.6em; text-align: right; font-variant-numeric: tabular-nums; }
.unit-input .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; pointer-events: none; }
.seg.seg-radio { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.seg-radio > label {
  position: relative; min-height: 40px; display: grid; place-items: center; padding: 0 8px; border-radius: 11px;
  color: var(--muted); font-size: 0.88rem; font-weight: 650; cursor: pointer; text-align: center;
}
.seg-radio > label input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio > label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-radio > label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
.hf-toggle { font-weight: 700; }
.house-form:not(:has(input[name="Kind"][value="construction"]:checked)) .only-build { display: none; }
.house-form:has(input[name="Kind"][value="construction"]:checked) .not-build { display: none; }
.house-form:not(:has(input[name="Together"]:checked)) .only-together { display: none; }

.cap-readout { display: flex; flex-direction: column; gap: 2px; }
.cap-when { color: var(--muted); font-size: 0.92rem; }
.cap-value { font-family: var(--display); font-weight: 900; font-size: 2.6rem; line-height: 1.1; letter-spacing: -0.01em; }
.cap-value.neg { color: var(--danger); }
.cap-note { min-height: 1.4em; font-size: 0.88rem; font-weight: 650; color: var(--primary); }
.seg.cap-scenarios { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 12px 0 4px; }
.seg.cap-scenarios[hidden] { display: none; }
.cap-plot { margin-top: 8px; }
svg.chart[data-scrub] { touch-action: pan-y; cursor: crosshair; -webkit-user-select: none; user-select: none; }
svg.chart .traj-whatif { fill: none; stroke: var(--invest-fill); stroke-width: 2.5; stroke-dasharray: 7 6; stroke-linejoin: round; }
svg.chart .cap-cursor { stroke: var(--muted); stroke-width: 1.5; pointer-events: none; }
svg.chart .cap-dot { fill: var(--primary); stroke: var(--surface); stroke-width: 3; pointer-events: none; }
svg.dot.key-whatif circle { fill: var(--invest-fill); }
.cap-range { display: block; width: 100%; height: 32px; margin: 4px 0 0; accent-color: var(--primary); }
.cap-range[hidden] { display: none; }

.whatif { display: flex; flex-direction: column; gap: 6px; }
.whatif-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.whatif-head output { font-weight: 800; color: var(--primary); white-space: nowrap; }
.whatif input[type="range"] { width: 100%; height: 40px; margin: 0; accent-color: var(--primary); }
.whatif-effect p, .whatif-effect ul { margin: 0; }
.whatif-effect ul { padding-left: 18px; display: grid; gap: 4px; }
.whatif [data-whatif-submit] { align-self: flex-start; }
.whatif.live [data-whatif-submit] { display: none; }

.cap-ms { padding-bottom: 8px; }
.cap-ms .milestones li { display: block; padding: 2px 0; }
.ms-btn {
  width: 100%; display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 2px 12px;
  padding: 10px 8px; border: 0; border-radius: 12px; background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.ms-btn:hover { background: var(--surface-2); }
.ms-btn[aria-pressed="true"] { background: var(--primary-soft); }

/* ---------- Jour de paie : 4 écrans plein cadre (téléphone), fenêtre centrée (ordinateur) ---------- */

body.payday-page { background: var(--feature-bg); color: #fff; min-height: 100vh; min-height: 100dvh; }
body.payday-page .wrap { max-width: 560px; padding-top: env(safe-area-inset-top); }
body.payday-page main { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.payday { flex: 1; display: flex; flex-direction: column; padding: 14px 4px calc(20px + env(safe-area-inset-bottom)); }
.payday-top { display: flex; align-items: center; gap: 10px; }
.payday-dots { flex: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.payday-dots li { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); transition: background 0.3s; }
.payday-dots li.done { background: #fff; }
.payday-dots li.current { background: #ffd76a; }
.payday-dots-space { flex: 1; }
.payday-close {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 15px; background: rgba(255, 255, 255, 0.14); color: #fff;
}
.payday-close svg { width: 18px; height: 18px; }
.payday-step { flex: 1; display: flex; flex-direction: column; padding: 28px 10px 0; }
.payday-kicker { margin: 0; font-size: 0.95rem; font-weight: 600; color: #bfe8e2; }
.payday-step h1 { margin: 6px 0 0; font-weight: 900; font-size: 1.95rem; line-height: 1.15; color: #fff; }
.payday-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 24px 0; }
.payday-hint { margin: 0; text-align: center; color: #cdece7; }
.payday-note { margin: 0; font-size: 0.88rem; color: #e3f5f2; }
.payday a:not(.payday-cta):not(.payday-close) { color: #fff; }
.payday-cta {
  display: flex; align-items: center; justify-content: center; min-height: 56px; width: 100%;
  border: 0; border-radius: 18px; background: #ffd76a; color: #3b2a00;
  font: inherit; font-weight: 800; font-size: 1.06rem; text-decoration: none; cursor: pointer;
  transition: transform 0.12s;
}
.payday-cta:active { transform: scale(0.98); }
.payday-cta.is-busy { opacity: 0.8; }
.payday-alt { align-self: center; margin-top: 8px; min-height: 44px; display: inline-flex; align-items: center; font-weight: 650; }

.stepper { display: flex; align-items: center; justify-content: center; gap: 12px; }
.stepper button {
  flex: none; width: 58px; height: 58px; border: 0; border-radius: 22px;
  background: rgba(255, 255, 255, 0.14); color: #fff; font: inherit; font-size: 1.9rem; cursor: pointer;
}
.stepper button:active { background: rgba(255, 255, 255, 0.24); }
.payday-amount {
  flex: 1; width: 100%; min-width: 0; max-width: 220px; padding: 4px 0;
  border: 0; border-bottom: 2px solid rgba(255, 255, 255, 0.35); border-radius: 0; background: transparent;
  color: #fff; font-family: var(--display); font-weight: 900; font-size: 2.8rem; text-align: center;
}
.payday-amount::placeholder { color: rgba(255, 255, 255, 0.45); }
.payday-amount:focus { outline: none; border-bottom-color: #ffd76a; }
.payday-field { display: grid; gap: 6px; font-size: 0.9rem; color: #e3f5f2; }
.payday-field input, .payday-field select, .payday-alloc input {
  min-height: 48px; padding: 0 14px; border: 0; border-radius: 14px;
  background: rgba(255, 255, 255, 0.95); color: #12302d; font: inherit; font-weight: 650;
}
.payday-big { margin: 0; text-align: center; font-family: var(--display); font-weight: 900; font-size: 4.2rem; line-height: 1.05; letter-spacing: -0.02em; color: #ffd76a; }
.payday-big.neg { color: #ffc4b5; }
.payday-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.payday-tiles > div { display: flex; flex-direction: column; padding: 14px; border-radius: 18px; background: rgba(255, 255, 255, 0.11); }
.payday-tiles .k { font-size: 0.82rem; color: #cdece7; }
.payday-tiles .v { font-family: var(--display); font-weight: 800; font-size: 1.5rem; }
.payday-split { display: grid; gap: 18px; }
.payday-alloc { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 8px 10px; align-items: center; }
.payday-alloc .name { display: flex; flex-direction: column; font-weight: 700; }
.payday-alloc .name small { font-size: 0.8rem; font-weight: 500; color: #cdece7; }
.payday-alloc input { min-height: 44px; padding: 0 10px; text-align: right; }
.payday-alloc svg.gauge { grid-column: 1 / -1; height: 12px; }
.payday .gauge-track { fill: rgba(255, 255, 255, 0.16); }
.payday-more summary { min-height: 40px; color: #e3f5f2; font-weight: 650; cursor: pointer; }
.payday-more .payday-alloc { margin-top: 10px; }
.payday-cap { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.payday-cap li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; border-radius: 18px; background: rgba(255, 255, 255, 0.11); }
.payday-cap span { font-weight: 700; overflow-wrap: anywhere; }
.payday-cap strong { color: #ffd76a; white-space: nowrap; }
/* Messages en haut : en bas, ils couvriraient le bouton de l'étape. */
body.payday-page .flash { top: calc(72px + env(safe-area-inset-top)); bottom: auto; }
@media (max-width: 380px) { .payday-big { font-size: 3.4rem; } .payday-amount { font-size: 2.3rem; } .stepper button { width: 50px; height: 50px; } }
@media (min-width: 701px) {
  body.payday-page { background: var(--bg); color: var(--ink); }
  body.payday-page main { min-height: 100vh; justify-content: center; padding: 40px 0; }
  .payday {
    flex: none; min-height: 640px; padding: 18px 18px 24px; color: #fff;
    border-radius: 28px; background: var(--feature-bg); box-shadow: var(--feature-shadow), 0 30px 80px rgba(0, 0, 0, 0.18);
  }
}

/* Glissement entre onglets (site.js) : la page suit un peu le doigt avant de changer d'onglet. */
body.has-tabbar main { transition: transform 0.18s var(--ease); }

/* ---------- Animations (désactivées si l'utilisateur réduit les animations) ---------- */

@media (prefers-reduced-motion: no-preference) {
  /* Transition entre pages seulement ici : avec « réduire les animations », changement de page instantané
     (sinon le navigateur appliquerait son fondu par défaut, plus long). */
  @view-transition { navigation: auto; }

  /* Rapidité d'abord : transition de page très courte, contenu affiché immédiatement (pas de fondu par vagues). */
  ::view-transition-old(root) { animation: 0.1s linear both fade-out; }
  ::view-transition-new(root) { animation: 0.12s linear both fade-in; }

  svg.split rect[fill], svg.gauge rect[fill] {
    transform-box: fill-box;
    transform-origin: left center;
    animation: grow-x 0.35s var(--ease) both;
  }
  /* Changement de mois : les segments glissent depuis le mois quitté (site.js) au lieu de pousser depuis la gauche. */
  svg.split.morph rect[fill] { animation: none; }
  @media (max-width: 700px) {
    .month-panes.tabbed > .pane.active { animation: rise-in 0.25s var(--ease) both; }
    /* Onglet suivant ou précédent (toucher ou glissement) : le bloc arrive du côté où l'on va. */
    .month-panes.tabbed[data-dir="next"] > .pane.active { animation: slide-from-right 0.25s var(--ease) both; }
    .month-panes.tabbed[data-dir="prev"] > .pane.active { animation: slide-from-left 0.25s var(--ease) both; }
  }
  .page-panes.tabbed[data-dir="next"] > .active { animation: slide-from-right 0.25s var(--ease) both; }
  .page-panes.tabbed[data-dir="prev"] > .active { animation: slide-from-left 0.25s var(--ease) both; }
  .payday-step { animation: slide-from-right 0.3s var(--ease) both; }

  svg.chart .line-planned, svg.chart .traj-line { stroke-dasharray: 1; animation: draw 0.6s var(--ease) both; }
  svg.chart.static .traj-line { animation: none; } /* courbe rechargée par le curseur « Et si » : pas de tracé rejoué */
  svg.chart rect[fill] { transform-box: fill-box; transform-origin: center bottom; animation: grow-y 0.35s var(--ease) both; }

  .row:target { animation: highlight 2.2s ease-out both; }
  dialog.sheet[open] { animation: sheet-up 0.22s var(--ease) both; }
  dialog.sheet[open]::backdrop { animation: fade-in 0.18s ease both; }
  .flash { animation: toast-in 0.4s var(--ease) both; }
  details.fold[open] > .list, details.more[open] > * { animation: rise-in 0.3s var(--ease) both; }
}

@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide-from-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-28px); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } }

/* ---------- Rapport annuel et impression ---------- */

.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
@media print {
  .top, .tabbar, .sidebar, .app-version, .no-print, .flash, .fab, .help-bubble { display: none !important; }
  body.has-tabbar { display: block; }
  body { background: #fff; color: #000; padding: 0; }
  .panel, .stats, .list, .table-wrap { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  main > * { animation: none !important; }
  a { color: inherit; text-decoration: none; }
}

/* Panneaux de champs empilés (bilan, compte) : même espacement que les formulaires. */
div.stack { display: grid; gap: 14px; }

/* ---------- Pointage (indicatif) ---------- */
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.feature .calc {
  list-style: none;
  margin: 0 0 14px;
  padding: 10px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}
.feature .calc li { display: flex; justify-content: space-between; gap: 12px; }
.feature .calc li span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.feature a.on-feature { color: #fff; text-decoration: underline; }
.check-progress .head { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.check-progress .gauge-track { fill: rgba(255, 255, 255, 0.25); }
.check-progress p { margin: 6px 0 0; opacity: 0.9; }
.check-end { margin: 16px 0 24px; }
.check-form { margin: 0; }
button.check-row {
  width: 100%;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.list > .check-form:first-child > .row { border-top: 0; }
button.check-row:hover:not(:disabled) { background: var(--surface-2); }
button.check-row:active:not(:disabled) { background: var(--primary-soft); }
button.check-row:disabled { cursor: default; }
.check-row .tick, .tick-placeholder {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tick-placeholder { border-style: dashed; }
.check-row .tick svg { width: 16px; height: 16px; }
.check-row.is-checked .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.check-row.is-checked .label { color: var(--muted); }
.check-row[aria-busy="true"] .tick { opacity: 0.6; }
@media (prefers-reduced-motion: reduce) { .check-row .tick { transition: none; } }

/* ---------- Retraits d'épargne ---------- */
.group-head .ico-withdraw { flex: none; display: grid; place-items: center; width: 16px; color: var(--warn); }
.group-head .ico-withdraw .ic { width: 15px; height: 15px; }

/* ---------- Finitions : icônes SVG centrées, alignements et espacements ---------- */
/* Icônes (Web/Icons.cs) : à la place des caractères ‹ › × ⌫ ↑ ↓ ↩ ⚡ ⇄, toujours centrées par leur conteneur. */
.ic { display: block; flex: none; width: 1.15em; height: 1.15em; }
.month-nav a .ic { width: 22px; height: 22px; }
.row .amounts.chevron { display: flex; align-items: center; justify-content: flex-end; color: var(--muted); }
.row .amounts.chevron .ic { width: 18px; height: 18px; }
dialog.sheet .sheet-head button { display: grid; place-items: center; padding: 0; }
dialog.sheet .sheet-head button .ic { width: 18px; height: 18px; }
.notes .ico .ic { width: 15px; height: 15px; }
.numpad button { display: grid; place-items: center; }
.numpad button .ic { width: 26px; height: 26px; }
.stepper button { display: grid; place-items: center; padding: 0; }
.stepper button .ic { width: 26px; height: 26px; stroke-width: 2.6; }
.reorder .btn { display: grid; place-items: center; }
.reorder .btn .ic { width: 16px; height: 16px; }

/* Titre de page (h1) : un vrai écart avant la première section, comme les pages à en-tête (.page-head). */
.section-head:has(> h1) { margin-bottom: 18px; }
/* Piles de champs ou d'options (div, fieldset) : même écart régulier que les formulaires, options un peu plus serrées. */
.stack { display: grid; gap: 12px; }
fieldset.stack { gap: 10px; }
/* Dans une pile, l'écart est donné par la pile : pas de marge de paragraphe en plus. */
.stack > p, .stack > h2, .stack > h3 { margin: 0; }

/* Cases à cocher : alignées sur la première ligne d'un libellé qui passe à la ligne (pas au milieu du paragraphe). */
.check { align-items: flex-start; }
.check > input[type="checkbox"], .check > input[type="radio"] { flex: none; margin-top: 0.2em; }

/* Panneau Noter : tous les intitulés du même style (Montant, Enveloppe, Libellé), case « Secret » discrète. */
.noter .field > span { font-size: 0.85rem; color: var(--muted); }
.noter .check, .sheet .check { font-size: 0.88rem; color: var(--muted); }

/* Menu latéral : bouton « Noter une dépense » et mois en cours sur une ligne. */
.side-add { white-space: nowrap; padding-left: 12px; padding-right: 12px; font-size: 0.95rem; }
.sidebar .brand small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Aperçu du Cap (Accueil) : le montant sur sa ligne, la légende dessous (pas de mot isolé à la ligne). */
.cap-mini-value strong { display: block; margin: 0 0 2px; }

/* Bandeau d'onglets du mois collé en haut : il masque proprement ce qui défile dessous. */
.month-tabs { top: env(safe-area-inset-top, 0px); box-shadow: 0 0 0 6px var(--bg), 0 10px 14px -10px rgba(0, 0, 0, 0.25); }

/* Tuiles de l'Accueil sur téléphone : une ligne chacune (libellé à gauche, montant à droite), jamais coupées. */
@media (max-width: 520px) {
  .hero-tiles { grid-template-columns: 1fr; gap: 6px; }
  .hero-tile { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 12px; }
  .hero-tile .k { font-size: 0.82rem; }
  .hero-tile .v { font-size: 1.05rem; }
}

/* Cadeaux sur téléphone : pas de second « + » flottant au-dessus de celui de la barre d'onglets (le bouton
   « + Cadeau ou idée » est en haut de la liste). */
@media (max-width: 700px) { body.has-tabbar .fab { display: none; } main:has(.fab) { padding-bottom: 0; } }
.panel.question { border: 2px solid var(--warn); }
/* Groupes de choix dans un panneau (question du bilan, apparence, crédits à solder) : sans le cadre du navigateur. */
.panel fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.panel legend { padding: 0; margin-bottom: 4px; }

/* ---------- Aide : bulle « ? », panneau de la page, guide (Web/Help.cs) ---------- */

/* Téléphone : bouton rond de l'en-tête. Ordinateur : bulle flottante en bas à droite (au-dessus du « + » des
   cadeaux s'il y en a un). */
.help-btn .ic { width: 21px; height: 21px; stroke-width: 2.5; }
/* Quatre boutons dans l'en-tête : un peu plus serrés sur les très petits écrans (320 px). */
@media (max-width: 360px) {
  .top-actions { gap: 5px; }
  .top-actions .icon-btn, .top-actions .theme-toggle button { width: 36px; height: 36px; }
}
.help-btn, .help-bubble { position: relative; }
.help-bubble { display: none; }
@media (min-width: 701px) {
  .help-bubble {
    position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 24;
    display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px 0 13px;
    border-radius: 999px; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-lg);
    font-weight: 700; text-decoration: none; transition: background 0.15s, color 0.15s, transform 0.15s var(--ease);
  }
  .help-bubble .ic { width: 22px; height: 22px; }
  .help-bubble:hover { background: var(--primary); color: var(--primary-ink); }
  .help-bubble:active { transform: scale(0.95); }
  body:has(.fab) .help-bubble { bottom: calc(96px + env(safe-area-inset-bottom)); }
  /* Le bas de la page peut toujours défiler au-dessus de la bulle. */
  body:has(.help-bubble) .wrap { padding-bottom: 84px; }
}

/* Aide jamais ouverte sur cette page (cet appareil) : une pastille, qui pulse trois fois. */
.help-btn.is-new::after, .help-bubble.is-new::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 2px var(--surface);
}
.help-bubble.is-new::after { top: -2px; right: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .help-btn.is-new::after, .help-bubble.is-new::after { animation: help-ping 1.8s var(--ease) 0.6s 3; }
}
@keyframes help-ping {
  0% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px var(--primary); }
  100% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 11px transparent; }
}

/* Panneau d'aide */
.help-sheet .sheet-head { align-items: flex-start; }
.help-head { min-width: 0; }
.help-kicker { display: block; color: var(--primary); font-size: 0.78rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; }
.help-sheet .help-head h2 { font-size: 1.4rem; margin-top: 2px; }
.help-summary { font-size: 1rem; line-height: 1.5; }
.help-body h3 { margin: 18px 0 10px; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.help-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 12px; }
.help-steps li { counter-increment: step; position: relative; padding-left: 40px; min-height: 28px; line-height: 1.45; }
.help-steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
  font: 800 0.9rem/1 var(--display);
}
.help-tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.help-tips li { position: relative; padding: 10px 12px 10px 32px; border-radius: 12px; background: var(--surface-2); font-size: 0.92rem; line-height: 1.45; }
.help-tips li::before { content: ""; position: absolute; left: 13px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.help-links { display: flex; flex-wrap: wrap; gap: 8px; }
.help-tour { display: block; margin-top: 22px; padding: 14px; border-radius: 16px; background: var(--primary-soft); }
.help-tour-label { display: block; color: var(--primary); font-size: 0.78rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; }
.help-dots { display: flex; gap: 4px; margin: 10px 0 12px; }
.help-dots span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.help-dots span.done { background: var(--primary-2); opacity: 0.55; }
.help-dots span.here { background: var(--primary); }
.help-tour-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.help-tour-nav .btn { gap: 4px; }
.help-tour-nav .btn:last-child { margin-left: auto; } /* l'étape suivante reste à droite, même passée à la ligne */
.help-tour-nav .ic { width: 16px; height: 16px; flex: none; }
.help-all { margin: 16px 0 0; font-size: 0.9rem; text-align: center; }

/* Guide (/aide) */
.help-inline { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; vertical-align: -5px; background: var(--surface); box-shadow: var(--shadow); color: var(--primary); }
.help-inline .ic { width: 14px; height: 14px; stroke-width: 2.6; }
ol.tour-list { list-style: none; margin: 0; padding: 0; }
.tour-list > li:first-child > .row { border-top: 0; }
.tour-num {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font: 800 0.92rem/1 var(--display);
}
.help-list > details:first-child > summary.row { border-top: 0; }
.help-topic > summary { list-style: none; cursor: pointer; font-weight: 400; }
.help-topic > summary .label { font-weight: 650; }
.help-topic > summary::-webkit-details-marker { display: none; }
.help-topic > summary:hover { background: var(--surface-2); }
.help-topic > summary .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.help-topic > summary::after {
  content: ""; flex-shrink: 0; margin: 0 4px 0 auto; width: 9px; height: 9px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.25s var(--ease);
}
.help-topic[open] > summary::after { transform: rotate(45deg) translate(-2px, -2px); }
.help-topic[open] > summary .sub { -webkit-line-clamp: unset; }
.help-topic:target > summary { background: var(--primary-soft); }
.help-topic-body { padding: 2px 14px 16px; }
.help-topic-body .help-body h3:first-child { margin-top: 8px; }
.help-topic-body > .btn { margin-top: 16px; }
.help-from { margin: 4px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 0.88rem; font-weight: 600; }

/* ---------- Anniversaires ---------- */

/* Le prochain (liste) ou celui de la fiche : compte à rebours sur la carte colorée. */
a.feature { text-decoration: none; }
.feature.bday-hero { display: grid; gap: 2px; }
.bday-hero > * { position: relative; } /* au-dessus du cercle décoratif */
.bday-hero-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bday-hero .avatar { width: 36px; height: 36px; font-size: 1rem; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4); }
.bday-hero-name { font-family: var(--display); font-weight: 900; font-size: 2.2rem; line-height: 1.1; }
.bday-hero-when { font-weight: 650; }
.bday-hero-age { color: #ffd76a; font-weight: 700; }
.bday-hero-gift { justify-self: start; margin-top: 10px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); font-size: 0.88rem; font-weight: 650; }
.bday-hero-gift.state-bought { background: rgba(127, 214, 207, 0.28); }
.bday-hero-gift.state-none, .bday-hero-gift.state-no-idea { background: rgba(255, 215, 106, 0.24); }
@media (max-width: 520px) { .bday-hero-name { font-size: 1.9rem; } }
.bday-hero + .stats { margin-top: 16px; }
/* Trois chiffres côte à côte, même sur téléphone. */
.stats.bday-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bday-stats .stat { padding: 10px 12px; }
.bday-stats .hint { overflow-wrap: anywhere; }

/* Une ligne : pastille du jour, prénom et âge, état du cadeau, montant prévu. */
.row.bday-row { gap: 12px; }
.bday-day { flex: none; display: grid; place-items: center; align-content: center; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); line-height: 1.05; }
.bday-day strong { font-family: var(--display); font-size: 1.05rem; font-weight: 800; }
.bday-day small { font-size: 0.66rem; color: var(--muted); }
.bday-row.is-soon .bday-day { background: var(--primary-soft); color: var(--primary); }
.bday-row.is-soon .bday-day small { color: inherit; }
.bday-state { flex: none; padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.bday-state.state-bought { background: var(--ok-soft); color: var(--ok); }
.bday-state.state-to-buy { background: var(--primary-soft); color: var(--primary); }
.bday-state.state-no-idea { background: var(--warn-soft); color: var(--warn); }
.bday-state.state-none { background: var(--surface-2); color: var(--muted); }
.tag.milestone { background: var(--warn-soft); color: var(--warn); }
/* Téléphone étroit : l'état passe sous le prénom, le montant reste à droite. */
@media (max-width: 420px) {
  .row.bday-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; }
  .bday-row .bday-day { grid-row: 1 / span 2; }
  .bday-row .main { grid-column: 2; grid-row: 1; }
  .bday-row .bday-state { grid-column: 2; grid-row: 2; justify-self: start; }
  .bday-row .amounts { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
}

/* Fiche : repères en pastilles, note, cadeaux sans le retrait des listes par personne. */
.bday-facts { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.bday-facts li { padding: 5px 10px; border-radius: 999px; background: var(--surface-2); font-size: 0.82rem; font-weight: 600; }
.bday-facts + * { margin-top: 16px; }
.bday-note h2 { margin: 0 0 6px; font-size: 1rem; }
.bday-note p { margin: 0; white-space: pre-line; }
.bday-gifts .row.gift { padding-left: 14px; }
.bday-ideas .row .label { white-space: normal; overflow-wrap: anywhere; }
.bday-ideas .row .btn { flex: none; }
/* Jour | Mois, puis Année | Ou son âge (l'un ou l'autre) */
.bday-date-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bday-help { margin: -4px 0 0; }
.bday-empty { text-align: center; justify-items: center; }
.bday-empty-ico .ic { width: 42px; height: 42px; color: var(--primary); }
.bday-empty h2 { margin: 0; }

/* Accueil : prochains anniversaires. */
.bday-mini .section-head { margin-bottom: 8px; }
.bday-mini ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bday-mini a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.bday-mini .main { display: grid; min-width: 0; flex: 1; }
.bday-mini .label { font-weight: 650; }
.bday-mini .sub { font-size: 0.82rem; color: var(--muted); }
.tag.due-anniversaire { background: var(--warn-soft); color: var(--warn); }
/* Fiche d'un cadeau : lien vers l'anniversaire de la personne. */
.callout.bday-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.callout.bday-link .ic { width: 22px; height: 22px; color: var(--primary); }
