/* ============================================
   Caisse v3 — Soft Light Wallet
   ============================================ */

:root {
  /* Toile */
  --bg:        #fafaf7;
  --surface:   #ffffff;
  --surface-2: #f5f4ee;
  --border:    #ebe9e3;
  --border-2:  #e0ddd5;

  /* Encre */
  --ink:       #1a1a1a;
  --ink-2:     #4d4d48;
  --ink-3:     #8a8a82;
  --ink-4:     #b8b6ad;

  /* Sémantique */
  --green:     #0fa968;
  --green-bg:  #dff5ea;
  --red:       #e85d4d;
  --red-bg:    #fde6e3;
  --blue:      #4d7cdb;
  --blue-bg:   #e0ebfc;
  --amber:     #d97706;

  /* Pastels (cartes de comptes) */
  --p-lavender: #d4c5f7;
  --p-peach:    #ffd4b3;
  --p-mint:     #b8e5d3;
  --p-sky:      #bcdbf3;
  --p-rose:     #f7c5c8;
  --p-sand:     #f0e4c2;
  --p-sage:     #d4dfc8;
  --p-lilac:    #e8c5e5;

  /* Forme */
  --r-sm: 12px;
  --r:    18px;
  --r-lg: 24px;
  --r-xl: 32px;

  /* Ombres très douces */
  --sh-sm: 0 1px 2px rgba(26, 26, 26, 0.04), 0 1px 3px rgba(26, 26, 26, 0.06);
  --sh:    0 2px 4px rgba(26, 26, 26, 0.04), 0 4px 16px rgba(26, 26, 26, 0.06);
  --sh-lg: 0 8px 24px rgba(26, 26, 26, 0.08), 0 16px 40px rgba(26, 26, 26, 0.06);

  --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t:      220ms cubic-bezier(0.4, 0, 0.2, 1);
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

input, button, select, textarea {
  font: inherit; color: inherit;
  -webkit-appearance: none; appearance: none;
  border: none; outline: none; background: none;
  letter-spacing: inherit;
}
input[type="date"], input[type="number"], input[type="text"],
input[type="search"], input[type="tel"], select, textarea {
  font-size: 16px; /* iOS no-zoom */
}
button { cursor: pointer; }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; }
.tab-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }

.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ============================================
   LAYOUT
   ============================================ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ----- Bandeau "Voyage dans le temps" ----- */
.time-banner {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px calc(10px + env(safe-area-inset-top)) 18px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(135deg, #ffd166 0%, #f4a261 100%);
  color: #3d2a05;
  font-size: 13px;
  position: sticky; top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(244, 162, 97, 0.25);
}
.time-banner .icon { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 2.2; }
.time-banner-text { flex: 1; min-width: 0; line-height: 1.35; }
.time-banner-text strong { font-weight: 700; }
.time-banner-date {
  background: rgba(0,0,0,0.1);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.time-banner-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  background: rgba(0, 0, 0, 0.85);
  color: #ffd166;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.time-banner-btn:hover { background: #1a1a1a; }
.time-banner-btn .icon { width: 14px; height: 14px; }

/* Carte voyage dans le temps active */
.card-tinted.time-card-active {
  background: #fff5dc;
  border: 1.5px solid #f4a261;
}

@media (max-width: 900px) { .app { grid-template-columns: 1fr; } }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  padding: 24px 14px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex; flex-direction: column; gap: 2px;
}
@media (max-width: 900px) { .sidebar { display: none; } }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 24px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center;
  font-weight: 700; letter-spacing: -0.04em;
}
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 17px; }
.brand-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  color: var(--ink-2); transition: background var(--t-fast), color var(--t-fast);
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--ink); color: var(--bg);
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

/* ----- Comptes favoris (sidebar) ----- */
.fav-section {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1px;
}
.fav-head {
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px 8px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3);
}
.fav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
  font-size: 13px;
}
.fav-item:hover { background: var(--surface-2); color: var(--ink); }
.fav-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.fav-name {
  flex: 1; min-width: 0;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fav-bal {
  font-size: 11px; font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.fav-bal.neg { color: var(--red); }
.fav-item:hover .fav-bal { color: var(--ink); }

/* ----- Toggle Favori (modale compte) ----- */
.fav-toggle {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  text-align: left;
  transition: all var(--t-fast);
  color: var(--ink-3);
}
.fav-toggle:hover { border-color: var(--border-2); }
.fav-toggle.on {
  background: #fef9e7;
  border-color: #f6c947;
  color: #8a6d10;
  box-shadow: 0 0 0 3px rgba(246, 201, 71, 0.15);
}
.fav-toggle.on .icon-lg { color: #d4a017; }
.fav-toggle .fav-toggle-text { flex: 1; min-width: 0; }
.fav-toggle-title {
  font-size: 14px; font-weight: 600;
  color: inherit;
}
.fav-toggle-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.fav-toggle.on .fav-toggle-sub { color: #a07e1e; }

.fav-toggle-switch {
  position: relative;
  width: 42px; height: 24px;
  background: var(--border-2);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.fav-toggle-switch.on { background: #f6c947; }
.fav-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--t-fast);
}
.fav-toggle-switch.on .fav-toggle-knob { transform: translateX(18px); }

.main {
  padding: 28px 36px 120px;
  max-width: 1200px; width: 100%;
  margin: 0 auto;
}
@media (max-width: 900px) { .main { padding: 0 16px 100px; padding-top: calc(8px + env(safe-area-inset-top)); } }

/* Header mobile */
.mob-header {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 12px 0 16px;
}
@media (max-width: 900px) { .mob-header { display: flex; } }

/* Bottom navigation */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(250, 250, 247, 0.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}
@media (max-width: 900px) { .bottom-nav { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; } }

.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 4px;
  color: var(--ink-3); font-size: 10px; font-weight: 500;
  border-radius: 12px;
}
.bn-item.active { color: var(--ink); }
.bn-item .icon { width: 20px; height: 20px; stroke-width: 2; }
.bn-item.active .icon { stroke-width: 2.5; }

.bn-fab { transform: translateY(-14px); }
.bn-fab .fab-circle {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(26, 26, 26, 0.25);
}
.bn-fab .fab-circle .icon { width: 22px; height: 22px; stroke-width: 2.5; }

/* ============================================
   HERO (total)
   ============================================ */
.hero {
  padding: 8px 4px 24px;
}
.hero-label {
  font-size: 13px; font-weight: 500;
  color: var(--ink-3);
}
.hero-amount {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 56px; line-height: 1.05; font-weight: 600;
  letter-spacing: -0.04em; margin-top: 8px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) { .hero-amount { font-size: 44px; } }

.hero-deltas {
  display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap;
}
.delta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
}
.delta .dot { width: 6px; height: 6px; border-radius: 50%; }
.delta.up .dot { background: var(--green); }
.delta.down .dot { background: var(--red); }
.delta .lbl { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.delta .val { font-weight: 600; }
.delta.up .val { color: var(--green); }
.delta.down .val { color: var(--red); }

/* ============================================
   SECTION HEAD
   ============================================ */
.sec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 4px 12px;
}
.sec-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.sec-link {
  font-size: 13px; color: var(--ink-3); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
  transition: color var(--t-fast);
}
.sec-link:hover { color: var(--ink); }

/* ============================================
   ACCOUNT CARDS (pastels)
   ============================================ */
.acc-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 220px;
  gap: 12px; padding: 4px 4px 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 900px) {
  .acc-row {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-auto-columns: unset;
    overflow: visible;
  }
}

.acc-card {
  position: relative;
  scroll-snap-align: start;
  background: var(--ac, var(--p-lavender));
  border-radius: var(--r-lg);
  padding: 18px 18px 20px;
  text-align: left;
  min-height: 140px;
  display: flex; flex-direction: column;
  justify-content: space-between;
  transition: transform var(--t), box-shadow var(--t);
  border: 1px solid rgba(0,0,0,0.04);
  color: var(--ink);
  isolation: isolate;
}
.acc-card:hover { transform: translateY(-2px); box-shadow: var(--sh); }
.acc-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(155deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0) 50%);
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
}

.acc-head {
  display: flex; align-items: center; justify-content: space-between;
}
.acc-icon {
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(26, 26, 26, 0.08);
  display: grid; place-items: center;
  color: var(--ink);
}
.acc-fav { color: rgba(26, 26, 26, 0.4); }
.acc-fav.on { color: var(--ink); }

/* Désactive le menu natif iOS sur appui long et la sélection de texte */
.acc-card {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ----- Bandeau récap du compte filtré ----- */
.acc-summary {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
  overflow: hidden;
  isolation: isolate;
}
.acc-summary::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--ac, var(--p-lavender)) 0%, transparent 80%);
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}
.acc-summary::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--ac, var(--p-lavender));
}

.acc-summary-top {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.acc-summary-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.06);
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--ink);
}
.acc-summary-meta { flex: 1; min-width: 0; }
.acc-summary-name {
  font-size: 16px; font-weight: 700; letter-spacing: -0.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-summary-type {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-top: 2px;
}

.acc-summary-balances {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.balance-card {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
}
.balance-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3);
}
.balance-label .icon { width: 13px; height: 13px; }
.balance-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px; font-weight: 600; letter-spacing: -0.025em;
  margin-top: 6px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.balance-value.neg { color: var(--red); }
.balance-value.diff { color: var(--ink-2); }
.balance-sub {
  font-size: 11px; color: var(--ink-3);
  margin-top: 2px;
}

.balance-card-diff {
  background: rgba(255, 245, 220, 0.7);
  border-color: rgba(217, 119, 6, 0.2);
}
.balance-card-diff .balance-label { color: var(--amber); }

.acc-name {
  font-size: 14px; font-weight: 600; margin-top: 14px;
  opacity: 0.85;
}
.acc-balance {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px; font-weight: 600; letter-spacing: -0.025em;
  margin-top: 4px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.acc-balance.neg { color: var(--red); }
.acc-balance-recon {
  display: flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; font-weight: 500;
  color: rgba(26, 26, 26, 0.55);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.acc-balance-recon .icon { width: 11px; height: 11px; stroke-width: 2.5; }
.acc-balance-recon .lbl-mini {
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; font-size: 10px;
}
.acc-type {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(26, 26, 26, 0.55);
  margin-top: 6px;
}

/* Statut des opérations dans la liste */
.row.void { opacity: 0.45; }
.row.void .row-title,
.row.void .row-amt { text-decoration: line-through; }
.row.void .row-pill { filter: grayscale(0.6); }

/* Segment plus dense pour le statut */
.seg.seg-compact button {
  padding: 8px 4px;
  font-size: 12px;
}
.seg.seg-compact button .icon { width: 14px; height: 14px; }

/* Add card */
.acc-card.add {
  background: var(--surface);
  border: 1.5px dashed var(--border-2);
  color: var(--ink-3);
  align-items: center; justify-content: center;
  text-align: center;
}
.acc-card.add::before { display: none; }
.acc-card.add:hover { border-color: var(--ink); color: var(--ink); }
.acc-card.add .acc-icon {
  background: var(--surface-2);
  margin-bottom: 8px;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.qa-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: 8px 0 8px;
}
@media (max-width: 600px) { .qa-row { grid-template-columns: repeat(2, 1fr); } }

.qa {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 12px;
  display: flex; align-items: center; gap: 10px;
  transition: border-color var(--t-fast), transform var(--t-fast);
  text-align: left;
}
.qa:hover { border-color: var(--ink); transform: translateY(-1px); }
.qa-ico {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2);
  flex-shrink: 0;
}
.qa-ico.dn { background: var(--red-bg); color: var(--red); }
.qa-ico.up { background: var(--green-bg); color: var(--green); }
.qa-ico.tr { background: var(--blue-bg); color: var(--blue); }
.qa-ico.rc { background: #f3edff; color: #6d4ed4; }
.qa-lbl { font-size: 13px; font-weight: 600; }

/* ============================================
   ROWS / LIST
   ============================================ */
.list { display: flex; flex-direction: column; gap: 2px; }

.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.row + .row { border-top: 1px solid var(--border); border-radius: var(--r); }
.row:hover { background: var(--surface-2); border-color: var(--border); }

.row-pill {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--c, var(--surface-2));
  color: var(--ink);
  position: relative;
}
.row-pill.up { background: var(--green-bg); color: var(--green); }
.row-pill.down { background: var(--red-bg); color: var(--red); }
.row-pill.tr { background: var(--blue-bg); color: var(--blue); }

.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub {
  font-size: 12px; color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-amt {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.row-amt.up { color: var(--green); }
.row-amt.down { color: var(--ink); }

/* ----- Pastille de statut cliquable ----- */
.status-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.status-dot:hover { background: var(--surface-2); }
.status-dot:active { transform: scale(0.88); }

.status-dot-inner {
  display: block;
  width: 16px; height: 16px;
  border-radius: 50%;
  transition: all var(--t-fast);
}

/* Non rapprochée : cercle vide */
.status-dot.pending .status-dot-inner {
  background: transparent;
  border: 1.8px solid var(--ink-4);
}
.status-dot.pending:hover .status-dot-inner {
  border-color: var(--green);
}

/* Rapprochée : disque plein vert */
.status-dot.reconciled .status-dot-inner {
  background: var(--green);
  border: 1.8px solid var(--green);
  box-shadow: 0 0 0 3px rgba(15, 169, 104, 0.15);
}

/* Nulle : disque rouge avec barre */
.status-dot.void-status .status-dot-inner {
  background: var(--red);
  border: 1.8px solid var(--red);
  position: relative;
}
.status-dot.void-status .status-dot-inner::after {
  content: '';
  position: absolute;
  top: 50%; left: 15%; right: 15%;
  height: 2px;
  background: white;
  border-radius: 2px;
  transform: translateY(-50%) rotate(-45deg);
}

.day-sep {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 4px 8px;
  font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700;
}
.day-sep::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}

/* Group container so rows look connected */
.list-grouped .row { background: transparent; border-radius: 0; }
.list-grouped .row + .row { border-top: 1px solid var(--border); }
.list-grouped {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.list-grouped .row:first-child { border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg); }
.list-grouped .row:last-child { border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-lg); }
.list-grouped .row:hover { background: var(--surface-2); }

/* ============================================
   CARDS / SURFACES
   ============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card-tinted {
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: 16px;
}

/* ============================================
   FORMS
   ============================================ */
.lbl {
  display: block; margin-bottom: 6px;
  font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700;
}
.input, select.input, textarea.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  color: var(--ink);
  transition: border-color var(--t-fast);
}
.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--ink);
}
select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
input[type="color"].input { padding: 4px; height: 44px; cursor: pointer; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  font-weight: 600; font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--ink); color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: #2a2a2a; border-color: #2a2a2a; }

.btn-ghost {
  background: transparent; border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }

.btn-danger { color: var(--red); }
.btn-danger:hover { color: var(--red); background: var(--red-bg); border-color: var(--red-bg); }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; border-radius: var(--r); }

.icon { width: 16px; height: 16px; stroke-width: 2; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 28px; height: 28px; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px; color: var(--ink-2); font-weight: 500;
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip-pastel { background: var(--c, var(--surface-2)); border-color: transparent; color: var(--ink); }
.chip-pastel.active { background: var(--ink); color: var(--bg); }

.tag-mini {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; font-size: 11px; font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.tag-mini.up { background: var(--green-bg); color: var(--green); }
.tag-mini.down { background: var(--red-bg); color: var(--red); }
.tag-mini.tr { background: var(--blue-bg); color: var(--blue); }

/* Segmented */
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 4px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.seg button {
  padding: 10px 8px;
  border-radius: 9px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--t-fast);
}
.seg button.active {
  color: var(--ink); background: var(--surface);
  box-shadow: var(--sh-sm);
}

/* ============================================
   SHEETS / MODAL
   ============================================ */
.sheet-bg {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(26, 26, 26, 0.4);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s;
}
@media (min-width: 700px) { .sheet-bg { align-items: center; padding: 20px; } }

.sheet {
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-lg);
  padding-bottom: env(safe-area-inset-bottom);
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@media (min-width: 700px) { .sheet { border-radius: var(--r-xl); border-bottom: 1px solid var(--border); } }

.sheet-handle {
  display: block;
  width: 40px; height: 4px;
  background: var(--border-2);
  border-radius: 4px;
  margin: 10px auto 0;
}
@media (min-width: 700px) { .sheet-handle { display: none; } }

.sheet-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  padding: 16px 22px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sheet-title {
  font-size: 19px; font-weight: 700; letter-spacing: -0.015em;
}
.sheet-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.sheet-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--ink-2);
}

.sheet-body { padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 16px; }
.row-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================================
   AMOUNT INPUT (saisie)
   ============================================ */
.amt-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display: flex; align-items: baseline; gap: 8px;
  transition: border-color var(--t-fast);
}
.amt-input:focus-within { border-color: var(--ink); }
.amt-input input {
  flex: 1;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 40px; font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  background: none; border: none; outline: none;
  padding: 0; min-width: 0;
  font-variant-numeric: tabular-nums;
}
.amt-input input::placeholder { color: var(--ink-4); }
.amt-input .cur {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 24px; color: var(--ink-3);
  font-weight: 500;
}

/* Suggestions */
.suggestions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}

/* ============================================
   ACCOUNT PICKER (saisie)
   ============================================ */
.acc-pick {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.acc-pick-item {
  position: relative;
  background: var(--ac, var(--surface));
  border: 2px solid transparent;
  border-radius: var(--r);
  padding: 12px 14px;
  text-align: left;
  transition: all var(--t-fast);
  display: flex; flex-direction: column;
  min-height: 70px;
  justify-content: space-between;
}
.acc-pick-item.active {
  border-color: var(--ink);
  transform: scale(0.98);
}
.acc-pick-item .nm { font-size: 13px; font-weight: 600; color: var(--ink); }
.acc-pick-item .bl {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600;
  color: var(--ink); margin-top: 4px;
  font-variant-numeric: tabular-nums; opacity: 0.75;
}

/* ============================================
   CATEGORY BARS (donut alternative)
   ============================================ */
.cat-bar { display: flex; flex-direction: column; gap: 14px; }
.cat-bar-row { display: flex; flex-direction: column; gap: 6px; }
.cat-bar-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}
.cat-bar-head .left { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.cat-bar-head .left .dot { width: 10px; height: 10px; border-radius: 4px; flex-shrink: 0; }
.cat-bar-head .amt {
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 500;
}
.cat-bar-track {
  height: 6px; border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 96px; z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--sh-lg);
}
@media (min-width: 900px) { .toast { bottom: 32px; } }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.section { animation: fadeUp 0.25s ease-out; }

/* ============================================
   UTILITY
   ============================================ */
.flex { display: flex; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-1 { flex: 1; } .flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-2 { color: var(--ink-2); } .text-3 { color: var(--ink-3); } .text-4 { color: var(--ink-4); }
.text-up { color: var(--green); } .text-dn { color: var(--red); }
.text-sm { font-size: 13px; } .text-xs { font-size: 11px; } .text-lg { font-size: 18px; }
.fw-5 { font-weight: 500; } .fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.uppercase { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; font-weight: 700; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }

.empty {
  text-align: center; padding: 56px 16px;
  color: var(--ink-3); font-size: 14px;
}
.empty .icon-xl { color: var(--ink-4); margin-bottom: 14px; display: block; margin-left: auto; margin-right: auto; }
.empty .empty-t { font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }

/* ============================================
   IMPORT CSV
   ============================================ */
.csv-preview {
  font-size: 12px;
  border-collapse: collapse;
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
}
.csv-preview th, .csv-preview td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.csv-preview th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink);
  position: sticky; top: 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.csv-preview tbody tr:hover { background: var(--surface-2); }

.mapping-grid {
  display: grid; gap: 10px;
}
.mapping-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  align-items: center;
}
@media (max-width: 600px) {
  .mapping-row { grid-template-columns: 1fr; }
}
.mapping-label {
  font-size: 13px; font-weight: 600;
}
.mapping-label .text-xs {
  font-weight: 400;
  margin-top: 1px;
}
