/* Envelops — app mobile une colonne (max 480px), cartes empilées, grands montants, barre d'onglets fixe en bas,
   feuilles modales qui montent du bas, bannière de notification en haut. */
:root {
  --bg: #F2F3F5;
  --surface: #FFFFFF;
  --surface-2: #E8EAEE;
  --ink: #0D1014;
  --muted: #687080;
  --line: #E0E3E9;
  --pos: #0D8A5C;
  --neg: #C4412E;
  --warn: #A86A12;
  --accent: #0D1014;
  --on-accent: #FFFFFF;
  --scrim: rgba(13, 16, 20, .38);
  --shadow: 0 12px 32px rgba(13, 16, 20, .14);
  --e0: #3B6FE0; --e1: #E5674A; --e2: #1E9B6E; --e3: #8B5CE0; --e4: #D99A16; --e5: #1592A6;
  --font: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-lg: 26px; --r-md: 18px; --r-sm: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0B0D; --surface: #15171B; --surface-2: #22252B; --ink: #F2F3F5; --muted: #98A0AD; --line: #292D34;
    --pos: #3DCB90; --neg: #FF7D69; --warn: #E7B45A; --accent: #F2F3F5; --on-accent: #0A0B0D; --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 12px 32px rgba(0, 0, 0, .55);
    --e0: #6F97FF; --e1: #FF8A6E; --e2: #46C996; --e3: #AE89FF; --e4: #F2BC45; --e5: #3FC0D3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0B0D; --surface: #15171B; --surface-2: #22252B; --ink: #F2F3F5; --muted: #98A0AD; --line: #292D34;
  --pos: #3DCB90; --neg: #FF7D69; --warn: #E7B45A; --accent: #F2F3F5; --on-accent: #0A0B0D; --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 12px 32px rgba(0, 0, 0, .55);
  --e0: #6F97FF; --e1: #FF8A6E; --e2: #46C996; --e3: #AE89FF; --e4: #F2BC45; --e5: #3FC0D3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--e0); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

html { padding-top: env(safe-area-inset-top, 0px); }
#app { grid-template-columns: minmax(0, 1fr); max-width: 480px; margin: 0 auto; padding-block: 14px calc(96px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 18px; }

/* En-tête */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-actions { display: flex; gap: 8px; flex: none; }
.bank-logo { width: 38px; height: 38px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; color: var(--pos); border: 1px solid var(--line); flex: none; }
.top h1 { font-size: 15px; font-weight: 600; margin: 0; }
.top-left > div { min-width: 0; }
.top-left > button { min-width: 0; color: inherit; font: inherit; }
.top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top p { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.count { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--neg); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--warn); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Solde */
.hero { display: grid; gap: 4px; padding-top: 6px; }
.hero .label { font-size: 13px; color: var(--muted); }
.hero .amount { font-size: clamp(40px, 12vw, 52px); font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }
.hero .amount small { font-size: .5em; font-weight: 600; letter-spacing: -.01em; }
.plafond { display: grid; gap: 6px; margin-top: 8px; }
.plafond-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); gap: 8px; }
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--ink); }

.chart-block { display: grid; gap: 10px; margin-top: 4px; }
.chart-svg { display: block; width: 100%; height: auto; max-width: 100%; touch-action: pan-y; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.readout { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13.5px; min-height: 20px; }
.readout .delta { font-weight: 600; }
.readout .ro-date { color: var(--muted); }
.ranges { display: flex; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.card .ranges { background: var(--bg); }
.range { flex: 1; border: 0; background: none; border-radius: 999px; padding: 7px 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.range[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(13, 16, 20, .12); }

/* Carte à répartir */
.todo { background: var(--accent); color: var(--on-accent); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 12px; }
.todo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.todo-head span { font-size: 13px; opacity: .72; }
.todo-head strong { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.todo p { margin: 0; font-size: 13.5px; opacity: .8; }
.btn-inv { background: var(--on-accent); color: var(--accent); border: 0; border-radius: 999px; padding: 11px 16px; font-weight: 600; justify-self: start; }

/* Sections */
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sec-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.link { background: none; border: 0; padding: 6px 0; font-weight: 600; color: var(--ink); font-size: 14px; }
.link.muted { color: var(--muted); font-weight: 500; justify-self: start; }

/* Enveloppes */
.env-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.env-card { background: var(--surface); border: 0; border-radius: var(--r-md); padding: 14px; text-align: left; display: grid; gap: 10px; min-width: 0; align-content: start; }
.env-card .dot { width: 30px; height: 30px; border-radius: 10px; background: var(--c); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.env-card .name { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-card .bal { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.env-card .bar > i { background: var(--c); }
.env-card .goal { font-size: 11.5px; color: var(--muted); }
.env-card.wide { grid-column: 1 / -1; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.env-card.wide .stack { display: grid; gap: 1px; min-width: 0; }
.env-card.wide .name { color: var(--ink); font-weight: 600; }
.env-add { border: 1.5px dashed var(--line); background: transparent; display: grid; place-items: center; color: var(--muted); font-weight: 600; min-height: 120px; }
.neg-note { color: var(--neg); }

/* Mouvements */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.month { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 4px 0; }
.list { background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.tx { width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; text-align: left; }
.tx + .tx { border-top: 1px solid var(--line); }
.tx-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.tx-ico svg { width: 18px; height: 18px; }
.tx-main { min-width: 0; display: grid; gap: 3px; }
.tx-label { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.tx-amt { font-weight: 600; font-size: 15px; text-align: right; }
.in { color: var(--pos); }
.pill { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); }
.pill.todo-pill { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.sug { background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.unread { width: 8px; height: 8px; border-radius: 50%; background: var(--e0); display: inline-block; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 26px 12px; margin: 0; }

/* Détail enveloppe */
.back { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 0; font-weight: 600; }
.back svg { width: 18px; height: 18px; }
.card { background: var(--surface); border-radius: var(--r-md); padding: 16px; display: grid; gap: 12px; }
.card h3 { margin: 0; font-size: 14px; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.kv span:first-child { color: var(--muted); }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 600; background: var(--accent); color: var(--on-accent); }
.btn.sec { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 4px 10px; justify-self: start; }

/* Compte */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.note { font-size: 12.5px; color: var(--muted); margin: 0; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; font-size: 14px; }
.switch { width: 48px; height: 28px; border-radius: 999px; border: 0; background: var(--surface-2); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--pos); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Barre d'onglets */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.tabbar nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab { border: 0; background: none; display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.tab { text-decoration: none; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* Feuille modale */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade .18s ease-out; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); animation: up .24s cubic-bezier(.2, .8, .2, 1); }
.sheet-in { max-width: 480px; margin: 0 auto; display: grid; gap: 16px; }
.grip { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 4px; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.sheet .big { font-size: 34px; font-weight: 700; letter-spacing: -.03em; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { transform: translateY(-120%); } }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim, .spin svg, .banner { animation: none; } .switch, .switch::after { transition: none; } }

.remain { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px; }
.remain strong { font-size: 17px; }
.suggest { background: color-mix(in srgb, var(--e0) 10%, var(--surface)); border-radius: var(--r-sm); padding: 12px 14px; display: grid; gap: 8px; font-size: 13.5px; }
.suggest-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.suggest-head b { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--e0); }
.suggest p { margin: 0; }
.suggest .why { color: var(--muted); font-size: 12.5px; }
.alloc-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px auto; gap: 8px; align-items: center; background: var(--surface); border-radius: var(--r-sm); padding: 10px 12px; }
.alloc-row.locked { grid-template-columns: minmax(0, 1fr) auto; opacity: .75; }
.alloc-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.alloc-name i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.alloc-name div { min-width: 0; }
.alloc-name b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-name small { color: var(--muted); font-size: 12px; }
.field { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.mini { border: 0; background: var(--surface-2); border-radius: 999px; padding: 8px 10px; font-size: 12.5px; font-weight: 600; }
.err { color: var(--neg); font-size: 13px; margin: 0; min-height: 18px; }
.warn-txt { color: var(--warn); font-size: 13px; margin: 0; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.form .field, select.field { text-align: left; background: var(--surface); padding: 12px; font-size: 15px; color: var(--ink); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 12px; border: 3px solid transparent; background: var(--c); }
.swatch[aria-checked="true"] { border-color: var(--ink); }

.sca { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 10px 0; }
.sca .phone { width: 64px; height: 64px; border-radius: 20px; background: var(--surface); display: grid; place-items: center; }
.sca .phone svg { width: 28px; height: 28px; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--accent); color: var(--on-accent); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; max-width: calc(100% - 32px); text-align: center; }

/* Bannière de notification */
.banner-wrap { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 70; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); pointer-events: none; }
.banner { pointer-events: auto; max-width: 456px; margin: 0 auto; background: var(--surface); box-shadow: var(--shadow); border-radius: 20px; padding: 12px 12px 12px 14px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; animation: drop .3s cubic-bezier(.2, .8, .2, 1); }
.banner .app-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.banner .txt { min-width: 0; display: grid; gap: 1px; }
.banner .txt b { font-size: 13.5px; }
.banner .txt span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner .acts { display: flex; gap: 6px; }

/* ------------------------------------------------------------ écrans d'accueil */
[hidden] { display: none !important; }
body { margin: 0; }
img { max-width: 100%; }
#app.bare { padding-bottom: 32px; }
.auth { min-height: 80vh; display: grid; align-content: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.brand b { font-size: 22px; letter-spacing: -.02em; }
.auth h1, .page-title { font-size: 28px; line-height: 1.15; letter-spacing: -.03em; margin: 0; text-wrap: balance; }
.lead { color: var(--muted); margin: 0; font-size: 15px; max-width: 60ch; }
.points { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.points li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 14px; }
.points li span:first-child { width: 28px; height: 28px; border-radius: 9px; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 9px 0; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(13, 16, 20, .12); }
.bank-list { max-height: 46vh; overflow-y: auto; }
.bank-row { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; font-size: 14.5px; }
.bank-row + .bank-row { border-top: 1px solid var(--line); }
.bank-row img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; }
.bank-row .ph { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.bank-row[aria-pressed="true"] { background: color-mix(in srgb, var(--e0) 10%, var(--surface)); font-weight: 600; }
.pick { border: 2px solid transparent; }
.pick[aria-pressed="true"] { border-color: var(--ink); }
.alert { border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 10px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.alert.bad { background: color-mix(in srgb, var(--neg) 13%, var(--surface)); }
.alert b { font-size: 14.5px; }
.alert p { margin: 0; font-size: 13.5px; color: var(--ink); opacity: .85; }
.skeleton { color: var(--muted); text-align: center; padding: 60px 0; }

a.back, a.link { color: inherit; text-decoration: none; }
a.link.muted { color: var(--muted); }

/* -------------------------------------------------------- écran de verrouillage */
.lock { justify-items: center; text-align: center; }
.lock .lock-ico { width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.lock .lock-ico svg { width: 28px; height: 28px; }
.lock .btn, .lock form { width: 100%; max-width: 320px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; min-height: 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots i.on { background: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px 22px; justify-content: center; }
.key { width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--surface); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.key:active { background: var(--surface-2); }
body.veil #app, body.veil #sheet-root { filter: blur(18px); }
@media (prefers-reduced-motion: no-preference) { .key { transition: background .1s; } }
.lock .link { justify-self: center; }
