/* Budgest : le cahier de comptes. Papier quadrillé Seyès, encre bleue, surligneur jaune. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #fbfbff;
  --sheet: #ffffff;
  --grid: #e9edfc;
  --grid2: #d3dbf7;
  --ink: #141a52;
  --brand: #1f2a8a;
  --on-brand: #ffffff;
  --muted: #565d8c;
  --line: #d3daf3;
  --pos: #137a52;
  --neg: #c92a1f;
  --neg-soft: #fbe3e0;
  --hl: #ffe45c;
  --hl-neg: #ffb0a8;
  --hl-ink: #141a52;
  --focus: #1f2a8a;
  --shadow: 0 10px 30px rgba(20, 26, 82, .16);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1230;
    --sheet: #151a45;
    --grid: #151b48;
    --grid2: #1f2760;
    --ink: #eceeff;
    --brand: #9aa8ff;
    --on-brand: #0e1230;
    --muted: #a3abdc;
    --line: #2b3376;
    --pos: #61d6a2;
    --neg: #ff8d84;
    --neg-soft: #3a1c2c;
    --hl: #f5d93a;
    --hl-neg: #ff9d94;
    --focus: #c3cbff;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid2) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid2) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px, 12px 12px, 12px 12px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mise en page ---------- */
.app { max-width: 520px; margin: 0 auto; padding: 20px 20px calc(112px + env(safe-area-inset-bottom)); }
.top h1 { font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chip-sync { font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--ink); background: var(--hl); border-radius: 999px; padding: 4px 12px; }
.chip-sync.bad { background: var(--hl-neg); }
.month { display: flex; align-items: center; justify-content: space-between; background: var(--sheet); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 22px; }
.month button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.month button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.month button:active { background: var(--grid); }
.month strong { font-size: 17px; font-weight: 700; text-transform: capitalize; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 12px; }
section { margin-bottom: 26px; }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; padding: 6px 16px; }
.panel.pad { padding: 16px; }
.muted { color: var(--muted); }
.in { color: var(--pos); }
.out { color: var(--neg); }

/* ---------- le moment fort : le reste à vivre, passé au surligneur ---------- */
.hero-label { margin: 0; font-size: 15px; color: var(--muted); font-weight: 500; }
.rav { margin: 4px 0 6px; font-size: clamp(46px, 15vw, 68px); line-height: 1.05; font-weight: 800; letter-spacing: -.035em; color: var(--hl-ink); }
.hl { position: relative; display: inline-block; padding: 0 .14em; margin-left: -.14em; z-index: 0; }
.hl::before { content: ""; position: absolute; left: 0; right: 0; bottom: .04em; height: .56em; background: var(--hl); border-radius: .1em .35em .12em .4em; transform: rotate(-1.4deg); z-index: -1; }
.rav.neg .hl::before { background: var(--hl-neg); }
/* Nuit : le texte reste clair, le surligneur devient un voile translucide pour garder le contraste. */
@media (prefers-color-scheme: dark) {
  .rav { color: var(--ink); }
  .hl::before { background: rgba(245, 217, 58, .42); }
  .rav.neg .hl::before { background: rgba(255, 141, 132, .5); }
}
.rav-sub { margin: 4px 0 18px; font-size: 16px; color: var(--ink); }
.rule { height: 10px; border-radius: 5px; background: var(--grid2); overflow: hidden; margin-bottom: 18px; }
.rule i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 5px; transition: width .35s ease; }
.rule.over i { background: var(--neg); }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.figures div { background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.figures dt { font-size: 14px; color: var(--muted); }
.figures dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- catégories ---------- */
.cat { padding: 12px 0; border-top: 1px solid var(--line); }
.cat:first-child { border-top: 0; }
.cat-head { display: flex; align-items: baseline; gap: 10px; }
.cat-head .e { font-size: 20px; }
.cat-head .n { flex: 1; font-weight: 600; }
.cat-head .m { font-weight: 800; }
.cat-head .m small { font-weight: 500; color: var(--muted); }
.cat .rule { height: 8px; margin: 8px 0 0; background: var(--grid); }
.cat .rule i { background: var(--brand); }
.cat.over .rule i { background: var(--neg); }
.cat .warn { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--neg); }

/* ---------- pistes ---------- */
.tips .panel { padding: 4px 16px 4px 0; }
.tips p { margin: 0; padding: 12px 0 12px 16px; border-left: 4px solid var(--brand); }
.tips p + p { border-top: 1px solid var(--line); }

/* ---------- opérations ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.filters .pill { padding: 8px 11px; font-size: 14px; }
.pill { flex: 0 0 auto; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 8px 14px; min-height: 40px; font-weight: 600; font-size: 15px; }
.pill[aria-pressed="true"], .pill.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 64px; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.tx:first-child { border-top: 0; }
.tx .e { width: 42px; height: 42px; border-radius: 8px; background: var(--grid); display: grid; place-items: center; font-size: 21px; flex: none; }
.tx .t { flex: 1; min-width: 0; }
.tx .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .t small { display: block; color: var(--muted); font-size: 14px; }
.tx .a { font-weight: 800; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; background: var(--hl); color: #141a52; border-radius: 4px; padding: 1px 7px; margin-right: 6px; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty p { margin: 0 0 14px; }

/* ---------- boutons et champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 20px; border-radius: 12px; border: 2px solid var(--brand); background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 16px; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; border-color: var(--neg); color: var(--neg); }
.btn.block { width: 100%; }
.linklike { background: none; border: 0; padding: 10px 6px; min-height: 44px; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
label { display: block; font-size: 15px; font-weight: 600; margin: 16px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search] {
  width: 100%; min-height: 50px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); color: var(--ink); font-size: 17px;
}
input.big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; min-height: 66px; }
input[aria-invalid="true"] { border-color: var(--neg); }
.field-pw { position: relative; }
.field-pw input { padding-right: 96px; }
.field-pw button { position: absolute; right: 4px; top: 4px; bottom: 4px; border: 0; background: none; color: var(--brand); font-weight: 700; padding: 0 12px; border-radius: 8px; }
.check { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; font-weight: 600; }
.check input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.hint.warn { color: var(--ink); background: var(--hl); padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--grid); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; border-radius: 9px; min-height: 44px; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.actions .btn { flex: 1 1 140px; }
.actions .btn.primary-wide { flex-basis: 100%; }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice p { margin: 0; flex: 1; }
.notice .btn { min-height: 44px; padding: 8px 16px; flex: none; }
.msg { margin: 14px 0 0; padding: 10px 14px; border-radius: 8px; font-weight: 600; background: var(--neg-soft); color: var(--neg); }
.msg.ok { background: var(--hl); color: #141a52; }

/* ---------- réglages ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); min-height: 56px; }
.set-row:first-child { border-top: 0; }
.set-row > div { min-width: 0; }
.set-row b { display: block; overflow-wrap: anywhere; }
.set-row small { color: var(--muted); font-size: 14px; }
.stack { display: grid; gap: 10px; padding: 14px 0; }
.stack .btn { justify-content: flex-start; }
.version { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- barre du bas ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--sheet); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs-in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr 76px 1fr; align-items: end; }
.tab { border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 4px; min-height: 56px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--brand); }
.tab[aria-current="page"] span { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; text-decoration-color: var(--hl); }
.add { justify-self: center; width: 60px; height: 60px; margin-top: -26px; border: 4px solid var(--paper); border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; box-shadow: var(--shadow); }
.add svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: round; }
.add:active { transform: scale(.96); }

/* ---------- feuilles (fenêtres du bas) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 13, 40, .5); display: none; z-index: 10; }
.sheet-bg.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; background: var(--sheet); border-radius: 18px 18px 0 0; padding: 20px 20px calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; max-height: 92dvh; overflow: auto; transform: translateY(100%); visibility: hidden; transition: transform .24s ease, visibility 0s .24s; z-index: 11; box-shadow: var(--shadow); }
.sheet.open { transform: none; visibility: visible; transition: transform .24s ease; }
.sheet h3 { margin: 0 0 8px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.limit-row { display: grid; grid-template-columns: 30px 1fr 120px; gap: 8px; align-items: center; margin: 8px 0; }
.limit-row label { margin: 0; font-weight: 500; }
.limit-row input { text-align: right; min-height: 46px; font-size: 16px; }

/* ---------- connexion ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; align-content: center; padding: 28px 22px calc(28px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.brand img { width: 52px; height: 52px; border-radius: 12px; }
.gate h1 { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.03em; margin: 0 0 6px; }
.gate .lead { margin: 0 0 8px; color: var(--muted); }
.gate .btn { margin-top: 20px; }
.gate .alt { display: flex; flex-wrap: wrap; justify-content: space-between; margin-top: 8px; }
.gate .fine { margin-top: 22px; font-size: 14px; color: var(--muted); }

/* ---------- bandeaux ---------- */
.update { position: fixed; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); max-width: 496px; margin: 0 auto; z-index: 30; background: var(--brand); color: var(--on-brand); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; box-shadow: var(--shadow); }
.update button { border: 0; border-radius: 8px; padding: 10px 14px; min-height: 44px; font-weight: 700; background: var(--on-brand); color: var(--brand); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 40; background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 18px; font-weight: 600; max-width: 90%; width: max-content; text-align: center; box-shadow: var(--shadow); }
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--paper); z-index: 50; color: var(--muted); }
.boot img { width: 72px; height: 72px; border-radius: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
