/* Franko — interface.
   Concept : un relevé de banque suisse lisible. Fond neutre vert-de-gris, une couleur de marque (pétrole),
   une couleur par enveloppe reprise partout (icônes, barres, calcul). */
:root {
  --bg: #f2f4f3; --surface: #ffffff; --surface-2: #edf0ef; --ink: #15211f; --muted: #5d6b69; --faint: #8a9795; --line: #e0e5e3;
  --primary: #0d5c57; --primary-ink: #ffffff; --primary-soft: #dfeeec;
  --fixed: #3d62a6; --daily: #b4741a; --savings: #23855a; --invest: #6a54ad; --income: #23855a; --transfer: #5d6b69;
  --danger: #b3322a; --danger-soft: #fbe8e5; --warn: #8f5d10; --warn-soft: #fbf1dc; --info: #2c5b98; --info-soft: #e5edf8; --ok: #23855a; --ok-soft: #e1f2e9;
  /* graphiques : palette validée daltonisme (clair / sombre) */
  --c-income: #1baf7a; --c-fixed: #2a78d6; --c-daily: #eb6834;
  --shadow: 0 1px 2px rgba(21, 33, 31, .05), 0 6px 18px rgba(21, 33, 31, .05);
  --toast-action: #7fe0d8;
  --font-ui: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-fig: "Manrope", "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px; --radius-s: 12px; --nav-h: 64px; --quick-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1413; --surface: #161e1d; --surface-2: #1e2827; --ink: #e5edeb; --muted: #97a7a4; --faint: #6d7d7a; --line: #26312f;
    --primary: #5cc3b9; --primary-ink: #05201d; --primary-soft: #14302d;
    --fixed: #8daae2; --daily: #e8b15a; --savings: #5fcf98; --invest: #b5a1ec; --income: #5fcf98; --transfer: #97a7a4;
    --danger: #ff8e7c; --danger-soft: #391c18; --warn: #efc46b; --warn-soft: #322819; --info: #94bdf2; --info-soft: #18283a; --ok: #5fcf98; --ok-soft: #15302a;
    --c-income: #199e70; --c-fixed: #3987e5; --c-daily: #d95926;
    --toast-action: #0b5c58; --shadow: 0 1px 2px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1413; --surface: #161e1d; --surface-2: #1e2827; --ink: #e5edeb; --muted: #97a7a4; --faint: #6d7d7a; --line: #26312f;
  --primary: #5cc3b9; --primary-ink: #05201d; --primary-soft: #14302d;
  --fixed: #8daae2; --daily: #e8b15a; --savings: #5fcf98; --invest: #b5a1ec; --income: #5fcf98; --transfer: #97a7a4;
  --danger: #ff8e7c; --danger-soft: #391c18; --warn: #efc46b; --warn-soft: #322819; --info: #94bdf2; --info-soft: #18283a; --ok: #5fcf98; --ok-soft: #15302a;
  --c-income: #199e70; --c-fixed: #3987e5; --c-daily: #d95926;
  --toast-action: #0b5c58; --shadow: 0 1px 2px rgba(0, 0, 0, .35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.45 var(--font-ui); font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--nav-h) + var(--quick-h) + env(safe-area-inset-bottom) + 20px); min-height: 100vh;
}
body.no-quick { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--font-fig); text-wrap: balance; }
h2 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--danger); } .pos { color: var(--income); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cap { text-transform: capitalize; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.brand { flex: none; display: flex; align-items: center; gap: 8px; font: 800 1.1rem/1 var(--font-fig); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand svg { color: var(--primary); width: 26px; height: 26px; }
#periodLabel { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-weight: 600; }
.sync { white-space: nowrap; flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.sync.ok::before { background: var(--ok); } .sync.busy::before, .sync.pending::before { background: var(--daily); } .sync.err::before { background: var(--danger); }

main { max-width: 560px; margin: 0 auto; padding: 4px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); outline: none; display: grid; gap: 22px; }
main > * { min-width: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 8px; }
.section-head .sub { color: var(--muted); font-size: .84rem; text-align: right; }
.link { color: var(--primary); text-decoration: none; font-weight: 650; font-size: .88rem; background: none; border: 0; padding: 0; cursor: pointer; }
.eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.card.flush { padding: 2px 16px; }
.stack-v { display: grid; gap: 12px; }

/* résumé */
.hero { display: grid; gap: 12px; padding: 18px 18px 16px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.big { font: 800 2.5rem/1.05 var(--font-fig); letter-spacing: -.03em; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.big .cur { font-size: 1rem; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.hero .sub { color: var(--muted); font-size: .92rem; margin-top: -4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.beta { background: var(--primary-soft); color: var(--primary); }
.bank-line { display: grid; gap: 2px; font-size: .86rem; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-s); padding: 10px 12px; }
.bank-line b { color: var(--ink); font-weight: 650; } .bank-line b.neg { color: var(--danger); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.meter > i { display: block; height: 100%; background: var(--c, var(--primary)); }
.meter.over > i { background: var(--danger); } .meter.thin { height: 5px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 2px 0 0; border-top: 1px solid var(--line); padding-top: 12px; }
.stats > div { min-width: 0; padding: 0 8px; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; padding-left: 0; }
.stats dt { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd { margin: 2px 0 0; font: 700 1rem/1.2 var(--font-fig); white-space: nowrap; }
.stats.plain { border: 0; padding: 14px 0 4px; }

/* calcul */
.calc { display: grid; gap: 14px; }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.stack > i { display: block; height: 100%; min-width: 3px; }
.stack > i.due { background: repeating-linear-gradient(135deg, var(--fixed) 0 3px, color-mix(in srgb, var(--fixed) 45%, transparent) 3px 6px) !important; }
.flow { display: grid; font-size: .92rem; }
.flow-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: baseline; column-gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.flow-row:first-child { border-top: 0; }
.flow-row .key { width: 10px; height: 10px; border-radius: 3px; background: var(--c, transparent); align-self: center; }
.flow-row small { display: block; font-size: .78rem; color: var(--muted); margin-top: 1px; }
.flow-row.sum { font-weight: 700; background: var(--surface-2); margin: 0 -16px; padding: 8px 16px; border-top: 0; }
.flow-row.sum + .flow-row { border-top: 0; }
.flow-row.pending { color: var(--muted); }
.flow-row .soft { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1px; }
.flow-row.total { font: 800 1.05rem/1.3 var(--font-fig); border-top: 2px solid var(--ink); padding-top: 10px; }
button.flow-row { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 12px 1fr auto; align-items: baseline; column-gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); cursor: pointer; width: 100%; }
button.flow-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list li:last-child { border-bottom: 0; }
.ic { --c: var(--transfer); width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: var(--c); }
.ic svg { width: 20px; height: 20px; }
.ic.fixed { --c: var(--fixed); } .ic.daily { --c: var(--daily); } .ic.savings { --c: var(--savings); } .ic.invest { --c: var(--invest); }
.ic.income { --c: var(--income); } .ic.transfer { --c: var(--transfer); } .ic.brand { --c: var(--primary); }
.list .main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.list .title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { display: flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta svg { width: 13px; height: 13px; stroke-width: 2.2; color: var(--ok); }
.list .meta b { color: var(--ink); font-weight: 650; }
.list button.row { all: unset; display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.list button.row:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 8px; }
.list .partial { margin-top: 5px; max-width: 160px; }
.group-label { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 0 2px; }
details.paid > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; font-size: .9rem; font-weight: 600; color: var(--muted); border-top: 1px solid var(--line); }
details.paid > summary::-webkit-details-marker { display: none; }
details.paid > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -4px 4px 0 0; }
details.paid[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.day { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: capitalize; padding: 14px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.tag { display: inline-block; font-size: .7rem; font-weight: 650; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag.dup { background: var(--warn-soft); color: var(--warn); } .tag.tr { background: var(--info-soft); color: var(--info); } .tag.ok { background: var(--ok-soft); color: var(--ok); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }

.state { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px 0 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .84rem; font-weight: 650; cursor: pointer; white-space: nowrap; }
.state .box { width: 18px; height: 18px; border-radius: 50%; border: 1.6px solid var(--faint); display: grid; place-items: center; }
.state .box svg { width: 12px; height: 12px; stroke-width: 3; opacity: 0; }
.state.done { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.state.done .box { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.state.done .box svg { opacity: 1; }
.state:not(.done):hover { border-color: var(--primary); color: var(--primary); }

.notes { display: grid; }
.note { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.note:first-child { border-top: 0; padding-top: 0; } .note:last-child { padding-bottom: 0; }
.note::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--info)); }
.note.danger { --c: var(--danger); } .note.warn { --c: var(--warn); } .note.info { --c: var(--info); }

.gauge { display: flex; align-items: center; gap: 14px; }
.gauge .ring { --p: 0; width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 700 .8rem/1 var(--font-fig); background: radial-gradient(closest-side, var(--surface) 78%, transparent 79%), conic-gradient(var(--savings) calc(var(--p) * 1%), var(--surface-2) 0); }
.gauge > div:last-child { min-width: 0; display: grid; gap: 2px; }
.split-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; gap: 2px; }
.legend { display: grid; gap: 4px 12px; font-size: .82rem; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); flex: none; }
.legend b { color: var(--ink); font-weight: 650; margin-left: auto; }
.legend.inline { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend.inline span { flex: none; }

.tax-card { all: unset; box-sizing: border-box; display: flex; gap: 14px; align-items: flex-start; width: 100%; cursor: pointer; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.tax-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tax-card .main { display: grid; gap: 4px; min-width: 0; } .tax-card .big { font-size: 1.7rem; }

/* mois par mois */
.hist { display: grid; gap: 12px; }
.hchart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; align-items: end; border-bottom: 1px solid var(--line); padding-top: 4px; }
.hcol { all: unset; box-sizing: border-box; display: grid; justify-items: center; gap: 6px; cursor: pointer; padding: 4px 0 6px; border-radius: 10px; min-width: 0; }
.hcol.on { background: var(--surface-2); }
.hcol:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hbars { display: flex; align-items: flex-end; gap: 2px; }
.hbar { width: 14px; display: flex; flex-direction: column-reverse; gap: 2px; }
.hbar.inc { background: var(--c-income); border-radius: 4px 4px 0 0; }
.hbar.out > i { display: block; width: 100%; }
.hbar.out > i:last-child { border-radius: 4px 4px 0 0; }
.hlab { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.hcol.on .hlab { color: var(--ink); }
.htable { overflow-x: auto; }
.htable table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.htable th, .htable td { padding: 7px 3px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.htable thead th { border-top: 0; font-size: .74rem; color: var(--muted); font-weight: 650; }
.htable th[scope=row], .htable thead th:first-child { text-align: left; }
.htable th[scope=row] .link { text-transform: capitalize; }
.htable tr.on th, .htable tr.on td { font-weight: 700; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 99px; white-space: nowrap; cursor: pointer; font-size: .86rem; font-weight: 550; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 16px; border-radius: var(--radius-s); font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; text-decoration: none; color: var(--ink); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { color: var(--danger); } .btn.block { width: 100%; } .btn:disabled { opacity: .5; cursor: default; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; } .row-btns > .btn { flex: 1; }
label.field { display: grid; gap: 5px; font-size: .84rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 46px; font-size: 1rem; font-weight: 450; min-width: 0; }
.field input:focus, .field select:focus, .quick input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--ink); }
.form { display: grid; gap: 12px; }
.hint { font-size: .82rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .grid2 > * { min-width: 0; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 3px; border-radius: 12px; }
.seg label { text-align: center; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
input[type="range"] { accent-color: var(--primary); width: 100%; }
input[type="checkbox"] { accent-color: var(--primary); width: 20px; height: 20px; flex: none; margin: 0; }
.split-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 6px; }
.split-row select { grid-column: 1 / -1; }
.split-row input, .split-row select { width: 100%; padding: 10px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 42px; font-size: 1rem; min-width: 0; }
.split-row + .split-row { border-top: 1px solid var(--line); padding-top: 10px; }
.imp-row { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.imp-row:first-child { border-top: 0; }
.imp-row .t { font-weight: 600; overflow-wrap: anywhere; } .imp-row .s { font-size: .8rem; color: var(--muted); }

.quick { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 6px; align-items: center; padding: 10px max(12px, calc((100% - 536px) / 2)) 8px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.quick input { flex: 1; min-width: 0; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; box-shadow: var(--shadow); font-size: 1rem; }
.icon-btn { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: var(--shadow); padding: 0; }
.icon-btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.icon-btn.rec { background: var(--danger); color: var(--surface); border-color: var(--danger); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.tabs button { border: 0; background: none; display: grid; justify-items: center; align-content: center; gap: 3px; font-size: .7rem; font-weight: 550; color: var(--muted); cursor: pointer; padding: 0; position: relative; }
.tabs button[aria-current="page"] { color: var(--primary); font-weight: 700; }
.tabs button[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }

dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); width: min(520px, 100vw); max-width: 100vw; max-height: 92vh; border-radius: 22px 22px 0 0; margin: auto auto 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); }
dialog::backdrop { background: rgba(10, 16, 15, .5); }
@media (min-width: 600px) { dialog { border-radius: 22px; margin: auto; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 4px; }
.dlg-head h2 { font-size: 1.12rem; }
.dlg-body { padding: 12px 16px 16px; overflow: auto; max-height: calc(92vh - 60px); }
.dlg-foot { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 calc(4px + env(safe-area-inset-bottom)); }
.close { border: 0; background: var(--surface-2); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; line-height: 1; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--quick-h) + env(safe-area-inset-bottom) + 10px); z-index: 20; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100vw - 32px); font-size: .92rem; }
.toast button { background: none; border: 0; color: var(--toast-action); font-weight: 700; cursor: pointer; padding: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===================== finitions UX / UI ===================== */
/* tableau d'accueil : une colonne sur téléphone, deux sur grand écran */
.dash { display: grid; gap: 22px; }
.dash > .col { display: grid; gap: 22px; align-content: start; min-width: 0; }

/* graphiques */
.chart-card { display: grid; gap: 10px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; stroke: none; stroke-width: 0; }
.chart .axis { fill: var(--muted); font: 500 11px var(--font-ui); }
.chart .gridl { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .cross { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; transition: opacity .12s; }
.chart .cross.on { opacity: 1; }
.legend.inline span.dash::before { background: none; border-top: 2px dashed var(--c); height: 0; width: 14px; border-radius: 0; }
.tip { position: absolute; z-index: 30; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 11px; font-size: .8rem; line-height: 1.4; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); box-shadow: 0 8px 24px rgba(0, 0, 0, .22); }
.tip b { font-weight: 700; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.hcol .hbars { transition: transform .15s ease; }
.hcol:hover .hbars { transform: translateY(-2px); }

/* catégories du quotidien */
.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cats li { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; }
.cat-main { display: grid; gap: 6px; min-width: 0; }
.cat-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; font-weight: 600; }
.cat-top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-pct { font-size: .8rem; color: var(--muted); width: 3.2em; text-align: right; }

/* boutons : retour visuel net, sans effet gadget */
.btn, .chip, .state, .icon-btn, .link, .tabs button, .tax-card, .list button.row { transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease; -webkit-tap-highlight-color: transparent; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); border-color: transparent; }
.btn:active, .chip:active, .state:active, .icon-btn:active, .tax-card:active { transform: scale(.98); }
.btn:focus-visible, .chip:focus-visible, .state:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon-btn:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.icon-btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); }
.list button.row:hover .title { color: var(--primary); }
.tax-card:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.chip:hover:not([aria-pressed="true"]) { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.field input, .field select, .quick input { transition: border-color .15s ease, box-shadow .15s ease; }
.field input:hover, .field select:hover { border-color: color-mix(in srgb, var(--ink) 18%, var(--line)); }

/* mouvements doux : apparition de vue, feuille de dialogue, notification */
@media (prefers-reduced-motion: no-preference) {
  #view.enter { animation: viewIn .22s ease-out; }
  @keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
  dialog[open] { animation: sheetIn .24s cubic-bezier(.2, .8, .2, 1); }
  dialog[open]::backdrop { animation: fadeIn .2s ease-out; }
  @keyframes sheetIn { from { transform: translateY(32px); opacity: .4; } }
  @keyframes fadeIn { from { opacity: 0; } }
  .toast:not([hidden]) { animation: toastIn .22s cubic-bezier(.2, .8, .2, 1); }
  @keyframes toastIn { from { transform: translate(-50%, 12px); opacity: 0; } }
  .meter > i, .split-bar > i { transition: width .45s cubic-bezier(.2, .8, .2, 1); }
}

/* grand écran : navigation latérale, contenu sur deux colonnes */
@media (min-width: 960px) {
  body { padding-left: 240px; padding-bottom: calc(var(--quick-h) + 28px); }
  body.no-quick { padding-bottom: 40px; }
  .top { padding-left: 32px; padding-right: 32px; }
  .top .brand { display: none; }
  main { max-width: 1180px; padding: 8px 32px 0; }
  .dash { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); align-items: start; }
  .tabs { top: 0; right: auto; width: 240px; height: auto; grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 4px; padding: 84px 14px 24px; border-top: 0; border-right: 1px solid var(--line); }
  .tabs::before { content: "Franko"; position: absolute; top: 24px; left: 26px; font: 800 1.25rem/1 var(--font-fig); letter-spacing: -.02em; color: var(--ink); padding-left: 36px; background: no-repeat left center / 26px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%230d5c57'/%3E%3Cpath d='M22 46V18h22M22 32h16' fill='none' stroke='%23fff' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); line-height: 26px; }
  .tabs button { grid-auto-flow: column; justify-content: start; justify-items: start; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; font-size: .95rem; font-weight: 600; }
  .tabs button:hover { background: var(--surface-2); color: var(--ink); }
  .tabs button[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  .tabs button[aria-current="page"]::before { display: none; }
  .quick { left: 240px; padding: 12px max(32px, calc((100vw - 240px - 1180px) / 2 + 32px)) 16px; }
  .toast { left: calc(50% + 120px); bottom: calc(var(--quick-h) + 24px); }
  .big { font-size: 2.9rem; }
  .card { padding: 18px 20px; }
  .card.flush { padding: 2px 20px; }
  .flow-row.sum { margin: 0 -20px; padding: 8px 20px; }
}

/* feuille de saisie : type, gros montant, dictée */
.seg.kind label.k-exp:has(input:checked) { color: var(--danger); }
.seg.kind label.k-inc:has(input:checked) { color: var(--income); }
.amount-field { display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--line); padding: 6px 2px 8px; transition: border-color .15s ease; }
.amount-field:focus-within { border-color: var(--primary); }
.amount-field .cur { font: 700 1rem var(--font-fig); color: var(--muted); }
.amount-field input { flex: 1; min-width: 0; border: 0; background: none; font: 800 2.4rem/1.1 var(--font-fig); letter-spacing: -.02em; color: var(--ink); padding: 0; outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn.dictate { width: 100%; border-style: dashed; color: var(--primary); }
.btn.dictate.rec { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
@media (prefers-reduced-motion: no-preference) { .btn.dictate.rec svg { animation: pulse 1s ease-in-out infinite; } @keyframes pulse { 50% { transform: scale(1.18); } } }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hero-actions .btn { min-height: 42px; }
/* Apple Pay / Wallet */
.steps-list { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; font-size: .88rem; color: var(--ink); }
.copy-row { display: flex; gap: 8px; align-items: stretch; min-width: 0; }
.copy-row code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: var(--surface-2); border-radius: 10px; padding: 11px 12px; font: 500 .78rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); scrollbar-width: thin; }
.copy-row .btn { flex: none; min-height: 42px; }
/* cibles tactiles : liens d'action d'au moins 36 px de haut */
button.link { min-height: 36px; padding: 6px 2px; }
.brand { min-height: 40px; }
/* feuille de dialogue : jamais plus large que l'écran, même sur 320 px */
dialog { width: 100%; max-width: min(520px, 100%); box-sizing: border-box; }
dialog > form, .dlg-body, .dlg-body > * { min-width: 0; max-width: 100%; }
.dlg-body { overflow-x: hidden; }
.field input[type="date"] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }
/* tablette en portrait : deux colonnes dès 720 px */
@media (min-width: 720px) and (max-width: 959px) {
  main { max-width: 920px; }
  .dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
/* téléphone en paysage : barres plus compactes pour garder de la place au contenu */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --nav-h: 50px; --quick-h: 56px; }
  .tabs button { grid-auto-flow: column; gap: 8px; font-size: .8rem; }
  .tabs button svg { width: 20px; height: 20px; }
  .quick { padding-top: 6px; padding-bottom: 6px; }
  .big { font-size: 2.1rem; }
}
.form { grid-template-columns: minmax(0, 1fr); }
.amount-field input { width: 100%; }

/* ===================== motion (app) =====================
   Réponses aux actions : courtes, sans file d'attente. Aucun décalage en cascade sur les écrans utilisés chaque jour. */
@media (prefers-reduced-motion: no-preference) {
  .big.bump .num { animation: bump .45s cubic-bezier(.2, .8, .2, 1); display: inline-block; }
  @keyframes bump { 30% { transform: translateY(-2px); } }
  .state.done.pop .box { animation: popBox .4s cubic-bezier(.2, .8, .2, 1); }
  .state.done.pop .box svg { stroke-dasharray: 24; animation: drawCheck .32s cubic-bezier(.645, .045, .355, 1) .08s both; }
  @keyframes popBox { 0% { transform: scale(.55); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
  @keyframes drawCheck { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
  .list li.flash { animation: rowFlash 1.1s ease-out; border-radius: 12px; }
  @keyframes rowFlash { 0% { background: color-mix(in srgb, var(--primary) 16%, transparent); } 100% { background: transparent; } }
  svg.draw .pace-line { stroke-dasharray: 1; animation: drawLine .9s cubic-bezier(.645, .045, .355, 1) both; }
  svg.draw .pace-area { animation: fadeArea .6s ease .5s both; }
  svg.draw .pace-dot { animation: popDot .35s cubic-bezier(.2, .8, .2, 1) .85s both; transform-box: fill-box; transform-origin: center; }
  @keyframes drawLine { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  @keyframes fadeArea { from { opacity: 0; } }
  @keyframes popDot { from { transform: scale(0); } }
  .hchart.draw .hbar { transform-origin: bottom; animation: grow .55s cubic-bezier(.2, .8, .2, 1) both; }
  .hchart.draw .hcol:nth-child(2) .hbar { animation-delay: 40ms; }
  .hchart.draw .hcol:nth-child(3) .hbar { animation-delay: 75ms; }
  .hchart.draw .hcol:nth-child(4) .hbar { animation-delay: 105ms; }
  .hchart.draw .hcol:nth-child(5) .hbar { animation-delay: 130ms; }
  .hchart.draw .hcol:nth-child(n+6) .hbar { animation-delay: 150ms; }
  @keyframes grow { from { transform: scaleY(0); } }
}

/* ressorts : mêmes courbes que la page de présentation */
/* la vue glisse de côté : sans ce clip, le débordement passager fait dézoomer les téléphones */
html, body { overflow-x: clip; }
:root { --spring: cubic-bezier(.2, .9, .25, 1.15); --spring-dur: .5s; }
@supports (transition-timing-function: linear(0, 1)) {
  :root { --spring: linear(0, .009, .035 2.1%, .141 4.4%, .723 12.9%, .938 16.7%, 1.017 19.5%, 1.061 22.6%, 1.074 25.6%, 1.061 29.5%, 1.004 38.7%, .99 43.4%, .997 55%, 1); --spring-dur: .55s; }
}
@media (prefers-reduced-motion: no-preference) {
  #view.enter { animation: viewSlide .42s var(--spring); }
  @keyframes viewSlide { from { opacity: 0; transform: translateX(calc(var(--dir, 0) * 18px)) translateY(calc((1 - var(--dir, 0) * var(--dir, 0)) * 6px)); } }
  dialog[open] { animation: sheetIn var(--spring-dur) var(--spring); }
  @keyframes sheetIn { from { transform: translateY(48px); opacity: 0; } }
  .toast:not([hidden]) { animation: toastIn .45s var(--spring); }
  @keyframes toastIn { from { transform: translate(-50%, 18px) scale(.96); opacity: 0; } }
  .tabs button[aria-current="page"]::before { animation: tabMark .45s var(--spring); }
  @keyframes tabMark { from { transform: scaleX(0); } }
  .tabs button[aria-current="page"] svg { animation: tabIcon .45s var(--spring); }
  @keyframes tabIcon { 40% { transform: translateY(-2px) scale(1.08); } }
  .btn:active, .chip:active, .state:active, .icon-btn:active { transform: scale(.96); }
}

/* première visite : les charges fixes à saisir, en un toucher */
.setup { border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--line)); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); display: grid; gap: 10px; }
.setup h2 { margin: 0; }
.setup .chips { flex-wrap: wrap; overflow: visible; }

/* charge annuelle : les champs suivent la fréquence choisie */
#fixForm[data-freq="month"] [data-when="year"], #fixForm[data-freq="year"] [data-when="month"] { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.list .num small { display: block; font-size: .7rem; font-weight: 500; text-align: right; }
.list.wrapmeta .meta, .list.wrapmeta .title { white-space: normal; overflow: visible; text-overflow: clip; }
.list.wrapmeta .meta { display: block; }

/* catégories avec plafond : la ligne entière se touche */
.cat-btn { all: unset; box-sizing: border-box; display: contents; cursor: pointer; }
.cats li:has(.cat-btn) { cursor: pointer; border-radius: 10px; }
.cats li:has(.cat-btn):hover { background: var(--surface-2); }
.cat-btn:focus-visible > * { outline: 2px solid var(--primary); outline-offset: 2px; }
.cats .num small { font-weight: 500; }
/* 13e salaire / prime */
.bonus { border: 1px solid color-mix(in srgb, var(--savings) 40%, var(--line)); background: color-mix(in srgb, var(--savings) 6%, var(--surface)); display: grid; gap: 8px; }
.bonus h2 { margin: 0; }
.review .big { margin: 2px 0; }

/* prévision du solde */
.forecast .chart svg { width: 100%; height: 96px; display: block; overflow: visible; }
.forecast .chart .zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.forecast .chart .line { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.forecast .chart .area { fill: var(--primary); opacity: .08; stroke: none; }
.forecast .chart .ev { fill: var(--surface); stroke: var(--fixed); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.forecast .chart .low { fill: var(--primary); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.forecast.is-neg .chart .line { stroke: var(--danger); }
.forecast.is-neg .chart .area { fill: var(--danger); }
.forecast.is-neg .chart .low { fill: var(--danger); }
.forecast .note { margin: 8px 0 0; }
.fc-events { list-style: none; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: grid; gap: 4px; font-size: .84rem; }
.fc-events li { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 8px; }
.fc-events li span:first-child { color: var(--muted); }
.fc-events li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* scan de facture QR */
.scan-view { position: relative; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: #0b1211; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-view.off { aspect-ratio: auto; min-height: 72px; background: var(--surface-2); }
.scan-view.off video, .scan-view.off .scan-frame { display: none; }
.scan-frame { position: absolute; inset: 18% 26%; border: 2.5px solid #fff; border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scan-msg { position: absolute; left: 12px; right: 12px; bottom: 10px; margin: 0; color: #fff; font-size: .86rem; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.scan-view.off .scan-msg { position: static; color: var(--muted); padding: 24px 12px; text-shadow: none; }
.scan-msg.err { color: #ffd1c9; }
.scan-view.off .scan-msg.err { color: var(--danger); }
.file-btn { cursor: pointer; }
.qr-card { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); font-size: .88rem; }
.qr-card small { display: block; color: var(--muted); font-size: .76rem; word-break: break-all; }
.row-btns .btn svg, .btn.block svg { width: 18px; height: 18px; }
@media (prefers-reduced-motion: no-preference) { .scan-frame { animation: scanPulse 1.8s ease-in-out infinite; } @keyframes scanPulse { 50% { border-color: color-mix(in srgb, #fff 55%, var(--primary)); } } }
.fc-events li b { color: var(--ink); font-weight: 600; }
