/* =====================================================================
   My Wallet — feuille de style unique (mobile-first, Samsung S23+)
   ===================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #efefec;
  --surface-3: #e4e4e0;
  --line: rgba(0, 0, 0, .08);
  --text: #0e0e10;
  --text-2: #4d4e53;
  --muted: #7c7d83;
  --pos: #12924a;
  --pos-soft: rgba(18, 146, 74, .12);
  --neg: #d6363b;
  --neg-soft: rgba(214, 54, 59, .1);
  --gold: #a87a16;
  --gold-soft: rgba(168, 122, 22, .13);
  --blue: #2a6fd6;
  --blue-soft: rgba(42, 111, 214, .12);
  --accent: #b8892a;
  --hero-1: #17181c;
  --hero-2: #2a2b31;
  --hero-text: #f6f5f1;
  --hero-muted: #a9a8a2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .06);
  --seg-on: #ffffff;
  --radius: 20px;
  --radius-sm: 14px;
  --tab-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Inter", "SamsungOne", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #16171a;
  --surface-2: #1e1f23;
  --surface-3: #2a2b30;
  --line: rgba(255, 255, 255, .07);
  --text: #f3f3f1;
  --text-2: #c4c4c0;
  --muted: #8b8c92;
  --pos: #34c46c;
  --pos-soft: rgba(52, 196, 108, .14);
  --neg: #f0565a;
  --neg-soft: rgba(240, 86, 90, .13);
  --gold: #d9b25c;
  --gold-soft: rgba(217, 178, 92, .14);
  --blue: #5b9bf0;
  --blue-soft: rgba(91, 155, 240, .14);
  --accent: #d9b25c;
  --hero-1: #1c1d22;
  --seg-on: #34353c;
  --hero-2: #2c2d33;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0d;
    --surface: #16171a;
    --surface-2: #1e1f23;
    --surface-3: #2a2b30;
    --line: rgba(255, 255, 255, .07);
    --text: #f3f3f1;
    --text-2: #c4c4c0;
    --muted: #8b8c92;
    --pos: #34c46c;
    --pos-soft: rgba(52, 196, 108, .14);
    --neg: #f0565a;
    --neg-soft: rgba(240, 86, 90, .13);
    --gold: #d9b25c;
    --gold-soft: rgba(217, 178, 92, .14);
    --blue: #5b9bf0;
    --blue-soft: rgba(91, 155, 240, .14);
    --accent: #d9b25c;
    --hero-1: #1c1d22;
  --seg-on: #34353c;
    --hero-2: #2c2d33;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
  }
}

/* ------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; flex: none; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.gold { color: var(--gold); }
.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }
.center-block { display: flex; margin: 12px auto; align-items: center; gap: 6px; }

/* ------------------------------------------------------------ splash */

.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: #0b0b0d; color: #f3f3f1; font-weight: 650; font-size: 20px; transition: opacity .35s;
}
.splash img { border-radius: 24px; }
.splash.hide { opacity: 0; pointer-events: none; }

/* ------------------------------------------------------------ boutons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  min-height: 48px; padding: 0 14px; border-radius: 14px; font-weight: 600; font-size: 15px;
  transition: transform .12s, background .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .ic { width: 20px; height: 20px; }
.btn-lg { min-height: 56px; width: 100%; font-size: 16px; border-radius: 16px; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-soft { background: var(--surface); color: var(--text); box-shadow: var(--shadow); flex: 1; }
.btn-ghost { color: var(--text-2); }
.btn-danger { background: var(--neg); color: #fff; }
.btn-danger-ghost { color: var(--neg); }
.btn-row { display: flex; gap: 10px; margin: 14px 0; }
.btn-row > .btn { flex: 1; }
.link { color: var(--blue); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.link .ic { width: 16px; height: 16px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2);
  transition: background .2s;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.filled { background: var(--surface); box-shadow: var(--shadow); }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after { content: ""; position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.mini-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--hero-muted); padding: 4px 8px; border-radius: 10px; background: rgba(255,255,255,.07); }
.mini-btn .ic { width: 16px; height: 16px; }

/* ------------------------------------------------------------ écrans plein */

.screen {
  min-height: 100dvh; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  display: flex; flex-direction: column; max-width: 520px; margin: 0 auto;
}
.brand-mark {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 14px;
  background: linear-gradient(145deg, var(--hero-2), var(--hero-1)); color: var(--accent);
  box-shadow: var(--shadow);
}
.brand-mark .ic { width: 34px; height: 34px; }
.brand-mark.big { width: 84px; height: 84px; border-radius: 26px; }
.brand-mark.big .ic { width: 44px; height: 44px; }

.screen-welcome { justify-content: space-between; text-align: center; }
.welcome-top { margin-top: 8vh; }
.welcome-top h1 { font-size: 32px; }
.lead { color: var(--text-2); margin-top: 8px; }
.promise { list-style: none; padding: 0; margin: 32px 0; text-align: left; display: grid; gap: 12px; }
.promise li { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); padding: 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.promise li .ic { color: var(--accent); margin-top: 2px; }
.promise b { display: block; }
.promise span { color: var(--muted); font-size: 14px; }
.welcome-actions { display: grid; gap: 8px; }

.screen-setup h1 { font-size: 26px; margin-top: 12px; }
.screen-setup .lead { margin-bottom: 20px; }
.setup-acc { display: flex; gap: 12px; align-items: flex-end; }
.setup-ic { width: 48px; height: 48px; border-radius: 14px; background: var(--surface); display: grid; place-items: center; color: var(--accent); box-shadow: var(--shadow); margin-bottom: 2px; }
.setup-extra { display: flex; gap: 10px; }
.grow { flex: 1; }

/* PIN */
.screen-lock { justify-content: center; }
.pin-screen { text-align: center; display: flex; flex-direction: column; align-items: center; }
.pin-screen.is-busy { opacity: .6; pointer-events: none; }
.pin-title { font-size: 22px; }
.pin-sub { color: var(--muted); margin: 8px 0 20px; min-height: 22px; font-size: 15px; }
.pin-sub.err { color: var(--neg); }
.pin-dots { display: flex; gap: 14px; height: 18px; margin-bottom: 28px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); transition: background .15s, border-color .15s; }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; }
.key {
  width: 76px; height: 76px; border-radius: 50%; font-size: 28px; font-weight: 500;
  background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center;
  transition: transform .1s, background .15s;
}
.key:active { transform: scale(.92); background: var(--surface-3); }
.key-fn { background: transparent; box-shadow: none; color: var(--text-2); }
.key-ok { background: var(--accent); color: #111; }
.key .ic { width: 28px; height: 28px; }
.bio-btn { margin-top: 22px; color: var(--accent); }
.bio-btn .ic { width: 26px; height: 26px; }
.back-link { margin: 18px auto 0; }

/* ------------------------------------------------------------ coquille */

.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 10px 8px 18px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar-title .back { display: grid; place-items: center; width: 34px; height: 34px; margin-left: -8px; }
.logo-dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(145deg, var(--hero-2), var(--hero-1)); color: var(--accent); }
.logo-dot .ic { width: 18px; height: 18px; }
.topbar-actions { display: flex; }

.view {
  padding: 6px 16px calc(var(--tab-h) + var(--safe-b) + 28px);
  max-width: 560px; margin: 0 auto; animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 8px 0; transition: color .2s; }
.tab.active { color: var(--text); }
.tab.active .ic { color: var(--accent); }
.tab-add {
  justify-self: center; width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); margin-top: -18px;
  transition: transform .15s;
}
.tab-add:active { transform: scale(.92); }
.tab-add .ic { width: 28px; height: 28px; }

/* ------------------------------------------------------------ accueil */

.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; }
.banner span { flex: 1; }
.banner-warn { background: var(--gold-soft); color: var(--gold); }

.hero {
  background: radial-gradient(120% 140% at 100% 0%, rgba(217, 178, 92, .18), transparent 55%), linear-gradient(160deg, var(--hero-2), var(--hero-1));
  color: var(--hero-text); border-radius: 26px; padding: 22px 18px 16px; box-shadow: var(--shadow);
}
.hero-label { color: var(--hero-muted); font-size: 14px; font-weight: 500; }
.hero-value { font-size: 38px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 2px; overflow-wrap: anywhere; }
.hero-sub { color: var(--hero-muted); font-size: 12px; }
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.hero-cell { background: rgba(255, 255, 255, .06); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; transition: background .2s; }
.hero-cell:active { background: rgba(255, 255, 255, .12); }
.hero-cell .lbl { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--hero-muted); }
.hero-cell .lbl .ic { width: 16px; height: 16px; }
.hero-cell b { font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.hero-cell small { color: var(--hero-muted); font-size: 11.5px; line-height: 1.35; }
.hero .gold { color: #e3bf6c; }
.hero .neg { color: #ff7b7f; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.quick button, .add-grid button {
  background: var(--surface); border-radius: 18px; padding: 14px 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow); transition: transform .12s;
  text-align: center; line-height: 1.15; hyphens: manual;
}
.quick button:active, .add-grid button:active { transform: scale(.95); }
.q-ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; }
.q-exp { background: var(--neg-soft); color: var(--neg); }
.q-inc { background: var(--pos-soft); color: var(--pos); }
.q-loan { background: var(--gold-soft); color: var(--gold); }
.q-debt { background: var(--neg-soft); color: var(--neg); }
.q-rep { background: var(--blue-soft); color: var(--blue); }
.q-trf { background: var(--surface-2); color: var(--text-2); }
.add-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-bottom: 8px; }
.add-grid button { background: var(--surface-2); box-shadow: none; padding: 18px 4px 14px; font-size: 13.5px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 16px; }
.card .hint { margin: -4px 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip-pos { background: var(--pos-soft); color: var(--pos); }
.chip-neg { background: var(--neg-soft); color: var(--neg); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat > span:first-child { font-size: 13px; color: var(--muted); }
.stat b { font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.delta { font-size: 12px; color: var(--muted); }
.delta.good { color: var(--pos); }
.delta.bad { color: var(--neg); }

.details summary { list-style: none; display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.details summary::-webkit-details-marker { display: none; }
.details summary .ic { transition: transform .2s; color: var(--muted); }
.details[open] summary .ic { transform: rotate(90deg); }
.details[open] summary { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; margin: 8px 0; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ graphiques */

.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .tick { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart .line { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .cross-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .cross-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.bar-income { fill: var(--pos); transition: opacity .15s; }
.bar-expense { fill: var(--neg); transition: opacity .15s; }
.chart svg:hover path[data-i]:not(.lift) { opacity: .55; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .lkey, .tip-key { display: inline-block;  width: 10px; height: 10px; border-radius: 3px; }
.key-income { background: var(--pos); }
.key-expense { background: var(--neg); }
.key-net { background: var(--muted); }
.key-line { background: var(--accent); height: 3px !important; border-radius: 2px; }
.chart-tip {
  position: absolute; top: -6px; transform: translateY(-100%); pointer-events: none; z-index: 2;
  background: var(--surface-3); color: var(--text); border-radius: 12px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); white-space: nowrap;
}
.tip-title { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { font-weight: 700; }
.tip-row span { color: var(--text-2); }

.meters { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.meter-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 5px; }
.meter-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-val { font-weight: 600; white-space: nowrap; }
.meter-val small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.meter-track { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 6px; background: var(--neg); opacity: .85; }

/* ------------------------------------------------------------ listes */

.op-list { display: flex; flex-direction: column; }
.op-row, .acc-row, .person-row, .set-row, .cat-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 4px; border-radius: 12px;
  min-height: 60px; transition: background .15s;
}
.op-row:active, .acc-row:active, .person-row:active, .set-row:active { background: var(--surface-2); }
.op-ic, .acc-ic {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none;
}
.op-ic .ic, .acc-ic .ic { width: 20px; height: 20px; }
.op-expense, .op-debt_repay { background: var(--neg-soft); color: var(--neg); }
.op-income, .op-loan_repay { background: var(--pos-soft); color: var(--pos); }
.op-loan { background: var(--gold-soft); color: var(--gold); }
.op-debt { background: var(--neg-soft); color: var(--neg); }
.op-transfer { background: var(--surface-2); color: var(--text-2); }
.acc-cash { background: var(--pos-soft); color: var(--pos); }
.acc-bank { background: var(--blue-soft); color: var(--blue); }
.acc-savings { background: var(--gold-soft); color: var(--gold); }
.acc-other { background: var(--surface-2); color: var(--text-2); }
.op-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.op-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-sub em { font-style: normal; }
.op-amt { font-weight: 650; font-size: 15px; white-space: nowrap; }
.amt-in { color: var(--pos); }
.amt-out { color: var(--text); }
.amt-neutral { color: var(--text-2); }
.detail-amount.amt-out { color: var(--neg); }
.masked { letter-spacing: .05em; color: var(--muted); }

.day-group { margin-bottom: 6px; }
.day-head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 4px 2px; }
.list-card { background: var(--surface); border-radius: var(--radius); padding: 4px 10px; box-shadow: var(--shadow); margin: 12px 0; }
.list-card > * + * { border-top: 1px solid var(--line); }
.section-title { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 22px 4px 4px; }
.empty, .empty-sm { color: var(--muted); text-align: center; padding: 24px 12px; font-size: 14.5px; }
.empty-sm { padding: 14px 8px; }
.hint { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.hint .ic { width: 16px; height: 16px; margin-top: 1px; }

.total-card {
  background: linear-gradient(160deg, var(--hero-2), var(--hero-1)); color: var(--hero-text);
  border-radius: 22px; padding: 18px; box-shadow: var(--shadow); margin-top: 6px;
}
.total-card > span { color: var(--hero-muted); font-size: 14px; }
.total-card > b { display: block; font-size: 30px; font-weight: 700; margin: 2px 0 10px; overflow-wrap: anywhere; }
.total-card > b small { font-size: 14px; }
.total-card .split { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--hero-muted); font-size: 13px; align-items: center; }
.total-card .split b { color: var(--hero-text); font-weight: 600; margin-left: 4px; }
.total-card .masked { color: var(--hero-muted); }
.tc-gold > b { color: #e3bf6c; }
.tc-red > b { color: #ff7b7f; }
.tc-green > b { color: #5fd690; }

.segmented { display: flex; background: var(--surface-2); padding: 4px; border-radius: 14px; gap: 4px; }
.segmented button { flex: 1; padding: 10px 8px; border-radius: 11px; font-weight: 600; font-size: 14px; color: var(--muted); transition: background .2s, color .2s; }
.segmented button.on { background: var(--seg-on); color: var(--text); box-shadow: var(--shadow); }
.segmented.sm button { padding: 7px 10px; font-size: 13px; }
.segmented.inline { flex: none; }
.form .segmented { margin-bottom: 4px; }

/* personnes */
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-3); color: var(--text-2); flex: none; }
.person-sum { display: flex; gap: 10px; }
.person-sum > div { flex: 1; background: var(--surface-2); border-radius: 16px; padding: 12px; }
.person-sum span { display: block; color: var(--muted); font-size: 13px; }
.person-sum b { font-size: 20px; }
.loan-card { background: var(--surface-2); border-radius: 18px; padding: 14px; margin-bottom: 10px; }
.loan-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.loan-top > div { display: flex; flex-direction: column; min-width: 0; }
.loan-top .muted { font-size: 13px; }
.status { font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.st-open { background: var(--neg-soft); color: var(--neg); }
.st-partial { background: var(--gold-soft); color: var(--gold); }
.st-repaid { background: var(--pos-soft); color: var(--pos); }
.loan-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.loan-nums span { display: block; font-size: 12px; color: var(--muted); }
.loan-nums b { font-size: 14.5px; overflow-wrap: anywhere; }
.progress { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--pos); border-radius: 4px; transition: width .4s; }
.due { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 10px; }
.due .ic { width: 15px; height: 15px; }
.repay-list { margin-top: 10px; border-top: 1px solid var(--line); }
.repay-row { display: flex; justify-content: space-between; width: 100%; padding: 9px 0; font-size: 13.5px; color: var(--text-2); border-bottom: 1px solid var(--line); }
.repay-row b { color: var(--pos); }
.loan-actions { display: flex; gap: 8px; margin-top: 12px; }

/* historique */
.search-bar { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 14px; padding: 0 12px; height: 46px; box-shadow: var(--shadow); color: var(--muted); }
.search input { flex: 1; border: 0; background: none; outline: none; color: var(--text); min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-x { background: var(--text); color: var(--bg); }
.chip-x .ic { width: 14px; height: 14px; }
.hist-sum { display: flex; gap: 12px; align-items: center; font-size: 13.5px; color: var(--muted); padding: 8px 4px; flex-wrap: wrap; }
.hist-sum .pos, .hist-sum .neg { font-weight: 600; }
.hist-sum .link { margin-left: auto; }

/* réglages */
.set-row { padding: 10px 4px; }
.set-row > .ic { color: var(--text-2); }
.set-row .chev { color: var(--muted); width: 18px; height: 18px; }
.inline-select { background: var(--surface-2); border: 0; border-radius: 10px; padding: 8px 10px; max-width: 46%; }
.privacy p { display: flex; gap: 12px; font-size: 14px; color: var(--text-2); line-height: 1.5; }
.privacy .ic { color: var(--pos); }
.prose { font-size: 14.5px; color: var(--text-2); line-height: 1.55; }
.prose p + p, .prose h3 + ol, .prose ol + h3, .prose ol + p { margin-top: 12px; }
.prose h3 { color: var(--text); font-size: 16px; }
.prose ol { padding-left: 20px; margin: 8px 0 0; }
.prose li { margin: 4px 0; }
.prose b { color: var(--text); }
.version { text-align: center; color: var(--muted); font-size: 12px; margin: 20px 0 0; }
.cat-row { padding: 6px 4px; min-height: 52px; }

.switch, .switch-row { position: relative; display: inline-flex; align-items: center; }
.switch-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 15px; }
.switch input, .switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i, .switch-row i { width: 48px; height: 28px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .2s; flex: none; }
.switch i::after, .switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + i, .switch-row input:checked + i { background: var(--pos); }
.switch input:checked + i::after, .switch-row input:checked + i::after { transform: translateX(20px); }

/* ------------------------------------------------------------ formulaires */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .amount-wrap {
  width: 100%; height: 50px; border-radius: 14px; border: 1.5px solid transparent; background: var(--surface-2);
  padding: 0 14px; outline: none; font-size: 16px; transition: border-color .2s;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.amount-wrap { display: flex; align-items: center; padding: 0; }
.amount-wrap input { border: 0; background: none; height: 100%; }
.amount-wrap em { font-style: normal; color: var(--muted); padding-right: 14px; }
.amount-big { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 8px 0 4px; }
.amount-big input { width: 100%; max-width: 280px; field-sizing: content; min-width: 3ch; text-align: center; font-size: 40px; font-weight: 700; background: none; border: 0; outline: none; border-bottom: 2px solid var(--surface-3); padding: 4px 0; letter-spacing: -.02em; }
.amount-big input:focus { border-color: var(--accent); }
.amount-big em { font-style: normal; font-size: 18px; color: var(--muted); font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > .field:only-child { grid-column: 1 / -1; }
.form-error { color: var(--neg); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }
.cat-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cat { position: relative; }
.cat input { position: absolute; opacity: 0; }
.cat span, .cat-add { display: inline-flex; align-items: center; gap: 4px; padding: 9px 13px; border-radius: 12px; background: var(--surface-2); font-size: 14px; font-weight: 500; border: 1.5px solid transparent; transition: all .15s; }
.cat input:checked + span { background: var(--text); color: var(--bg); }
.cat input:focus-visible + span { border-color: var(--accent); }
.cat-add { color: var(--blue); }
.cat-add .ic { width: 16px; height: 16px; }

/* ------------------------------------------------------------ feuilles */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background .25s;
}
.sheet-backdrop.open { background: rgba(0, 0, 0, .5); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; background: var(--surface); border-radius: 26px 26px 0 0;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-b);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px 20px; }
.sheet-head h2 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 8px 20px 24px; overscroll-behavior: contain; }
.sheet .op-row:active { background: var(--surface-2); }
.sheet .list-card, .sheet .card { box-shadow: none; background: var(--surface-2); }
.dialog-msg { color: var(--text-2); line-height: 1.5; margin-bottom: 4px; }
.detail-amount { font-size: 34px; font-weight: 700; text-align: center; margin: 8px 0 12px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ toasts / busy */

.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 520px; width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 14.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast span { flex: 1; }
.toast button { font-weight: 700; color: var(--accent); }
.toast-error { background: var(--neg); color: #fff; }
.toast-error button { color: #fff; }
.busy { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; font-weight: 600; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fatal { padding: 40px 24px; text-align: center; }
.fatal p { color: var(--muted); margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (min-width: 700px) {
  .tabbar { left: 50%; transform: translateX(-50%); max-width: 560px; border-radius: 24px 24px 0 0; border: 1px solid var(--line); }
}
