:root {
  --bg: #fff8f0; --card: #ffffff; --ink: #2b2140; --muted: #7a7090; --line: #efe6f7;
  --violet: #7c5cff; --pink: #ff6fb5; --teal: #2ec4b6; --yellow: #ffbe0b; --coral: #ff7a59; --blue: #3a86ff;
  --green: #06d6a0; --red: #ef476f; --soft: #f4efff;
  --radius: 22px; --shadow: 0 6px 0 rgba(124, 92, 255, .10);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17131f; --card: #221c2e; --ink: #f4effc; --muted: #a79fbb; --line: #352c45; --soft: #2c2440;
    --shadow: 0 6px 0 rgba(0, 0, 0, .25); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Nunito, system-ui, sans-serif; font-weight: 600; }
body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
main { max-width: 720px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px 16px; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -.02em; }
h1 { font-size: 28px; } h2 { font-size: 20px; margin: 22px 0 10px; } h3 { font-size: 16px; }
small, .muted { color: var(--muted); }
a { color: var(--violet); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; box-shadow: var(--shadow); border: 2px solid var(--line); }
.card.pop { border: none; color: #fff; background: var(--violet); box-shadow: 0 8px 0 #5a3fd6; }
.card.pop small, .card.pop .muted { color: rgba(255, 255, 255, .85); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2 .card { margin: 0; }
.big { font-size: 34px; font-weight: 900; letter-spacing: -.03em; line-height: 1.1; }
.mid { font-size: 22px; font-weight: 900; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--green); } .neg { color: var(--ink); } .danger { color: var(--red); }

.hero { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.iconbtn { width: 44px; height: 44px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-size: 20px; cursor: pointer; }
.monthnav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 4px; }
.monthnav b { min-width: 150px; text-align: center; text-transform: capitalize; }
.monthnav button { border: none; background: var(--soft); width: 36px; height: 36px; border-radius: 12px; font-size: 18px; cursor: pointer; }

.bar { height: 12px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.card.pop .bar { background: rgba(255, 255, 255, .25); }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--teal); transition: width .5s; }
.bar > i.warn { background: var(--yellow); } .bar > i.over { background: var(--red); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--soft); font-size: 13px; font-weight: 800; }
.health { padding: 12px 16px; border-radius: 18px; font-weight: 800; margin: 10px 0; display: flex; gap: 10px; align-items: center; }
.health.vert { background: #d8f8ee; color: #046b50; } .health.orange { background: #fff1cc; color: #7a5400; }
.health.rouge { background: #ffe0e7; color: #8f1235; } .health.neutre { background: var(--soft); color: var(--muted); }
.health i { width: 14px; height: 14px; border-radius: 50%; flex: none; background: currentColor; }

.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 2px dashed var(--line); cursor: pointer; }
.list li:last-child { border-bottom: none; }
.emoji { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; flex: none; background: var(--soft); }
.amount { font-weight: 900; white-space: nowrap; }
.dayhead { margin: 18px 0 4px; font-size: 13px; color: var(--muted); font-weight: 800; text-transform: capitalize; }

.alert { padding: 10px 14px; border-radius: 14px; margin: 6px 0; font-size: 14px; }
.alert.danger { background: #ffe0e7; color: #8f1235; } .alert.warning { background: #fff1cc; color: #7a5400; }
.alert.info { background: #e3efff; color: #123f7a; }

.btn { border: none; border-radius: 16px; padding: 13px 18px; font-weight: 900; cursor: pointer; background: var(--violet); color: #fff; box-shadow: 0 4px 0 #5a3fd6; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #5a3fd6; }
.btn.ghost { background: var(--soft); color: var(--ink); box-shadow: none; }
.btn.danger { background: var(--red); box-shadow: 0 4px 0 #b3264a; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 12px; }

input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--violet); }
label.f { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); font-weight: 800; }
label.f > input, label.f > select, label.f > textarea { margin-top: 4px; color: var(--ink); font-size: 16px; }
label.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; font-weight: 700; }
label.check input { width: 22px; height: 22px; accent-color: var(--violet); }

/* Saisie express */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--soft); border-radius: 16px; padding: 4px; gap: 4px; }
.seg button { border: none; background: transparent; border-radius: 12px; padding: 10px; font-weight: 900; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: 0 2px 0 var(--line); }
.amountin { font-size: 44px; font-weight: 900; text-align: center; border: none; background: transparent; padding: 10px 0; letter-spacing: -.03em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border: 2px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 12px; font-weight: 800; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--violet); color: #fff; border-color: var(--violet); }
.tools { display: flex; gap: 10px; justify-content: center; margin: 4px 0 8px; }
.tools button { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 8px 14px; font-weight: 800; cursor: pointer; }
.tools button.rec { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* Barre d'onglets */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--card); border-top: 2px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
#tabs a { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); font-weight: 800; gap: 2px; }
#tabs a span { font-size: 22px; filter: grayscale(.6); }
#tabs a.on { color: var(--violet); } #tabs a.on span { filter: none; }
#fab { justify-self: center; width: 62px; height: 62px; border-radius: 22px; border: none; background: var(--pink); color: #fff;
  font-size: 36px; font-weight: 900; margin-top: -26px; box-shadow: 0 6px 0 #d14a8f; cursor: pointer; }
#fab:active { transform: translateY(4px); box-shadow: 0 2px 0 #d14a8f; }

/* Fenêtres */
.sheet-back { position: fixed; inset: 0; background: rgba(23, 19, 31, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet .grab { width: 46px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 800; transition: .25s; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* Verrouillage */
.lock { min-height: 88vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.logo { width: 92px; height: 92px; border-radius: 30px; background: var(--violet); color: #fff; display: grid; place-items: center; font-size: 34px; font-weight: 900; box-shadow: 0 8px 0 #5a3fd6; transform: rotate(-6deg); }
.dots { display: flex; gap: 14px; margin: 8px 0; } .dots i { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--violet); }
.dots i.on { background: var(--violet); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.pad button { height: 64px; border-radius: 22px; border: 2px solid var(--line); background: var(--card); font-size: 26px; font-weight: 900; cursor: pointer; }
.pad button:active { background: var(--soft); }
.shake { animation: shake .35s; } @keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Mode discret : montants floutés, touchez l'œil pour afficher */
body.discret .amt { filter: blur(7px); user-select: none; }
.amt { transition: filter .2s; }

.menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.menu a { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 16px; color: var(--ink); box-shadow: var(--shadow); }
.menu a span { font-size: 28px; display: block; margin-bottom: 6px; }
.menu a small { display: block; margin-top: 2px; font-weight: 600; }
.steps { display: flex; gap: 6px; margin: 10px 0; } .steps i { flex: 1; height: 6px; border-radius: 9px; background: var(--line); } .steps i.on { background: var(--violet); }
canvas { max-width: 100%; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty span { font-size: 44px; display: block; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; } table.t td { padding: 8px 4px; border-bottom: 2px dashed var(--line); }
table.t td:not(:first-child) { text-align: right; white-space: nowrap; }
