/* =============================================================================
   SYSTÈME DE DESIGN — Application de budget personnel / couple
   Thème sombre unique · mobile-first · densité « produit », pas « template »
   Aucun build, aucune dépendance, aucune police distante.
   Ordre des sections :
     01 Jetons (couleurs, espacement, rayons, ombres, z-index, mouvement)
     02 Reset & base
     03 Typographie & chiffres
     04 Coquille applicative (shell, header, conteneurs, grille)
     05 Navigation (barre d'onglets mobile + FAB, sidebar desktop)
     06 Sections & cartes
     07 KPI & statistiques
     08 Boutons
     09 Formulaires
     10 Chips, pills, badges, segmented, tabs
     11 Interrupteurs & cases à cocher
     12 Progression & jauges (cagnottes)
     13 Avatars
     14 Listes & tableaux
     15 Calendrier
     16 Graphiques (donut / courbe) — habillage seulement
     17 Feuilles modales & superpositions
     18 Toasts
     19 États : vide, chargement, squelette, spinner
     20 Page de connexion
     21 Utilitaires
     22 Accessibilité & mouvement réduit
   ========================================================================== */


/* =============================================================================
   01 · JETONS
   ========================================================================== */

:root {
  color-scheme: dark;

  /* --- Échelle ardoise (fond, surfaces, texte) --------------------------- */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* --- Accent : sarcelle (identité + valeurs positives) ------------------ */
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  /* --- Rose : valeurs négatives, dépenses, destructif ------------------- */
  --rose-200: #fecdd3;
  --rose-300: #fda4af;
  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-700: #be123c;

  /* --- Ciel : information, virements, neutre chiffré -------------------- */
  --sky-200: #bae6fd;
  --sky-300: #7dd3fc;
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;

  /* --- Ambre : alertes, échéances proches, dépassement léger ------------ */
  --amber-200: #fef08a;
  --amber-300: #fde047;
  --amber-400: #facc15;
  --amber-500: #eab308;
  --amber-600: #ca8a04;

  /* --- Violet / indigo : uniquement catégories & séries de graphiques ---- */
  --violet-400: #a78bfa;
  --indigo-400: #818cf8;
  --fuchsia-400: #e879f9;
  --lime-400: #a3e635;

  /* --- Triplets RGB : composition alpha sans color-mix ------------------- */
  --rgb-teal:   45 212 191;
  --rgb-rose:   251 113 133;
  --rgb-sky:    56 189 248;
  --rgb-amber:  250 204 21;
  --rgb-violet: 167 139 250;
  --rgb-white:  255 255 255;
  --rgb-ink:    2 6 23;
  --rgb-slate:  148 163 184;

  /* --- Jetons sémantiques : surfaces ------------------------------------ */
  --bg:            var(--slate-950);
  --bg-sunk:       #010410;                       /* creux : pistes, champs  */
  --surface:       rgb(15 23 42 / 0.62);          /* carte standard          */
  --surface-solid: #0d1526;                       /* carte opaque (sticky)   */
  --surface-2:     rgb(30 41 59 / 0.55);          /* zone interne, en-tête   */
  --surface-3:     rgb(30 41 59 / 0.85);          /* survol, sélection       */
  --surface-nav:   rgb(7 13 28 / 0.86);           /* barres translucides     */
  --border:        rgb(30 41 59 / 0.9);           /* slate-800               */
  --border-soft:   rgb(30 41 59 / 0.55);
  --border-strong: rgb(51 65 85 / 0.95);          /* slate-700               */
  --hairline:      rgb(var(--rgb-white) / 0.045); /* filet lumineux haut     */

  /* --- Jetons sémantiques : texte --------------------------------------- */
  --text-1: var(--slate-50);    /* titres, montants                          */
  --text-2: var(--slate-300);   /* corps                                     */
  --text-3: var(--slate-400);   /* secondaire, placeholders (contraste ok)   */
  --text-4: var(--slate-500);   /* décoratif uniquement, jamais informatif   */
  --text-on-accent: #04201d;    /* texte sur aplat sarcelle                  */

  /* --- Jetons sémantiques : intentions ---------------------------------- */
  --accent:        var(--teal-400);
  --accent-hi:     var(--teal-300);
  --accent-lo:     var(--teal-600);
  --accent-wash:   rgb(var(--rgb-teal) / 0.12);
  --accent-line:   rgb(var(--rgb-teal) / 0.32);
  --accent-glow:   rgb(var(--rgb-teal) / 0.22);

  --pos:      var(--teal-400);
  --pos-wash: rgb(var(--rgb-teal) / 0.12);
  --neg:      var(--rose-400);
  --neg-wash: rgb(var(--rgb-rose) / 0.13);
  --neg-line: rgb(var(--rgb-rose) / 0.34);
  --info:      var(--sky-400);
  --info-wash: rgb(var(--rgb-sky) / 0.12);
  --info-line: rgb(var(--rgb-sky) / 0.32);
  --warn:      var(--amber-400);
  --warn-wash: rgb(var(--rgb-amber) / 0.12);
  --warn-line: rgb(var(--rgb-amber) / 0.32);

  /* --- Séries catégorielles (donut, légendes, tags de catégorie) --------- */
  --cat-1: var(--teal-400);
  --cat-2: var(--sky-400);
  --cat-3: var(--violet-400);
  --cat-4: var(--amber-400);
  --cat-5: var(--rose-400);
  --cat-6: var(--indigo-400);
  --cat-7: var(--lime-400);
  --cat-8: var(--fuchsia-400);

  /* --- Espacement : base 4, rythme dense --------------------------------- */
  --space-0: 0;
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 12px;
  --space-6: 16px;
  --space-7: 20px;
  --space-8: 24px;
  --space-9: 32px;
  --space-10: 40px;
  --space-11: 48px;
  --space-12: 64px;

  /* --- Gouttières & largeurs -------------------------------------------- */
  --gutter: 14px;
  --gap: var(--space-5);
  --content-max: 1560px;
  --sidebar-w: 248px;
  --tabbar-h: 60px;
  --header-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* --- Rayons ------------------------------------------------------------ */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;    /* 1rem   — cartes courantes  */
  --r-xl: 24px;    /* 1.5rem — cartes majeures   */
  --r-2xl: 28px;   /* feuilles modales           */
  --r-full: 999px;

  /* --- Ombres : décalage + flou réels, jamais un halo plat --------------- */
  --shadow-1: 0 1px 2px rgb(var(--rgb-ink) / 0.6);
  --shadow-2: 0 2px 6px -1px rgb(var(--rgb-ink) / 0.65),
              0 1px 2px rgb(var(--rgb-ink) / 0.5);
  --shadow-3: 0 8px 20px -6px rgb(var(--rgb-ink) / 0.75),
              0 2px 6px -2px rgb(var(--rgb-ink) / 0.6);
  --shadow-4: 0 20px 44px -14px rgb(var(--rgb-ink) / 0.85),
              0 6px 14px -6px rgb(var(--rgb-ink) / 0.7);
  --shadow-5: 0 -12px 40px -12px rgb(var(--rgb-ink) / 0.9),
              0 -2px 8px -4px rgb(var(--rgb-ink) / 0.7);
  --shadow-accent: 0 6px 18px -6px rgb(var(--rgb-teal) / 0.5),
                   0 2px 5px -2px rgb(var(--rgb-ink) / 0.6);
  --inset-top: inset 0 1px 0 var(--hairline);

  /* --- Anneau de focus --------------------------------------------------- */
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px rgb(var(--rgb-teal) / 0.85);
  --ring-danger: 0 0 0 2px var(--bg), 0 0 0 4px rgb(var(--rgb-rose) / 0.85);

  /* --- Plans (z-index) --------------------------------------------------- */
  --z-base: 0;
  --z-raised: 10;
  --z-sticky: 20;
  --z-nav: 40;
  --z-fab: 45;
  --z-backdrop: 60;
  --z-sheet: 70;
  --z-popover: 80;
  --z-toast: 90;
  --z-max: 100;

  /* --- Courbes ----------------------------------------------------------- */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);        /* entrées, réponses   */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);    /* déplacements        */
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);     /* feuilles iOS        */
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);         /* couleurs, survols   */
  --ease-pop: cubic-bezier(0.34, 1.28, 0.64, 1);     /* rebond très léger   */

  /* --- Durées ------------------------------------------------------------ */
  --t-press: 110ms;
  --t-1: 140ms;
  --t-2: 180ms;
  --t-3: 220ms;
  --t-4: 280ms;
  --t-5: 360ms;
  --t-6: 460ms;

  /* --- Typographie ------------------------------------------------------- */
  --font-sans: "Inter", "Inter var", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans",
               "Liberation Sans", Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo,
               Consolas, "Liberation Mono", monospace;
}

@media (min-width: 640px) {
  :root { --gutter: 20px; --gap: var(--space-6); }
}

@media (min-width: 1024px) {
  :root { --gutter: 28px; --gap: var(--space-6); --header-h: 62px; }
}

@media (min-width: 1440px) {
  :root { --gutter: 36px; --sidebar-w: 268px; }
}


/* =============================================================================
   02 · RESET & BASE
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  tab-size: 2;
}

body {
  min-height: 100dvh;
  background-color: var(--bg);
  /* Deux nappes très diffuses : la page respire sans motif décoratif. */
  background-image:
    radial-gradient(1100px 620px at 88% -12%, rgb(var(--rgb-teal) / 0.055), transparent 62%),
    radial-gradient(900px 560px at -8% 8%, rgb(var(--rgb-sky) / 0.04), transparent 60%);
  background-attachment: fixed;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  font-synthesis-weight: none;
  font-feature-settings: "cv05" 1, "ss01" 1, "case" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

img, svg, video, canvas { display: block; max-width: 100%; }
svg { flex: none; }

button, input, select, textarea, optgroup { font: inherit; color: inherit; letter-spacing: inherit; }

button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

ul, ol { list-style: none; padding: 0; }

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin-block: var(--space-6);
}

table { border-collapse: collapse; width: 100%; }

::selection { background: rgb(var(--rgb-teal) / 0.3); color: var(--text-1); }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* Barres de défilement discrètes (WebKit + Firefox) */
* { scrollbar-width: thin; scrollbar-color: var(--slate-700) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--slate-800);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--slate-700); background-clip: content-box; }


/* =============================================================================
   03 · TYPOGRAPHIE & CHIFFRES
   ========================================================================== */

h1, h2, h3, h4, h5 {
  color: var(--text-1);
  font-weight: 620;
  line-height: 1.18;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.t-display {
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.5rem);
  font-weight: 680;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--text-1);
}
.t-h1 { font-size: 1.5rem;  letter-spacing: -0.028em; font-weight: 660; }
.t-h2 { font-size: 1.1875rem; letter-spacing: -0.022em; font-weight: 640; }
.t-h3 { font-size: 1rem;    letter-spacing: -0.014em; font-weight: 620; }
.t-body { font-size: 0.9375rem; line-height: 1.55; color: var(--text-2); }
.t-sm   { font-size: 0.8125rem; line-height: 1.45; color: var(--text-3); }
.t-xs   { font-size: 0.75rem;   line-height: 1.4;  color: var(--text-3); }
.t-micro {
  font-size: 0.6875rem;
  line-height: 1.3;
  font-weight: 560;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-4);
}
.t-lead { max-width: 68ch; font-size: 0.9375rem; color: var(--text-3); }
.t-strong { color: var(--text-1); font-weight: 600; }
.t-muted { color: var(--text-3); }
.t-faint { color: var(--text-4); }

/* Chiffres tabulaires : montants, colonnes, compteurs, dates. */
.tnum {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1, "case" 1, "zero" 0;
  letter-spacing: -0.012em;
}

/* Montants — la classe .money hérite toujours de .tnum. */
.money {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: -0.018em;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
}
.money--pos { color: var(--pos); }
.money--neg { color: var(--neg); }
.money--info { color: var(--info); }
.money--muted { color: var(--text-3); font-weight: 550; }
/* Cadran : le montant principal d'un écran (solde du mois, total cagnotte). */
.money--xl {
  font-size: clamp(1.875rem, 1.3rem + 2.6vw, 2.625rem);
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 1;
}
.money--lg { font-size: 1.375rem; letter-spacing: -0.03em; line-height: 1.1; }
.money--sm { font-size: 0.8125rem; font-weight: 560; }
/* Le symbole/les centimes s'effacent d'un cran : lecture plus rapide. */
.money-frac, .money-cur { color: var(--text-3); font-weight: 500; }
.money--pos .money-frac, .money--neg .money-frac { opacity: 0.72; color: inherit; }

.mono { font-family: var(--font-mono); font-size: 0.8125em; }

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* =============================================================================
   04 · COQUILLE APPLICATIVE
   ========================================================================== */

.app { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }

.app-main { min-width: 0; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--space-9)); }

/* En-tête collant : mois courant, titre d'écran, actions. */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: var(--header-h);
  padding: var(--space-4) var(--gutter);
  padding-top: calc(var(--space-4) + var(--safe-t));
  background: var(--surface-nav);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.app-header__title {
  flex: 1;
  min-width: 0;
  font-size: 1.0625rem;
  font-weight: 640;
  letter-spacing: -0.024em;
  color: var(--text-1);
}
.app-header__actions { display: flex; align-items: center; gap: var(--space-3); }

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: var(--space-6);
}
.container--flush { padding-inline: 0; }
.container--narrow { max-width: 720px; }
.container--form { max-width: 560px; }

/* --- Grille 12 colonnes ------------------------------------------------- */
/* Mobile : tout occupe la largeur, sauf .col-h (demi) et .col-t (tiers).   */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
.grid--tight { gap: var(--space-4); }
.grid > * { grid-column: 1 / -1; min-width: 0; }
.col-h { grid-column: span 6; }   /* deux par ligne dès le mobile (KPI)     */
.col-t { grid-column: span 4; }   /* trois par ligne dès le mobile          */

@media (min-width: 640px) {
  .col-sm-3 { grid-column: span 3; }
  .col-sm-4 { grid-column: span 4; }
  .col-sm-6 { grid-column: span 6; }
  .col-sm-8 { grid-column: span 8; }
  .col-sm-12 { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .col-lg-3 { grid-column: span 3; }
  .col-lg-4 { grid-column: span 4; }
  .col-lg-5 { grid-column: span 5; }
  .col-lg-6 { grid-column: span 6; }
  .col-lg-7 { grid-column: span 7; }
  .col-lg-8 { grid-column: span 8; }
  .col-lg-9 { grid-column: span 9; }
  .col-lg-12 { grid-column: 1 / -1; }
}

/* --- Corps + rail : la mise en page du tableau de bord ------------------ */
/* Mobile : empilé. Desktop : contenu large + colonne latérale collante.     */
.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  align-items: start;
}
@media (min-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1fr) 372px; }
  .split--wide-rail { grid-template-columns: minmax(0, 1fr) 440px; }
  .split__rail {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
    display: flex;
    flex-direction: column;
    gap: var(--gap);
  }
}

/* Rangée d'éléments qui déborde horizontalement (filtres, mois, comptes). */
.scroller {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding-inline: var(--gutter);
  margin-inline: calc(var(--gutter) * -1);
  -webkit-overflow-scrolling: touch;
}
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: none; }

/* Pile verticale au rythme constant. */
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack--sm { gap: var(--space-4); }
.stack--lg { gap: var(--space-9); }
.row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}
.row--between { justify-content: space-between; }
.row--top { align-items: flex-start; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1 1 auto; min-width: 0; }


/* =============================================================================
   05 · NAVIGATION
   ========================================================================== */

/* --- Barre d'onglets mobile (6 onglets + FAB central) ------------------- */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-nav);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface-nav);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -8px 24px -14px rgb(var(--rgb-ink) / 0.9);
}

.tabbar-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: var(--space-3) 2px var(--space-2);
  color: var(--text-4);
  font-size: 0.625rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  transition: color var(--t-2) var(--ease-soft);
  -webkit-tap-highlight-color: transparent;
}
.tabbar-item svg,
.tabbar-item .icon { width: 21px; height: 21px; stroke-width: 1.75; }
.tabbar-item__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Filet d'activation : 2px sarcelle collé au bord haut de la barre. */
.tabbar-item::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 22px;
  height: 2px;
  border-radius: 0 0 var(--r-full) var(--r-full);
  background: var(--accent);
  box-shadow: 0 2px 10px var(--accent-glow);
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  opacity: 0;
  transition: transform var(--t-3) var(--ease-out), opacity var(--t-2) linear;
}
.tabbar-item.is-active { color: var(--accent); }
.tabbar-item.is-active::before { transform: translateX(-50%) scaleX(1); opacity: 1; }
.tabbar-item:active { transform: scale(0.94); transition: transform var(--t-press) var(--ease-out); }
.tabbar-item:focus-visible { box-shadow: var(--ring); border-radius: var(--r-md); }

/* Les onglets 3 et 4 se décalent pour dégager le FAB central. */
.tabbar-item:nth-child(3) { padding-right: 16px; }
.tabbar-item:nth-child(4) { padding-left: 16px; }

/* --- Bouton flottant central ------------------------------------------- */
.fab {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) - 26px);
  z-index: var(--z-fab);
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-full);
  background: linear-gradient(160deg, var(--teal-300), var(--teal-500) 78%);
  color: var(--text-on-accent);
  /* L'anneau couleur du fond découpe visuellement la barre sous le FAB. */
  box-shadow:
    0 0 0 5px var(--bg),
    var(--shadow-accent),
    var(--inset-top);
  transform: translateX(-50%);
  transition:
    transform var(--t-2) var(--ease-out),
    box-shadow var(--t-3) var(--ease-soft),
    filter var(--t-2) var(--ease-soft);
}
.fab svg, .fab .icon { width: 24px; height: 24px; stroke-width: 2.2; }
.fab:active { transform: translateX(-50%) scale(0.92); transition-duration: var(--t-press); }
.fab:focus-visible { box-shadow: 0 0 0 5px var(--bg), 0 0 0 7px var(--accent), var(--shadow-accent); }
.fab.is-open { transform: translateX(-50%) rotate(45deg); }

/* --- Sidebar desktop ---------------------------------------------------- */
.sidebar { display: none; }

@media (min-width: 1024px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .app-main { padding-bottom: var(--space-11); }
  .tabbar { display: none; }
  .fab { display: none; }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    height: 100dvh;
    padding: var(--space-7) var(--space-5) var(--space-6);
    background: rgb(7 13 28 / 0.72);
    border-right: 1px solid var(--border-soft);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow-y: auto;
  }

  .sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding-inline: var(--space-3);
    font-size: 0.9375rem;
    font-weight: 660;
    letter-spacing: -0.025em;
    color: var(--text-1);
  }
  .sidebar__mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(155deg, var(--teal-300), var(--teal-600));
    color: var(--text-on-accent);
    font-size: 0.8125rem;
    font-weight: 720;
    box-shadow: var(--shadow-2), var(--inset-top);
  }

  .sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar__group {
    padding: var(--space-6) var(--space-3) var(--space-2);
    font-size: 0.6875rem;
    font-weight: 580;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-4);
  }
  .sidebar__foot { margin-top: auto; padding-top: var(--space-5); border-top: 1px solid var(--border-soft); }

  /* Le FAB devient l'action primaire pleine largeur de la sidebar. */
  .sidebar .fab {
    position: static;
    display: flex;
    gap: var(--space-4);
    width: 100%;
    height: 40px;
    padding-inline: var(--space-5);
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 620;
    letter-spacing: -0.01em;
    transform: none;
    box-shadow: var(--shadow-accent), var(--inset-top);
  }
  .sidebar .fab svg, .sidebar .fab .icon { width: 18px; height: 18px; }
  .sidebar .fab:active { transform: scale(0.975); }
}

/* Élément de navigation (sidebar, réutilisable dans un menu réglages). */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: 0.875rem;
  font-weight: 540;
  letter-spacing: -0.01em;
  transition:
    background-color var(--t-2) var(--ease-soft),
    color var(--t-2) var(--ease-soft);
}
.nav-item svg, .nav-item .icon { width: 18px; height: 18px; stroke-width: 1.8; opacity: 0.9; }
.nav-item__badge { margin-left: auto; }
.nav-item.is-active { background: var(--accent-wash); color: var(--accent-hi); font-weight: 600; }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--accent);
  transform: translateY(-50%);
  box-shadow: 0 0 10px var(--accent-glow);
}
.nav-item:active { transform: scale(0.985); transition: transform var(--t-press) var(--ease-out); }
.nav-item:focus-visible { box-shadow: var(--ring); }

@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: var(--surface-2); color: var(--text-1); }
  .nav-item.is-active:hover { background: rgb(var(--rgb-teal) / 0.16); color: var(--accent-hi); }
  .tabbar-item:hover { color: var(--text-2); }
  .fab:hover { filter: brightness(1.05); box-shadow: 0 0 0 5px var(--bg), 0 8px 22px -6px rgb(var(--rgb-teal) / 0.6); }
}


/* =============================================================================
   06 · SECTIONS & CARTES
   ========================================================================== */

.section { display: flex; flex-direction: column; gap: var(--space-5); }
.section + .section { margin-top: var(--space-9); }

/* Titre de section : filet qui consomme la largeur restante (zéro vide mort). */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-4);
}
.section-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent 92%);
}
.section-title__action {
  flex: none;
  font-size: 0.75rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--accent);
  transition: color var(--t-2) var(--ease-soft);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
}
.section-head__title {
  font-size: 1.0625rem;
  font-weight: 640;
  letter-spacing: -0.024em;
  color: var(--text-1);
}
.section-head__meta { font-size: 0.75rem; color: var(--text-4); }

/* --- Carte -------------------------------------------------------------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  /* Dégradé très court : la carte capte la lumière par le haut. */
  background-image: linear-gradient(180deg, rgb(30 41 59 / 0.5), rgb(15 23 42 / 0.62) 58%);
  background-color: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2), var(--inset-top);
  overflow: clip;
}
.card--lg { border-radius: var(--r-xl); }
.card--flat { box-shadow: none; background-image: none; background-color: rgb(15 23 42 / 0.45); }
.card--solid { background-image: none; background-color: var(--surface-solid); }
.card--accent { border-color: var(--accent-line); box-shadow: var(--shadow-3), var(--inset-top); }
.card--danger { border-color: var(--neg-line); }
.card--pad { padding: var(--space-6); }
.card--pad-lg { padding: var(--space-7); }
.card--interactive { transition: transform var(--t-2) var(--ease-out), border-color var(--t-2) var(--ease-soft); }
.card--interactive:active { transform: scale(0.99); transition-duration: var(--t-press); }
.card--interactive:focus-visible { box-shadow: var(--ring), var(--shadow-2); }

.card__head {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-soft);
}
.card__title {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 620;
  letter-spacing: -0.012em;
  color: var(--text-1);
}
.card__sub { font-size: 0.75rem; color: var(--text-4); }
.card__body { padding: var(--space-6); }
.card__body--tight { padding: var(--space-5); }
.card__foot {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: rgb(2 6 23 / 0.35);
  border-top: 1px solid var(--border-soft);
  font-size: 0.75rem;
  color: var(--text-3);
}
/* Bandeau coloré fin en tête de carte : type de compte, statut d'enveloppe. */
.card__accentbar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.85;
}

@media (hover: hover) and (pointer: fine) {
  .card--interactive:hover { border-color: var(--border-strong); }
  .section-title__action:hover { color: var(--accent-hi); }
}


/* =============================================================================
   07 · KPI & STATISTIQUES
   ========================================================================== */

/* Tuile KPI : libellé court, montant, variation. Deux par ligne en mobile. */
.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-5) var(--space-5);
  border-radius: var(--r-lg);
  background-image: linear-gradient(180deg, rgb(30 41 59 / 0.5), rgb(15 23 42 / 0.6));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1), var(--inset-top);
  min-width: 0;
}
.kpi__label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.6875rem;
  font-weight: 580;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--text-4);
}
.kpi__label svg, .kpi__label .icon { width: 13px; height: 13px; }
.kpi__value {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
  font-size: 1.375rem;
  font-weight: 660;
  letter-spacing: -0.032em;
  line-height: 1.12;
  color: var(--text-1);
}
.kpi__value--pos { color: var(--pos); }
.kpi__value--neg { color: var(--neg); }
.kpi__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.75rem;
  color: var(--text-4);
}
.kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px var(--space-3);
  border-radius: var(--r-full);
  font-size: 0.6875rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.kpi__delta--up { color: var(--pos); background: var(--pos-wash); }
.kpi__delta--down { color: var(--neg); background: var(--neg-wash); }
.kpi__delta--flat { color: var(--text-3); background: rgb(var(--rgb-slate) / 0.12); }
.kpi__spark { margin-top: var(--space-2); height: 26px; opacity: 0.85; }
.kpi--accent { border-color: var(--accent-line); }
.kpi--accent .kpi__label { color: var(--accent); }

@media (min-width: 640px) {
  .kpi { padding: var(--space-6); }
  .kpi__value { font-size: 1.5rem; }
}

/* Paire libellé/valeur compacte, à l'intérieur des cartes et des lignes. */
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat__label {
  font-size: 0.6875rem;
  font-weight: 560;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-4);
}
.stat__value {
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--text-1);
}
.stat--inline { flex-direction: row; align-items: baseline; justify-content: space-between; gap: var(--space-5); }
.stat--inline .stat__label { text-transform: none; letter-spacing: 0; font-size: 0.8125rem; color: var(--text-3); }
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: var(--space-5) var(--space-6);
}
/* Séparateurs verticaux entre stats alignées : densité sans boîtes imbriquées. */
.stat-row--divided > .stat + .stat {
  padding-left: var(--space-6);
  border-left: 1px solid var(--border-soft);
}


/* =============================================================================
   08 · BOUTONS
   ========================================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  height: 40px;
  padding-inline: var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t-1) var(--ease-out),
    background-color var(--t-2) var(--ease-soft),
    border-color var(--t-2) var(--ease-soft),
    color var(--t-2) var(--ease-soft),
    box-shadow var(--t-2) var(--ease-soft),
    opacity var(--t-2) linear;
}
.btn svg, .btn .icon { width: 17px; height: 17px; stroke-width: 1.9; flex: none; }
.btn:active { transform: scale(0.97); transition-duration: var(--t-press); }
.btn:focus-visible { box-shadow: var(--ring); }
.btn:disabled, .btn.is-disabled {
  opacity: 0.42;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

/* Primaire — une seule par écran. */
.btn--primary {
  background: linear-gradient(170deg, var(--teal-300), var(--teal-500));
  color: var(--text-on-accent);
  box-shadow: var(--shadow-2), var(--inset-top);
}
/* Secondaire — surface tenue, contour visible. */
.btn--secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-1);
}
/* Fantôme — actions tertiaires, barres d'outils. */
.btn--ghost { background: transparent; color: var(--text-3); }
.btn--ghost:focus-visible { box-shadow: var(--ring); }
/* Danger — suppression, dépassement. */
.btn--danger {
  background: rgb(var(--rgb-rose) / 0.14);
  border-color: var(--neg-line);
  color: var(--rose-300);
}
.btn--danger:focus-visible { box-shadow: var(--ring-danger); }
/* Danger plein — confirmation finale seulement. */
.btn--danger-solid {
  background: var(--rose-500);
  color: #fff;
  box-shadow: var(--shadow-2), var(--inset-top);
}
.btn--danger-solid:focus-visible { box-shadow: var(--ring-danger); }

/* Icône seule — toujours accompagnée d'un aria-label côté markup. */
.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-md);
  color: var(--text-3);
}
.btn--icon svg, .btn--icon .icon { width: 19px; height: 19px; }
.btn--icon.btn--round { border-radius: var(--r-full); }

.btn--sm { height: 32px; padding-inline: var(--space-5); font-size: 0.8125rem; border-radius: var(--r-sm); gap: var(--space-3); }
.btn--sm.btn--icon { width: 32px; padding: 0; }
.btn--sm svg, .btn--sm .icon { width: 15px; height: 15px; }
.btn--lg { height: 48px; padding-inline: var(--space-7); font-size: 0.9375rem; border-radius: var(--r-lg); }
.btn--lg.btn--icon { width: 48px; padding: 0; }
.btn--block { display: flex; width: 100%; }
.btn--pill { border-radius: var(--r-full); }

/* État chargement : le libellé reste en place, le spinner le remplace. */
.btn.is-loading { pointer-events: none; color: transparent; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  border: 2px solid rgb(var(--rgb-white) / 0.28);
  border-top-color: currentColor;
  color: var(--text-1);
  animation: spin 620ms linear infinite;
}
.btn--primary.is-loading::after { border-color: rgb(4 32 29 / 0.3); border-top-color: var(--text-on-accent); }

/* Groupe de boutons accolés (barre d'actions d'une ligne). */
.btn-group { display: inline-flex; gap: var(--space-3); }
.btn-group--attached { gap: 0; }
.btn-group--attached .btn { border-radius: 0; }
.btn-group--attached .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group--attached .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group--attached .btn + .btn { margin-left: -1px; }

@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { filter: brightness(1.06); box-shadow: var(--shadow-accent); }
  .btn--secondary:hover { background: var(--surface-3); border-color: var(--slate-600); }
  .btn--ghost:hover { background: var(--surface-2); color: var(--text-1); }
  .btn--icon:hover { background: var(--surface-2); color: var(--text-1); }
  .btn--danger:hover { background: rgb(var(--rgb-rose) / 0.2); color: var(--rose-200); }
  .btn--danger-solid:hover { background: var(--rose-600); }
}


/* =============================================================================
   09 · FORMULAIRES
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr; gap: var(--space-5); }
@media (min-width: 640px) {
  .field-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: 0;
  border: 0;
}

.label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.8125rem;
  font-weight: 560;
  letter-spacing: -0.005em;
  color: var(--text-2);
}
.label__req { color: var(--rose-400); font-weight: 600; }
.label__hint { margin-left: auto; font-size: 0.75rem; font-weight: 500; color: var(--text-4); }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-sunk);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: 0.9375rem;
  letter-spacing: -0.008em;
  appearance: none;
  transition:
    border-color var(--t-2) var(--ease-soft),
    background-color var(--t-2) var(--ease-soft),
    box-shadow var(--t-2) var(--ease-soft);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  background: rgb(2 6 23 / 0.85);
  box-shadow: 0 0 0 3px rgb(var(--rgb-teal) / 0.18);
}
.input:disabled, .select:disabled, .textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgb(15 23 42 / 0.4);
}
.input[readonly] { color: var(--text-3); border-style: dashed; }
.input:-webkit-autofill {
  -webkit-text-fill-color: var(--text-1);
  -webkit-box-shadow: 0 0 0 40px #071023 inset;
  caret-color: var(--text-1);
}
/* Saisie de montant : gros chiffres tabulaires, alignés à droite. */
.input--money {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
  font-size: 1.25rem;
  font-weight: 620;
  letter-spacing: -0.03em;
  text-align: right;
  padding-right: var(--space-6);
}
.input--search { padding-left: 38px; }

.select {
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 51%, calc(100% - 13px) 51%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.select option { background: var(--slate-900); color: var(--text-1); }

/* Champ avec affixe (icône de recherche, symbole €, unité). */
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap__icon {
  position: absolute;
  left: var(--space-5);
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  color: var(--text-4);
  pointer-events: none;
}
.input-wrap__suffix {
  position: absolute;
  right: var(--space-5);
  font-size: 0.875rem;
  font-weight: 560;
  color: var(--text-3);
  pointer-events: none;
}
.input-wrap:focus-within .input-wrap__icon { color: var(--accent); }

.hint { font-size: 0.75rem; line-height: 1.4; color: var(--text-4); }
.error-text {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--rose-300);
}
.error-text svg, .error-text .icon { width: 13px; height: 13px; margin-top: 2px; flex: none; }

.field.is-invalid .input,
.field.is-invalid .select,
.field.is-invalid .textarea { border-color: var(--rose-500); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 3px rgb(var(--rgb-rose) / 0.2); }
.field.is-valid .input { border-color: rgb(var(--rgb-teal) / 0.55); }

/* Barre d'actions de formulaire, collée en bas d'une feuille. */
.form-actions {
  display: flex;
  gap: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-soft);
}
.form-actions > .btn { flex: 1; }
.form-actions--end { justify-content: flex-end; border-top: 0; }
.form-actions--end > .btn { flex: none; }


/* =============================================================================
   10 · CHIPS, PILLS, BADGES, SEGMENTED, TABS
   ========================================================================== */

/* Chip : filtre sélectionnable (catégorie, compte, période). */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  height: 32px;
  padding-inline: var(--space-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition:
    background-color var(--t-2) var(--ease-soft),
    color var(--t-2) var(--ease-soft),
    border-color var(--t-2) var(--ease-soft),
    transform var(--t-1) var(--ease-out);
}
.chip svg, .chip .icon { width: 14px; height: 14px; }
.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: currentColor;
  flex: none;
}
.chip:active { transform: scale(0.96); transition-duration: var(--t-press); }
.chip:focus-visible { box-shadow: var(--ring); }
.chip.is-active,
.chip[aria-pressed="true"] {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent-hi);
  font-weight: 600;
}
.chip--removable { padding-right: var(--space-3); }
.chip__remove {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  color: var(--text-4);
  transition: background-color var(--t-2) var(--ease-soft), color var(--t-2) var(--ease-soft);
}

/* Pill : étiquette statique colorée (catégorie d'une transaction). */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-4);
  border-radius: var(--r-full);
  background: rgb(var(--rgb-slate) / 0.13);
  color: var(--text-3);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.012em;
  line-height: 1.55;
  white-space: nowrap;
}
.pill--pos  { background: var(--pos-wash);  color: var(--teal-300); }
.pill--neg  { background: var(--neg-wash);  color: var(--rose-300); }
.pill--info { background: var(--info-wash); color: var(--sky-300); }
.pill--warn { background: var(--warn-wash); color: var(--amber-300); }
.pill--outline { background: transparent; border: 1px solid var(--border-strong); }

/* Badge : compteur ou pastille d'état. */
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding-inline: 5px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 0.625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.badge--neg { background: var(--rose-500); color: #fff; }
.badge--warn { background: var(--amber-400); color: #2a1c00; }
.badge--muted { background: var(--slate-700); color: var(--text-2); }
.badge--dot { min-width: 8px; width: 8px; height: 8px; padding: 0; }

/* Segmented : bascule 2 à 4 options (mois/année, dépenses/revenus). */
.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.segmented--block { display: grid; width: 100%; }
.segmented__item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  height: 32px;
  padding-inline: var(--space-5);
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 560;
  white-space: nowrap;
  transition:
    background-color var(--t-3) var(--ease-out),
    color var(--t-2) var(--ease-soft),
    box-shadow var(--t-3) var(--ease-out);
}
.segmented__item:active { transform: scale(0.97); transition-duration: var(--t-press); }
.segmented__item:focus-visible { box-shadow: var(--ring); }
.segmented__item.is-active,
.segmented__item[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text-1);
  font-weight: 620;
  box-shadow: var(--shadow-1), var(--inset-top);
}

/* Tabs : navigation intra-écran, indicateur soudé sous l'onglet actif. */
.tabs {
  position: relative;
  display: flex;
  gap: var(--space-6);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  position: relative;
  flex: none;
  padding: var(--space-4) 2px var(--space-5);
  color: var(--text-3);
  font-size: 0.875rem;
  font-weight: 560;
  letter-spacing: -0.012em;
  white-space: nowrap;
  transition: color var(--t-2) var(--ease-soft);
}
.tabs__item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: var(--r-full);
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  opacity: 0;
  transition: transform var(--t-3) var(--ease-out), opacity var(--t-2) linear;
}
.tabs__item.is-active,
.tabs__item[aria-selected="true"] { color: var(--text-1); font-weight: 620; }
.tabs__item.is-active::after,
.tabs__item[aria-selected="true"]::after { transform: scaleX(1); opacity: 1; }
.tabs__item:focus-visible { box-shadow: var(--ring); border-radius: var(--r-sm); }
.tabs__count { margin-left: var(--space-3); font-size: 0.75rem; color: var(--text-4); font-variant-numeric: tabular-nums; }

@media (hover: hover) and (pointer: fine) {
  .chip:hover { background: var(--surface-3); color: var(--text-1); }
  .chip.is-active:hover { background: rgb(var(--rgb-teal) / 0.17); }
  .chip__remove:hover { background: rgb(var(--rgb-rose) / 0.18); color: var(--rose-300); }
  .segmented__item:hover { color: var(--text-1); }
  .tabs__item:hover { color: var(--text-2); }
}


/* =============================================================================
   11 · INTERRUPTEURS & CASES À COCHER
   ========================================================================== */

.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: var(--r-full);
  background: var(--slate-700);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  appearance: none;
  transition:
    background-color var(--t-3) var(--ease-soft),
    border-color var(--t-3) var(--ease-soft);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  background: var(--slate-300);
  box-shadow: var(--shadow-1);
  transition:
    transform var(--t-3) var(--ease-out),
    background-color var(--t-3) var(--ease-soft),
    width var(--t-1) var(--ease-out);
}
.switch:checked,
.switch[aria-checked="true"] { background: var(--teal-500); border-color: var(--teal-400); }
.switch:checked::after,
.switch[aria-checked="true"]::after { transform: translateX(18px); background: #eafffb; }
/* Le pouce s'étire légèrement pendant l'appui : la bascule paraît physique. */
.switch:active::after { width: 24px; }
.switch:checked:active::after { transform: translateX(14px); }
.switch:focus-visible { box-shadow: var(--ring); }
.switch:disabled { opacity: 0.45; cursor: not-allowed; }

.checkbox {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--slate-600);
  border-radius: var(--r-xs);
  background: var(--bg-sunk);
  cursor: pointer;
  appearance: none;
  transition:
    background-color var(--t-2) var(--ease-soft),
    border-color var(--t-2) var(--ease-soft),
    transform var(--t-1) var(--ease-out);
}
.checkbox::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 6px;
  width: 5px;
  height: 10px;
  border: solid var(--text-on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg) scale(0.5);
  opacity: 0;
  transition: transform var(--t-2) var(--ease-pop), opacity var(--t-1) linear;
}
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after { transform: rotate(42deg) scale(1); opacity: 1; }
.checkbox:indeterminate { background: var(--accent); border-color: var(--accent); }
.checkbox:indeterminate::after {
  top: 8px; left: 3px; width: 12px; height: 2px;
  border-width: 0 0 2px 0;
  background: var(--text-on-accent);
  transform: none;
  opacity: 1;
}
.checkbox:active { transform: scale(0.9); }
.checkbox:focus-visible { box-shadow: var(--ring); }
.checkbox:disabled { opacity: 0.45; cursor: not-allowed; }

.radio { border-radius: var(--r-full); }
.radio::after {
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--text-on-accent);
  transform: translate(-50%, -50%) scale(0.4);
}
.radio:checked::after { transform: translate(-50%, -50%) scale(1); }

/* Ligne cliquable englobant un contrôle (réglages, sélection de catégorie). */
.control-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: 48px;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background-color var(--t-2) var(--ease-soft);
}
.control-row__text { flex: 1; min-width: 0; }
.control-row__title { font-size: 0.875rem; font-weight: 550; color: var(--text-1); }
.control-row__desc { font-size: 0.75rem; color: var(--text-4); }
.control-row:active { background: var(--surface-2); }

@media (hover: hover) and (pointer: fine) {
  .control-row:hover { background: var(--surface-2); }
  .switch:hover { border-color: var(--slate-500); }
  .checkbox:hover { border-color: var(--slate-500); }
}


/* =============================================================================
   12 · PROGRESSION & JAUGES (cagnottes / enveloppes)
   ========================================================================== */

/* Le remplissage est piloté par --value (0 à 100) posé en style inline. */
.progress {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--bg-sunk);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
.progress--thin { height: 5px; }
.progress--thick { height: 12px; }
.progress__bar {
  height: 100%;
  width: calc(var(--value, 0) * 1%);
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-300));
  box-shadow: 0 0 12px -2px var(--accent-glow);
  transition: width var(--t-6) var(--ease-out), background-color var(--t-3) var(--ease-soft);
}
.progress--warn .progress__bar { background: linear-gradient(90deg, var(--amber-500), var(--amber-300)); box-shadow: 0 0 12px -2px rgb(var(--rgb-amber) / 0.25); }
.progress--neg .progress__bar  { background: linear-gradient(90deg, var(--rose-500), var(--rose-300)); box-shadow: 0 0 12px -2px rgb(var(--rgb-rose) / 0.25); }
.progress--info .progress__bar { background: linear-gradient(90deg, var(--sky-500), var(--sky-300)); box-shadow: 0 0 12px -2px rgb(var(--rgb-sky) / 0.25); }
/* Repère de référence (part du mois écoulée, objectif intermédiaire). */
.progress__marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: calc(var(--at, 0) * 1%);
  width: 2px;
  background: rgb(var(--rgb-white) / 0.45);
  border-radius: var(--r-full);
}
/* Dépassement : hachures animées, lisibles sans dépendre de la couleur. */
.progress.is-over .progress__bar {
  background-image: repeating-linear-gradient(
    115deg,
    var(--rose-500) 0 7px,
    var(--rose-400) 7px 14px
  );
  animation: progress-stripes 900ms linear infinite;
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.progress-head__label {
  font-size: 0.8125rem;
  font-weight: 560;
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress-head__value {
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 620;
  color: var(--text-1);
  white-space: nowrap;
}
.progress-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-3);
  font-size: 0.75rem;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

/* Barre segmentée : répartition d'un budget en une seule ligne. */
.progress-stack {
  display: flex;
  width: 100%;
  height: 10px;
  gap: 2px;
  border-radius: var(--r-full);
  background: var(--bg-sunk);
  overflow: hidden;
}
.progress-stack__seg {
  height: 100%;
  width: calc(var(--value, 0) * 1%);
  background: var(--seg-color, var(--cat-1));
  transition: width var(--t-6) var(--ease-out);
}
.progress-stack__seg:first-child { border-radius: var(--r-full) 0 0 var(--r-full); }
.progress-stack__seg:last-child  { border-radius: 0 var(--r-full) var(--r-full) 0; }


/* =============================================================================
   13 · AVATARS
   ========================================================================== */

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: linear-gradient(150deg, var(--slate-700), var(--slate-800));
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 640;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { width: 22px; height: 22px; font-size: 0.5625rem; }
.avatar--sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar--lg { width: 44px; height: 44px; font-size: 0.9375rem; }
.avatar--xl { width: 64px; height: 64px; font-size: 1.25rem; }
/* Teintes de titulaire : différencie les deux membres du couple. */
.avatar--a { background: linear-gradient(150deg, var(--teal-500), var(--teal-800)); color: var(--teal-100); border-color: var(--accent-line); }
.avatar--b { background: linear-gradient(150deg, var(--violet-400), #3b2a72); color: #ede9fe; border-color: rgb(var(--rgb-violet) / 0.35); }
.avatar--shared { background: linear-gradient(150deg, var(--sky-500), #0c3b5e); color: var(--sky-200); border-color: var(--info-line); }

.avatar-group { display: flex; }
.avatar-group > .avatar + .avatar { margin-left: -10px; }
.avatar-group > .avatar { box-shadow: 0 0 0 2px var(--bg); }

/* Pastille d'icône de catégorie : la couleur vient de --tone en inline. */
.icon-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: rgb(var(--tone, var(--rgb-teal)) / 0.14);
  border: 1px solid rgb(var(--tone, var(--rgb-teal)) / 0.26);
  color: rgb(var(--tone, var(--rgb-teal)) / 1);
}
.icon-badge svg, .icon-badge .icon { width: 18px; height: 18px; stroke-width: 1.85; }
.icon-badge--sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-badge--sm svg { width: 15px; height: 15px; }
.icon-badge--round { border-radius: var(--r-full); }


/* =============================================================================
   14 · LISTES & TABLEAUX
   ========================================================================== */

/* Liste : filets internes seulement, jamais de bordure sur chaque ligne. */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--border-soft); }
.list--card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1), var(--inset-top);
  overflow: clip;
}
.list--gap { gap: var(--space-3); }
.list--gap > * + * { border-top: 0; }

.list-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: 56px;
  padding: var(--space-4) var(--space-5);
  min-width: 0;
  text-align: left;
  transition: background-color var(--t-2) var(--ease-soft), transform var(--t-1) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.list-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row__title {
  font-size: 0.875rem;
  font-weight: 560;
  letter-spacing: -0.012em;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.75rem;
  color: var(--text-4);
  min-width: 0;
}
.list-row__meta > * { min-width: 0; }
/* Séparateur discret entre métadonnées, sans caractère dans le markup. */
.list-row__meta > * + *::before { content: "·"; margin-right: var(--space-3); color: var(--slate-600); }
.list-row__end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex: none;
}
.list-row__chevron { flex: none; width: 16px; height: 16px; color: var(--slate-600); }
.list-row:active { background: var(--surface-2); transform: scale(0.995); transition-duration: var(--t-press); }
.list-row:focus-visible { box-shadow: var(--ring); border-radius: var(--r-md); }
.list-row.is-selected { background: var(--accent-wash); }
.list-row.is-pending { opacity: 0.6; }
/* Marque d'état sur le bord gauche : 2px, jamais plus. */
.list-row--flagged::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--space-4);
  bottom: var(--space-4);
  width: 2px;
  border-radius: var(--r-full);
  background: var(--warn);
}

/* En-tête de jour dans la liste des transactions, collant sous le header. */
.list-day {
  position: sticky;
  top: var(--header-h);
  z-index: var(--z-raised);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: rgb(2 6 23 / 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.6875rem;
  font-weight: 620;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.list-day__total {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  text-transform: none;
  font-size: 0.75rem;
  color: var(--text-4);
}

/* --- Tableau (desktop : comptes, récurrences, export) -------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.table { width: 100%; font-size: 0.8125rem; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--space-4) var(--space-5);
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-4);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--t-2) var(--ease-soft); }
.table td.num, .table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.table td.strong { color: var(--text-1); font-weight: 560; }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.table tfoot td {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-strong);
  background: rgb(2 6 23 / 0.4);
  color: var(--text-1);
  font-weight: 620;
}
.table th[aria-sort] { cursor: pointer; user-select: none; }
.table th[aria-sort="ascending"], .table th[aria-sort="descending"] { color: var(--accent); }

@media (hover: hover) and (pointer: fine) {
  .list-row:hover { background: var(--surface-2); }
  .table tbody tr:hover { background: var(--surface-2); }
}


/* =============================================================================
   15 · CALENDRIER
   ========================================================================== */

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.calendar__weekday {
  padding-bottom: var(--space-3);
  text-align: center;
  font-size: 0.625rem;
  font-weight: 620;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
}

.calendar-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  aspect-ratio: 1 / 1.05;
  padding: var(--space-3) 2px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: rgb(15 23 42 / 0.42);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 550;
  transition:
    background-color var(--t-2) var(--ease-soft),
    border-color var(--t-2) var(--ease-soft),
    transform var(--t-1) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.calendar-day__num { line-height: 1.1; }
/* Total du jour, visible dès que la cellule est assez haute. */
.calendar-day__sum {
  font-size: 0.5625rem;
  font-weight: 620;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text-4);
}
.calendar-day__sum--pos { color: var(--pos); }
.calendar-day__sum--neg { color: var(--neg); }
.calendar-day__dots { display: flex; gap: 2px; margin-top: auto; }
.calendar-day__dot {
  width: 4px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--dot-color, var(--slate-500));
}
.calendar-day.is-outside { color: var(--slate-600); background: transparent; }
.calendar-day.is-outside .calendar-day__sum { display: none; }
.calendar-day.is-today { border-color: var(--accent-line); color: var(--accent-hi); font-weight: 680; }
.calendar-day.is-today::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}
.calendar-day.is-selected {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--text-1);
}
.calendar-day.is-weekend { background: rgb(15 23 42 / 0.62); }
.calendar-day.has-over { border-color: var(--neg-line); }
.calendar-day:active { transform: scale(0.94); transition-duration: var(--t-press); }
.calendar-day:focus-visible { box-shadow: var(--ring); }

@media (min-width: 640px) {
  .calendar { gap: var(--space-2); }
  .calendar-day { aspect-ratio: 1 / 0.9; padding: var(--space-4) var(--space-3); font-size: 0.875rem; }
  .calendar-day__sum { font-size: 0.625rem; }
}
@media (min-width: 1024px) {
  .calendar-day { aspect-ratio: 1 / 0.72; align-items: flex-start; padding: var(--space-4); }
  .calendar-day__dots { align-self: flex-start; }
}

@media (hover: hover) and (pointer: fine) {
  .calendar-day:hover { background: var(--surface-3); }
  .calendar-day.is-outside:hover { background: var(--surface-2); }
}

/* --- Navigation de mois (partagée dashboard / calendrier / transactions) - */
.month-nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2);
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.month-nav__btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  color: var(--text-3);
  transition: background-color var(--t-2) var(--ease-soft), color var(--t-2) var(--ease-soft), transform var(--t-1) var(--ease-out);
}
.month-nav__btn svg, .month-nav__btn .icon { width: 17px; height: 17px; stroke-width: 2; }
.month-nav__btn:active { transform: scale(0.9); transition-duration: var(--t-press); }
.month-nav__btn:focus-visible { box-shadow: var(--ring); }
.month-nav__btn:disabled { opacity: 0.35; pointer-events: none; }
.month-nav__label {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 620;
  letter-spacing: -0.015em;
  color: var(--text-1);
  text-transform: capitalize;
  white-space: nowrap;
}
.month-nav__year { margin-left: var(--space-2); color: var(--text-4); font-weight: 500; }
.month-nav--bare { background: transparent; border-color: transparent; padding: 0; }

@media (hover: hover) and (pointer: fine) {
  .month-nav__btn:hover { background: var(--surface-3); color: var(--text-1); }
}


/* =============================================================================
   16 · GRAPHIQUES — habillage (donut, courbe, légende)
   ========================================================================== */

.chart { position: relative; width: 100%; min-height: 160px; }
.chart--donut { display: grid; place-items: center; aspect-ratio: 1 / 1; max-width: 260px; margin-inline: auto; }
.chart--line { aspect-ratio: 16 / 8; min-height: 180px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
/* Le tracé est dessiné par JS via stroke-dashoffset ; ici on fixe le style. */
.chart__path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart__grid { stroke: var(--border-soft); stroke-width: 1; }
.chart__axis { fill: var(--text-4); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart__area { opacity: 0.16; }
/* Centre du donut : total du mois, en chiffres tabulaires. */
.chart__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
}
.chart__center-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.375rem;
  font-weight: 660;
  letter-spacing: -0.032em;
  color: var(--text-1);
}
.chart__center-label {
  font-size: 0.625rem;
  font-weight: 580;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
}

.legend { display: flex; flex-direction: column; gap: var(--space-1); }
.legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  color: var(--text-2);
  transition: background-color var(--t-2) var(--ease-soft), opacity var(--t-2) linear;
}
.legend__swatch {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--seg-color, var(--cat-1));
}
.legend__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend__value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-1); }
.legend__pct { width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-4); font-size: 0.75rem; }
.legend__item.is-muted { opacity: 0.4; }
.legend__item:focus-visible { box-shadow: var(--ring); }

@media (hover: hover) and (pointer: fine) {
  .legend__item:hover { background: var(--surface-2); }
}


/* =============================================================================
   17 · FEUILLES MODALES & SUPERPOSITIONS
   ========================================================================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  background: rgb(2 6 23 / 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-4) var(--ease-soft);
}
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-sheet);
  display: flex;
  flex-direction: column;
  max-height: min(88dvh, 860px);
  padding-bottom: var(--safe-b);
  background: #0b1322;
  background-image: linear-gradient(180deg, rgb(30 41 59 / 0.5), transparent 220px);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--shadow-5), var(--inset-top);
  transform: translateY(100%);
  visibility: hidden;
  transition:
    transform var(--t-5) var(--ease-drawer),
    visibility 0s linear var(--t-5);
}
.sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  transition:
    transform var(--t-5) var(--ease-drawer),
    visibility 0s linear 0s;
}
/* Poignée : affordance du glisser-fermer. */
.sheet__grabber {
  flex: none;
  width: 36px;
  height: 4px;
  margin: var(--space-4) auto var(--space-2);
  border-radius: var(--r-full);
  background: var(--slate-700);
}
.sheet__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}
.sheet__title {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 640;
  letter-spacing: -0.022em;
  color: var(--text-1);
}
.sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.sheet__foot {
  flex: none;
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  padding-bottom: calc(var(--space-5) + var(--safe-b));
  background: rgb(2 6 23 / 0.5);
  border-top: 1px solid var(--border-soft);
}
.sheet__foot > .btn { flex: 1; }
.sheet--full { max-height: calc(100dvh - 40px); height: calc(100dvh - 40px); }
/* Feuille d'actions courte (confirmer / supprimer). */
.sheet--compact .sheet__body { gap: var(--space-4); }

/* Desktop : la feuille devient une boîte de dialogue centrée. */
@media (min-width: 1024px) {
  .sheet {
    inset: 0;
    margin: auto;
    width: min(560px, calc(100vw - 64px));
    height: max-content;
    max-height: min(82dvh, 840px);
    padding-bottom: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-4), var(--inset-top);
    /* Modale : origine au centre, pas de translation verticale complète. */
    transform: scale(0.96) translateY(8px);
    opacity: 0;
    transform-origin: center;
    transition:
      transform var(--t-3) var(--ease-out),
      opacity var(--t-2) var(--ease-soft),
      visibility 0s linear var(--t-3);
  }
  .sheet.is-open { transform: scale(1) translateY(0); opacity: 1; }
  .sheet--wide { width: min(760px, calc(100vw - 64px)); }
  .sheet__grabber { display: none; }
  .sheet__foot { padding-bottom: var(--space-5); justify-content: flex-end; }
  .sheet__foot > .btn { flex: none; min-width: 108px; }
}

/* Menu contextuel / popover ancré sur son déclencheur. */
.popover {
  position: absolute;
  z-index: var(--z-popover);
  min-width: 190px;
  padding: var(--space-2);
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-4);
  transform-origin: var(--transform-origin, top center);
  transform: scale(0.96);
  opacity: 0;
  visibility: hidden;
  transition:
    transform var(--t-2) var(--ease-out),
    opacity var(--t-1) linear,
    visibility 0s linear var(--t-2);
}
.popover.is-open { transform: scale(1); opacity: 1; visibility: visible; transition-delay: 0s; }
.popover__item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  font-weight: 540;
  color: var(--text-2);
  text-align: left;
  transition: background-color var(--t-1) var(--ease-soft), color var(--t-1) var(--ease-soft);
}
.popover__item svg, .popover__item .icon { width: 16px; height: 16px; color: var(--text-4); }
.popover__item--danger { color: var(--rose-300); }
.popover__sep { height: 1px; margin: var(--space-2) var(--space-3); background: var(--border); }

/* Corps figé quand une feuille est ouverte (classe posée par le JS). */
.is-locked { overflow: hidden; touch-action: none; }

@media (hover: hover) and (pointer: fine) {
  .popover__item:hover { background: var(--surface-2); color: var(--text-1); }
  .popover__item--danger:hover { background: rgb(var(--rgb-rose) / 0.14); color: var(--rose-200); }
}


/* =============================================================================
   18 · TOASTS
   ========================================================================== */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--space-5));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  width: min(440px, calc(100vw - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5);
  background: #101a2c;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-4), var(--inset-top);
  color: var(--text-1);
  font-size: 0.875rem;
  pointer-events: auto;
  /* Transitions (et non keyframes) : les toasts s'empilent vite et doivent
     pouvoir être interrompus / retargetés en cours de route. */
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition:
    transform var(--t-4) var(--ease-out),
    opacity var(--t-3) var(--ease-soft);
}
.toast.is-open { transform: translateY(0) scale(1); opacity: 1; }
.toast.is-leaving { transform: translateY(8px) scale(0.98); opacity: 0; transition-duration: var(--t-2); }
.toast__icon { flex: none; display: grid; place-items: center; width: 18px; height: 18px; color: var(--accent); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 600; letter-spacing: -0.012em; }
.toast__desc { font-size: 0.75rem; color: var(--text-3); }
.toast__action {
  flex: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  transition: background-color var(--t-2) var(--ease-soft);
}
.toast--success { border-color: var(--accent-line); }
.toast--error { border-color: var(--neg-line); }
.toast--error .toast__icon { color: var(--neg); }
.toast--info .toast__icon { color: var(--info); }
.toast--warn .toast__icon { color: var(--warn); }

@media (min-width: 1024px) {
  .toast-stack {
    left: auto;
    right: var(--space-8);
    bottom: var(--space-8);
    transform: none;
    width: 380px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .toast__action:hover { background: var(--accent-wash); }
}


/* =============================================================================
   19 · ÉTATS : VIDE, CHARGEMENT, SQUELETTE, SPINNER
   ========================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-10) var(--space-6);
  text-align: center;
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-4);
}
.empty__icon svg, .empty__icon .icon { width: 22px; height: 22px; stroke-width: 1.6; }
.empty__title { font-size: 0.9375rem; font-weight: 620; letter-spacing: -0.018em; color: var(--text-1); }
.empty__text { max-width: 40ch; font-size: 0.8125rem; line-height: 1.5; color: var(--text-3); }
.empty--inline { padding: var(--space-8) var(--space-5); }
.empty--row { flex-direction: row; text-align: left; align-items: center; }

.skeleton {
  position: relative;
  border-radius: var(--r-sm);
  background: rgb(30 41 59 / 0.6);
  overflow: hidden;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgb(var(--rgb-white) / 0.055) 45%,
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 1250ms var(--ease-soft) infinite;
}
.skeleton--text { height: 11px; border-radius: var(--r-full); }
.skeleton--title { height: 15px; width: 45%; border-radius: var(--r-full); }
.skeleton--line { height: 11px; width: 72%; border-radius: var(--r-full); }
.skeleton--amount { height: 15px; width: 74px; border-radius: var(--r-full); }
.skeleton--circle { border-radius: var(--r-full); width: 34px; height: 34px; }
.skeleton--card { height: 92px; border-radius: var(--r-lg); }
.skeleton--kpi { height: 88px; border-radius: var(--r-lg); }
.skeleton--chart { height: 200px; border-radius: var(--r-lg); }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  border: 2px solid rgb(var(--rgb-white) / 0.14);
  border-top-color: var(--accent);
  animation: spin 620ms linear infinite;
}
.spinner--sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner--lg { width: 26px; height: 26px; border-width: 2.5px; }
.spinner--muted { border-top-color: var(--text-3); }

.loading-center {
  display: grid;
  place-items: center;
  gap: var(--space-5);
  padding: var(--space-11) var(--space-6);
  color: var(--text-4);
  font-size: 0.8125rem;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes progress-stripes { to { background-position: 28px 0; } }
/* Entrée par défaut, utilisée en repli quand GSAP n'est pas disponible. */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-rise { animation: rise-in var(--t-5) var(--ease-out) both; animation-delay: var(--delay, 0ms); }


/* =============================================================================
   20 · PAGE DE CONNEXION
   ========================================================================== */

.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--space-8) var(--gutter);
  padding-bottom: calc(var(--space-8) + var(--safe-b));
}
.auth__inner { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--space-8); }
.auth__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  text-align: center;
}
.auth__mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-lg);
  background: linear-gradient(155deg, var(--teal-300), var(--teal-600));
  color: var(--text-on-accent);
  font-size: 1.25rem;
  font-weight: 720;
  box-shadow: var(--shadow-accent), var(--inset-top);
}
.auth__title { font-size: 1.375rem; font-weight: 660; letter-spacing: -0.03em; color: var(--text-1); }
.auth__sub { font-size: 0.8125rem; color: var(--text-3); }
.auth__card {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-7);
  border-radius: var(--r-xl);
  background-image: linear-gradient(180deg, rgb(30 41 59 / 0.55), rgb(15 23 42 / 0.65));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-3), var(--inset-top);
}
.auth__foot { text-align: center; font-size: 0.75rem; color: var(--text-4); }
.auth__link { color: var(--accent); font-weight: 550; }

@media (min-width: 1024px) {
  .auth__inner { max-width: 400px; }
  .auth__card { padding: var(--space-9); }
}


/* =============================================================================
   21 · UTILITAIRES
   ========================================================================== */

.u-hide { display: none !important; }
@media (max-width: 639.98px)  { .u-hide-mobile { display: none !important; } }
@media (min-width: 1024px)    { .u-hide-desktop { display: none !important; } }
@media (max-width: 1023.98px) { .u-only-desktop { display: none !important; } }

.u-flex { display: flex; }
.u-grid { display: grid; }
.u-block { display: block; }
.u-full { width: 100%; }
.u-center { display: grid; place-items: center; }
.u-nowrap { white-space: nowrap; }
.u-right { text-align: right; }
.u-center-text { text-align: center; }
.u-relative { position: relative; }
.u-scroll-y { overflow-y: auto; overscroll-behavior: contain; }

.u-mt-0 { margin-top: 0; }
.u-mt-2 { margin-top: var(--space-4); }
.u-mt-3 { margin-top: var(--space-5); }
.u-mt-4 { margin-top: var(--space-6); }
.u-mt-6 { margin-top: var(--space-9); }
.u-gap-1 { gap: var(--space-2); }
.u-gap-2 { gap: var(--space-4); }
.u-gap-3 { gap: var(--space-5); }
.u-gap-4 { gap: var(--space-6); }
.u-pad-4 { padding: var(--space-6); }

.u-pos { color: var(--pos); }
.u-neg { color: var(--neg); }
.u-info { color: var(--info); }
.u-warn { color: var(--warn); }
.u-accent { color: var(--accent); }

/* Filet horizontal léger entre deux blocs d'une même carte. */
.u-rule { height: 1px; background: var(--border-soft); }

/* Réservé aux 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;
}
.skip-link {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-max);
  padding: var(--space-4) var(--space-6);
  background: var(--surface-solid);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: 0.8125rem;
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--t-2) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

/* Cible tactile élargie sans changer la taille visuelle (icônes 24px). */
.u-hit::before { content: ""; position: absolute; inset: -10px; }


/* =============================================================================
   22 · ACCESSIBILITÉ & MOUVEMENT RÉDUIT
   ========================================================================== */

/* On conserve opacité et couleur (elles portent du sens), on retire le
   déplacement, les mises à l'échelle et les boucles décoratives. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 120ms !important;
    scroll-behavior: auto !important;
  }

  .btn:active,
  .chip:active,
  .card--interactive:active,
  .list-row:active,
  .calendar-day:active,
  .tabbar-item:active,
  .month-nav__btn:active,
  .checkbox:active,
  .fab:active { transform: none; }

  .fab:active { transform: translateX(-50%); }

  .sheet { transition: opacity 140ms linear, visibility 0s linear 140ms; transform: none; opacity: 0; }
  .sheet.is-open { transform: none; opacity: 1; transition-delay: 0s; }
  .popover, .toast { transform: none; }
  .popover.is-open, .toast.is-open { transform: none; }

  .skeleton::after { animation: none; }
  .progress.is-over .progress__bar { animation: none; }
  .anim-rise { animation: none; opacity: 1; transform: none; }
  .switch:active::after { width: 20px; }
}

/* Contraste renforcé : on solidifie les bordures et on retire les voiles. */
@media (prefers-contrast: more) {
  :root {
    --border: rgb(51 65 85 / 1);
    --border-soft: rgb(51 65 85 / 0.8);
    --border-strong: rgb(100 116 139 / 1);
    --text-3: var(--slate-300);
    --text-4: var(--slate-400);
  }
  .card, .kpi { background-image: none; background-color: #0d1526; }
}

/* Impression : export d'un relevé mensuel. */
@media print {
  body { background: #fff; color: #000; }
  .tabbar, .fab, .sidebar, .app-header, .toast-stack, .sheet-backdrop, .sheet { display: none !important; }
  .app-main { padding: 0; }
  .card, .kpi, .list--card { border-color: #ccc; box-shadow: none; background: #fff; color: #000; }
  .money--pos, .money--neg { color: #000; }
}
