/* ==========================================================================
   Gestion budget — styles
   Thème clair par défaut, sombre automatique (prefers-color-scheme)
   ou forcé via <html data-theme="light|dark">.
   ========================================================================== */

:root {
  color-scheme: light;
  /* thème clair : beige doux plutôt que blanc éclatant */
  --page: #ece6d8;
  --surface: #f5f0e4;
  --ink: #2a251c;
  --ink-2: #5a5346;
  --muted: #7a7161;
  --grid: #ddd5c3;
  --axis: #c4b9a3;
  --border: rgba(60, 45, 20, 0.13);
  --wash: rgba(60, 45, 20, 0.05);
  --accent: #256abf;
  --accent-ink: #ffffff;
  --series-1: #2a78d6; /* rendement 2 %  */
  --series-2: #eb6834; /* rendement 10 % */
  --good: #006300;
  --bad: #c22f2f;
  --shadow: 0 1px 2px rgba(60, 45, 20, 0.06);
  /* couleurs des catégories (identiques dans le camembert et les barres) */
  --cat-salaire: #1baf7a;
  --cat-aide: #008300;
  --cat-loyer: #2a78d6;
  --cat-factures: #eb6834;
  --cat-courses: #eda100;
  --cat-transport: #e87ba4;
  --cat-abonnements: #4a3aa7;
  --cat-activite: #9a6a3a;
  --cat-plaisir: #7a9a0e;
  --cat-autre: #e34948;
  --neutral-fill: #d6ccb6;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --series-1: #3987e5;
    --series-2: #d95926;
    --good: #0ca30c;
    --bad: #e66767;
    --shadow: none;
    --cat-salaire: #199e70;
    --cat-aide: #008300;
    --cat-loyer: #3987e5;
    --cat-factures: #d95926;
    --cat-courses: #c98500;
    --cat-transport: #d55181;
    --cat-abonnements: #9085e9;
    --cat-activite: #b7834f;
    --cat-plaisir: #9dbb2b;
    --cat-autre: #e66767;
    --neutral-fill: #4b4b47;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.05);
  --series-1: #3987e5;
  --series-2: #d95926;
  --good: #0ca30c;
  --bad: #e66767;
  --shadow: none;
  --cat-salaire: #199e70;
  --cat-aide: #008300;
  --cat-loyer: #3987e5;
  --cat-factures: #d95926;
  --cat-courses: #c98500;
  --cat-transport: #d55181;
  --cat-abonnements: #9085e9;
  --cat-activite: #b7834f;
  --cat-plaisir: #9dbb2b;
  --cat-autre: #e66767;
  --neutral-fill: #4b4b47;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
/* Pousse le footer en bas du viewport même quand le contenu est court (ex. page À propos). */
main.wrap { flex: 1 0 auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Header ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__in { position: relative; display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; margin-right: auto; }
.brand a { color: inherit; text-decoration: none; }

/* Sur desktop, le conteneur ne fait que grouper nav + thème sans exister dans la mise en page :
   .nav et #themeBtn restent des enfants flex directs de .topbar__in, comme avant. */
.site-menu { display: contents; }

/* Ancre les flèches de défilement mobiles (voir media query), sans effet sur
   le desktop où le nav ne défile jamais. */
.nav-scroll-wrap { position: relative; }
.nav { display: flex; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-2); text-decoration: none; font-size: 14px;
  padding: 6px 10px; border-radius: 8px;
}
.nav a:hover { background: var(--wash); color: var(--ink); }

/* L'icône n'apparaît que dans le menu déroulant mobile (voir media query) :
   sur desktop le nav reste un texte seul, plus compact. */
.nav-icon { display: none; flex: none; }

/* Bouton hamburger : masqué sur desktop, activé en media query mobile. */
.menu-toggle {
  display: none; flex: none;
  width: 40px; height: 40px; padding: 0;
  align-items: center; justify-content: center;
  color: var(--ink); background: transparent;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.menu-toggle:hover { background: var(--wash); }

/* Bascule animée barres <-> croix (fondu + légère rotation) plutôt qu'un
   affichage/masquage brut. */
.menu-icon {
  transform-box: fill-box; transform-origin: 50% 50%;
  transition: opacity .2s ease, transform .25s ease;
}
.menu-icon--bars { opacity: 1; transform: rotate(0deg); }
.menu-icon--close { opacity: 0; transform: rotate(-45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon--bars { opacity: 0; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon--close { opacity: 1; transform: rotate(0deg); }

/* Bouton thème : icône seule (soleil / lune), sans fond ni bordure de bouton.
   Le bouton Accueil (icône maison, à gauche du titre) partage exactement le
   même traitement visuel, mais n'apparaît que sur mobile (voir media query)
   où il remplace l'onglet Synthèse du menu déroulant ; sur desktop, Synthèse
   reste un onglet du menu comme avant (voir .nav-home plus bas). */
.theme-toggle, .home-link {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  color: var(--ink); background: transparent; border: none; border-radius: 8px; cursor: pointer;
  text-decoration: none;
}
.home-link { display: none; }
.theme-toggle:hover, .home-link:hover { background: var(--wash); }
/* Clair par défaut : lune visible, soleil masqué. */
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .theme-toggle .icon-moon { display: none; }
  :root:where(:not([data-theme="light"])) .theme-toggle .icon-sun { display: inline-flex; }
}
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-flex; }

/* ---------- Buttons & fields ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn--ghost:hover { background: var(--wash); filter: none; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }

input, select {
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  height: 40px; padding: 0 12px; min-width: 0;
}
input::placeholder { color: var(--muted); }
input:hover, select:hover { border-color: var(--axis); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.form-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  margin: 20px 0 8px;
}
.form-row label { flex: 0 1 190px; }
.form-row label.grow { flex: 1 1 220px; }

.input-with-btn { position: relative; display: block; }
/* 92px = bouton Exemple (≈ 81px avec sa marge) + un petit espace pour que
   les flèches haut/bas du champ nombre ne le touchent pas. */
.input-with-btn input { width: 100%; padding-right: 92px; }
.input-with-btn input:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent); }
.input-with-btn__btn {
  position: absolute; top: 50%; right: 5px; transform: translateY(-50%);
  flex: none; height: 26px; padding: 0 10px; gap: 5px;
  border-radius: 999px; font-size: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.input-with-btn__btn:hover { transform: translateY(-50%) scale(1.04); }

/* ---------- KPI tiles ---------- */

.kpis {
  display: grid; gap: 12px; margin: 24px 0 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
}
/* 4 tuiles sur une seule ligne en desktop (Revenus) ; 2 × 2 en mobile. */
.kpis--4 { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 12px;
}
.tile__body { flex: 1 1 0%; min-width: 0; }
.tile__label { font-size: 13px; color: var(--ink-2); }
.tile__value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; }
.tile__value--good { color: var(--good); }
.tile__unit { font-size: 14px; font-weight: 500; letter-spacing: normal; }
.tile__sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile__edit {
  flex: 0 0 auto; display: inline-flex; align-items: center; margin-left: auto;
  height: 30px; padding: 0 10px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.tile__edit:hover { background: var(--wash); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; margin: 20px 0;
  box-shadow: var(--shadow);
}
.card__head { display: flex; gap: 14px; align-items: flex-start; }
/* flex + min-width:0 : le titre prend toute la place disponible pour qu'un
   bouton éventuel (ex. Mois antérieur sur Dépenses) reste calé à sa droite,
   sans réduire la largeur du <p class="lead"> qui suit (hors de .card__head,
   donc sur toute la largeur de la carte, y compris en mobile). */
.card__head h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; flex: 1 1 auto; min-width: 0; }
.card__head .btn { flex: none; }
/* Boutons côte à côte (ex. Placement : Découvrir des produits + Simuler). */
.btn-group { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.card__head .btn-group { flex: none; margin-left: auto; }
.btn-group a.btn { text-decoration: none; }
.lead { color: var(--ink-2); font-size: 14px; margin-top: 2px; max-width: 62ch; }
.lead--full { max-width: none; text-align: justify; }
.h3 { font-size: 14px; font-weight: 650; color: var(--ink); }
.h3--gap { margin-top: 24px; }
.h3--center { text-align: center; font-size: 16px; }
.back-link { margin: 20px 0 4px; }
.back-link a { color: var(--ink-2); font-size: 14px; text-decoration: none; }
.back-link a:hover { color: var(--ink); text-decoration: underline; }
.note { font-size: 13px; color: var(--muted); margin-top: 14px; max-width: 80ch; }
/* Note sur toute la largeur de la carte, texte justifié (ex. Produits financiers). */
.note--full { max-width: none; text-align: justify; }
.about-text { font-size: 15px; line-height: 1.6; color: var(--ink-2); margin: 8px auto 0; max-width: 70ch; text-align: justify; }
/* Page Annexe : chaque terme est présenté comme une petite fiche, en grille
   qui passe naturellement à plusieurs colonnes sur les écrans larges (auto-fit,
   pas besoin de media query) et reste en une seule colonne sur mobile. */
.glossary { margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.glossary__item {
  background: var(--wash); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px;
}
.glossary dt { font-size: 14.5px; font-weight: 650; color: var(--ink); }
.glossary dd { margin: 4px 0 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); text-align: justify; }
/* Annexe : bouton « Plus d'infos » aligné à droite du terme (Action,
   Obligation, ETF), vers ses exemples dans la page Produits financiers. */
.glossary__dt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.glossary__dt-row .btn { flex: none; text-decoration: none; font-weight: 600; }
/* Lien de l'Annexe vers la page Produits financiers. */
.glossary__more { text-align: center; margin: 14px 0 0; font-size: 14px; }
/* Page Produits financiers : onglets Actions / Obligations / ETF. */
.tabs {
  display: flex; justify-content: center; gap: 4px; margin: 24px 0 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink-2);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 16px; margin-bottom: -1px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.tabpanel { margin-top: 16px; }
.tabpanel:focus-visible:not(:target) { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
/* Page Produits financiers : fiche produit (catégorie, ISIN, lien justETF). */
.product dd { text-align: left; }
.product dd p + p { margin-top: 6px; }
.product__meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.product__cat {
  font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.product__isin { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.product__link, .glossary__more a, .about-head .lead a { color: var(--accent); }
.product__link { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 13.5px; font-weight: 600; }
/* .card__head ne fait pas grandir ses enfants (flex sans grow) : sans width:100%,
   ce bloc reste large comme son contenu et le centrage du titre paraît décalé
   à gauche sur les écrans larges, où la carte est bien plus large que le texte. */
.about-head { width: 100%; }
.about-head .lead { font-size: 15px; line-height: 1.6; max-width: 70ch; margin: 8px auto 0; text-align: justify; }
/* Page Annexe (desktop) : l'intro tient sur une ligne, la justification la
   fait paraître collée à gauche dans le bloc large de 70ch ; centrée à la
   place. Repasse en justifié sur mobile (voir media query), où le bloc fait
   la largeur de l'écran et la justification reste pertinente. */
/* Spécificité égale à .about-head .lead (2 classes) pour gagner sur la
   règle de base malgré l'ordre dans le fichier. */
.about-head .lead--center { text-align: center; }
.about-title { text-align: center; text-transform: uppercase; }
.about-subtitle { text-align: center; }
/* Même besoin que .about-head ci-dessus : sans width:100%, le titre centré
   paraît décalé à gauche sur les écrans larges. */
.syn-head { width: 100%; }
#h-syn { text-align: center; }
.syn-head .lead { text-align: center; margin: 4px auto 0; }
#synthese .h3 { text-align: center; }
/* La légende à côté du titre empêche un centrage correct du texte seul :
   on empile titre et légende, tous deux centrés. */
#synthese .chart-head { flex-direction: column; align-items: center; }
.version-tag { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Tables ---------- */

/* Enveloppe non scrollable : porte les flèches, qui restent fixes pendant que
   .table-wrap défile en dessous (sinon elles défileraient avec le tableau). */
.table-scroll-wrap { position: relative; }
/* padding-bottom : laisse la place à la barre de défilement native du navigateur,
   qui sinon chevauche la ligne « Total » du tfoot juste en dessous. */
.table-wrap { position: relative; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; }
.table th, .table td { padding: 8px 10px; text-align: left; vertical-align: middle; }
.table thead th {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--axis); white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--grid); }
.table tbody tr:hover { background: var(--wash); }
.table tbody tr.is-sel { background: var(--wash); box-shadow: inset 3px 0 0 var(--accent); }
.table tbody tr.is-sel th { font-weight: 700; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th, .table tfoot td { font-weight: 700; border-top: 1px solid var(--axis); padding-top: 12px; }
.table tfoot th { font-size: 14px; }
.table .empty { text-align: center; color: var(--muted); padding: 24px 10px; }

/* Tableaux avec un ordre de colonnes différent en mobile (Dépenses, Revenus,
   Charges) : deux lignes d'en-tête/pied prêtes dans le HTML, une seule
   affichée selon le format (voir .row-desktop ci-dessous sous 640px). */
.row-mobile { display: none; }
.table--compact { font-size: 14px; min-width: 640px; }
.table--compact th, .table--compact td { padding: 6px 10px; }

.cell {
  width: 100%; height: 34px; padding: 0 8px;
  background: transparent; border-color: transparent; border-radius: 8px;
  font-size: 15px;
}
.cell:hover { border-color: var(--border); background: var(--surface); }
select.cell { padding: 0 4px; }
/* Catégorie (Revenus/Charges/Dépenses) : bouton qui ouvre la pop-up de choix, avec
   l'allure d'une cellule éditable plutôt que celle d'un .btn. */
.cell--pick {
  display: block; border: 1px solid transparent; color: var(--ink); font: inherit; font-size: 15px;
  text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell--pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
input.cell.num { text-align: right; max-width: 130px; margin-left: auto; display: block; font-variant-numeric: tabular-nums; }

.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: var(--wash); color: var(--bad); }
.icon-btn--view:hover { color: var(--accent); }
/* Œil + corbeille côte à côte dans la cellule Actions (Charges, Dépenses). */
.row-actions { white-space: nowrap; }

.delta { font-weight: 650; }
.delta small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.delta--good { color: var(--good); }
.delta--bad { color: var(--bad); }

.pill {
  display: inline-block; font-size: 11px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle;
  border: 1px solid var(--border); color: var(--ink-2);
}
.pill--good { color: var(--good); border-color: currentColor; }

.sub { display: block; font-size: 12px; color: var(--muted); }

/* ---------- Interrupteur (CashBack) ---------- */

.switch { position: relative; display: inline-flex; align-items: center; flex: none; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch__track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--border);
  position: relative; transition: background .25s ease;
}
/* Easing avec léger dépassement (cubic-bezier > 1) : le curseur « rebondit »
   légèrement en fin de course plutôt qu'un simple glissement linéaire. */
.switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.cb-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--grid);
}
.cb-row:last-child { border-bottom: 0; }
.cb-row__text { display: flex; flex-direction: column; min-width: 0; }
.cb-row__name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-row__amount { font-size: 12px; color: var(--muted); }
#cashbackSettingsTitle { margin-bottom: 4px; }
#cashbackSettingsOverlay .note, #roundUpSettingsOverlay .note { text-align: justify; margin-top: 0; }
.cb-rate-field { max-width: 140px; margin: 12px auto 16px; text-align: center; }

/* backOrRound.html : tuile enrichie (titre + 2 stats + bouton) au lieu du
   simple label/valeur/sous-texte habituel — toujours 2 tuiles à 50 % côte à
   côte (voir .kpis), y compris en mobile. */
.tile--summary { flex-direction: column; align-items: stretch; }
.tile--summary .tile__body { width: 100%; }
.tile--summary h2 { margin: 0 0 14px; font-size: 18px; font-weight: 700; text-align: center; }
.tile-stat { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 8px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.tile-stat:last-of-type { border-bottom: 0; }
.tile-stat__label { color: var(--ink-2); }
.tile-stat__value { font-weight: 650; font-variant-numeric: tabular-nums; }
.tile--summary .btn { display: block; text-align: center; margin-top: 14px; }

/* ---------- Breakdown ---------- */

.split {
  display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between;
  align-items: flex-start; margin-top: 24px;
}
.split > div:first-child { flex: 1 1 320px; max-width: 560px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Grille partagée par toutes les lignes : les colonnes (donc les chiffres) restent
   alignées d'une ligne à l'autre, chaque `.bd` n'étant qu'un groupe transparent. */
.breakdown {
  display: grid; grid-template-columns: 110px 1fr auto auto;
  column-gap: 12px; row-gap: 10px; align-items: center; margin-top: 12px;
}
.bd { display: contents; font-size: 14px; }
.bd__name { color: var(--ink-2); }
.bd__track { height: 8px; background: var(--wash); border-radius: 4px; overflow: hidden; }
.bd__bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bd__amt, .bd__pct {
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}
.bd__pct { color: var(--muted); min-width: 56px; }
/* Message « Ajoutez des… » : évite qu'il hérite de la 1re colonne (110px) de
   la grille et se retrouve comprimé sur plusieurs lignes au lieu de s'étaler. */
.breakdown > .note { grid-column: 1 / -1; margin-top: 0; }

/* ---------- Économies ---------- */

.preview { min-height: 22px; font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.preview .good { color: var(--good); font-weight: 650; }
.preview .bad { color: var(--bad); font-weight: 650; }

.mini-kpis {
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin: 8px 0 12px;
}
.mini {
  background: var(--wash); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.mini__label { font-size: 12px; color: var(--ink-2); }
.mini strong { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* ---------- Rendement ---------- */

/* Tableau comparatif des deux rendements : libellés à gauche, une colonne
   par taux (couleur de sa courbe en haut et teinte légère dessous). */
.cmp-wrap { margin: 16px 0 24px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.cmp { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.cmp__labels { width: 26%; }
.cmp--r2 { --key: var(--series-1); }
.cmp--r10 { --key: var(--series-2); }
.cmp col.cmp--r2, .cmp col.cmp--r10 { background: color-mix(in srgb, var(--key) 6%, transparent); }
.cmp th, .cmp td { padding: 10px 14px; }
.cmp thead th {
  border-top: 3px solid var(--key, transparent); padding-top: 14px;
  text-align: center; font-size: 13px; font-weight: 650; color: var(--ink-2);
}
.cmp thead th[scope="row"] { text-align: left; font-size: 14px; font-weight: 400; }
.cmp tbody tr { border-top: 1px solid var(--border); }
.cmp tbody th { text-align: left; font-weight: 400; color: var(--ink-2); }
.cmp tbody td { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp td.good { color: var(--good); }
.cmp__capital td { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; color: var(--ink); }
/* En-tête « [champ] % » : le taux annuel se modifie directement ici. */
.cmp__rate-field { display: inline-flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 6px; font-size: inherit; color: inherit; }
/* Largeur juste suffisante pour 4 caractères (de « 0,01 » à « 1000 ») ; les
   flèches natives du champ nombre sont masquées pour ne pas manger cette place. */
.cmp__rate {
  width: calc(4ch + 14px); height: 30px; padding: 0 6px; text-align: center;
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; border-radius: 8px;
  -moz-appearance: textfield; appearance: textfield;
}
.cmp__rate::-webkit-inner-spin-button, .cmp__rate::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* Année du gain : boutons haut/bas à côté du libellé (plus de champ dédié). */
.year-step { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.year-step__btns { display: inline-flex; flex-direction: column; gap: 2px; }
.year-step__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 14px; padding: 0; cursor: pointer;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px;
}
.year-step__btn:hover:not(:disabled) { background: var(--wash); color: var(--ink); }
.year-step__btn:disabled { opacity: 0.35; cursor: not-allowed; }
/* Le bloc titre + texte de la carte Placement prend la largeur restante,
   pour que le bouton Simuler un placement se cale à droite (desktop). */
#rendement .card__head > div { flex: 1 1 auto; min-width: 0; }

.chart-head { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--muted); }
.key--r2 { border-color: var(--series-1); }
.key--r10 { border-color: var(--series-2); }
.key--dep { border-top-style: dashed; border-color: var(--muted); }

.chart-wrap { position: relative; margin-top: 8px; }
#chart svg { display: block; width: 100%; height: auto; overflow: visible; }
#chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

.g-line { stroke: var(--grid); stroke-width: 1; }
.g-axis { stroke: var(--axis); stroke-width: 1; }
.g-text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.g-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.s-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.s-r2 { stroke: var(--series-1); }
.s-r10 { stroke: var(--series-2); }
.s-dep { stroke: var(--muted); stroke-dasharray: 5 4; }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.s-r2 { fill: var(--series-1); }
.dot.s-r10 { fill: var(--series-2); }
.dot.s-dep { fill: var(--muted); stroke-dasharray: none; }
.cross { stroke: var(--axis); stroke-width: 1; }

.tip {
  position: absolute; top: 8px; z-index: 2; pointer-events: none;
  min-width: 190px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  font-size: 13px;
}
.tip__head { font-weight: 650; margin-bottom: 6px; }
.tip__row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tip__row strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.tip__row span.lbl { color: var(--ink-2); }

.details { margin-top: 20px; }
.details summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); padding: 6px 0; }
.details summary:hover { color: var(--ink); }

/* ---------- Footer ---------- */

.foot { padding-top: 8px; padding-bottom: 40px; font-size: 13px; color: var(--muted); text-align: center; }
.foot p + p { margin-top: 6px; }
.link-btn {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--accent); filter: brightness(1.15); }

/* ---------- Pop-up de confirmation (suppression) ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45); padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3); padding: 20px;
}
.modal--narrow { max-width: 300px; }
.modal__title { font-size: 16px; font-weight: 650; line-height: 1.4; margin-bottom: 20px; white-space: pre-line; }
.modal__title--center { text-align: center; }
.modal__details {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px;
  font-size: 14px; margin: 0 0 20px;
}
.modal__details:empty { display: none; }
.modal__details dt { color: var(--ink-2); }
.modal__details dd { text-align: right; font-weight: 600; }
.modal__text { font-size: 14px; line-height: 1.5; color: var(--ink-2); margin: 12px 0 20px; text-align: justify; }
.modal__text--tight { margin-bottom: 16px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal__actions--center { justify-content: center; }
/* .btn impose display:inline-flex, qui l'emporte sinon sur l'attribut
   hidden natif (même piège que .modal-overlay[hidden] ci-dessus) : utile
   ici pour Retour/Terminer, masqués ou montrés selon l'étape du wizard. */
.modal__actions [hidden] { display: none; }
#infoOverlay .modal__actions { justify-content: center; }
.modal--wide { max-width: 460px; }

/* Pop-up d'ajout guidé (étapes) : remplace une ligne de formulaire à
   plusieurs champs côte à côte — pénible à remplir au clavier mobile — par
   un champ à la fois, avec Retour/Suivant et une croix pour annuler. */
.add-trigger { margin: 20px 0 8px; }
.add-trigger--center { text-align: center; margin: 24px 0 8px; }
/* Sur tablette/bureau, le JS vide ce conteneur (bouton déplacé dans
   .card__head) : :empty le masque pour ne pas laisser un espace vide. */
.add-trigger:empty { display: none; }
.modal--wizard { max-width: 360px; }
.wizard__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.wizard__head .modal__title { margin-bottom: 0; }
.wizard__close { flex: none; margin: -6px -6px 0 0; }
.wizard__step { margin-top: 20px; }
.wizard__progress { font-size: 12px; color: var(--muted); text-align: center; margin: 18px 0 0; }
.modal--wizard .modal__actions { margin-top: 16px; }
/* Wizard Placement : bouton « Simuler avec mes économies mensuelles » sous le
   champ Épargne, et les deux rendements à comparer sur la même étape. */
.wizard__extra { width: 100%; margin-top: 12px; }
.wizard__step--pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wizard__step--pair[hidden] { display: none; }
/* Étapes à petits champs (Durée, Rendements) : contenu centré dans la pop-up. */
.wizard__step--center { text-align: center; }
.wizard__step--center label { align-items: center; }
/* Épargne (avec le bouton Exemple incrusté) et Capital : taille utile pour
   un montant à 7 chiffres plutôt que la pleine largeur. */
.wizard__step--center .input-with-btn { width: calc(9ch + 118px); }
.wizard__step--center .wizard__extra { width: auto; }

/* Liste scrollable générique pour le contenu d'une modale qui grandit avec les
   données (Historique des dépenses, paramétrage CashBack…). */
/* padding-right : laisse la place à la barre de défilement native du
   navigateur, qui sinon chevauche le contenu collé au bord (ex. interrupteurs
   CashBack). */
/* Pop-up de choix de catégorie : une proposition par bouton, deux colonnes,
   la catégorie actuelle en couleur d'accent. */
.cat-picker {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin-top: 16px; max-height: 60vh; overflow-y: auto;
}
.cat-picker__opt {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  min-height: 40px; padding: 6px 10px; cursor: pointer; text-align: center;
}
.cat-picker__opt:hover { background: var(--wash); }
.cat-picker__opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.modal-list { max-height: 60vh; overflow-y: auto; overflow-x: hidden; margin-bottom: 16px; padding-right: 14px; }

/* Pop-up Historique (dépenses) : un bloc par mois archivé, chacun avec son
   propre petit tableau (mêmes styles que .table). */
.historique-month { margin-top: 20px; }
.historique-month:first-child { margin-top: 0; }
/* .table impose min-width:560px pour les tableaux principaux (pensés pour des
   champs éditables) ; bien trop large pour ce petit récapitulatif en lecture
   seule dans une modale de 460px, où ça masquait la colonne Montant. */
.historique-month .table { margin-top: 8px; font-size: 13px; min-width: 0; }

.example-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.example-item {
  width: 100%; display: flex; flex-direction: column; gap: 4px;
  text-align: left; padding: 10px 12px;
  background: transparent; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font: inherit; color: var(--ink);
}
.example-item:hover { background: var(--wash); border-color: var(--axis); }
.example-item__name { font-size: 14px; font-weight: 650; }
.example-item__desc { font-size: 12px; color: var(--ink-2); }
.btn--danger { background: var(--bad); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); }

.btn-with-info { display: inline-flex; align-items: center; gap: 8px; }
/* Champs nombre à leur taille utile plutôt qu'en pleine largeur : Durée
   (jusqu'à 50) et rendements (de « 0,01 » à « 1000 », « % » juste après). */
.input--fit { width: calc(3ch + 40px); text-align: center; }
.input--money { width: calc(9ch + 40px); text-align: center; }
.input-unit { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 15px; }
.input--rate { width: calc(4ch + 28px); text-align: center; -moz-appearance: textfield; appearance: textfield; }
.input--rate::-webkit-inner-spin-button, .input--rate::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* Formulaire Placement : Épargne mensuelle, bouton Simuler mes économies
   juste dessous, puis Capital de départ et Durée côte à côte (50/50). */
#yieldForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; max-width: 720px; }
#yieldForm label { flex: unset; min-width: 0; }
/* Libellé et champ sur la même ligne, pour gagner de la hauteur. */
#yieldForm label { flex-direction: row; align-items: center; gap: 10px; white-space: nowrap; }
#yieldForm label > input, #yieldForm label > .input-with-btn { flex: 1 1 auto; min-width: 0; }
/* Ligne Épargne mensuelle + bouton économies (et sa bulle) à droite. Le
   champ est à la taille d'un montant de « 0,001 » à « 1000000000000 »,
   bouton Exemple incrusté compris. */
#yieldForm .yield-line { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
#yieldForm .yield-line > label { flex: none; }
#yieldForm .yield-line .input-with-btn { flex: none; width: calc(13ch + 138px); }
.info-btn {
  flex: none; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--ink-2);
  cursor: pointer;
}
.info-btn:hover { background: var(--wash); color: var(--ink); }
.info-btn--sm { width: 18px; height: 18px; }

.tile__label--with-info { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Synthèse ---------- */

.syn-tools { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin: 20px 0 4px; }
.syn-tools .preview { margin: 0; flex: 1 1 320px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--wash); border-radius: 10px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2);
  height: 32px; padding: 0 14px; background: transparent; border: 0; border-radius: 8px; cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border); }

.syn-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px; margin-top: 16px; }
.pie-box { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; margin-top: 12px; }
.pie-wrap { position: relative; flex: 0 0 220px; max-width: 100%; }
.pie-wrap svg { display: block; width: 220px; height: 220px; max-width: 100%; }
.pie-slice { stroke: var(--surface); stroke-width: 2; cursor: default; outline: none; }
.pie-slice:hover, .pie-slice:focus-visible { opacity: 0.85; }
.pie-slice:focus-visible { stroke: var(--ink); }
.pie-c1 { fill: var(--muted); font-size: 12px; pointer-events: none; }
.pie-c2 { fill: var(--ink); font-size: 20px; font-weight: 650; pointer-events: none; }

.plegend { list-style: none; margin: 0; padding: 0; flex: 1 1 230px; display: grid; gap: 8px; font-size: 14px; }
.plegend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 56px; gap: 10px; align-items: center; }
.plegend__empty { display: block !important; color: var(--muted); }
.pl-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.pl-pct { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.sw { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--c, var(--muted)); }
.legend li .sw { margin-right: 0; }

.bilan { margin: 12px 0 0; }
.bilan > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.bilan dt { color: var(--ink-2); }
.bilan dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.bilan dd small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }

.chart-head--gap { margin-top: 32px; }
.syn-export { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 24px; }
.chart-scroll-wrap { position: relative; }
/* Marge basse pour laisser la place à la barre de défilement du navigateur,
   qui sinon chevauche les légendes REVENUS / CHARGES du graphique. */
.chart-scroll { overflow-x: auto; margin-top: 8px; padding-bottom: 16px; }
.chart-inner { position: relative; width: max-content; min-width: 100%; }

/* Flèches indiquant qu'il y a d'autre contenu à faire défiler horizontalement
   (graphique en barres, tableaux). Fond transparent pour ne pas masquer le
   contenu qu'elles survolent. */
.scroll-arrow {
  position: absolute; top: 0; bottom: 0; width: 36px;
  display: flex; align-items: center; border: 0; padding: 0; margin: 0;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
/* `display: flex` ci-dessus a plus de poids qu'une règle du navigateur : sans
   ceci, l'attribut `hidden` est posé par le JS mais n'a plus aucun effet visuel. */
.scroll-arrow[hidden] { display: none; }
.scroll-arrow:hover { color: var(--ink); }
.scroll-arrow--left { left: 0; justify-content: flex-start; }
.scroll-arrow--right { right: 0; justify-content: flex-end; }
/* Cantonnées à la zone des barres, pour ne chevaucher ni le repère « € / mois »
   en haut à gauche, ni les libellés et légendes de groupe en bas. */
.chart-scroll-wrap .scroll-arrow { top: 40px; bottom: 90px; }
#barChart svg { display: block; max-width: none; overflow: visible; }
.bar { outline: none; }
.bar:hover .bar-mark, .bar:focus-visible .bar-mark { opacity: 0.85; }
.bar:focus-visible .bar-hit { stroke: var(--accent); stroke-width: 2; }
.g-val { fill: var(--ink-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.g-xl { fill: var(--ink-2); font-size: 12px; }
.g-cap { fill: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }

/* ---------- Responsive ----------
   Ce bloc doit rester en dernier dans le fichier : les media queries
   ci-dessous ont la même spécificité que les règles de base qu'elles
   surchargent (.syn-grid, .pie-wrap, .plegend, .syn-tools…), donc seul
   leur ordre dans la cascade leur permet de gagner. */

/* Tablette */
@media (max-width: 900px) {
  .wrap { padding: 0 14px; }
  .syn-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  /* Sur mobile et tablette, seul l'export reste : l'impression est une action bureau. */
  #btnPrint { display: none; }
}

/* Mobile */
@media (max-width: 640px) {
  .wrap { padding: 0 12px; }
  .about-head .lead--center { text-align: justify; }
  /* Le bouton hamburger disparaît : le menu reste affiché en permanence, pas besoin
     de le déplier. Le lien Synthèse (icône + texte) est plus large que le
     bouton thème : centrer le titre dans la seule colonne du milieu le
     décale donc visiblement vers la droite. Il est à la place étalé sur
     toute la largeur de la ligne (grid-column 1/-1, superposé aux colonnes
     home/theme) et centré par rapport à l'écran, pas à l'espace restant. */
  .topbar__in {
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "home . theme" "nav nav nav";
    gap: 0 10px; height: auto; padding-top: 4px; padding-bottom: 2px;
  }
  .menu-toggle { display: none; }
  #homeBtn { display: inline-flex; grid-area: home; align-self: center; }
  .brand {
    grid-row: 1; grid-column: 1 / -1; margin-right: 0;
    justify-self: center; align-self: center;
  }
  /* Synthèse disparaît des onglets mobiles pour éviter le doublon avec
     #homeBtn (visible uniquement ici, voir .home-link plus haut) ; sur
     desktop c'est l'inverse : #homeBtn reste masqué et Synthèse garde sa
     place habituelle dans le menu. */
  .nav a.nav-home { display: none; }
  /* display: contents fait passer .nav et #themeBtn comme des enfants directs de
     .topbar__in (comme sur desktop), pour pouvoir les placer via grid-area. */
  .site-menu { display: contents; }
  #themeBtn { grid-area: theme; justify-self: end; align-self: center; }
  /* Onglets plats : pas de fond ni de bordure, seul un soulignement de 2px
     distingue l'onglet actif (couleur d'accent). Défilement horizontal en
     secours si les 6 onglets ne tiennent pas sur un petit écran, signalé par
     des flèches (voir .scroll-arrow) qui n'apparaissent que si la bordure
     correspondante n'est pas encore atteinte. Contrairement aux flèches des
     tableaux (superposées en overlay), celles-ci ont leur propre colonne dans
     la ligne (flex + order) pour ne jamais recouvrir le texte des onglets ;
     l'espace reste réservé même flèche masquée (visibility, pas display) pour
     éviter que les onglets ne sautent de largeur pendant le défilement. */
  .nav-scroll-wrap { grid-area: nav; display: flex; align-items: center; }
  .nav {
    order: 2; flex: 1 1 auto; min-width: 0; display: flex; gap: 2px;
    overflow-x: auto; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-scroll-wrap .scroll-arrow {
    position: static; flex: none; width: 22px; justify-content: center;
  }
  .nav-scroll-wrap .scroll-arrow[hidden] { display: flex; visibility: hidden; }
  #navScrollLeft { order: 1; }
  #navScrollRight { order: 3; }
  .nav a {
    flex: none; flex-direction: row; align-items: center; justify-content: center; gap: 5px;
    padding: 2px 10px 4px; text-align: center;
    color: var(--ink-2); background: transparent;
    border-bottom: 2px solid transparent;
    transition: color .15s ease, border-color .15s ease;
  }
  .nav a[aria-current="page"] {
    color: var(--accent); font-weight: 650; border-bottom-color: var(--accent);
  }
  .nav-icon { display: inline-flex; width: 15px; height: 15px; color: inherit; }
  .nav a span { font-size: 12.5px; }

  .card { padding: 16px 14px; border-radius: 14px; margin-top: 8px; }
  .card__head { gap: 10px; }
  /* .card ne garde que 8px de marge haute en mobile (contre 20px en
     desktop) : les 24px/8px du bouton Ajouter un revenu devenaient très
     asymétriques (gros espace au-dessus, presque rien en dessous). */
  .add-trigger--center { margin: 12px 0; }
  /* Bouton Ajouter une charge centré en mobile (desktop : déplacé dans
     .card__head par le JS, donc ce conteneur est vide et masqué). */
  #addChargeMobileSlot { text-align: center; }
  /* Bouton Nouvelle dépense centré en mobile, comme Ajouter une charge
     (desktop : déplacé dans .card__head par le JS, conteneur vide/masqué). */
  #addDepenseMobileSlot { text-align: center; }
  /* Bouton Ajouter une comparaison centré en mobile, comme Ajouter une charge. */
  #addScenarioMobileSlot { text-align: center; }
  /* Bouton Simuler un placement centré en mobile, comme Ajouter une charge. */
  #addYieldMobileSlot { text-align: center; }
  /* Les deux boutons Placement restent côte à côte en mobile. */
  /* (passent l'un sous l'autre seulement sur les très petits écrans). */
  #yieldActions .btn { padding-left: 10px; padding-right: 10px; font-size: 13px; }
  /* Tableau des rendements en mobile : cellules plus serrées pour tenir les
     trois colonnes. */
  .cmp { font-size: 13px; }
  .cmp__labels { width: 30%; }
  .cmp th, .cmp td { padding: 9px 8px; }
  .cmp__capital td { font-size: 17px; }
  /* Retour à la ligne réservé au desktop : en mobile, le texte coule normalement. */
  .br-desktop { display: none; }
  /* Le bouton Modifier se cale sur le bas de la tuile (grille : hauteur égale à la
     plus haute voisine), plutôt que juste après le texte, pour rester aligné avec
     celui des tuiles voisines même si leur contenu fait plus ou moins de lignes. */
  .tile { flex-direction: column; align-items: stretch; }
  .tile__edit { align-self: flex-end; }
  /* Historique n'est jamais dans la tuile en mobile (voir bindResponsiveTrigger) :
     neutralise l'align-self:flex-end de .tile__edit ci-dessus, qui le
     pousserait en bas de .card__head (rangée, pas colonne) une fois déplacé. */
  #btnHistorique { align-self: flex-start; }
  .tile__value { font-size: 20px; }
  .tile__unit { font-size: 12px; }
  .form-row { gap: 10px; }
  .form-row label, .form-row label.grow { flex: 1 1 100%; }
  .form-row .btn { width: 100%; }
  .form-row .input-with-btn__btn { width: auto; }
  /* Formulaire Rendement : la grille 2 colonnes (voir #yieldForm plus haut)
     s'applique déjà ; le bouton économies prend juste toute la largeur. */
  #yieldForm .btn-with-info .btn { flex: 1 1 auto; }
  /* Mobile : Épargne sur toute la ligne, bouton économies dessous. */
  #yieldForm .yield-line > label, #yieldForm .yield-line > .btn-with-info { flex: 1 1 100%; }
  #yieldForm .yield-line .input-with-btn { flex: 1 1 auto; width: auto; }
  .breakdown { grid-template-columns: 90px 1fr auto; }
  .bd__pct { grid-column: 1 / -1; font-size: 12px; margin-top: -6px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
  .tile { padding: 12px 14px; }
  .back-link { text-align: center; }
  .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plegend li { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .plegend .pl-pct { display: none; }
  .pie-wrap { flex: 1 1 100%; display: flex; justify-content: center; }
  .split { gap: 16px; }
  .actions { flex-basis: 100%; justify-content: center; }
  .chart-head, .syn-tools { gap: 10px 16px; }

  /* Camembert : donut centré dans sa largeur, bascule mois/an centrée. */
  #synMsg { text-align: center; }
  .seg { margin: 0 auto; }

  /* Dépenses : bascule vers l'ordre Libellé, Montant, Catégorie — largeurs
     fixes pour que Montant reste visible sans défilement (au lieu d'être
     repoussé au bord par la colonne Libellé, qui n'a pas de largeur max). */
  .row-desktop { display: none; }
  .row-mobile { display: table-row; }
  /* min-width 590px : Catégorie (~180px) affiche « Entretien ménager » en
     entier, tandis que Libellé (~186px) + Montant (~154px) tiennent sans
     défilement dès 390px d'écran. */
  #depensesTable { table-layout: fixed; min-width: 590px; }
  #depensesTable th:nth-child(1), #depensesTable td:nth-child(1) { width: 31.5%; }
  #depensesTable th:nth-child(2), #depensesTable td:nth-child(2) { width: 26%; }
  #depensesTable th:nth-child(3), #depensesTable td:nth-child(3) { width: 30.5%; }
  #depensesTable th:nth-child(4), #depensesTable td:nth-child(4) { width: 12%; }
  /* Œil + corbeille : boutons resserrés pour rapprocher les deux icônes. */
  #depensesTable .row-actions .icon-btn { width: 24px; }
  /* Catégorie alignée à droite : colle la valeur aux boutons œil/corbeille
     pour les catégories courtes, sans retirer la place nécessaire aux noms
     longs (« Entretien ménager ») qui occupent déjà toute la largeur. */
  #depensesTable td:nth-child(3) .cell--pick { text-align: right; }
  #depensesTable thead tr.row-mobile th:nth-child(3) { text-align: right; }

  /* Revenus/Charges : bascule vers l'ordre Libellé, Mensuel, Catégorie, Annuel
     — Libellé et Mensuel passent en premier pour rester visibles sans
     défilement, Libellé reçoit nettement plus de place qu'avant (pour les
     libellés longs) ; Catégorie/Annuel restent accessibles en défilant. */
  #revenusTable, #chargesTable { table-layout: fixed; }
  #revenusTable th:nth-child(1), #revenusTable td:nth-child(1),
  #chargesTable th:nth-child(1), #chargesTable td:nth-child(1) { width: 38%; }
  #revenusTable th:nth-child(2), #revenusTable td:nth-child(2),
  #chargesTable th:nth-child(2), #chargesTable td:nth-child(2) { width: 22%; }
  #revenusTable th:nth-child(3), #revenusTable td:nth-child(3),
  #chargesTable th:nth-child(3), #chargesTable td:nth-child(3) { width: 18%; }
  #revenusTable th:nth-child(4), #revenusTable td:nth-child(4),
  #chargesTable th:nth-child(4), #chargesTable td:nth-child(4) { width: 14%; }
  #revenusTable th:nth-child(5), #revenusTable td:nth-child(5),
  #chargesTable th:nth-child(5), #chargesTable td:nth-child(5) { width: 8%; }
  /* Charges : min-width 640px pour afficher Catégorie en entier (~154px,
     « Abonnements ») et loger œil + corbeille, sans rogner Libellé/Mensuel. */
  #chargesTable { min-width: 640px; }
  #chargesTable th:nth-child(1), #chargesTable td:nth-child(1) { width: 30%; }
  #chargesTable th:nth-child(2), #chargesTable td:nth-child(2) { width: 19%; }
  #chargesTable th:nth-child(3), #chargesTable td:nth-child(3) { width: 24%; }
  #chargesTable th:nth-child(4), #chargesTable td:nth-child(4) { width: 16%; }
  #chargesTable th:nth-child(5), #chargesTable td:nth-child(5) { width: 11%; }

  /* CashBack/RoundUp : bascule vers l'ordre Libellé, Cashback/RoundUp,
     Mensuel/Montant — les deux premières colonnes (ce qui compte le plus ici)
     restent visibles sans défilement ; Mensuel/Montant reste accessible en
     défilant. */
  #cashbackChargesTable, #cashbackDepensesTable,
  #roundUpChargesTable, #roundUpDepensesTable { table-layout: fixed; }
  #cashbackChargesTable th:nth-child(1), #cashbackChargesTable td:nth-child(1),
  #cashbackDepensesTable th:nth-child(1), #cashbackDepensesTable td:nth-child(1),
  #roundUpChargesTable th:nth-child(1), #roundUpChargesTable td:nth-child(1),
  #roundUpDepensesTable th:nth-child(1), #roundUpDepensesTable td:nth-child(1) { width: 35%; }
  #cashbackChargesTable th:nth-child(2), #cashbackChargesTable td:nth-child(2),
  #cashbackDepensesTable th:nth-child(2), #cashbackDepensesTable td:nth-child(2),
  #roundUpChargesTable th:nth-child(2), #roundUpChargesTable td:nth-child(2),
  #roundUpDepensesTable th:nth-child(2), #roundUpDepensesTable td:nth-child(2) { width: 25%; }
  #cashbackChargesTable th:nth-child(3), #cashbackChargesTable td:nth-child(3),
  #cashbackDepensesTable th:nth-child(3), #cashbackDepensesTable td:nth-child(3),
  #roundUpChargesTable th:nth-child(3), #roundUpChargesTable td:nth-child(3),
  #roundUpDepensesTable th:nth-child(3), #roundUpDepensesTable td:nth-child(3) { width: 40%; }
}

@media (max-width: 380px) {
  .mini-kpis { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-menu, .menu-icon { transition: none; }
}

@media print {
  .topbar, .form-row, .add-trigger, .actions, .icon-btn, .syn-export, .foot { display: none !important; }
  /* À l'export/impression, seule la Synthèse (camembert + bilan) est utile :
     les 6 tuiles résumé et le graphique en barres sont redondants sur papier. */
  .kpis, .chart-head--gap, .chart-scroll-wrap { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }

  /* Pop-up Historique (dépenses) ouvert : n'imprime que son contenu, pas le
     reste de la page derrière (déjà masqué ci-dessus par les règles
     génériques, sauf la carte Dépenses elle-même qu'on masque ici en plus). */
  body:has(#historiqueOverlay:not([hidden])) #depenses,
  body:has(#historiqueOverlay:not([hidden])) .back-link {
    display: none !important;
  }
  body:has(#historiqueOverlay:not([hidden])) #historiqueOverlay {
    position: static; background: none; padding: 0; display: block;
  }
  body:has(#historiqueOverlay:not([hidden])) .modal {
    max-width: none; width: 100%; box-shadow: none; border: none; padding: 0;
  }
  body:has(#historiqueOverlay:not([hidden])) .modal-list { max-height: none; overflow: visible; }
  body:has(#historiqueOverlay:not([hidden])) .modal__actions { display: none !important; }
}
