/* ── Reset & Variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0e0c;
  --bg2:       #161410;
  --surface:   #1c1a16;
  --surface2:  #242118;
  --border:    #2e2b22;
  --border2:   #3a3628;
  --text:      #f0ead8;
  --text2:     #a09880;
  --text3:     #6a6250;
  --amber:     #f0a020;
  --amber2:    #d48a10;
  --amber-dim: #f0a02022;
  --gain:      #34c77b;
  --loss:      #e05050;
  --chart1:    #f0a020;
  --chart2:    #f5c842;
  --chart3:    #e87830;
  --chart4:    #a0c878;
  --chart5:    #5898d8;
  --chart6:    #c868a8;
  --radius:    12px;
  --radius-sm: 8px;
  --font-body: 'Instrument Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --font-head: 'Syne', sans-serif;
  --sidebar-w: 220px;
  --header-h:  56px;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }
/* ── Sidebar ───────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease, transform .25s ease;
  z-index: 50;
}
#sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
#sidebar-logo .logo-mark {
  width: 28px; height: 28px;
  background: var(--amber);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 14px;
  color: #0f0e0c;
  flex-shrink: 0;
}
#sidebar-logo .logo-text {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -.3px;
}
nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text2);
  transition: background .15s, color .15s;
  user-select: none;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--amber-dim); color: var(--amber); }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}

/* ── Main ──────────────────────────────────────────────────────────────── */
#main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}
#menu-btn {
  display: none;
  background: none; border: none; color: var(--text2); cursor: pointer; padding: 4px;
}
#topbar h2 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
#topbar .topbar-sub { font-size: 12px; color: var(--text3); margin-left: 2px; }
#content {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
/* Empêche les enfants de se comprimer — ils doivent s'empiler et scroller */
#content > * { flex-shrink: 0; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  animation: fadeUp .35s ease both;
}
@keyframes fadeUp {
  from { opacity:0; transform: translateY(8px); }
  to   { opacity:1; transform: translateY(0); }
}
.card-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.card-title .hint { font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--text3); }

/* ── Stat cards grid ───────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: fadeUp .35s ease both;
}
.stat-card .stat-icon {
  width: 32px; height: 32px;
  background: var(--amber-dim);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--amber);
  margin-bottom: 10px;
}
.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 3px; }
.stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.stat-trend { font-size: 11px; margin-top: 4px; }
.stat-trend.up { color: var(--gain); }
.stat-trend.down { color: var(--loss); }

/* ── Grid helpers ──────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Table ─────────────────────────────────────────────────────────────── */
.account-rows { display: flex; flex-direction: column; gap: 2px; }
.account-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px;
  border-radius: 6px;
  gap: 8px;
  transition: background .12s;
}
.account-row:hover { background: var(--surface2); }
.account-row .row-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.account-row .row-name { color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-row .row-bank { color: var(--text3); font-size: 11px; white-space: nowrap; }
.account-row .del-btn {
  opacity: 0; background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 3px; border-radius: 5px;
  transition: opacity .15s, color .15s, background .15s;
  flex-shrink: 0;
}
.account-row:hover .del-btn { opacity: 1; }
.del-btn:hover { color: var(--loss) !important; background: #e0505018 !important; }
.row-total {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}
.row-total .label { color: var(--text3); }
.row-total .val { font-family: var(--font-mono); color: var(--amber); }

/* ── Editable amount ───────────────────────────────────────────────────── */
.amount-display {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  padding: 2px 5px;
  border-radius: 5px;
  transition: background .12s, color .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.amount-display:hover { background: var(--amber-dim); color: var(--amber); }
.amount-display .edit-icon { opacity: 0; transition: opacity .12s; }
.amount-display:hover .edit-icon { opacity: .6; }
.amount-input {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--amber);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 7px;
  width: 100px;
  text-align: right;
  outline: none;
  box-shadow: 0 0 0 3px var(--amber-dim);
}
.edit-actions { display: flex; gap: 3px; align-items: center; }
.edit-ok, .edit-cancel {
  background: none; border: none; cursor: pointer;
  padding: 3px; border-radius: 4px; transition: background .12s;
}
.edit-ok { color: var(--gain); }
.edit-ok:hover { background: #34c77b18; }
.edit-cancel { color: var(--loss); }
.edit-cancel:hover { background: #e0505018; }

/* ── Add form ──────────────────────────────────────────────────────────── */
.add-form {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 8px;
  display: none;
  flex-direction: column;
  gap: 8px;
  animation: fadeUp .2s ease;
}
.add-form.open { display: flex; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-input {
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-dim); }
.form-input.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn { 
  font-family: var(--font-body);
  font-size: 12px; font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn-primary { background: var(--amber); color: #0f0e0c; }
.btn-primary:hover { opacity: .85; }
.btn-ghost { background: transparent; color: var(--text3); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon {
  display: flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid var(--border2);
  color: var(--text3); font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s, color .15s;
  font-family: var(--font-body);
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* ── Repartition bar ───────────────────────────────────────────────────── */
.repartition-bar {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  height: 22px;
  margin-bottom: 16px;
}
.repartition-bar .seg { transition: width .5s ease; }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.legend-item { display: flex; align-items: flex-start; gap: 8px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; margin-top: 3px; }
.legend-item .lg-label { font-size: 11px; color: var(--text2); }
.legend-item .lg-pct { font-size: 11px; color: var(--text3); }
.legend-item .lg-val { font-family: var(--font-mono); font-size: 12px; color: var(--text); }

/* ── Enveloppes ────────────────────────────────────────────────────────── */
.enveloppe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
.env-card { display: flex; flex-direction: column; gap: 6px; }
.env-label { font-size: 11px; color: var(--text3); }
.env-amount .amount-display { font-size: 17px; font-weight: 500; padding: 0; }
.env-amount .amount-display:hover { background: none; }
.env-bar-bg { height: 4px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-top: 2px; }
.env-bar-fg { height: 100%; border-radius: 4px; transition: width .5s; }
.env-target { font-size: 10px; color: var(--text3); }

/* ── Allocation chart ──────────────────────────────────────────────────── */
.alloc-rows { display: flex; flex-direction: column; gap: 10px; }
.alloc-row { display: flex; flex-direction: column; gap: 4px; }
.alloc-header { display: flex; justify-content: space-between; font-size: 12px; }
.alloc-name { color: var(--text2); }
.alloc-vals { color: var(--text3); font-family: var(--font-mono); font-size: 11px; gap: 8px; display: flex; }
.alloc-bar-bg { height: 6px; background: var(--surface2); border-radius: 4px; overflow: hidden; position: relative; }
.alloc-bar-reel { height: 100%; border-radius: 4px; background: var(--amber); transition: width .5s; }
.alloc-bar-cible { position: absolute; top: 0; height: 100%; width: 2px; background: var(--text3); border-radius: 2px; }

/* ── Evolution chart ───────────────────────────────────────────────────── */
#evo-canvas { width: 100%; height: 180px; }
.evo-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

/* ── Budget bars ───────────────────────────────────────────────────────── */
.budget-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.budget-bar-label { width: 130px; font-size: 12px; color: var(--text2); flex-shrink: 0; }
.budget-bar-bg { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.budget-bar-fill { height: 100%; border-radius: 4px; transition: width .5s; }
.budget-bar-val { width: 90px; text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--text); flex-shrink: 0; }

/* ── Loan card ─────────────────────────────────────────────────────────── */
.loan-card { display: flex; flex-direction: column; gap: 14px; }
.loan-header { display: flex; justify-content: space-between; align-items: flex-start; }
.loan-name { font-family: var(--font-head); font-weight: 600; font-size: 14px; }
.loan-end { font-size: 11px; color: var(--text3); margin-top: 2px; }
.loan-monthly { font-family: var(--font-mono); font-size: 15px; font-weight: 500; color: var(--amber); text-align: right; }
.loan-rate { font-size: 11px; color: var(--text3); text-align: right; }
.loan-progress-bg { height: 6px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.loan-progress-fg { height: 100%; background: var(--amber); border-radius: 4px; transition: width .5s; }
.loan-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.loan-stat-label { font-size: 10px; color: var(--text3); }
.loan-stat-val { font-family: var(--font-mono); font-size: 12px; color: var(--text); margin-top: 2px; }

/* ── Invest table ──────────────────────────────────────────────────────── */
.invest-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: right; padding: 7px 8px;
  font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text3); border-bottom: 1px solid var(--border);
}
th:first-child, th:nth-child(2) { text-align: left; }
td {
  padding: 7px 8px; border-bottom: 1px solid var(--border);
  text-align: right; font-family: var(--font-mono);
  color: var(--text);
}
td:first-child, td:nth-child(2) { text-align: left; font-family: var(--font-body); }
td:first-child { color: var(--text3); font-size: 11px; }
tbody tr:hover td { background: var(--surface2); }
tfoot td { font-weight: 600; border-top: 2px solid var(--border); border-bottom: none; }
.pnl-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 20px; font-size: 11px; font-weight: 500;
  font-family: var(--font-mono);
}
.pnl-badge.up { background: #34c77b18; color: var(--gain); }
.pnl-badge.down { background: #e0505018; color: var(--loss); }
.text-gain { color: var(--gain); }
.text-loss { color: var(--loss); }

/* ── Invest tabs ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab {
  font-size: 12.5px; font-weight: 500; padding: 8px 14px;
  cursor: pointer; color: var(--text3); border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  font-family: var(--font-body);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ── Evolution history ─────────────────────────────────────────────────── */
.evo-list { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
.evo-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 4px; border-radius: 6px; }
.evo-row:hover { background: var(--surface2); }
.evo-date { font-family: var(--font-mono); font-size: 11px; color: var(--text3); }
.evo-val { font-family: var(--font-mono); font-size: 13px; color: var(--text); }

/* ── Collapse ──────────────────────────────────────────────────────────── */
.collapsible-header { cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.collapsible-header:hover .card-title { color: var(--amber); }
.collapsible-body { display: none; margin-top: 14px; }
.collapsible-body.open { display: block; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 13px;
  opacity: 0; transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ── Mobile overlay ────────────────────────────────────────────────────── */
#sidebar-overlay {
  display: none; position: fixed; inset: 0; background: #0009; z-index: 40;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px #0006;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.show { display: block; }
  #menu-btn { display: flex; align-items: center; justify-content: center; }
  #content { padding: 16px; gap: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .loan-stats { grid-template-columns: repeat(2, 1fr); }
  .enveloppe-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .legend-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Modale de confirmation ────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0; background: #000a;
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
.confirm-box {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 28px 28px 22px;
  width: 100%; max-width: 380px;
  animation: fadeUp .2s ease;
  display: flex; flex-direction: column; gap: 10px;
}
.confirm-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: #e0505018; display: flex; align-items: center; justify-content: center;
  color: var(--loss); margin-bottom: 2px;
}
.confirm-title {
  font-family: var(--font-head); font-weight: 700; font-size: 15px; color: var(--text);
  line-height: 1.4;
}
.confirm-sub {
  font-size: 12px; color: var(--text3); margin-top: -4px;
}
.confirm-btns {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px;
}
.btn-danger { background: var(--loss); color: #fff; }
.btn-danger:hover { opacity: .85; }

/* ── Credits ───────────────────────────────────────────────────────────── */
.credit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp .35s ease both;
}
.credit-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background .15s;
}
.credit-card-header:hover { background: var(--surface2); }
.credit-card-header .credit-name {
  font-family: var(--font-head); font-weight: 700; font-size: 15px; color: var(--text);
}
.credit-card-header .credit-meta {
  font-size: 11px; color: var(--text3); margin-top: 2px;
}
.credit-monthly {
  font-family: var(--font-mono); font-size: 18px; font-weight: 500; color: var(--amber);
  text-align: right; flex-shrink: 0;
}
.credit-monthly small { font-size: 11px; color: var(--text3); font-family: var(--font-body); display: block; }

.credit-progress-wrap { padding: 0 20px 14px; }
.credit-progress-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text3); margin-bottom: 6px;
}
.credit-progress-labels .pct { color: var(--amber); font-family: var(--font-mono); font-weight: 500; }
.credit-progress-bg { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.credit-progress-fg { height: 100%; background: var(--amber); border-radius: 4px; transition: width .6s ease; }

.credit-kpis {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 0;
  border-top: 1px solid var(--border);
}
.credit-kpi {
  padding: 12px 16px; border-right: 1px solid var(--border);
}
.credit-kpi:last-child { border-right: none; }
.credit-kpi-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.credit-kpi-val { font-family: var(--font-mono); font-size: 13px; color: var(--text); font-weight: 500; }
.credit-kpi-val.amber { color: var(--amber); }
.credit-kpi-val.gain  { color: var(--gain); }
.credit-kpi-val.loss  { color: var(--loss); }

/* Tableau amortissement */
.amort-section { border-top: 1px solid var(--border); }
.amort-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; cursor: pointer; transition: background .15s;
  font-size: 12px; font-weight: 600; color: var(--text2);
}
.amort-toggle:hover { background: var(--surface2); }
.amort-toggle svg { transition: transform .2s; flex-shrink: 0; }
.amort-toggle.open svg { transform: rotate(180deg); }
.amort-table-wrap {
  display: none; overflow-x: auto; max-height: 380px; overflow-y: auto;
}
.amort-table-wrap.open { display: block; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.amort-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface2); color: var(--text3);
  font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.amort-table th:first-child { text-align: left; }
.amort-table td {
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  text-align: right; font-family: var(--font-mono); color: var(--text2);
}
.amort-table td:first-child { text-align: left; color: var(--text3); }
.amort-table tbody tr:hover td { background: var(--surface2); }
.amort-table tbody tr.current-row td { background: #f0a02012; color: var(--text); }
.amort-table tbody tr.current-row td:first-child { color: var(--amber); font-weight: 500; }
.amort-table tfoot td {
  background: var(--surface2); color: var(--text); font-weight: 600;
  border-top: 2px solid var(--border2); border-bottom: none;
}

/* Formulaire crédit */
.credit-form-overlay {
  display: none; position: fixed; inset: 0; background: #0009;
  z-index: 200; align-items: center; justify-content: center; padding: 16px;
}
.credit-form-overlay.open { display: flex; }
.credit-form-modal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 28px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  animation: fadeUp .25s ease;
}
.credit-form-modal h3 {
  font-family: var(--font-head); font-weight: 700; font-size: 17px;
  margin-bottom: 20px; color: var(--text);
}
.form-section-title {
  font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase;
  letter-spacing: .06em; margin: 18px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; color: var(--text3); }
.form-group input {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 10px; outline: none; width: 100%;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-dim); }
.form-group input[readonly] { opacity: 0; position: absolute; pointer-events: none; } /* caché, remplacé par .form-result */
.form-group input[type="month"] {
  font-family: var(--font-mono); font-size: 13px;
  color-scheme: dark;
}
.form-result {
  font-family: var(--font-mono); font-size: 14px; font-weight: 500;
  color: var(--amber); background: var(--amber-dim);
  border: 1px solid #f0a02040; border-radius: var(--radius-sm);
  padding: 8px 10px; display: block;
}
.form-group .form-hint { font-size: 10px; color: var(--text3); }
.form-group.full { grid-column: 1 / -1; }
.form-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
}
.credit-actions {
  display: flex; gap: 6px; align-items: center; flex-shrink: 0;
}
.credit-action-btn {
  background: none; border: 1px solid var(--border2); color: var(--text3);
  padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 11px; font-family: var(--font-body); font-weight: 500;
  display: flex; align-items: center; gap: 5px;
  transition: background .15s, color .15s;
}
.credit-action-btn:hover { background: var(--surface2); color: var(--text); }
.credit-action-btn.danger:hover { background: #e0505018; color: var(--loss); border-color: var(--loss); }

@media (max-width: 768px) {
  .credit-kpis { grid-template-columns: repeat(2, 1fr); }
  .credit-kpi { border-right: none; border-bottom: 1px solid var(--border); }
  .credit-kpi:nth-child(odd) { border-right: 1px solid var(--border); }
  .form-grid { grid-template-columns: 1fr; }
}

/* ── Virements ─────────────────────────────────────────────────────────── */
.vir-section { display: flex; flex-direction: column; gap: 3px; }
.vir-row {
  display: grid; grid-template-columns: 1fr 120px 80px 80px;
  align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  transition: background .12s;
}
.vir-row:hover { background: var(--surface2); }
.vir-row.header {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text3); font-weight: 600; padding-bottom: 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 2px;
}
.vir-name { font-size: 13px; color: var(--text); }
.vir-bank { font-size: 11px; color: var(--text3); }
.vir-input {
  font-family: var(--font-mono); font-size: 13px; text-align: right;
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: 6px; padding: 5px 8px; width: 100%; outline: none;
  transition: border-color .15s;
}
.vir-input:focus { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-dim); }
.vir-input:disabled { opacity: .35; cursor: not-allowed; }
.vir-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 18px; border-radius: 9px; cursor: pointer;
  background: var(--border2); transition: background .2s; flex-shrink: 0;
  border: none; position: relative;
}
.vir-toggle::after {
  content: ''; position: absolute; left: 3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--text3); transition: transform .2s, background .2s;
}
.vir-toggle.on { background: var(--amber); }
.vir-toggle.on::after { transform: translateX(14px); background: #fff; }
.vir-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; margin-top: 4px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.vir-total-row .label { color: var(--text3); font-weight: 600; }
.vir-total-row .val { font-family: var(--font-mono); color: var(--amber); font-weight: 500; }
.vir-summary-bar {
  display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 4px 0 10px;
}
.vir-step-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--amber);
  background: var(--amber-dim); border: 1px solid #f0a02030;
  border-radius: 20px; padding: 3px 10px; margin-bottom: 8px;
}
.vir-salaire-input {
  font-family: var(--font-mono); font-size: 22px; font-weight: 500;
  background: none; border: none; border-bottom: 2px solid var(--border2);
  color: var(--text); outline: none; width: 180px; padding-bottom: 4px;
  transition: border-color .15s;
}
.vir-salaire-input:focus { border-bottom-color: var(--amber); }

/* ── Budget 3 colonnes ────────────────────────────────────────────────────── */
.budget-cols {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start;
}
.budget-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; flex-shrink: 0;
  animation: fadeUp .35s ease both;
}
.budget-col-header {
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 3px;
}
.budget-col-title {
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; gap: 7px;
}
.budget-col-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.budget-col-total { font-family: var(--font-mono); font-size: 18px; font-weight: 500; margin-top: 2px; }
.budget-col-target { font-size: 10px; color: var(--text3); }
.budget-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text3); padding: 10px 16px 4px;
}
.budget-item-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 16px 5px 10px; transition: background .12s;
}
.budget-item-row:hover { background: var(--surface2); }
.budget-item-row:hover .budget-del-btn { opacity: 1; }
.budget-del-btn {
  background: none; border: none; color: var(--text3); cursor: pointer;
  padding: 2px 3px; border-radius: 4px; opacity: 0; flex-shrink: 0;
  transition: opacity .12s, color .12s;
}
.budget-del-btn:hover { color: var(--loss); }
.budget-item-name { flex: 1; font-size: 12.5px; color: var(--text2); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; padding: 2px 4px; border-radius: 4px; transition: background .12s; }
.budget-item-name:hover { background: var(--amber-dim); color: var(--amber); }
.budget-item-account { font-size: 10px; color: var(--text3); flex-shrink: 0; max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.budget-item-amount {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text);
  flex-shrink: 0; text-align: right; min-width: 65px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px; transition: background .12s;
}
.budget-item-amount:hover { background: var(--amber-dim); color: var(--amber); }
.budget-subtotal-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 16px; font-size: 11px; color: var(--text3);
}
.budget-subtotal-row .val { font-family: var(--font-mono); color: var(--text2); }
.budget-add-btn {
  display: flex; align-items: center; gap: 5px;
  margin: 8px 16px 12px; padding: 6px 10px; border-radius: var(--radius-sm);
  background: none; border: 1px dashed var(--border2); color: var(--text3);
  cursor: pointer; font-size: 11px; font-family: var(--font-body); width: calc(100% - 32px);
  transition: all .15s; justify-content: center;
}
.budget-add-btn:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }
.budget-inline-form {
  display: none; padding: 10px 16px 14px; border-top: 1px solid var(--border);
  background: var(--bg); flex-direction: column; gap: 8px;
}
.budget-inline-form.open { display: flex; }
.budget-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Camembert SVG + légende */
.pie-wrap { display: flex; align-items: center; gap: 24px; padding: 20px; }
.pie-legend { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend-label { font-size: 12px; color: var(--text2); flex: 1; }
.pie-legend-val { font-family: var(--font-mono); font-size: 12px; color: var(--text); flex-shrink: 0; }
.pie-legend-pct { font-size: 11px; color: var(--text3); width: 42px; text-align: right; flex-shrink: 0; }

/* Reste à vivre */
.reste-banner {
  border-radius: var(--radius); padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid; animation: fadeUp .35s .2s ease both;
}
.reste-banner.positive { background: #34c77b14; border-color: #34c77b30; }
.reste-banner.negative { background: #e0505014; border-color: #e0505030; }
.reste-banner .reste-label { font-size: 12px; color: var(--text3); }
.reste-banner .reste-val { font-family: var(--font-mono); font-size: 22px; font-weight: 500; }
.reste-banner.positive .reste-val { color: var(--gain); }
.reste-banner.negative .reste-val { color: var(--loss); }

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

/* ── Analyse dépenses ──────────────────────────────────────────────────── */
.analyse-bar-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.analyse-bar-label { font-size: 12px; color: var(--text2); width: 190px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.analyse-bar-bg { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.analyse-bar-fg { height: 100%; border-radius: 4px; transition: width .5s; }
.analyse-bar-val { width: 80px; text-align: right; font-family: var(--font-mono); font-size: 12px; color: var(--text); flex-shrink: 0; }
.analyse-bar-pct { width: 38px; text-align: right; font-size: 11px; color: var(--text3); flex-shrink: 0; }

.dep-table-wrap { overflow-x: auto; }
.dep-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dep-table th {
  text-align: left; padding: 7px 10px;
  font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.dep-table th:nth-child(2), .dep-table th:nth-child(5) { text-align: right; }
.dep-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text2); vertical-align: middle; }
.dep-table td:nth-child(2) { text-align: right; font-family: var(--font-mono); color: var(--text); }
.dep-table td:nth-child(5) { text-align: right; }
.dep-table tbody tr:hover td { background: var(--surface2); }
.dep-table tfoot td { font-weight: 600; border-top: 2px solid var(--border2); border-bottom: none; background: var(--surface2); }
.dep-table tfoot td:nth-child(2) { color: var(--amber); }

.dep-cat-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.dep-type-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px; font-size: 10px;
  white-space: nowrap; border: 1px solid var(--border2); color: var(--text3);
}
.dep-actions-row { display: flex; gap: 6px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
.dep-table tbody tr:hover .dep-actions-row { opacity: 1; }
.dep-inline-btn {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  border-radius: 4px; transition: background .12s; color: var(--text3);
}
.dep-inline-btn:hover { background: var(--surface2); color: var(--text); }
.dep-inline-btn.del:hover { color: var(--loss); background: #e0505015; }

.analyse-donut-wrap { display: flex; align-items: center; gap: 24px; }
.analyse-donut-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.analyse-filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filter-chip {
  font-size: 11px; font-weight: 500; padding: 4px 11px; border-radius: 20px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text3);
  transition: all .15s; font-family: var(--font-body);
}
.filter-chip.active { background: var(--amber-dim); border-color: var(--amber); color: var(--amber); }
.filter-chip:hover:not(.active) { border-color: var(--text3); color: var(--text); }

/* Formulaire ajout dépense */
.dep-add-form {
  display: none; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--border); padding-top: 14px; margin-top: 8px;
  animation: fadeUp .2s ease;
}
.dep-add-form.open { display: flex; }
.dep-form-grid { display: grid; grid-template-columns: 2fr 1fr 2fr 2fr; gap: 8px; }
.dep-form-select {
  font-family: var(--font-body); font-size: 13px;
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; outline: none; width: 100%;
  transition: border-color .15s; cursor: pointer;
}
.dep-form-select:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-dim); }
@media (max-width: 768px) {
  .dep-form-grid { grid-template-columns: 1fr 1fr; }
  .analyse-bar-label { width: 110px; }
}
.settings-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  animation: fadeUp .35s ease both;
}
.settings-block-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.settings-block-icon {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.settings-block-title { font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--text); }
.settings-block-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.settings-block-body { padding: 20px; }
.settings-alert {
  background: #f0a02010; border: 1px solid #f0a02030;
  border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px;
}
.settings-alert-title { font-size: 12px; font-weight: 700; color: var(--amber); margin-bottom: 6px; }
.settings-alert-body { font-size: 12px; color: var(--text2); line-height: 1.7; }
.settings-alert-body ul { margin: 6px 0 0 16px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag-pill {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 20px; padding: 4px 10px; font-size: 12px; color: var(--text2);
}
.tag-pill .tag-del {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 1px;
  transition: color .12s;
}
.tag-pill .tag-del:hover { color: var(--loss); }
.tag-add-row { display: flex; gap: 8px; }
.tag-add-input {
  flex: 1; font-family: var(--font-body); font-size: 13px;
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; outline: none;
  transition: border-color .15s;
}
.tag-add-input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-dim); }
.fx-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fx-pill {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 4px 10px; color: var(--text2);
}
.fx-status { font-size: 11px; color: var(--text3); margin-bottom: 10px; }

/* ── Livret / Enveloppes ───────────────────────────────────────────────── */
.env-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.env-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; animation: fadeUp .3s ease both;
}
.env-card-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.env-card-name { font-family: var(--font-head); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.env-card-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.env-card-desc { font-size: 10px; color: var(--text3); margin-top: 4px; line-height: 1.5; }
.env-card-body { padding: 12px 16px; }
.env-card-solde { font-family: var(--font-mono); font-size: 20px; font-weight: 500; }
.env-card-objectif { font-size: 10px; color: var(--text3); margin-top: 2px; }
.env-progress-bg { height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.env-progress-fg { height: 100%; border-radius: 3px; transition: width .5s; }

.mvt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mvt-table th {
  text-align: left; padding: 6px 10px; font-size: 10px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.mvt-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text2); vertical-align: middle; }
.mvt-table tbody tr:hover td { background: var(--surface2); }
.mvt-table tfoot td { font-weight: 600; border-top: 2px solid var(--border2); border-bottom: none; background: var(--surface2); }
.mvt-add { font-family: var(--font-mono); font-size: 12.5px; color: var(--gain); text-align: right; }
.mvt-ret { font-family: var(--font-mono); font-size: 12.5px; color: var(--loss); text-align: right; }
.mvt-date { font-family: var(--font-mono); font-size: 11px; color: var(--text3); white-space: nowrap; }
.mvt-env-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: 20px; font-size: 10px; font-weight: 600; white-space: nowrap;
}
.livret-tab-row { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.livret-tab {
  font-size: 11px; font-weight: 600; padding: 5px 13px; border-radius: 20px;
  cursor: pointer; border: 1px solid var(--border2); color: var(--text3);
  background: var(--surface2); font-family: var(--font-body); transition: all .15s;
}
.livret-tab.active { background: var(--amber-dim); border-color: var(--amber); color: var(--amber); }
@media (max-width: 900px) { .env-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .env-grid { grid-template-columns: 1fr; } }
