/* ==========================================================
   Design : liquid glass clair, épuré, chiffres mis en avant
   ========================================================== */
:root {
  --bg: #f1f0ee;
  --ink: #161618;
  --ink-2: #55545a;
  --ink-3: #8d8c92;
  --line: rgba(20, 20, 24, .08);
  --accent: #660916;          /* rouge profond : dépenses, alertes */
  --accent-soft: rgba(102, 9, 22, .09);
  --income: #1f7a4d;          /* vert : revenus */
  --income-soft: rgba(31, 122, 77, .1);
  --warn: #b7791f;
  --glass: rgba(255, 255, 255, .52);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-border: rgba(255, 255, 255, .75);
  --shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 0 0 .5px rgba(0,0,0,.04), 0 10px 30px -12px rgba(30, 20, 25, .18);
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --font: 'Montserrat', system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.ico { width: 22px; height: 22px; flex: none; display: block; }

/* Fond : formes floues qui donnent de la matière au verre */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orbs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.bg-orbs span:nth-child(1) { width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax; background: radial-gradient(circle, #d9d6d2, transparent 70%); }
.bg-orbs span:nth-child(2) { width: 45vmax; height: 45vmax; right: -15vmax; top: 20vh; background: radial-gradient(circle, rgba(102, 9, 22, .16), transparent 70%); }
.bg-orbs span:nth-child(3) { width: 50vmax; height: 50vmax; left: 10vw; bottom: -30vmax; background: radial-gradient(circle, #cfd3da, transparent 70%); }

/* Verre */
.glass, .glass-strong {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}
.glass-strong { background: var(--glass-strong); }

/* ---------- Mise en page ---------- */
.layout { min-height: 100vh; }
.main {
  padding: calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 120px);
  max-width: 760px;
  margin: 0 auto;
}
.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Navigation mobile : barre flottante en bas */
.nav {
  position: fixed; z-index: 40;
  left: 12px; right: 12px; bottom: calc(var(--safe-b) + 10px);
  display: flex; align-items: center; justify-content: space-around;
  height: 70px; border-radius: 30px; padding: 0 6px;
}
.nav-brand, .nav-logout { display: none; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  width: 64px; padding: 6px 0; border-radius: 16px; transition: color .2s, background .2s;
}
.nav-item .ico { width: 24px; height: 24px; }
.nav-item.active { color: var(--ink); }
.nav-item.active .ico { stroke-width: 2.2; }
.nav-add {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.45);
  transition: transform .15s;
}
.nav-add:active { transform: scale(.94); }
.nav-add .ico { width: 26px; height: 26px; stroke-width: 2.4; }
.nav-add span { display: none; }

/* Ordinateur : barre latérale */
@media (min-width: 1000px) {
  .nav {
    left: 20px; top: 20px; bottom: 20px; right: auto; width: 230px; height: auto;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    border-radius: var(--r-lg); padding: 22px 14px; gap: 4px;
  }
  .nav-brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; font-weight: 800; font-size: 20px; }
  .nav-brand img { width: 38px; height: 38px; border-radius: 11px; }
  .nav-item { flex-direction: row; width: auto; gap: 12px; font-size: 15px; padding: 12px 14px; color: var(--ink-2); }
  .nav-item:hover { background: rgba(255,255,255,.5); }
  .nav-item.active { background: rgba(255,255,255,.85); box-shadow: 0 1px 0 #fff inset, 0 4px 14px -6px rgba(0,0,0,.15); }
  .nav-add { order: -1; width: auto; height: 48px; border-radius: 16px; display: flex; gap: 10px; justify-content: center; font-weight: 700; margin-bottom: 14px; }
  .nav-add span { display: inline; }
  .nav-add .ico { width: 20px; height: 20px; }
  .nav-brand { order: -2; }
  .nav-logout { display: flex; margin-top: auto; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink-3); text-decoration: none; font-size: 14px; font-weight: 600; border-radius: 16px; }
  .nav-logout:hover { color: var(--ink); }
  .main { margin-left: 270px; max-width: 1180px; padding: 28px 32px 40px; }
}

/* ---------- En-têtes ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 4px 18px; }
.page-title { font-size: 34px; font-weight: 900; letter-spacing: -.02em; margin: 0; line-height: 1.05; }
.page-sub { color: var(--ink-3); font-weight: 600; font-size: 14px; margin: 4px 0 0; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 26px 6px 10px; }

/* ---------- Cartes ---------- */
.card { border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 18px; margin: 0 0 14px; }
.card-title small { font-weight: 600; font-size: 13px; color: var(--ink-3); }

/* ---------- Boutons & champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 15px; font-weight: 700; font-size: 15px;
  background: rgba(255,255,255,.7); border: 1px solid rgba(0,0,0,.06); transition: transform .12s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn .ico { width: 19px; height: 19px; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-danger { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.6); border: 1px solid rgba(0,0,0,.05); }
.icon-btn .ico { width: 20px; height: 20px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.field {
  width: 100%; height: 50px; border-radius: 15px; padding: 0 16px;
  border: 1px solid rgba(0,0,0,.07); background: rgba(255,255,255,.75);
  font-size: 16px; font-weight: 600; outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.field:focus { border-color: rgba(0,0,0,.25); box-shadow: 0 0 0 4px rgba(0,0,0,.05); }
select.field { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d8c92' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; padding-right: 40px; }
.label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 16px 2px 8px; }

/* Contrôle segmenté */
.seg { display: inline-flex; padding: 4px; border-radius: 15px; background: rgba(0,0,0,.05); gap: 2px; }
.seg button { height: 36px; padding: 0 16px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--ink-2); transition: all .2s; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -2px rgba(0,0,0,.15); }
.seg.block { display: flex; }
.seg.block button { flex: 1; }
.seg .on-expense.on { color: var(--accent); }
.seg .on-income.on { color: var(--income); }

/* ---------- Période ---------- */
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 14px; }
.period-nav { display: flex; align-items: center; gap: 6px; }
.period-label { font-weight: 800; font-size: 17px; min-width: 150px; text-align: center; }
.week-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 8px; scrollbar-width: none; }
.week-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 12px; font-size: 13px; font-weight: 700; color: var(--ink-2); background: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.8); display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Récap ---------- */
.recap-grid { display: grid; gap: 14px; }
.recap-grid > .card { margin: 0; }
@media (min-width: 1000px) {
  .recap-grid { grid-template-columns: 1fr 1fr; }
  .recap-grid .span-2 { grid-column: span 2; }
}
.hero { padding: 24px; }
.hero-top { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpi-label { font-size: 13px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.kpi-label .sw { width: 9px; height: 9px; border-radius: 3px; }
.kpi-big { font-size: clamp(34px, 9vw, 52px); font-weight: 900; letter-spacing: -.035em; line-height: 1.05; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-mid { font-size: clamp(24px, 6vw, 32px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.kpi-small { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; padding: 5px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.delta .ico { width: 15px; height: 15px; stroke-width: 2.4; }
.delta.up { background: var(--accent-soft); color: var(--accent); }
.delta.down { background: var(--income-soft); color: var(--income); }
.delta.flat { background: rgba(0,0,0,.05); color: var(--ink-2); }
.neg { color: var(--accent); }
.pos { color: var(--income); }

/* Bilan du dimanche */
.weekly { position: relative; overflow: hidden; background: linear-gradient(135deg, rgba(22,22,24,.92), rgba(55,55,55,.88)); color: #fff; border: 1px solid rgba(255,255,255,.15); }
.weekly .kpi-label { color: rgba(255,255,255,.6); }
.weekly .weekly-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; background: rgba(255,255,255,.12); padding: 6px 10px; border-radius: 10px; }
.weekly .weekly-badge .ico { width: 15px; height: 15px; }
.weekly-main { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 22px; margin: 16px 0 6px; }
.weekly .delta.up { background: rgba(255,120,130,.18); color: #ffb3b9; }
.weekly .delta.down { background: rgba(120,220,170,.16); color: #a6ecc8; }
.weekly .delta.flat { background: rgba(255,255,255,.12); color: #ddd; }
.weekly-top { display: grid; gap: 10px; margin-top: 16px; }
.weekly-top .row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.weekly-top .bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 5px; }
.weekly-top .bar i { display: block; height: 100%; border-radius: 4px; }
.weekly-top .cat-ico { width: 28px; height: 28px; border-radius: 9px; }

/* Icône de catégorie (pastille colorée) */
.cat-ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; color: #fff; }
.cat-ico .ico { width: 20px; height: 20px; stroke-width: 2; }
.cat-ico.sm { width: 32px; height: 32px; border-radius: 10px; }
.cat-ico.sm .ico { width: 16px; height: 16px; }

/* Donut + légende */
.donut-wrap { display: grid; gap: 18px; align-items: center; }
@media (min-width: 560px) { .donut-wrap { grid-template-columns: 220px 1fr; } }
.donut { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.donut svg { width: 100%; height: 100%; overflow: visible; }
.donut path { transition: opacity .2s, transform .2s; transform-origin: 110px 110px; cursor: pointer; }
.donut.hovering path:not(.hl) { opacity: .3; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-size: 26px; font-weight: 900; letter-spacing: -.03em; }
.donut-center span { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.legend { display: grid; gap: 4px; }
.legend-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 12px; transition: background .15s; cursor: default; }
.legend-row:hover, .legend-row.hl { background: rgba(255,255,255,.6); }
.legend-row .nm { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .pc { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.legend-row .am { font-weight: 800; font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }

/* Graphiques SVG */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: rgba(0,0,0,.07); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.chart-legend i.dash { background: repeating-linear-gradient(90deg, var(--ink-3) 0 4px, transparent 4px 7px) !important; }
.chart-legend i.box { width: 11px; height: 11px; border-radius: 3px; }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: rgba(22,22,24,.92); color: #fff; border-radius: 12px; padding: 9px 12px;
  font-size: 13px; font-weight: 600; line-height: 1.45; min-width: 120px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 10px 25px -8px rgba(0,0,0,.4);
}
.tooltip.show { opacity: 1; }
.tooltip b { font-weight: 800; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span { display: inline-flex; align-items: center; gap: 6px; color: rgba(255,255,255,.75); }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tooltip .tt-head { font-size: 12px; color: rgba(255,255,255,.6); margin-bottom: 4px; }

/* Budgets */
.budget-row { padding: 12px 0; border-top: 1px solid var(--line); }
.budget-row:first-of-type { border-top: 0; padding-top: 0; }
.budget-head { display: flex; align-items: center; gap: 12px; }
.budget-head .nm { flex: 1; font-weight: 700; }
.budget-head .vals { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.budget-head .vals small { color: var(--ink-3); font-weight: 600; }
.progress { height: 10px; border-radius: 6px; background: rgba(0,0,0,.06); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; border-radius: 6px; transition: width .5s ease; }
.budget-note { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.budget-note.over { color: var(--accent); }
.budget-note.warn { color: var(--warn); }
.budget-note .ico { width: 14px; height: 14px; }

.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); font-weight: 600; }
.empty .ico { width: 38px; height: 38px; margin: 0 auto 10px; stroke-width: 1.5; opacity: .6; }
.empty p { margin: 0 0 14px; }

/* ---------- Historique ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search { position: relative; flex: 1; }
.search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 19px; height: 19px; }
.search .field { padding-left: 42px; }
.filters { display: none; border-radius: var(--r-md); padding: 4px 16px 16px; margin-bottom: 12px; }
.filters.open { display: block; }
.filters .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filter-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; position: absolute; top: -5px; right: -5px; }
.icon-btn { position: relative; }
.history-summary { display: flex; gap: 10px; margin: 4px 0 14px; }
.history-summary .glass { flex: 1; border-radius: var(--r-md); padding: 12px 14px; }
.history-summary .kpi-small { font-size: 19px; }
.day-group { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 8px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.day-head span:first-letter { text-transform: uppercase; }
.day-head b { font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 700; }
.tx-list { border-radius: var(--r-md); overflow: hidden; padding: 0; }
.tx-item { position: relative; overflow: hidden; }
.tx-item + .tx-item { border-top: 1px solid var(--line); }
.tx-del {
  visibility: hidden;
  position: absolute; right: 0; top: 0; bottom: 0; width: 110px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tx-del .ico { width: 18px; height: 18px; }
.tx-item.reveal .tx-del { visibility: visible; }
.tx-row {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: rgba(255,255,255,.62);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transition: transform .25s ease; touch-action: pan-y; cursor: pointer; user-select: none;
}
.tx-row.dragging { transition: none; }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-sub { font-size: 13px; color: var(--ink-3); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amt.income { color: var(--income); }
.tx-hover-del { display: none; }
@media (hover: hover) and (pointer: fine) {
  .tx-hover-del { display: grid; opacity: 0; width: 34px; height: 34px; border-radius: 10px; place-items: center; color: var(--ink-3); transition: opacity .15s; }
  .tx-hover-del:hover { color: var(--accent); background: var(--accent-soft); }
  .tx-row:hover .tx-hover-del { opacity: 1; }
  .tx-hover-del .ico { width: 18px; height: 18px; }
}

/* ---------- Split ---------- */
.split-input { text-align: center; padding: 26px 20px; }
.amount-input-wrap { display: flex; align-items: baseline; justify-content: center; gap: 8px; cursor: text; }
.amount-input {
  width: 1.2ch; min-width: .8em; max-width: 100%; border: 0; background: transparent; outline: none; text-align: center;
  font-size: 56px; font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums; padding: 0;
}
.amount-input::placeholder { color: rgba(0,0,0,.15); }
.amount-cur { font-size: 34px; font-weight: 800; color: var(--ink-3); }
.split-results { display: grid; gap: 10px; }
@media (min-width: 700px) { .split-results { grid-template-columns: 1fr 1fr; } }
.split-card { display: flex; align-items: center; gap: 14px; border-radius: var(--r-md); padding: 16px; }
.split-card .nm { font-weight: 700; font-size: 15px; }
.split-card .pc { font-size: 13px; font-weight: 600; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.split-card .pc .ico { width: 13px; height: 13px; color: var(--warn); fill: var(--warn); }
.split-card .am { margin-left: auto; font-size: 28px; font-weight: 900; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.split-total { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; margin-top: 10px; border-radius: var(--r-md); font-weight: 700; }
.split-total b { font-size: 20px; font-weight: 900; }
.pct-bar { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.06); gap: 2px; margin: 4px 0 10px; }
.pct-bar i { display: block; height: 100%; }
.pct-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.pct-status.ok { color: var(--income); }
.pct-status.ko { color: var(--warn); }
.pct-status .ico { width: 18px; height: 18px; }
.alert-box { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); background: rgba(183,121,31,.1); color: #7a4f12; font-weight: 600; font-size: 14px; }
.alert-box .ico { width: 20px; height: 20px; flex: none; }

/* ---------- Catégories / listes triables ---------- */
.sort-list { border-radius: var(--r-md); overflow: hidden; }
.sort-item { display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 14px; background: rgba(255,255,255,.55); }
.sort-item + .sort-item { border-top: 1px solid var(--line); }
.sort-item.dragging { position: relative; z-index: 5; background: #fff; box-shadow: 0 12px 30px -10px rgba(0,0,0,.3); border-radius: 14px; }
.sort-item .info { flex: 1; min-width: 0; cursor: pointer; }
.sort-item .nm { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.sort-item .sub { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.sort-item .pct { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.handle { width: 36px; height: 40px; display: grid; place-items: center; color: var(--ink-3); touch-action: none; cursor: grab; }
.handle .ico { width: 20px; height: 20px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 7px; background: rgba(0,0,0,.06); color: var(--ink-2); }
.badge .ico { width: 11px; height: 11px; }
.badge.star { background: rgba(183,121,31,.12); color: #8a5a14; }
.tabs-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* ---------- Feuille modale ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20,18,20,.28); opacity: 0; pointer-events: none; transition: opacity .25s; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0;
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border-radius: 28px 28px 0 0; padding: 10px 20px calc(var(--safe-b) + 22px);
  transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.8,.2,1);
  border-bottom: 0;
}
.sheet.open { transform: none; }
.sheet:not(.open) { visibility: hidden; transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s .32s; }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.15); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -.02em; }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { flex: 1; height: 52px; font-size: 16px; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; border-radius: 28px; border-bottom: 1px solid var(--glass-border);
    transform: translate(-50%, -46%) scale(.97); opacity: 0; pointer-events: none; transition: transform .25s, opacity .2s; padding-bottom: 22px; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
  .sheet:not(.open) { transition: transform .25s, opacity .2s, visibility 0s .25s; }
  .sheet-grab { display: none; }
}

/* Saisie d'une opération */
.tx-amount { text-align: center; margin: 14px 0 6px; }
.tx-amount .amount-input { font-size: 52px; }
.tx-amount.expense .amount-input { color: var(--accent); }
.tx-amount.income .amount-input { color: var(--income); }
.cat-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.cat-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 16px; border: 2px solid transparent; background: rgba(255,255,255,.55); font-size: 12px; font-weight: 700; text-align: center; line-height: 1.2; transition: border-color .15s, background .15s; }
.cat-opt span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.cat-opt.on { border-color: var(--ink); background: #fff; }
.cat-opt .cat-ico { width: 38px; height: 38px; border-radius: 12px; }
.cat-opt.add { color: var(--ink-3); border: 2px dashed rgba(0,0,0,.12); background: transparent; }
.cat-opt.add .cat-ico { background: rgba(0,0,0,.05); color: var(--ink-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Palette & icônes */
.palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; }
.swatch { aspect-ratio: 1; border-radius: 50%; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.on::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2.5px solid var(--ink); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; max-height: 210px; overflow-y: auto; padding: 2px; }
.icon-opt { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.55); color: var(--ink-2); border: 2px solid transparent; }
.icon-opt.on { color: #fff; border-color: transparent; }
.preview-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.55); margin-top: 6px; }
.preview-row .cat-ico { width: 48px; height: 48px; border-radius: 15px; }
.preview-row .nm { font-weight: 800; font-size: 17px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.55); margin-top: 16px; }
.toggle-row .t { font-weight: 700; font-size: 15px; }
.toggle-row .d { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: rgba(0,0,0,.14); transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(20px); }
.form-error { color: var(--accent); font-weight: 700; font-size: 14px; margin-top: 12px; min-height: 1px; }
.confirm-text { color: var(--ink-2); font-weight: 600; margin: 6px 0 0; }

/* Toast (annuler) */
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--safe-b) + 96px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px; border-radius: 18px;
  font-weight: 700; font-size: 14.5px; transition: all .25s; white-space: nowrap; max-width: calc(100vw - 32px);
}
.toast:not(.show) { visibility: hidden; transition: all .25s, visibility 0s .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast .btn { height: 38px; }
@media (min-width: 1000px) { .toast { bottom: 30px; left: calc(50% + 125px); } }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; border-radius: 30px; padding: 34px 26px; text-align: center; }
.login-logo img { width: 72px; height: 72px; border-radius: 20px; box-shadow: 0 10px 25px -10px rgba(0,0,0,.4); }
.login-title { font-size: 30px; font-weight: 900; margin: 16px 0 4px; letter-spacing: -.02em; }
.login-sub { color: var(--ink-3); font-weight: 600; margin: 0 0 22px; }
.login-card .field { margin-bottom: 12px; text-align: center; }
.login-error { color: var(--accent); font-weight: 700; font-size: 14px; margin: 0 0 12px; }
