@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,800&family=Figtree:wght@400;500;600;700&display=swap");

:root {
  --bg: #f3f6f2;
  --surface: #ffffff;
  --ink: #16231c;
  --muted: #5d6e64;
  --line: #dbe3dc;
  --accent: #1d7a4f;
  --accent-soft: #e1f0e7;
  --gold: #8a5710;
  --gold-bar: #c08a2e;
  --gold-soft: #f8ecd6;
  --warn: #c2610c;
  --bad: #b42318;
  --bad-soft: #fde7e5;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Figtree", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512; --surface: #17201b; --ink: #e6efe9; --muted: #93a69a; --line: #2a372f;
    --accent: #3fb37a; --accent-soft: #1b3326; --gold: #e0a548; --gold-bar: #e0a548; --gold-soft: #33280f;
    --warn: #f0a050; --bad: #f07a6e; --bad-soft: #3a1c19;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 20px 110px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.num { font-variant-numeric: tabular-nums; }
.title { font-family: var(--display); font-size: 24px; font-weight: 800; margin: 0; }
.subtitle { font-family: var(--display); font-size: 17px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; color: var(--ink); text-decoration: none;
}
.icon-btn svg { width: 20px; height: 20px; }

.hero { background: var(--accent); color: #fff; border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.hero.neg { background: var(--bad); }
.hero .label { color: #fff; opacity: .85; }
.hero .big { font-family: var(--display); font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .v { font-family: var(--display); font-size: 17px; font-weight: 800; }
.in { color: var(--accent); } .out { color: var(--bad); } .save { color: var(--gold); }

.nudge { background: var(--gold-soft); border-radius: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.nudge p { margin: 0; flex: 1; font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 2px 14px; }
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.dot { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center; font-weight: 800; }
.dot.depense { background: var(--bad-soft); color: var(--bad); }
.dot.revenu { background: var(--accent-soft); color: var(--accent); }
.dot.epargne { background: var(--gold-soft); color: var(--gold); }
.tx .info { flex: 1; min-width: 0; }
.tx .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .r { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tx .amt { font-weight: 700; white-space: nowrap; }
.amt.depense { color: var(--bad); } .amt.revenu { color: var(--accent); } .amt.epargne { color: var(--gold); }
.del { border: 0; background: none; padding: 0; font-size: 12px; color: var(--muted); text-decoration: underline; }
.del.confirm { color: var(--bad); font-weight: 700; }
.empty { color: var(--muted); padding: 14px 0; font-size: 14px; }
.day-head { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin-top: 4px; }

.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: var(--line); border-radius: 14px; padding: 4px; }
.seg button { border: 0; border-radius: 11px; padding: 11px 0; background: transparent; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button.on[data-t="depense"] { color: var(--bad); }
.seg button.on[data-t="revenu"] { color: var(--accent); }
.seg button.on[data-t="epargne"] { color: var(--gold); }

.amount-box { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; }
.amount-box .line { display: flex; align-items: baseline; gap: 8px; }
.amount-box input { width: 200px; border: 0; background: transparent; text-align: right; font-family: var(--display); font-size: 48px; font-weight: 800; letter-spacing: -.03em; }
.amount-box input:focus { outline: none; }
.amount-box span { font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .flabel { font-size: 13px; color: var(--muted); font-weight: 500; }
.input { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; width: 100%; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 500; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.pay { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 0; font-size: 13px; font-weight: 500; }
.pay.on { border: 2px solid var(--accent); background: var(--accent-soft); font-weight: 700; }

.warn-box { border-radius: 12px; padding: 10px 14px; font-size: 13px; background: var(--bad-soft); color: var(--bad); }
.btn { display: block; width: 100%; text-align: center; border: 0; border-radius: 16px; padding: 16px; font-weight: 700; font-size: 16px; background: var(--accent); color: #fff; text-decoration: none; }
.btn.small { width: auto; padding: 10px 16px; font-size: 14px; border-radius: 12px; }
.btn.gold { background: var(--gold-bar); color: #1a1205; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .6; }

.bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar i.warn { background: var(--warn); } .bar i.bad { background: var(--bad); }
.goal .bar { height: 12px; } .goal .bar i { background: var(--gold-bar); }
.goal .big { font-family: var(--display); font-size: 34px; font-weight: 800; color: var(--gold); letter-spacing: -.02em; }
.pill { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-radius: 99px; padding: 2px 8px; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--gold-soft); color: var(--warn); }
.pill.gold { background: var(--gold-soft); color: var(--gold); font-size: 13px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom, 0px));
}
.nav .in-nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; }
.nav a { color: var(--muted); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 600; }
.nav a.on { color: var(--accent); }
.nav a svg { width: 22px; height: 22px; }
.nav a.plus { justify-self: center; width: 56px; height: 56px; margin-top: -30px; border-radius: 18px; background: var(--accent); color: #fff; justify-content: center; }
.nav a.plus svg { width: 26px; height: 26px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.on { opacity: 1; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; }

.auth { max-width: 400px; margin: 0 auto; min-height: 100vh; padding: 48px 20px; display: flex; flex-direction: column; gap: 18px; justify-content: center; }
.brand { font-family: var(--display); font-size: 40px; font-weight: 800; color: var(--accent); letter-spacing: -.03em; margin: 0; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth .seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.auth .seg button.on { color: var(--ink); }

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