/* ================= COULEURS =================
   Graphiques : palette validée (daltonisme) du skill dataviz, avec des teintes
   choisies séparément pour le thème clair et le thème sombre. */
:root {
  color-scheme: light;
  --page: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e8e7e1;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, .07);
  --s1: #2a78d6;   /* bleu   : revenus, ce mois-ci, couleur principale */
  --s2: #eb6834;   /* orange : dépenses */
  --s3: #1baf7a;   /* aqua */
  --s4: #eda100;   /* jaune */
  --s5: #e87ba4;   /* magenta */
  --s6: #008300;   /* vert */
  --s7: #6250d6;   /* violet */
  --s8: #e34948;   /* rouge */
  --good: #0ca30c; --good-ink: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  /* Calendrier : rampe séquentielle bleue (clair = peu, foncé = beaucoup) */
  --h0: #eef0f4; --h1: #cde2fb; --h2: #9ec5f4; --h3: #6da7ec; --h4: #3987e5; --h5: #1c5cab;
  --grad: linear-gradient(135deg, #2a78d6 0%, #4f5fd9 55%, #6250d6 100%);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px rgba(16, 24, 40, .06);
  --radius: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, .08);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-ink: #0ca30c;
    --h0: #242422; --h1: #0d366b; --h2: #184f95; --h3: #256abf; --h4: #3987e5; --h5: #86b6ef;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, .08);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-ink: #0ca30c;
  --h0: #242422; --h1: #0d366b; --h2: #184f95; --h3: #256abf; --h4: #3987e5; --h5: #86b6ef;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased;
  background: radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--s7) 9%, transparent), transparent 70%),
              radial-gradient(900px 500px at 20% -20%, color-mix(in srgb, var(--s1) 9%, transparent), transparent 70%), var(--page);
  background-attachment: fixed;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
h1:focus { outline: none; }
.muted { color: var(--muted); font-size: .84rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ================= BARRE LATÉRALE (toujours sombre) ================= */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 24px 16px; background: #111214; color: #c3c2b7; }
.logo { display: flex; align-items: center; gap: 11px; padding: 0 10px; }
.logo__mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--grad); color: #fff; font-weight: 800; font-size: 1.1rem; box-shadow: 0 8px 20px rgba(79, 95, 217, .45); }
.logo__text { color: #fff; font-weight: 800; font-size: 1.35rem; letter-spacing: -.03em; }
.side__nav { display: grid; gap: 2px; }
.side__label { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #6f6e69; padding: 14px 12px 6px; }
.side__nav a, .side__btn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-size: .9rem; font-weight: 500; border: 0; background: none; color: inherit; text-align: left; width: 100%; transition: background .15s, color .15s; }
.side__nav a:hover, .side__btn:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side__nav a.active { background: rgba(255, 255, 255, .09); color: #fff; box-shadow: inset 3px 0 0 #6d8dff; }
.side__nav svg, .side__btn svg { width: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tip { margin-top: auto; padding: 16px; border-radius: 16px; background: linear-gradient(160deg, rgba(79, 95, 217, .35), rgba(98, 80, 214, .12)); border: 1px solid rgba(255, 255, 255, .08); color: #e6e5df; font-size: .8rem; }
.tip__icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, .12); margin-bottom: 8px; }
.tip b { color: #fff; display: block; margin-bottom: 3px; }
.side__foot { display: grid; gap: 2px; }
.credit { font-size: .78rem; padding: 8px 12px 0; color: #898781; }
.credit a { color: #9db4ff; font-weight: 600; }

/* ================= EN-TÊTE ================= */
.main { padding: 26px 32px 44px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.top__title { display: flex; align-items: center; gap: 14px; }
.avatar { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #f5b38a, #e87ba4); color: #fff; font-weight: 700; font-size: 1.1rem; box-shadow: 0 0 0 3px var(--surface); }
.top__hello { color: var(--muted); font-size: .88rem; }
.top h1 { font-size: 1.65rem; letter-spacing: -.03em; line-height: 1.2; }
.top__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ================= PAGES ================= */
.page { animation: page-in .35s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }

/* ================= CONTRÔLES ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 0; background: var(--s1); color: #fff; font-weight: 600; font-size: .9rem; white-space: nowrap; transition: filter .15s, transform .15s, box-shadow .15s; }
.btn svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn--grad { background: var(--grad); box-shadow: 0 8px 20px rgba(79, 95, 217, .35); }
.btn--ghost { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ring); padding: 9px 14px; font-size: .85rem; }
.btn--ghost svg { width: 16px; stroke-width: 1.9; }
.btn--ghost:hover { filter: none; box-shadow: inset 0 0 0 1px var(--s1); color: var(--s1); }
.btn--full { width: 100%; }
.btn--danger { background: none; color: var(--critical); box-shadow: inset 0 0 0 1px var(--ring); }
.btn--danger:hover { background: color-mix(in srgb, var(--critical) 10%, transparent); filter: none; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--ring); background: var(--surface); }
.icon-btn svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.seg { display: flex; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--ring); }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--ink); color: var(--surface); }
.seg--wide { margin-bottom: 18px; background: var(--surface-2); }
.seg--wide button { flex: 1; padding: 9px; font-size: .9rem; }
.month { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--ring); }
.month button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; font-size: 1.2rem; line-height: 1; color: var(--ink-2); }
.month button:hover:not(:disabled) { background: var(--surface-2); }
.month button:disabled { opacity: .3; cursor: default; }
.month span { min-width: 128px; text-align: center; font-weight: 600; font-size: .9rem; }
.link { border: 0; background: none; color: var(--s1); font-weight: 600; font-size: .84rem; white-space: nowrap; }
.link:hover { text-decoration: underline; }

/* ================= GRILLE + CARTES ================= */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card__title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card__icon { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--s1) 11%, transparent); color: var(--s1); }
.card__icon svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card h2, .section-head h2 { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.sub-title { font-size: .86rem; font-weight: 700; margin: 22px 0 10px; }

/* Icône ronde colorée */
.ic { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--c, var(--s1)) 13%, transparent); color: var(--c, var(--s1)); flex: none; }
.ic svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic--sm { width: 32px; height: 32px; border-radius: 10px; }
.ic--sm svg { width: 16px; }

/* Chiffres clés en haut des pages */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.tile { display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.tile .ic { width: 48px; height: 48px; border-radius: 14px; }
.tile .ic svg { width: 22px; }
.tile small { color: var(--ink-2); font-size: .84rem; font-weight: 500; }
.tile b { display: block; font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.25; }
.tile p { color: var(--muted); font-size: .8rem; }

/* Petite liste d'opérations (cliquables pour les modifier) */
.mini-list { display: grid; gap: 2px; }
.mini-row { width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 6px; border: 0; border-radius: 12px; background: none; text-align: left; }
.mini-row:hover { background: var(--surface-2); }
.mini-row b { display: block; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row small { display: block; color: var(--muted); font-size: .76rem; }
.mini-row .amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mini-row .amount.in { color: var(--good-ink); }
.mini-list .empty { padding: 18px 0; }

/* ================= VUE D'ENSEMBLE ================= */
.hero { position: relative; overflow: hidden; border-radius: var(--radius); padding: 24px; color: #fff; background: var(--grad); box-shadow: 0 18px 40px rgba(79, 95, 217, .28); display: flex; flex-direction: column; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .08); pointer-events: none; }
.hero::before { width: 260px; height: 260px; right: -80px; top: -110px; }
.hero::after { width: 160px; height: 160px; right: 70px; top: -60px; background: rgba(255, 255, 255, .06); }
.hero__head { display: flex; justify-content: space-between; align-items: center; position: relative; }
.hero__head p { font-size: .9rem; opacity: .9; font-weight: 500; }
.hero__badge { font-size: .74rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .16); }
.hero__value { display: block; font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; margin: 8px 0 2px; position: relative; }
.hero__spark { position: relative; flex: 1; min-height: 70px; margin: 12px -24px 0; }
.hero__spark svg { width: 100%; height: 100%; }
.hero__foot { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.hero__foot div { padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .13); backdrop-filter: blur(6px); }
.hero__foot small { display: block; font-size: .75rem; opacity: .85; }
.hero__foot b { font-size: 1.05rem; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 18px 20px 0; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.kpi__top { display: flex; align-items: center; gap: 10px; }
.kpi__icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); }
.kpi__icon svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi p { color: var(--ink-2); font-size: .86rem; font-weight: 500; }
.kpi b { display: block; font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; margin: 10px 0 2px; }
.kpi__spark { height: 44px; margin: 8px -20px 0; }
.kpi__spark svg { width: 100%; height: 100%; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.delta.good { color: var(--good-ink); }
.delta.bad { color: var(--critical); }
.delta--light, .delta--light.good, .delta--light.bad { color: #fff; opacity: .92; position: relative; }

/* ================= GRAPHIQUES ================= */
.chart { position: relative; flex: 1; min-height: 260px; }
.chart--tall { min-height: 300px; }
.donut { display: grid; grid-template-columns: 170px 1fr; gap: 22px; align-items: center; min-height: 260px; }
.chart--donut { flex: none; height: 170px; min-height: 0; }
.donut__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut__center small { color: var(--muted); font-size: .74rem; }
.donut__center b { font-size: 1.05rem; }
.legend { display: grid; gap: 9px; font-size: .84rem; min-width: 0; }
.legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend small { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.table-view { max-height: 300px; overflow: auto; }
.table-view table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 7px 8px; border-bottom: 1px solid var(--grid); text-align: right; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.chart-error { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .85rem; text-align: center; padding: 20px; }

/* Légende en ligne (en-tête de carte) */
.key { display: flex; gap: 16px; font-size: .8rem; color: var(--ink-2); flex-wrap: wrap; }
.key > span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 3px; }

/* Comparaison par catégorie (deux barres : ce mois-ci / mois précédent) */
.compare { display: grid; gap: 4px; }
.cmp { display: grid; grid-template-columns: minmax(150px, 220px) 1fr minmax(150px, 190px); gap: 18px; align-items: center; padding: 10px 6px; border-radius: 12px; }
.cmp:hover { background: var(--surface-2); }
.cmp__name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; }
.cmp__bars { display: grid; gap: 4px; }
.cmp__bars i { display: block; height: 10px; border-radius: 0 6px 6px 0; min-width: 2px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.cmp__bars .cur { background: var(--s1); }
.cmp__bars .prev { background: var(--muted); opacity: .55; height: 6px; }
.cmp__val { text-align: right; font-variant-numeric: tabular-nums; }
.cmp__val b { display: block; }
.cmp__val small { color: var(--muted); font-size: .76rem; display: block; }

/* ================= ANALYSES ================= */
.insights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.insight { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 10px; align-content: start; transition: transform .2s; }
.insight:hover { transform: translateY(-3px); }
.insight small { color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.insight b { font-size: 1.3rem; letter-spacing: -.02em; }
.insight p { color: var(--ink-2); font-size: .86rem; }

/* Habitudes : barres par jour de la semaine */
.weekbars { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: 1fr; gap: 14px; height: 250px; padding-top: 26px; }
.wbar { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; padding: 0; min-width: 0; }
.wbar__track { position: relative; flex: 1; width: 100%; display: flex; justify-content: center; align-items: flex-end; }
.wbar i { width: 100%; max-width: 46px; height: var(--h); min-height: 3px; border-radius: 8px 8px 3px 3px; background: color-mix(in srgb, var(--s1) 45%, transparent); transition: height .6s cubic-bezier(.2, .8, .2, 1), background .2s; }
.wbar--max i { background: var(--s1); }
.wbar:hover i, .wbar:focus-visible i { background: var(--s1); }
.wbar small { font-size: .76rem; color: var(--muted); font-weight: 600; }
.wbar__val { position: absolute; left: 50%; bottom: calc(var(--h) + 6px); transform: translateX(-50%); font-size: .76rem; font-weight: 700; white-space: nowrap; opacity: 0; transition: opacity .15s; font-variant-numeric: tabular-nums; }
.wbar--max .wbar__val, .wbar:hover .wbar__val, .wbar:focus-visible .wbar__val { opacity: 1; }
.habit-note { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: .86rem; }
.habit-note b { color: var(--ink); }

/* Top dépenses */
.top-list { display: grid; gap: 4px; counter-reset: top; }
.top-list li { display: grid; grid-template-columns: 22px 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 12px; counter-increment: top; }
.top-list li::before { content: counter(top); font-size: .8rem; font-weight: 700; color: var(--muted); text-align: center; }
.top-list li:hover { background: var(--surface-2); }
.top-list small { display: block; color: var(--muted); font-size: .76rem; }
.top-list b { font-variant-numeric: tabular-nums; }
.top-list .share { height: 4px; border-radius: 99px; background: var(--surface-2); margin-top: 5px; overflow: hidden; }
.top-list .share i { display: block; height: 100%; background: var(--s2); border-radius: 99px; }

/* ================= CALENDRIER ================= */
.heat { display: grid; gap: 8px; }
.heat__days, .heat__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.heat__days span { text-align: center; font-size: .74rem; color: var(--muted); font-weight: 600; }
/* min-width: 0 : sans lui, le ratio + la hauteur max imposent une largeur minimale qui déborde sur mobile */
.cell { position: relative; min-width: 0; aspect-ratio: 1.45; max-height: 64px; border: 0; border-radius: 12px; background: var(--h0); font-size: .78rem; font-weight: 600; color: var(--ink-2); display: flex; align-items: flex-start; justify-content: flex-start; padding: 6px 9px; transition: transform .12s, box-shadow .12s; }
.cell[data-l="1"] { background: var(--h1); } .cell[data-l="2"] { background: var(--h2); }
.cell[data-l="3"] { background: var(--h3); color: #fff; } .cell[data-l="4"] { background: var(--h4); color: #fff; } .cell[data-l="5"] { background: var(--h5); color: #fff; }
:root[data-theme="dark"] .cell[data-l="5"] { color: #0b0b0b; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .cell[data-l="5"] { color: #0b0b0b; } }
.cell:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--s1); }
.cell.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.cell.today::after { content: ""; position: absolute; right: 8px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cell:disabled { opacity: .35; cursor: default; }
.cell--empty { background: none; pointer-events: none; }
.heat__legend { display: flex; align-items: center; gap: 5px; justify-content: flex-end; margin-top: 16px; font-size: .74rem; color: var(--muted); }
.heat__legend i { width: 16px; height: 12px; border-radius: 3px; background: var(--h0); }
.heat__legend i[data-l="1"] { background: var(--h1); } .heat__legend i[data-l="2"] { background: var(--h2); } .heat__legend i[data-l="3"] { background: var(--h3); }
.heat__legend i[data-l="4"] { background: var(--h4); } .heat__legend i[data-l="5"] { background: var(--h5); }
.tooltip { position: fixed; z-index: 70; pointer-events: none; padding: 8px 11px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: .8rem; line-height: 1.35; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; }
.tooltip b { display: block; }

/* Détail du jour sélectionné */
.day-panel h2 { font-size: 1.25rem; margin: 4px 0 2px; }
.day-total { color: var(--ink-2); font-size: .9rem; margin-bottom: 14px; }
.day-total b { color: var(--ink); }
.facts { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--grid); }
.facts ul { display: grid; gap: 10px; margin-top: 10px; }
.facts li { display: flex; justify-content: space-between; gap: 12px; font-size: .86rem; color: var(--ink-2); }
.facts li b { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }

/* ================= BUDGETS ================= */
.budgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.budget { padding: 16px; border-radius: 16px; background: var(--surface-2); }
.budget__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .88rem; margin-bottom: 10px; }
.budget__name { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.budget__val { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .82rem; white-space: nowrap; }
.budget__val b { color: var(--ink); }
.bar { height: 8px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--s1); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.budget--warn .bar i { background: var(--warning); }
.budget--over .bar i { background: var(--critical); }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 600; margin-top: 8px; color: var(--muted); }
.budget--over .status { color: var(--critical); }
.status svg { width: 14px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.budget--ok .status svg { stroke: var(--good); }
.budget--warn .status svg { stroke: var(--warning); }
.budget--over .status svg { stroke: var(--critical); }

/* ================= OBJECTIFS ================= */
.goals { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.goal { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 26px 20px 20px; background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .2s; }
.goal:hover { transform: translateY(-3px); }
.ring { position: relative; width: 110px; height: 110px; margin-bottom: 8px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .ring__bg { stroke: var(--surface-2); }
.ring .ring__fg { stroke: var(--s1); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.goal--done .ring__fg { stroke: var(--good); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.goal > b { font-size: 1.02rem; }
.goal p { font-size: .84rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.goal .left { color: var(--muted); font-size: .8rem; }
.goal--done .left { color: var(--good-ink); font-weight: 600; }
.goal__actions { display: flex; gap: 16px; margin-top: 10px; }

/* ================= PRÉLÈVEMENTS ================= */
.bills { display: grid; gap: 4px; }
.bill { display: grid; grid-template-columns: 38px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .9fr) auto; gap: 16px; align-items: center; padding: 12px 8px; border-radius: 12px; }
.bill:hover { background: var(--surface-2); }
.bill b { display: block; }
.bill small { display: block; color: var(--muted); font-size: .78rem; }
.bill__when { color: var(--ink-2); font-size: .86rem; }
.bill__next { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bill__next small { display: inline; }
.bill__amount { text-align: right; font-variant-numeric: tabular-nums; }
.due { display: inline-block; font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.bill:hover .due { background: var(--surface); }
.due--soon { background: color-mix(in srgb, var(--warning) 22%, transparent) !important; color: var(--ink); }

/* ================= PORTEFEUILLE ================= */
.bank-card { position: relative; overflow: hidden; aspect-ratio: 1.62; max-height: 230px; border-radius: 18px; padding: 20px 22px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(circle at 110% -10%, rgba(255, 255, 255, .22), transparent 45%), linear-gradient(135deg, #1b1d29 0%, #2b2f4a 55%, #4f5fd9 140%); box-shadow: 0 14px 30px rgba(17, 18, 20, .25); margin-bottom: 18px; }
.bank-card::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; border: 30px solid rgba(255, 255, 255, .04); right: -90px; bottom: -110px; }
.bank-card__top { display: flex; justify-content: space-between; align-items: center; }
.bank-card__brand { font-weight: 800; letter-spacing: -.02em; font-size: 1.15rem; }
.bank-card__chip { width: 40px; height: 30px; border-radius: 6px; background: linear-gradient(135deg, #e9d48c, #b8954a); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.bank-card__num { font-size: 1.1rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; opacity: .95; }
.bank-card__bottom { display: flex; align-items: flex-end; gap: 22px; position: relative; z-index: 1; }
.bank-card__bottom small { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; opacity: .65; }
.bank-card__bottom b { font-size: .85rem; font-weight: 600; }
.bank-card__logo { margin-left: auto; display: flex; }
.bank-card__logo i { width: 26px; height: 26px; border-radius: 50%; background: #eb6834; opacity: .9; }
.bank-card__logo i + i { background: #eda100; margin-left: -10px; opacity: .85; }
.card-info { display: grid; gap: 4px; }
.card-info li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--grid); font-size: .88rem; color: var(--ink-2); }
.card-info li:last-child { border-bottom: 0; }
.card-info li > b { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.card-info .limit { display: block; }
.card-info .limit__top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-info .limit b { color: var(--ink); font-variant-numeric: tabular-nums; }
.card-info .bar { background: var(--surface-2); }
.badge-ok { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--good-ink); }
.badge-ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.accounts { display: grid; gap: 4px; }
.accounts li { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-radius: 12px; }
.accounts li:hover { background: var(--surface-2); }
.accounts small { display: block; color: var(--muted); font-size: .76rem; }
.accounts b { font-variant-numeric: tabular-nums; }
.accounts .total { border-top: 1px dashed var(--grid); border-radius: 0; margin-top: 4px; padding-top: 14px; }
.accounts .total > b { font-size: 1.15rem; }
.split { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface); }
.split i { display: block; height: 100%; transition: flex-grow .6s; }
.split-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; font-size: .84rem; color: var(--ink-2); }
.split-legend li { display: inline-flex; align-items: center; gap: 8px; }
.split-legend i { width: 10px; height: 10px; border-radius: 3px; }
.split-legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ================= OPÉRATIONS ================= */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--ring); border-radius: 12px; background: var(--surface-2); }
.search:focus-within { border-color: var(--s1); }
.search svg { width: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 10px 0; outline: none; }
select { padding: 10px 12px; border: 1px solid var(--ring); border-radius: 12px; background: var(--surface-2); }
.table-wrap { max-height: calc(100vh - 290px); min-height: 300px; overflow: auto; margin: 0 -8px; }
.tx { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tx th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-size: .74rem; font-weight: 600; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--grid); }
.tx td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tx tr:hover td { background: var(--surface-2); }
.tx .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.tx .in { color: var(--good-ink); }
.tx-op { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.tx td.date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: .84rem; }
.cat-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--ink-2); white-space: nowrap; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); }
.cat-pill i { width: 7px; height: 7px; border-radius: 50%; }
.edit-btn { border: 0; background: none; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); }
.edit-btn:hover { background: var(--surface); color: var(--ink); }
.edit-btn svg { width: 16px; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: .9rem; }

/* ================= FENÊTRES ================= */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(10, 12, 20, .5); backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal__card { position: relative; width: min(440px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: 22px; padding: 28px; border: 1px solid var(--ring); animation: pop .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal__card h2 { font-size: 1.25rem; margin-bottom: 18px; padding-right: 30px; }
.modal__card > .muted { margin: -10px 0 16px; }
.modal__close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 10px; border: 0; background: var(--surface-2); }
.modal label { display: grid; gap: 6px; font-size: .84rem; font-weight: 600; margin-bottom: 14px; color: var(--ink-2); }
.modal input, .modal select { width: 100%; padding: 11px 12px; border: 1px solid var(--ring); border-radius: 12px; background: var(--surface-2); font-weight: 400; color: var(--ink); outline: none; }
.modal input:focus, .modal select:focus { border-color: var(--s1); }
.modal .invalid { border-color: var(--critical); }
.money-input { position: relative; }
.money-input span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money-input input { padding-left: 26px; font-size: 1.05rem; font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; }
.btn-row .btn { flex: 1; }
.error { color: var(--critical); font-size: .84rem; min-height: 1.2em; margin-bottom: 10px; }
.budget-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translateX(-50%); padding: 11px 18px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: .88rem; font-weight: 500; animation: toast .25s; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ================= RESPONSIVE ================= */
@media (max-width: 1320px) {
  .span-5, .span-7 { grid-column: span 6; }
  .span-4 { grid-column: span 5; } .span-8 { grid-column: span 7; }
  .insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bill { grid-template-columns: 38px minmax(0, 1.4fr) minmax(0, 1fr) auto; }
  .bill__when { display: none; }
}
@media (max-width: 1080px) {
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .main { padding: 22px 20px 40px; }
  .budgets { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; overflow-x: auto; overflow-y: hidden; }
  .logo__text, .side__nav a span, .side__label, .side__foot, .tip { display: none; }
  .side__nav { display: flex; gap: 2px; }
  .side__nav a { padding: 9px 10px; }
  .side__nav a.active { box-shadow: inset 0 -3px 0 #6d8dff; }
  .tiles { grid-template-columns: 1fr; }
  .cmp { grid-template-columns: 1fr auto; }
  .cmp__bars { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 560px) {
  .kpis, .insights { grid-template-columns: 1fr; }
  .donut { grid-template-columns: 1fr; justify-items: center; }
  .legend { width: 100%; }
  .row, .budget-fields { grid-template-columns: 1fr; }
  .top__actions { width: 100%; }
  .top__actions .btn { flex: 1; }
  .tx th:nth-child(2), .tx td:nth-child(2) { display: none; }
  .hero__value { font-size: 2.1rem; }
  .heat__days, .heat__grid { gap: 5px; }
  .cell { padding: 4px 5px; font-size: .68rem; border-radius: 8px; }
  .bill { grid-template-columns: 38px minmax(0, 1fr) auto; row-gap: 6px; }
  .bill > .ic { grid-row: 1 / span 2; }
  .bill__next { grid-column: 2; grid-row: 2; }
  .bill__amount { grid-column: 3; grid-row: 1 / span 2; }
  .weekbars { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
