/* =========================================================
   Pécule — feuille de style
   ========================================================= */

/* ---------- Jetons de design (clair) ---------- */
:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji";

  --page: #f3f2f8;
  --glow-1: rgba(124, 108, 255, 0.24);
  --glow-2: rgba(42, 120, 214, 0.16);
  --glow-3: rgba(235, 104, 52, 0.12);

  --surface: #fcfcfb;
  --surface-2: #f4f3ef;
  --surface-3: #ebeae4;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --shadow-sm: 0 1px 2px rgba(24, 18, 64, 0.06);
  --shadow: 0 1px 2px rgba(24, 18, 64, 0.05), 0 12px 32px -14px rgba(24, 18, 64, 0.18);
  --shadow-lg: 0 28px 70px -20px rgba(24, 18, 64, 0.35);

  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d67;

  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --axis-text: #898781;

  --brand: #5b4bd5;
  --brand-strong: #4a3bc2;
  --brand-2: #8b5cf6;
  --brand-soft: #ecebff;
  --brand-ink: #ffffff;
  --focus: #5b4bd5;

  /* Couleurs des données (palette validée clair) */
  --income: #2a78d6;
  --expense: #eb6834;
  --pos: #2a78d6;
  --neg: #e34948;
  --deemph: #b4b2a9;
  --accent-track: #cde2fb;

  /* Statuts (réservés) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --bad-text: #c42f2f;
  --warn-text: #8a5a00;

  --radius-lg: 24px;
  --radius: 18px;
  --radius-sm: 12px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Jetons de design (sombre) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e0d12;
    --glow-1: rgba(124, 108, 255, 0.20);
    --glow-2: rgba(57, 135, 229, 0.12);
    --glow-3: rgba(217, 89, 38, 0.10);
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 34px -14px rgba(0, 0, 0, 0.65);
    --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, 0.75);
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --axis-text: #898781;
    --brand: #6d5ef0;
    --brand-strong: #7d70f5;
    --brand-2: #a78bfa;
    --brand-soft: #25213f;
    --brand-ink: #ffffff;
    --focus: #a99ff8;
    --income: #3987e5;
    --expense: #d95926;
    --pos: #3987e5;
    --neg: #e66767;
    --deemph: #5f5d57;
    --accent-track: #1c3557;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --warn-text: #fab219;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e0d12;
  --glow-1: rgba(124, 108, 255, 0.20);
  --glow-2: rgba(57, 135, 229, 0.12);
  --glow-3: rgba(217, 89, 38, 0.10);
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 34px -14px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, 0.75);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --axis-text: #898781;
  --brand: #6d5ef0;
  --brand-strong: #7d70f5;
  --brand-2: #a78bfa;
  --brand-soft: #25213f;
  --brand-ink: #ffffff;
  --focus: #a99ff8;
  --income: #3987e5;
  --expense: #d95926;
  --pos: #3987e5;
  --neg: #e66767;
  --deemph: #5f5d57;
  --accent-track: #1c3557;
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --warn-text: #fab219;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

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

.container { width: min(1200px, 100% - 32px); margin-inline: auto; }

/* ---------- Décor d'arrière-plan ---------- */
.bg-decor { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-decor span {
  position: absolute; border-radius: 50%; filter: blur(70px);
  animation: blob-float 18s ease-in-out infinite alternate;
}
.bg-decor span:nth-child(1) { width: 520px; height: 520px; background: var(--glow-1); top: -160px; left: -120px; }
.bg-decor span:nth-child(2) { width: 460px; height: 460px; background: var(--glow-2); top: 30%; right: -160px; animation-duration: 22s; }
.bg-decor span:nth-child(3) { width: 380px; height: 380px; background: var(--glow-3); bottom: -140px; left: 30%; animation-duration: 26s; }

@keyframes blob-float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(40px, 30px, 0) scale(1.12); }
}

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.03em; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 36px; height: 36px; flex: none; }
.logo:hover .logo-mark { animation: coin-flip 0.9s var(--ease-out); }

@keyframes coin-flip {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(360deg); }
}

/* ---------- En-tête ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  background: color-mix(in oklab, var(--page) 78%, transparent);
  border-bottom: 1px solid var(--border);
  animation: slide-down 0.7s var(--ease-out) both;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.nav-links { display: flex; gap: 22px; margin-right: 8px; }
.nav-links a { color: var(--ink-2); font-weight: 600; font-size: 0.95rem; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }

@keyframes slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- Boutons ---------- */
.btn {
  --btn-bg: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--btn-bg); color: var(--ink);
  font-weight: 650; font-size: 0.95rem; line-height: 1.1; white-space: nowrap;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background-color 0.2s, border-color 0.2s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  border-color: transparent; color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 22px -10px color-mix(in oklab, var(--brand) 80%, transparent);
}
.btn-primary:hover { box-shadow: 0 14px 30px -12px color-mix(in oklab, var(--brand) 90%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); box-shadow: none; }
.btn-danger { color: var(--bad-text); }
.btn-danger.solid { background: var(--critical); border-color: transparent; color: #fff; }
.btn-lg { min-height: 54px; padding: 14px 26px; font-size: 1.05rem; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; border-radius: 10px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  transition: transform 0.2s var(--ease-out), background-color 0.2s, color 0.2s;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bouton de thème */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; }
.field label, .field-label { font-weight: 650; font-size: 0.9rem; color: var(--ink-2); }
.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: color-mix(in oklab, var(--brand) 40%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in oklab, var(--brand) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--critical); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-wrap .peek {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  display: grid; place-items: center;
}
.input-wrap .peek:hover { color: var(--ink); background: var(--surface-2); }
.input-wrap .peek svg { width: 20px; height: 20px; }
.input-suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.hint { font-size: 0.85rem; color: var(--muted); }

.form-error {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--critical) 12%, var(--surface)); color: var(--bad-text);
  font-weight: 600; font-size: 0.92rem;
  animation: shake 0.45s var(--ease-out);
}
.form-error svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* Interrupteur segmenté (dépense / revenu) */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border-radius: 10px;
  font-weight: 700; color: var(--ink-2); transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg-dot { width: 10px; height: 10px; border-radius: 50%; }

/* Puces de catégories */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  border: 1.5px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: 0.9rem;
  transition: transform 0.15s var(--ease-out), border-color 0.2s, background-color 0.2s;
}
.chip input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); transform: scale(1.04); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Indicateur de force du mot de passe */
.strength { display: grid; gap: 6px; }
.strength-track { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.strength-fill { height: 100%; width: 0; border-radius: 999px; background: var(--critical); transition: width 0.4s var(--ease-out), background-color 0.3s; }
.strength-label { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---------- Cartes ---------- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 1.08rem; font-weight: 750; letter-spacing: -0.01em; }
.card-sub { color: var(--muted); font-size: 0.9rem; margin-top: 3px; }
.card-tools { display: flex; gap: 6px; flex: none; }

/* ---------- Tuiles d'indicateurs ---------- */
.kpi-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 18px; }
.kpi { display: flex; flex-direction: column; gap: 6px; min-height: 150px; overflow: hidden; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--ink-2); font-size: 0.92rem; }
.kpi-label .dot { width: 10px; height: 10px; border-radius: 3px; }
.kpi-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.kpi-hero {
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in oklab, var(--brand-2) 18%, transparent), transparent 60%),
    var(--surface);
}
.kpi-hero .kpi-value { font-size: clamp(2.6rem, 5vw, 3.4rem); }
.kpi-delta { display: inline-flex; align-items: center; gap: 6px; font-size: 0.87rem; font-weight: 650; color: var(--muted); }
.kpi-delta.good { color: var(--good-text); }
.kpi-delta.bad { color: var(--bad-text); }
.kpi-delta svg { width: 14px; height: 14px; }
.kpi-spark { margin-top: auto; height: 40px; width: 100%; }

/* ---------- Grilles du tableau de bord ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; margin-top: 18px; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-12 { grid-column: span 12; }

/* ---------- Graphiques ---------- */
.chart { position: relative; width: 100%; min-height: 120px; }
.chart svg { overflow: visible; }
.chart text { font-family: var(--font); font-size: 11.5px; fill: var(--axis-text); }
.chart .tick-y { font-variant-numeric: tabular-nums; }
.chart .end-label { fill: var(--ink-2); font-weight: 650; font-size: 12px; }
.chart .val-label { fill: var(--ink); font-weight: 700; font-size: 12px; }
.chart .marker-label { fill: var(--ink-2); font-weight: 650; font-size: 11.5px; }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart .hit:focus-visible { stroke: var(--focus); stroke-width: 2px; }
.chart .bar-hit { fill: transparent; cursor: pointer; outline: none; }
.chart .bar-hit:focus-visible { stroke: var(--focus); stroke-width: 2px; }
.chart .bar { transition: opacity 0.2s; }
.chart .bar.dim { opacity: 0.5; }
.chart .bar.hover { opacity: 1; filter: brightness(1.08); }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); text-align: center; gap: 8px; padding: 20px; }
.chart-empty .big { font-size: 2rem; }

.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 260px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s; font-size: 0.85rem;
}
.chart-tooltip.show { opacity: 1; transform: none; }
.tt-head { font-weight: 700; color: var(--ink-2); margin-bottom: 6px; font-size: 0.8rem; text-transform: capitalize; }
.tt-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; padding: 2px 0; }
.tt-key { width: 14px; height: 0; border-top: 2.5px solid; border-radius: 2px; }
.tt-key.dashed { border-top-style: dashed; }
.tt-val { font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }
.tt-name { color: var(--muted); font-size: 0.8rem; }
.tt-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--ink-2); font-size: 0.8rem; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 2px 0 10px; font-size: 0.85rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-line { width: 16px; border-top: 2.5px solid; border-radius: 2px; }
.legend-line.dashed { border-top-style: dashed; }
.legend-rect { width: 12px; height: 12px; border-radius: 3px; }

.view-toggle { font-size: 0.8rem; }
.data-table-wrap { overflow-x: auto; max-height: 340px; border-radius: 12px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2); font-weight: 700; }
.data-table td { font-variant-numeric: tabular-nums; }
.data-table tbody th { font-weight: 600; color: var(--ink); background: transparent; }
.card.show-table .chart-zone { display: none; }
.card:not(.show-table) .data-table-wrap { display: none; }

/* Phrase de synthèse au-dessus d'un graphique */
.callout {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px;
  border-radius: 12px; background: var(--surface-2); font-size: 0.92rem; color: var(--ink);
}
.callout .status-icon { flex: none; }

/* Icônes de statut */
.status-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; }
.status-icon svg { width: 14px; height: 14px; }
.status-icon.good { background: var(--good); }
.status-icon.warning { background: var(--warning); color: #0b0b0b; }
.status-icon.serious { background: var(--serious); color: #0b0b0b; }
.status-icon.critical { background: var(--critical); }
.status-icon.info { background: var(--brand); }

/* ---------- Barres classées (où part mon argent) ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank-row {
  display: grid; grid-template-columns: minmax(120px, 150px) 1fr minmax(92px, auto); align-items: center; gap: 12px;
  padding: 7px 8px; border-radius: 10px; outline: none; transition: background-color 0.2s;
}
.rank-row:hover, .rank-row:focus-visible { background: var(--surface-2); }
.rank-row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.rank-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.92rem; min-width: 0; }
.rank-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-emoji { font-size: 1.05rem; }
.rank-bar-wrap { height: 14px; }
.rank-bar {
  display: block; height: 14px; width: 0; border-radius: 0 4px 4px 0; background: var(--expense);
  transition: width 1s var(--ease-out); transition-delay: var(--delay, 0ms);
}
.rank-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.92rem; white-space: nowrap; }
.rank-value small { color: var(--muted); font-weight: 600; margin-left: 4px; }

/* ---------- Jauges de budget ---------- */
.meter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.meter-row {
  --fill: var(--pos); --track: var(--accent-track);
  display: grid; grid-template-columns: minmax(120px, 150px) 1fr minmax(118px, auto) minmax(112px, auto);
  align-items: center; gap: 12px; padding: 8px; border-radius: 10px; transition: background-color 0.2s;
}
.meter-row:hover { background: var(--surface-2); }
.meter-row.warning { --fill: var(--warning); --track: color-mix(in oklab, var(--warning) 26%, var(--surface)); }
.meter-row.critical { --fill: var(--critical); --track: color-mix(in oklab, var(--critical) 22%, var(--surface)); }
.meter-row.none { --fill: var(--deemph); --track: var(--surface-3); }
.meter-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.92rem; min-width: 0; }
.meter-track { position: relative; height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: var(--fill);
  transition: width 1.1s var(--ease-out); transition-delay: var(--delay, 0ms);
}
.meter-figure { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap; }
.meter-figure small { color: var(--muted); font-weight: 600; }
.meter-status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.meter-status .status-icon { width: 18px; height: 18px; }
.meter-status .status-icon svg { width: 11px; height: 11px; }
.meter-total { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 12px 8px 0; border-top: 1px solid var(--border); font-weight: 650; color: var(--ink-2); }
.meter-total strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- À retenir ---------- */
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insight {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; padding: 12px; border-radius: 14px;
  background: var(--surface-2); font-size: 0.93rem; color: var(--ink);
  opacity: 0; transform: translateX(14px); animation: insight-in 0.6s var(--ease-out) forwards; animation-delay: var(--delay, 0ms);
}
.insight strong { font-weight: 750; }
@keyframes insight-in { to { opacity: 1; transform: none; } }

/* ---------- Barre d'outils du tableau de bord ---------- */
.dash-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin: 26px 0 18px; }
.dash-hello h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.dash-hello p { color: var(--muted); margin-top: 4px; }
.dash-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.month-nav {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.month-nav .icon-btn { border: 0; width: 38px; height: 38px; }
.month-label { min-width: 150px; text-align: center; font-weight: 750; text-transform: capitalize; }
.month-label.flip { animation: month-flip 0.45s var(--ease-out); }
@keyframes month-flip {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Menu utilisateur */
.user-menu { position: relative; }
.avatar-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 650;
}
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; padding: 6px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  transform-origin: top right; animation: pop-in 0.18s var(--ease-out);
}
.menu-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head strong { display: block; }
.menu-head span { color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; text-align: left; font-weight: 600; color: var(--ink);
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button.danger { color: var(--bad-text); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Opérations ---------- */
.tx-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tx-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 650; font-size: 0.88rem; color: var(--ink-2);
}
.filter-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.search { position: relative; flex: 1 1 220px; max-width: 320px; }
.search .input { min-height: 40px; padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

.tx-group + .tx-group { margin-top: 10px; }
.tx-date { font-size: 0.8rem; font-weight: 750; color: var(--muted); text-transform: capitalize; padding: 6px 8px; }
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx {
  display: grid; grid-template-columns: 42px 1fr auto auto; gap: 12px; align-items: center; padding: 8px;
  border-radius: 14px; transition: background-color 0.2s;
  opacity: 0; transform: translateY(8px); animation: tx-in 0.45s var(--ease-out) forwards; animation-delay: var(--delay, 0ms);
}
.tx:hover { background: var(--surface-2); }
.tx-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); font-size: 1.2rem; }
.tx:hover .tx-icon { background: var(--surface); }
.tx-main { min-width: 0; }
.tx-label { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-cat { font-size: 0.82rem; color: var(--muted); }
.tx-amount { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amount.income { color: var(--good-text); }
.tx-actions { display: flex; gap: 2px; opacity: 0.35; transition: opacity 0.2s; }
.tx:hover .tx-actions, .tx:focus-within .tx-actions { opacity: 1; }
.tx-actions button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); display: grid; place-items: center; }
.tx-actions button:hover { background: var(--surface-3); color: var(--ink); }
.tx-actions svg { width: 17px; height: 17px; }
.tx.static { animation: none; opacity: 1; transform: none; }
.tx.flash { opacity: 1; transform: none; animation: flash 1.8s ease-out; }
@keyframes tx-in { to { opacity: 1; transform: none; } }
@keyframes flash {
  0% { background: color-mix(in oklab, var(--brand) 22%, transparent); }
  100% { background: transparent; }
}
.tx-empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.tx-total { display: flex; justify-content: flex-end; gap: 18px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--ink-2); }
.tx-total strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Écran de bienvenue (compte vide) ---------- */
.welcome {
  display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; padding: 30px;
  background:
    radial-gradient(90% 120% at 0% 0%, color-mix(in oklab, var(--brand-2) 20%, transparent), transparent 60%),
    var(--surface);
}
.welcome-art { width: 140px; }
.welcome h2 { font-size: 1.6rem; margin-bottom: 8px; }
.welcome p { color: var(--ink-2); max-width: 60ch; }
.welcome .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- Chargement ---------- */
.app-loader { display: grid; place-items: center; gap: 14px; min-height: 60vh; color: var(--muted); font-weight: 600; }
.app-loader .coin { width: 64px; height: 64px; animation: coin-spin 1.2s linear infinite; }
@keyframes coin-spin {
  0% { transform: perspective(300px) rotateY(0); }
  100% { transform: perspective(300px) rotateY(360deg); }
}

/* ---------- Fenêtres modales ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 8, 26, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease-out;
}
.modal-card {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: modal-in 0.35s var(--ease-spring);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { font-size: 1.3rem; }
.modal-body { display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.budget-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.budget-total { display: flex; justify-content: space-between; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-weight: 650; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------- Notifications ---------- */
.toasts { position: fixed; top: 82px; right: 16px; z-index: 90; display: grid; gap: 10px; width: min(380px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 0.93rem; animation: toast-in 0.4s var(--ease-spring);
}
.toast.out { animation: toast-out 0.3s ease-in forwards; }
.toast .toast-msg { flex: 1; }
.toast button { border: 0; background: transparent; color: var(--brand); font-weight: 750; padding: 6px 8px; border-radius: 8px; }
.toast button:hover { background: var(--brand-soft); }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }

/* =========================================================
   Page d'accueil
   ========================================================= */
.hero { padding: 64px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; font-size: 0.85rem;
}
:root[data-theme="dark"] .eyebrow { color: #cfc8ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .eyebrow { color: #cfc8ff; } }
.hero h1 { font-size: clamp(2.3rem, 5.4vw, 4rem); font-weight: 850; letter-spacing: -0.045em; margin: 18px 0 18px; }
.hero h1 .word { display: inline-block; opacity: 0; transform: translateY(0.5em) rotate(2deg); animation: word-in 0.8s var(--ease-out) forwards; animation-delay: var(--delay, 0ms); }
.hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), var(--brand-2) 45%, var(--expense));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead { font-size: 1.15rem; color: var(--ink-2); max-width: 54ch; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hero .reassure { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 22px; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.hero .reassure span { display: inline-flex; align-items: center; gap: 6px; }
.hero .reassure svg { width: 16px; height: 16px; color: var(--good-text); }
@keyframes word-in { to { opacity: 1; transform: none; } }

.preview { position: relative; }
.preview-card { padding: 20px; transform: perspective(1200px) rotateY(-6deg) rotateX(3deg); transition: transform 0.6s var(--ease-out); }
.preview:hover .preview-card { transform: perspective(1200px) rotateY(0) rotateX(0); }
.preview-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.mini-kpi { padding: 12px; border-radius: 14px; background: var(--surface-2); }
.mini-kpi .l { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); font-weight: 650; }
.mini-kpi .l i { width: 8px; height: 8px; border-radius: 2px; }
.mini-kpi .v { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.floating-badge {
  position: absolute; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-weight: 650; font-size: 0.88rem;
  animation: bob 4s ease-in-out infinite;
}
.floating-badge.b1 { left: -26px; bottom: 40px; }
.floating-badge.b2 { right: -14px; top: -18px; animation-delay: -2s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.section { padding: 70px 0; }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 40px; }
.section-head h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); font-weight: 820; }
.section-head p { color: var(--ink-2); margin-top: 12px; font-size: 1.08rem; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.feature { padding: 24px; transition: transform 0.3s var(--ease-out), box-shadow 0.3s; }
.feature:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.feature-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; font-size: 1.6rem; margin-bottom: 16px;
  background: var(--brand-soft);
}
.feature h3 { font-size: 1.1rem; margin-bottom: 8px; }
.feature p { color: var(--ink-2); font-size: 0.95rem; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; counter-reset: step; }
.step { padding: 24px; }
.step-num {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800;
}
.step h3 { font-size: 1.08rem; margin-bottom: 6px; }
.step p { color: var(--ink-2); font-size: 0.95rem; }
.cta-band {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; padding: 36px;
  border-radius: 28px; color: #fff; overflow: hidden; position: relative;
  background: linear-gradient(120deg, #4a3bc2, #7c5cf0 50%, #2a78d6);
}
.cta-band h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); max-width: 22ch; }
.cta-band p { opacity: 0.88; margin-top: 8px; }
.cta-band .btn { background: #fff; color: #2b2190; border-color: transparent; }
.site-footer { padding: 30px 0 120px; color: var(--muted); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding-top: 22px; }
.footer-inner nav { display: flex; gap: 16px; }
.footer-inner a { color: var(--ink-2); }

/* =========================================================
   Pages inscription / connexion
   ========================================================= */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { display: flex; flex-direction: column; padding: 24px clamp(20px, 5vw, 64px); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-form-wrap { flex: 1; display: grid; place-items: center; padding: 30px 0 110px; }
.auth-card { width: min(440px, 100%); animation: rise-in 0.8s var(--ease-out) both; }
.auth-card h1 { font-size: clamp(1.9rem, 3.4vw, 2.4rem); font-weight: 830; }
.auth-card .sub { color: var(--ink-2); margin: 10px 0 26px; }
.auth-form { display: grid; gap: 16px; }
.auth-switch { margin-top: 22px; text-align: center; color: var(--ink-2); }
.auth-switch a { font-weight: 700; }
.auth-legal { margin-top: 14px; font-size: 0.8rem; color: var(--muted); text-align: center; }

.auth-visual {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 26px;
  padding: 48px clamp(24px, 5vw, 70px); color: #fff;
  background: linear-gradient(150deg, #3b2db0 0%, #6a4ff0 45%, #2a78d6 100%);
}
.auth-visual::before, .auth-visual::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(10px); opacity: 0.35;
  animation: blob-float 14s ease-in-out infinite alternate;
}
.auth-visual::before { width: 380px; height: 380px; background: #ff9f6e; top: -120px; right: -100px; }
.auth-visual::after { width: 300px; height: 300px; background: #59d3ff; bottom: -110px; left: -80px; animation-duration: 18s; }
.auth-visual > * { position: relative; z-index: 1; }
.auth-visual h2 { font-size: clamp(1.7rem, 3vw, 2.5rem); font-weight: 820; max-width: 18ch; }
.auth-visual p { opacity: 0.9; max-width: 44ch; font-size: 1.05rem; }
.glass {
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 22px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 20px;
  animation: rise-in 1s var(--ease-out) 0.25s both;
}
.glass-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.glass-row .t { opacity: 0.85; font-weight: 600; font-size: 0.9rem; }
.glass-row .v { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.glass svg { width: 100%; height: 110px; margin-top: 10px; }
.glass .draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s var(--ease-out) 0.6s forwards; }
.glass .fill-in { opacity: 0; animation: fade-in 1.2s ease-out 1.6s forwards; }
.bullets { display: grid; gap: 12px; list-style: none; padding: 0; margin: 0; }
.bullets li { display: flex; gap: 12px; align-items: center; font-weight: 600; opacity: 0; animation: rise-in 0.7s var(--ease-out) forwards; animation-delay: var(--delay, 0ms); }
.bullets .b-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, 0.18); flex: none; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* =========================================================
   Page 404
   ========================================================= */
.lost { min-height: 80vh; display: grid; place-items: center; text-align: center; padding: 40px 16px; }
.lost h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 18px 0 10px; }
.lost p { color: var(--ink-2); margin-bottom: 24px; }
.lost .big-num { font-size: clamp(4rem, 14vw, 8rem); font-weight: 900; letter-spacing: -0.06em; line-height: 1; background: linear-gradient(120deg, var(--brand), var(--expense)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* =========================================================
   Léon — la mascotte
   ========================================================= */
.leon-root { position: fixed; right: 16px; bottom: 10px; z-index: 70; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.leon-root > * { pointer-events: auto; }
.leon-btn {
  position: relative; width: 96px; height: 120px; padding: 0; border: 0; background: transparent;
  animation: leon-enter 1.1s var(--ease-spring) 0.6s both; -webkit-tap-highlight-color: transparent;
}
.leon-btn:focus-visible { outline-offset: -4px; border-radius: 24px; }
.leon-svg { width: 100%; height: 100%; overflow: visible; }
.leon-body { animation: leon-bob 2.6s ease-in-out infinite; transform-box: view-box; transform-origin: 60px 140px; }
.leon-shadow { animation: leon-shadow 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.leon-blink { animation: leon-blink 4.6s infinite; transform-box: fill-box; transform-origin: center; }
.leon-arm-right { transform-box: view-box; transform-origin: 97px 72px; animation: leon-wave-idle 9s ease-in-out 2.4s infinite; }
.leon-btn:hover .leon-arm-right, .leon-root.is-open .leon-arm-right { animation: leon-wave 0.9s ease-in-out infinite; }
.leon-sprout { transform-box: view-box; transform-origin: 60px 26px; animation: leon-sprout 3.2s ease-in-out infinite; }
.leon-look { transition: transform 0.18s ease-out; }
.leon-mouth-open { opacity: 0; transform-box: fill-box; transform-origin: center; }
.leon-root.is-talking .leon-mouth { opacity: 0; }
.leon-root.is-talking .leon-mouth-open { opacity: 1; animation: leon-talk 0.22s ease-in-out infinite alternate; }
.leon-root.is-thinking .leon-look { transform: translate(2px, -3px) !important; }
.leon-root.is-happy .leon-body { animation: leon-jump 0.7s var(--ease-out); }
.leon-btn:active .leon-body { animation: leon-squash 0.25s ease-out; }

@keyframes leon-enter {
  0% { opacity: 0; transform: translateY(140px) scale(0.6); }
  70% { opacity: 1; transform: translateY(-10px) scale(1.04); }
  100% { opacity: 1; transform: none; }
}
@keyframes leon-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes leon-shadow { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.85); opacity: 0.7; } }
@keyframes leon-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.08); } }
@keyframes leon-wave { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-28deg); } }
@keyframes leon-wave-idle {
  0%, 80%, 100% { transform: rotate(0deg); }
  84%, 92% { transform: rotate(-28deg); }
  88%, 96% { transform: rotate(4deg); }
}
@keyframes leon-sprout { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(6deg); } }
@keyframes leon-talk { from { transform: scaleY(0.35); } to { transform: scaleY(1); } }
@keyframes leon-jump {
  0% { transform: translateY(0) scale(1, 1); }
  20% { transform: translateY(0) scale(1.08, 0.9); }
  45% { transform: translateY(-22px) scale(0.95, 1.06); }
  70% { transform: translateY(0) scale(1.05, 0.95); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes leon-squash { 50% { transform: scale(1.06, 0.92); } }

.leon-teaser {
  position: relative; margin: 0 14px 4px 0; max-width: 220px; padding: 10px 14px; border-radius: 16px 16px 4px 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-weight: 650; font-size: 0.9rem; color: var(--ink); cursor: pointer;
  animation: teaser-in 0.5s var(--ease-spring) both;
}
.leon-teaser.out { animation: teaser-out 0.3s ease-in forwards; }
@keyframes teaser-in { from { opacity: 0; transform: translateY(10px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes teaser-out { to { opacity: 0; transform: translateY(6px) scale(0.92); } }

.leon-chat {
  width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100vh - 170px)); margin-bottom: 6px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg);
  transform-origin: bottom right; animation: chat-in 0.35s var(--ease-spring);
}
.leon-chat.out { animation: chat-out 0.22s ease-in forwards; }
@keyframes chat-in { from { opacity: 0; transform: scale(0.85) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes chat-out { to { opacity: 0; transform: scale(0.9) translateY(14px); } }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.chat-head .mini-leon { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); display: grid; place-items: center; flex: none; }
.chat-head .mini-leon svg { width: 34px; height: 34px; }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head strong { display: block; font-size: 1rem; }
.chat-head span { font-size: 0.8rem; opacity: 0.9; display: inline-flex; align-items: center; gap: 6px; }
.chat-head span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7cf29c; box-shadow: 0 0 0 3px rgba(124, 242, 156, 0.3); }
.chat-head .icon-btn { background: rgba(255, 255, 255, 0.16); border-color: transparent; color: #fff; width: 36px; height: 36px; }
.chat-head .icon-btn:hover { background: rgba(255, 255, 255, 0.28); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; font-size: 0.93rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; animation: msg-in 0.3s var(--ease-out); }
.msg.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-bottom-right-radius: 5px; }
.msg .src { display: block; margin-top: 6px; font-size: 0.72rem; color: var(--muted); }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }
.chat-suggest { display: flex; gap: 6px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.chat-suggest::-webkit-scrollbar { display: none; }
.chat-suggest button {
  flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 0.82rem; font-weight: 650; color: var(--ink-2); white-space: nowrap;
}
.chat-suggest button:hover { border-color: var(--brand); color: var(--ink); background: var(--brand-soft); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form .input { min-height: 44px; border-radius: 999px; padding: 10px 16px; }
.chat-form button {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.chat-form button svg { width: 20px; height: 20px; }
.chat-form button[disabled] { opacity: 0.5; }

/* =========================================================
   Musique d'ascenseur
   ========================================================= */
.music-root { position: fixed; left: 16px; bottom: 18px; z-index: 65; display: flex; align-items: center; gap: 10px; }
.music-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg); font-weight: 700; font-size: 0.85rem;
  color: var(--ink-2); animation: rise-in 0.8s var(--ease-out) 1s both; transition: transform 0.2s var(--ease-out);
}
.music-btn:hover { transform: translateY(-2px); color: var(--ink); }
.music-btn .note {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.music-btn .note svg { width: 18px; height: 18px; }
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; }
.eq i { width: 3px; height: 4px; border-radius: 2px; background: var(--brand); }
.music-btn[data-playing="true"] .eq i { animation: eq 0.9s ease-in-out infinite alternate; }
.music-btn[data-playing="true"] .eq i:nth-child(2) { animation-delay: -0.3s; animation-duration: 0.7s; }
.music-btn[data-playing="true"] .eq i:nth-child(3) { animation-delay: -0.6s; animation-duration: 1.1s; }
.music-btn[data-playing="true"] .eq i:nth-child(4) { animation-delay: -0.15s; animation-duration: 0.8s; }
.music-btn[aria-pressed="false"] .note { background: var(--surface-3); color: var(--muted); }
@keyframes eq { from { height: 3px; } to { height: 16px; } }
.music-hint {
  max-width: 240px; padding: 10px 12px; border-radius: 14px; background: var(--ink); color: var(--surface);
  font-size: 0.82rem; font-weight: 600; box-shadow: var(--shadow-lg); animation: teaser-in 0.5s var(--ease-spring) both;
}
.music-hint.out { animation: teaser-out 0.3s ease-in forwards; }

/* =========================================================
   Apparitions au défilement
   ========================================================= */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out); transition-delay: var(--d, 0ms); }
.js .reveal.is-visible { opacity: 1; transform: none; }
.page-enter { animation: fade-in 0.6s ease-out both; }

/* =========================================================
   Adaptation aux écrans
   ========================================================= */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .features { grid-template-columns: 1fr 1fr; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .preview-card { transform: none; }
  .floating-badge.b1 { display: none; }
  .floating-badge.b2 { right: 12px; top: -20px; }
}

@media (max-width: 860px) {
  .nav-links { display: none; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { order: -1; padding: 28px 20px; gap: 14px; }
  .auth-visual .glass, .auth-visual .bullets { display: none; }
  .auth-visual h2 { font-size: 1.5rem; }
  .auth-visual p { font-size: 0.95rem; }
  .auth-form-wrap { padding-top: 10px; }
  .steps { grid-template-columns: 1fr; }
  .welcome { grid-template-columns: 1fr; text-align: center; }
  .welcome-art { margin: 0 auto; }
  .welcome .actions { justify-content: center; }
  .meter-row { grid-template-columns: 1fr auto; grid-template-areas: "name figure" "track track" "status status"; row-gap: 8px; }
  .meter-name { grid-area: name; }
  .meter-figure { grid-area: figure; }
  .meter-track { grid-area: track; }
  .meter-status { grid-area: status; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { width: min(1200px, 100% - 32px); }
  .header-inner { height: 60px; }
  .card { padding: 16px; border-radius: 20px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi-hero { grid-column: span 2; }
  .kpi { min-height: 128px; }
  .kpi-value { font-size: 1.45rem; }
  .dash-grid { gap: 12px; margin-top: 12px; }
  .dash-head { margin: 18px 0 12px; }
  .dash-actions { width: 100%; }
  .month-nav { flex: 1; justify-content: space-between; }
  .month-label { min-width: 0; }
  .features { grid-template-columns: 1fr; }
  .hero { padding-top: 34px; }
  .preview-kpis { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .mini-kpi { padding: 8px; }
  .mini-kpi .v { font-size: 1rem; }
  .floating-badge { display: none; }
  .rank-row { grid-template-columns: 1fr auto; grid-template-areas: "name value" "bar bar"; row-gap: 6px; }
  .rank-name { grid-area: name; }
  .rank-value { grid-area: value; }
  .rank-bar-wrap { grid-area: bar; }
  .tx { grid-template-columns: 38px 1fr auto; }
  .tx-icon { width: 38px; height: 38px; }
  .tx-actions { grid-column: 2 / -1; justify-content: flex-end; opacity: 1; margin-top: -6px; }
  .budget-grid { grid-template-columns: 1fr; }
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100%; border-radius: 24px 24px 0 0; max-height: 92vh; animation: sheet-in 0.4s var(--ease-out); }
  .leon-btn { width: 76px; height: 96px; }
  .leon-root { right: 8px; bottom: 6px; }
  .leon-chat { height: min(520px, calc(100vh - 150px)); }
  .music-root { left: 10px; bottom: 14px; }
  .music-btn { height: 46px; padding: 0 6px; }
  .music-btn .label { display: none; }
  .music-btn .eq { margin-right: 6px; }
  .cta-band { padding: 26px; }
  .user-name { display: none; }
  .avatar-btn { padding: 3px; }
  main.dash { padding-bottom: 140px; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-hero { grid-column: auto; }
}

/* Mouvements réduits */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

@media (forced-colors: active) {
  .rank-bar, .meter-fill { background: CanvasText; }
}

/* =========================================================
   Pastilles de couleur et clés de légende
   ========================================================= */
.sw-income { background: var(--income); }
.sw-expense { background: var(--expense); }
.sw-brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.sw-pos { background: var(--pos); }
.sw-neg { background: var(--neg); }
.lk-income { border-top-color: var(--income); }
.lk-expense { border-top-color: var(--expense); }
.lk-deemph { border-top-color: var(--deemph); }
.legend-line { border-top-color: var(--ink-2); }
.legend-line.lk-income { border-top-color: var(--income); }
.legend-line.lk-expense { border-top-color: var(--expense); }
.legend-line.lk-deemph { border-top-color: var(--deemph); }

.bullets li:nth-child(1) { --delay: 700ms; }
.bullets li:nth-child(2) { --delay: 850ms; }
.bullets li:nth-child(3) { --delay: 1000ms; }

.kpi-label { margin: 0; letter-spacing: 0; line-height: 1.3; }
.chart-zone.chart { min-height: 0; }
.rank-list .chart-empty { min-height: 160px; }
.leon-teaser { white-space: normal; }

body.leaving { animation: page-out 0.38s ease-in forwards; }
@keyframes page-out { to { opacity: 0; transform: translateY(-8px); } }
.chart.kpi-spark { min-height: 0; height: 40px; }
@media (max-width: 640px) {
  .month-nav { flex: 1 1 100%; }
  .month-label { white-space: nowrap; }
  .dash-actions > .btn { flex: 1 1 0; }
}
@media (max-width: 640px) {
  .site-header .btn-ghost[data-guest-only] { display: none; }
  .site-header .btn { min-height: 40px; padding: 8px 12px; font-size: 0.88rem; }
  .header-actions { gap: 8px; }
  .logo { font-size: 1.1rem; }
}
