[hidden] { display: none !important; }
:root {
  --bg: #f4f6fa; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --blue: #2563eb; --green: #16a34a; --red: #dc2626; --orange: #ea7a1a; --yellow: #d4a017; --violet: #7c3aed;
  --c-rev: #2dd683; --c-dep: #f28c28; --c-chg: #f5a65b; --c-fam: #e46fa0; --c-det: #d9534f; --c-epa: #f6c343; --c-trf: #64748b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; font-size: 16px; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
.splash { padding: 40vh 0; text-align: center; color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 14px 20px; }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 4px; max-width: 1100px; margin: 0 auto; }
header.top h1 { font-size: 20px; margin: 0; }
header.top .who { color: var(--muted); font-size: 13px; }
h2 { font-size: 17px; margin: 18px 2px 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .grid.k3 { grid-template-columns: repeat(3, 1fr); } .grid.k2 { grid-template-columns: repeat(2, 1fr); } }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; margin: 4px 0 8px; letter-spacing: -.5px; }
.kpi .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi.blue { background: var(--blue); color: #fff; } .kpi.blue .label, .kpi.blue .row { color: #dbe7ff; }
.bar { height: 8px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }
.hero { background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; }
.hero .big { font-size: 30px; font-weight: 800; }
.hero .muted { color: #e0e7ff; }

/* navigation basse */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
nav.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 4px 6px; min-width: 60px; cursor: pointer; }
nav.tabs button .ico { font-size: 22px; line-height: 1; }
nav.tabs button.on { color: var(--blue); font-weight: 700; }
nav.tabs button.add .ico { background: var(--blue); color: #fff; border-radius: 50%; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin-top: -2px; }

/* formulaire de saisie */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 9px 13px; font-size: 14px; cursor: pointer; }
.chip.on { border-color: var(--blue); background: #e8f0fe; color: var(--blue); font-weight: 700; }
.chip.t { border-left-width: 6px; }
.field { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.amount { width: 100%; font-size: 34px; font-weight: 800; text-align: center; border: 2px solid var(--line);
  border-radius: var(--radius); padding: 12px; background: #fffbea; }
.amount:focus, .in:focus { outline: none; border-color: var(--blue); }
.in { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; font-size: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { border: 0; border-radius: 12px; padding: 14px 18px; font-weight: 800; font-size: 17px; cursor: pointer; background: var(--blue); color: #fff; }
.btn.block { width: 100%; } .btn.green { background: var(--green); } .btn.red { background: var(--red); }
.btn.ghost { background: #eef2ff; color: var(--blue); } .btn.small { padding: 8px 12px; font-size: 14px; }
.btn:disabled { opacity: .6; }

/* listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.grow { flex: 1; min-width: 0; }
.grow .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow .t2 { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 700; white-space: nowrap; }
.amt.plus { color: var(--green); } .amt.minus { color: var(--text); } .amt.trf { color: var(--c-trf); }
.day { font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 2px 2px; text-transform: capitalize; }
.clickable { cursor: pointer; }

/* tableau catégories */
table.cats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.cats th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.cats td { padding: 8px 4px; border-bottom: 1px solid #f1f2f5; }
table.cats td.n { text-align: right; white-space: nowrap; }
td.alert-red { color: #b91c1c; font-weight: 800; background: #fde2e2; }
td.alert-orange { color: #c2410c; font-weight: 800; background: #ffedd5; }
td.alert-green { color: #15803d; font-weight: 800; background: #dcfce7; }
.typehead { display: flex; align-items: center; gap: 8px; font-weight: 800; margin: 4px 0 6px; }

/* mini graphiques */
.hbar { display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.hbar .bar { height: 14px; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; }
.cols .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cols .pair { display: flex; align-items: flex-end; gap: 2px; height: 110px; }
.cols .pair span { width: 7px; border-radius: 3px 3px 0 0; display: block; }
.cols .lbl { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.period { display: flex; gap: 8px; align-items: center; }
.period select { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; font-weight: 700; }
.monthnav { display: flex; align-items: center; justify-content: space-between; }
.monthnav button { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; width: 42px; height: 38px; font-size: 18px; cursor: pointer; }

/* toast & modale */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom));
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 30; max-width: 92vw; text-align: center; }
.toast.err { background: var(--red); }
.modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) { .modal { align-items: center; } .modal-box { border-radius: 18px; } }

/* écran de connexion */
.auth { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.auth h1 { font-size: 26px; margin-bottom: 4px; }
.auth .card { padding: 20px; }
.auth label { display: block; margin: 12px 0 6px; font-size: 14px; font-weight: 600; }
.err-msg { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 1em; }
