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

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #22263a;
  --border:     #2e3350;
  --accent:     #4f8ef7;
  --accent2:    #36d399;
  --danger:     #f87171;
  --warn:       #fbbf24;
  --text:       #e2e8f0;
  --text-dim:   #8892aa;
  --green:      #36d399;
  --red:        #f87171;
  --radius:     10px;
  --num-font:   'SF Mono', 'Fira Mono', 'Cascadia Code', 'Consolas', monospace;
  --transition: .18s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── App Layout ─────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-title  { display: flex; align-items: center; gap: 8px; }
.app-icon   { font-size: 18px; }
.app-title h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.header-actions { display: flex; gap: 8px; }

/* ── Lien retour hub ─────────────────────────────────────────────── */
.back-link {
  font-size: .75rem;
  color: var(--text-dim);
  text-decoration: none;
  padding: .2rem .5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); }

.app-body {
  flex: 1;
  padding: 20px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 90px;
}

/* ── Buttons ────────────────────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; font-size: 13px; border: none; background: none; }

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 5px 12px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-danger { color: var(--red); border-color: rgba(224,87,87,0.3); }
.btn-danger:hover { color: var(--red); border-color: var(--red); background: rgba(224,87,87,0.08); }

/* ── Salary Card ─────────────────────────────────────────────────── */
.salary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.salary-fields { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; }
.card-field    { display: flex; flex-direction: column; gap: 4px; }
.card-field label { font-size: 11px; color: var(--text-dim); font-weight: 500; }

.fi {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 14px;
  width: 150px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.fi:focus { border-color: var(--accent); }
.fi.sel   { width: 175px; }

/* Remove native spinner arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.fi-display { display: inline-block; padding: 6px 0; white-space: nowrap; }

/* ── Stepper ────────────────────────────────────────────────────── */
.stepper           { display: inline-flex; align-items: center; gap: 3px; }
.stepper .fi       { width: 120px; }

.step-btn {
  width: 24px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 15px;
  flex-shrink: 0;
  transition: color 0.1s, border-color 0.1s;
}
.step-btn:hover { color: var(--text); border-color: var(--accent); }

/* ── Number typography ──────────────────────────────────────────── */
.num    { font-family: var(--num-font); font-variant-numeric: tabular-nums; font-size: 14px; }
.num-lg { font-family: var(--num-font); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 600; }
.positive { color: var(--green); }
.negative { color: var(--red); }

/* ── Groups section ─────────────────────────────────────────────── */
.groups-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.groups-header h2 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Group Card ──────────────────────────────────────────────────── */
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.group-header {
  display: grid;
  grid-template-columns: 20px 28px 1fr auto 32px;
  align-items: center;
  padding: 9px 12px;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.group-header:hover { background: var(--surface2); }

.group-drag-handle {
  color: var(--text-dim);
  cursor: grab;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.group-card:hover .group-drag-handle { opacity: 1; }
.group-drag-handle:active { cursor: grabbing; }

.group-card.dragging-group  { opacity: 0.4; }
.group-card.group-drag-over { box-shadow: 0 -2px 0 var(--accent); }

.collapse-btn {
  color: var(--text-dim);
  font-size: 10px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}
.collapse-btn:hover { color: var(--text); }

.group-name {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  outline: none;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: text;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.group-name:hover { background: var(--surface2); }
.group-name:focus { background: var(--surface2); border-color: var(--border); }

.group-total { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.group-total .per-period { font-size: 10px; margin-left: 2px; }

.del-group-btn {
  color: var(--text-dim);
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.group-card:hover .del-group-btn { opacity: 1; }
.del-group-btn:hover { color: var(--red); }

/* ── Row Grid ────────────────────────────────────────────────────── */
.group-body { padding: 0 12px 10px; }
.group-body.row-drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--radius); background: rgba(108,99,255,0.05); }

.grid-header,
.grid-row {
  display: grid;
  grid-template-columns: 20px 1fr 155px 96px 34px;
  align-items: center;
  gap: 6px;
}

.grid-header {
  padding: 4px 0 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.grid-header > div:nth-child(3) { text-align: right; }
.grid-header > div:nth-child(4) { text-align: center; }

.grid-row {
  padding: 2px 0;
  border-radius: 4px;
  transition: background 0.1s;
}
.grid-row:hover    { background: var(--surface2); }
.grid-row.dragging { opacity: 0.35; }
.grid-row.drag-over { box-shadow: 0 -2px 0 var(--accent); }

.drag-handle {
  color: var(--text-dim);
  cursor: grab;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.grid-row:hover .drag-handle { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.cell-input:hover,
.cell-input:focus  { background: var(--surface2); border-color: var(--border); }
.cell-input:focus  { border-color: var(--accent); }

.amount-input {
  text-align: right;
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
}

/* ── Freq toggle (pill buttons) ─────────────────────────────────── */
.freq-toggle { display: flex; gap: 3px; justify-content: center; }
.freq-btn {
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  border: 1px solid var(--border);
  line-height: 1;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.freq-btn:hover             { color: var(--text); border-color: var(--text-dim); }
.freq-btn.active-M          { background: #1e3a8a; color: #93c5fd; border-color: #3b82f6; }
.freq-btn.active-S          { background: #064e3b; color: #6ee7b7; border-color: #10b981; }
.freq-btn.active-A          { background: #451a03; color: #fcd34d; border-color: #d97706; }

.del-cell { display: flex; justify-content: flex-end; }

.row-del {
  color: transparent;
  font-size: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.grid-row:hover .row-del { color: var(--text-dim); }
.row-del:hover { color: var(--red) !important; background: rgba(224,87,87,0.1); }

/* ── Add row / Add group ─────────────────────────────────────────── */
.add-row-wrap {
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
}
.add-row-btn {
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.add-row-btn:hover { color: var(--accent); background: rgba(108,99,255,0.08); }

.add-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 6px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.add-group-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(108,99,255,0.06);
}

/* ── KPI Bar (fixed bottom) ─────────────────────────────────────── */
#kpi-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; }

.kpi-inner {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 12px 20px;
}
.kpi-item  { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.kpi-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Salary actions ─────────────────────────────────────────────── */
.salary-actions { display: flex; flex-direction: column; gap: 6px; margin-top: .85rem; }
.salary-actions .transfer-btn { margin-top: 0; }

/* ── Transfer button ─────────────────────────────────────────────── */
.transfer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: .5rem 1rem;
  margin-top: .85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .83rem;
  color: var(--accent);
  text-decoration: none;
  background: rgba(79,142,247,.07);
  transition: var(--transition);
}
.transfer-btn:hover { border-color: var(--accent); background: rgba(79,142,247,.14); }

/* ── MonProfil additions ─────────────────────────────────────────── */

/* ── Nav section links ───────────────────────────────────────────── */
.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}
.nav-link {
  font-size: 13px;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.nav-link:hover  { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); background: rgba(79,142,247,.1); border-color: rgba(79,142,247,.25); }
.nav-link.locked { opacity: .35; cursor: not-allowed; }
.nav-link.done::after { content: ' ✓'; font-size: 10px; color: var(--accent2); }

/* ── Section container ───────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

/* ── Notification bar ────────────────────────────────────────────── */
.notif-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 1.5rem;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
.notif-bar.hidden        { display: none; }
.notif-bar.notif-success { background: rgba(54,211,153,.12);  border-color: rgba(54,211,153,.3);  color: var(--accent2); }
.notif-bar.notif-warn    { background: rgba(251,191,36,.10);  border-color: rgba(251,191,36,.3);  color: var(--warn); }
.notif-bar.notif-error   { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); color: var(--danger); }
.notif-message  { flex: 1; }
.notif-close    { color: currentColor; opacity: .6; font-size: .9rem; flex-shrink: 0; }
.notif-close:hover { opacity: 1; }

/* ── Inline field validation ─────────────────────────────────────── */
.field-error { border-color: var(--danger) !important; }
.field-hint  { font-size: .72rem; color: var(--danger); margin-top: 2px; min-height: 1em; }
.field-hint:empty { visibility: hidden; }

/* ── Bi-weekly freq pill ─────────────────────────────────────────── */
.freq-btn.active-B { background: #3b1f6e; color: #c4b5fd; border-color: #7c3aed; }

/* ── Welcome modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.modal-card h2 { font-size: 1.25rem; font-weight: 700; }
.modal-card p  { font-size: .9rem; color: var(--text-dim); line-height: 1.6; }
.modal-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem .9rem;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.modal-input:focus { border-color: var(--accent); }
.modal-btn-primary {
  width: 100%;
  padding: .65rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  transition: opacity var(--transition);
}
.modal-btn-primary:hover { opacity: .85; }
.modal-btn-skip {
  text-align: center;
  font-size: .8rem;
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  transition: color var(--transition);
}
.modal-btn-skip:hover { color: var(--text); }

/* ── Dashboard metric cards ──────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.metric-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-bottom: 6px; }
.metric-value { font-family: var(--num-font); font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.metric-hint  { font-size: .75rem; color: var(--text-dim); margin-top: 4px; }
.metric-nudge { font-size: .82rem; color: var(--text-dim); font-style: italic; }

/* ── No-debts / No-assets toggle ─────────────────────────────────── */
.no-items-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  margin-bottom: 12px;
  cursor: pointer;
}
.no-items-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.no-items-label { font-size: .88rem; color: var(--text-dim); user-select: none; }
.no-items-label:hover { color: var(--text); }

/* ── Flat list section (income / assets) ─────────────────────────── */
.flat-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.flat-header,
.flat-row {
  display: grid;
  align-items: center;
  gap: 6px;
}
.flat-header {
  padding: 4px 0 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.flat-row {
  padding: 2px 0;
  border-radius: 4px;
  transition: background .1s;
}
.flat-row:hover { background: var(--surface2); }

/* ── CSV import wizard ───────────────────────────────────────────── */
.import-wizard { display: flex; flex-direction: column; gap: 1.2rem; }
.import-step   { display: flex; flex-direction: column; gap: .75rem; }
.import-step h3 { font-size: .9rem; font-weight: 600; color: var(--text-dim); }
.import-col-map { display: flex; flex-direction: column; gap: .5rem; }
.import-col-map label { font-size: .82rem; color: var(--text-dim); }
.import-review  { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.import-review-row { display: flex; align-items: center; gap: 8px; font-size: .85rem; padding: 3px 0; }
.import-row-new      { color: var(--accent2); }
.import-row-conflict { color: var(--warn); }
.import-row-inactive { color: var(--text-dim); }
.import-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: .5rem; }

/* ── Section nudge (empty state) ─────────────────────────────────── */
.section-nudge {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  font-size: .9rem;
  line-height: 1.8;
}
.section-nudge strong { display: block; font-size: 1.5rem; margin-bottom: .5rem; color: var(--text); }

/* ── Debt payoff list ────────────────────────────────────────────── */
.payoff-list { display: flex; flex-direction: column; gap: 8px; }
.payoff-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .88rem;
}
.payoff-item-name  { color: var(--text); }
.payoff-item-date  { color: var(--text-dim); font-family: var(--num-font); font-size: .82rem; }

/* ── Primary action button ───────────────────────────────────────── */
.btn-primary {
  padding: .6rem 1.4rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  transition: opacity var(--transition);
}
.btn-primary:hover { opacity: .85; }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-secondary {
  padding: .6rem 1.4rem;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

/* ── Section card layout ─────────────────────────────────────────── */
.section-card  { max-width: 640px; margin: 2.5rem auto; padding: 0 1.5rem; }
.section-title { font-size: 1.25rem; font-weight: 700; margin-bottom: .4rem; }
.section-desc  { font-size: .9rem; color: var(--text-dim); margin-bottom: 1.75rem; line-height: 1.5; }
.form-field    { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field-label   { font-size: .8rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-links { gap: 2px; }
  .nav-link  { padding: 4px 7px; font-size: 12px; }
  .kpi-inner { gap: 20px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 1.5rem; }
}

/* ── No-flag toggle (shared: no-income, no-debts, no-assets) ────── */
.no-debts-toggle {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s;
}
.no-debts-toggle:hover { border-color: var(--accent); background: rgba(99,102,241,.06); }
.no-debts-toggle input[type="checkbox"] {
  width: 1rem; height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.no-debts-label { font-size: .9rem; color: var(--text); }

/* ── Income section ──────────────────────────────────────────────── */
.section-footer { margin-top: 2rem; display: flex; justify-content: flex-end; }

.income-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.income-section-header > div:first-child .section-desc { margin-bottom: 0; }

.section-monthly-total {
  flex-shrink: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent2);
  text-align: right;
  white-space: nowrap;
}

.income-grid-header {
  display: grid;
  grid-template-columns: 1fr 9rem 8.5rem 2.5rem;
  gap: .75rem;
  padding: .25rem .5rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}

.income-rows { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }

.income-row {
  display: grid;
  grid-template-columns: 1fr 9rem 8.5rem 2.5rem;
  gap: .75rem;
  align-items: start;
  padding: .6rem .5rem;
  border-radius: var(--radius);
  background: var(--bg2);
}

.freq-btn.freq-active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.income-row .row-del { color: var(--text-dim); }

.freq-label-active {
  display: block;
  font-size: .72rem;
  color: var(--text-dim);
  margin-top: .3rem;
  padding-left: .1rem;
}

.empty-nudge {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: .95rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.empty-nudge-group {
  padding: 1rem 1rem;
  font-size: .875rem;
  margin: .25rem 0;
}

@media (max-width: 600px) {
  .income-grid-header { display: none; }
  .income-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    row-gap: .5rem;
  }
  .income-row > div:nth-child(3) { grid-column: 1; }
  .income-row > div:nth-child(4) { grid-column: 2; grid-row: 1; align-self: center; }
  .section-monthly-total { font-size: 1.15rem; }
}

/* ── Wrapping freq toggles (income + debts have more pills than archive default) */
.income-row .freq-toggle,
.debts-row  .freq-toggle { flex-wrap: wrap; justify-content: flex-start; }

/* ── Debts section ───────────────────────────────────────────────── */
.section-card-lg { max-width: 880px; }

.debts-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.debts-section-header > div:first-child .section-desc { margin-bottom: 0; }

.debts-totals {
  display: flex;
  gap: 1.5rem;
  flex-shrink: 0;
}
.debts-total-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .2rem;
}
.debts-total-pmt {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--warn);
  font-family: var(--num-font);
}
.debts-total-bal {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--danger);
  font-family: var(--num-font);
}

.debts-grid-header {
  display: grid;
  grid-template-columns: 1fr 9rem 6.5rem 9rem 9rem 2.5rem;
  gap: .75rem;
  padding: .25rem .5rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}

.debts-rows { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }

.debts-row {
  display: grid;
  grid-template-columns: 1fr 9rem 6.5rem 9rem 9rem 2.5rem;
  gap: .75rem;
  align-items: start;
  padding: .6rem .5rem;
  border-radius: var(--radius);
}

.debts-row .row-del { color: var(--text-dim); }

@media (max-width: 600px) {
  .debts-grid-header { display: none; }
  .debts-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    row-gap: .5rem;
  }
  .debts-row > div:nth-child(3),
  .debts-row > div:nth-child(4) { grid-column: 1; }
  .debts-row > div:nth-child(5) { grid-column: 1; }
  .debts-row > div:nth-child(6) { grid-column: 2; grid-row: 1; align-self: center; }
  .debts-totals { gap: .75rem; }
  .debts-total-pmt,
  .debts-total-bal { font-size: .95rem; }
}

/* ── Expenses section ────────────────────────────────────────────── */

.expenses-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.expenses-total-header {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .15rem;
  white-space: nowrap;
}

.expenses-total-amt {
  font-family: var(--num-font);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--warn);
}

.expenses-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .75rem 0;
}

/* ── CSV import modal ────────────────────────────────────────────── */

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(600px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--border);
}

.modal-box-title {
  font-size: 1rem;
  font-weight: 700;
}

.modal-box-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: .25rem .5rem;
  border-radius: var(--radius);
}
.modal-box-close:hover { color: var(--text); background: var(--surface2); }

.modal-box-body {
  padding: 1rem 1.25rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.csv-step-desc {
  color: var(--text-dim);
  font-size: .9rem;
  margin-bottom: 1rem;
}

.csv-hint {
  font-size: .8rem;
  color: var(--text-dim);
  margin-top: .5rem;
}

.csv-upload-wrap {
  margin: .5rem 0;
}

.csv-file-input {
  color: var(--text);
  font-size: .9rem;
}

.csv-mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem .75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.csv-map-label {
  font-size: .85rem;
  color: var(--text-dim);
}

.csv-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .35rem .5rem;
  font-size: .875rem;
  width: 100%;
}
.csv-select:focus { outline: none; border-color: var(--accent); }

.csv-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  margin-bottom: 1rem;
}
.csv-preview-table th,
.csv-preview-table td {
  text-align: left;
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--border);
}
.csv-preview-table th { color: var(--text-dim); font-weight: 600; }
.csv-preview-table td.num { font-family: var(--num-font); text-align: right; }

.csv-review-wrap { margin-bottom: .5rem; }

.csv-review-heading {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin: .75rem 0 .35rem;
}

.csv-review-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .25rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: .875rem;
}
.csv-review-row:hover { background: var(--surface2); }
.csv-review-row input[type="checkbox"] { flex-shrink: 0; }

.csv-conflict-hint {
  font-family: var(--num-font);
  font-size: .8rem;
  color: var(--warn);
  margin-left: .35rem;
}

.csv-empty-list {
  color: var(--text-dim);
  font-size: .85rem;
  padding: .25rem .25rem .5rem;
}

.csv-done-msg {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: var(--accent2);
}

.csv-done-stats {
  list-style: none;
  font-size: .9rem;
  color: var(--text-dim);
  line-height: 1.8;
  margin-bottom: 1rem;
}
.csv-done-stats strong { color: var(--text); }

.csv-modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
  .csv-mapping-grid { grid-template-columns: 1fr; }
  .expenses-section-header { flex-direction: column; }
}

/* ── Assets section ──────────────────────────────────────────────── */

.assets-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.assets-total-header {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.assets-total-amt {
  font-family: var(--num-font);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent2);
}

.assets-actions {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* Asset row — 4 columns: drag · label · value · del */
.asset-grid-row,
.asset-grid-header {
  grid-template-columns: 20px 1fr 155px 34px;
}

@media (max-width: 600px) {
  .asset-grid-row,
  .asset-grid-header { grid-template-columns: 1fr; }
  .assets-section-header { flex-direction: column; }
}

/* ── Dashboard section ────────────────────────────────────────────── */
.dashboard-header { margin-bottom: 1.5rem; }

/* Metric value color states (dashboard cards) */
.value-positive { color: var(--accent2); }
.value-warn     { color: var(--warn); }
.value-danger   { color: var(--danger); }
.value-negative { color: var(--danger); }
.value-neutral  { color: var(--text); }

/* Pad body so fixed KPI bar never covers content */
#app { padding-bottom: 4rem; }

/* ── Missing-debts warning banner (expenses section) ─────────────── */
.debt-warn-banner {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--warn);
  line-height: 1.5;
}
.debt-warn-banner strong { font-weight: 600; }

/* ── Nav warning indicator ───────────────────────────────────────── */
.nav-warn { color: var(--warn); font-size: .7em; margin-left: 3px; vertical-align: middle; }

/* ── Amortissement tool card (inside dashboard) ───────────────────── */
.amort-tool-card {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.amort-tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}

.amort-tool-title {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.amort-tool-icon { font-size: 1.1rem; }

.amort-toggle-btn { font-size: .8rem; }

.amort-header-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-shrink: 0;
}

.amort-status-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 4px;
  letter-spacing: .03em;
}
.amort-status-on  { background: rgba(52,211,153,.15); color: var(--accent2); }
.amort-status-off { background: rgba(148,163,184,.12); color: var(--text-dim); }

.amort-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  padding: .75rem 0 .5rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}

.amort-kpi-item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.amort-kpi-label {
  font-size: .75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.amort-kpi-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.amort-kpi-positive { color: var(--accent2); }
.amort-kpi-negative { color: var(--danger); }

.amort-tool-card--enabled { border-top-color: var(--accent2); border-top-width: 2px; }

.amort-nudge { padding: .5rem 0; }
.amort-row-hidden { display: none; }
.kpi-freq-sub { font-size: .65em; font-weight: 400; color: var(--text-dim); margin-left: .2em; }

.amort-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.amort-params-card,
.amort-summary-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.amort-card-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .75rem;
}

.amort-field {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-bottom: .75rem;
}
.amort-field label { font-size: .8rem; color: var(--text-dim); }

.amort-freq-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-top: .25rem;
}

.amort-freq-btn {
  padding: .3rem .6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: .78rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.amort-freq-btn.amort-freq-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.amort-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  gap: .5rem;
}
.amort-result-row:last-child { border-bottom: none; }
.amort-result-row label { color: var(--text-dim); flex-shrink: 0; }

.amort-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: .25rem 0;
}

.amort-schedule-wrap {
  overflow-x: auto;
  margin-top: .5rem;
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.amort-table th {
  text-align: right;
  color: var(--text-dim);
  font-weight: 500;
  padding: .45rem .75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.amort-table th:first-child { text-align: left; }
.amort-table td {
  text-align: right;
  padding: .4rem .75rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.amort-table td:first-child { text-align: left; color: var(--text-dim); }
.amort-table tr.amort-last-year td { color: var(--accent2); font-weight: 500; }
.amort-td-positive { color: var(--accent2); }
.amort-td-negative { color: var(--danger); }
.amort-td-dim      { color: var(--text-dim); }

@media (max-width: 600px) {
  .amort-layout { grid-template-columns: 1fr; }
  .amort-table  { font-size: .75rem; }
  .amort-table th,
  .amort-table td { padding: .35rem .4rem; }
}

/* ── Mise de fonds & Projection d'épargne tools ─────────────────── */
/* Structural/visual elements reuse .amort-tool-card / .amort-kpi-* / .amort-field etc. */

.mdf-afford-ok { color: var(--accent2); }
.mdf-afford-no { color: var(--danger); }

/* Closing items list */
.mdf-closing-section { margin-top: 1rem; }
.mdf-closing-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 .5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mdf-closing-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr 8rem 2rem;
  align-items: center;
  gap: .5rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.mdf-closing-row:last-of-type { border-bottom: none; }
.mdf-closing-row.dragging { opacity: .4; }
.mdf-closing-row.drag-over { border-top: 2px solid var(--accent); }
.mdf-closing-total {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0 0;
  border-top: 2px solid var(--border);
  margin-top: .25rem;
  font-size: .875rem;
}
.mdf-closing-total label { color: var(--text-dim); font-weight: 500; }

/* Savings progress */
.ep-progress-wrap {
  background: var(--surface2);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin: .75rem 0 .3rem;
}
.ep-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899, #f97316, #10b981);
  border-radius: 99px;
  transition: width .4s ease;
}
.ep-progress-label { font-size: .8rem; color: var(--text-dim); text-align: right; }

/* Link-to-MDF toggle */
.ep-link-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  margin-bottom: .5rem;
}
.ep-link-row input[type="checkbox"] { accent-color: var(--accent2); }

/* Savings projection table */
.ep-table-wrap { overflow-x: auto; margin-top: .5rem; }
.ep-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ep-table th {
  text-align: right;
  color: var(--text-dim);
  font-weight: 500;
  padding: .45rem .75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.ep-table th:first-child { text-align: left; }
.ep-table td {
  text-align: right;
  padding: .4rem .75rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.ep-table td:first-child { text-align: left; color: var(--text-dim); }
.ep-table tr.ep-reached td       { color: var(--accent2); }
.ep-table tr.ep-first-reached td { font-weight: 600; }
.ep-gap-neg { color: var(--danger); }
.ep-gap-pos { color: var(--accent2); }

@media (max-width: 600px) {
  .mdf-closing-row { grid-template-columns: 1.25rem 1fr 7rem 2rem; }
  .ep-table        { font-size: .75rem; }
  .ep-table th,
  .ep-table td     { padding: .35rem .4rem; }
}

.amort-kpi-label--sm { font-size: .65rem; }

/* ── Two-row nav ─────────────────────────────────────────────────── */
/* Override the single-row flex layout for .app-header when the
   two-row modifier class is present. Existing .app-header rules
   remain untouched. */
.nav-two-row {
  flex-direction: column;
  align-items:    stretch;
  gap:            0;
  padding:        8px 20px 0;
}

.nav-top-row {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding-bottom:  6px;
}

/* Section-link row — full width, wraps on narrow screens */
.nav-two-row .nav-links {
  display:     flex;
  flex-wrap:   wrap;
  gap:         2px;
  padding:     4px 0;
  border-top:  1px solid var(--border);
}

/* Slightly larger tap targets on touch devices */
@media (max-width: 600px) {
  .nav-two-row { padding: 6px 12px 0; }
  .nav-top-row { padding-bottom: 4px; }
  .nav-two-row .nav-links { gap: 2px; }
  .nav-two-row .nav-link  { padding: 6px 10px; font-size: 12px; }
  .nav-top-row .header-actions { gap: 4px; }
  .nav-top-row .btn-ghost { padding: 4px 8px; font-size: 12px; }
}

/* ── MDF full-width sections ──────────────────────────────────── */
/* Closing costs and budget selection sit outside amort-layout    */
/* so they already span full width — just add spacing/borders.    */
.mdf-closing-section {
  margin-top:    16px;
  padding-top:   16px;
  border-top:    1px solid var(--border);
}

/* ── MDF Budget selection ─────────────────────────────────────── */
.mdf-budget-select {
  margin-top:  16px;
  padding-top: 16px;
  border-top:  1px solid var(--border);
}
.mdf-budget-select-header {
  display:        flex;
  align-items:    baseline;
  gap:            12px;
  margin-bottom:  10px;
  flex-wrap:      wrap;
}
.mdf-budget-select-title { font-weight: 600; font-size: .9rem; }
.mdf-budget-select-hint  { font-size: .78rem; color: var(--text-dim); }
.mdf-budget-group        { margin-bottom: 10px; }
.mdf-budget-group-name {
  font-size:      .72rem;
  font-weight:    600;
  color:          var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom:  4px;
}
.mdf-budget-item {
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     3px 0;
  font-size:   .85rem;
  cursor:      pointer;
}
.mdf-budget-item:hover { color: var(--accent); }
.mdf-budget-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.mdf-budget-item-desc { flex: 1; }
.mdf-budget-item-amt  { font-variant-numeric: tabular-nums; color: var(--text-dim); white-space: nowrap; }

/* ── Retraite tool ────────────────────────────────────────────── */
.rt-schedule-section {
  margin-top:  16px;
  padding-top: 16px;
  border-top:  1px solid var(--border);
}
.rt-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       .82rem;
}
.rt-table th,
.rt-table td         { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.rt-table th         { color: var(--text-dim); font-weight: 600; text-align: left; }
.rt-table .text-right { text-align: right; font-variant-numeric: tabular-nums; }
.rt-total-cell       { font-weight: 600; }
.rt-row-retirement   { background: color-mix(in srgb, var(--accent2) 12%, transparent); font-weight: 600; }
.rt-split-row  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rt-split-label { color: var(--text-dim); font-size: .8rem; white-space: nowrap; }
.rt-split-input { width: 64px; }
.rt-split-celi  { font-variant-numeric: tabular-nums; min-width: 24px; }
.amort-card-hint { font-size: .78rem; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }
.mdf-budget-item-amt  { font-variant-numeric: tabular-nums; color: var(--text-dim); white-space: nowrap; }

/* ── Retraite chart ───────────────────────────────────────── */
.rt-chart             { display: block; width: 100%; height: auto; margin-bottom: 12px; }
.rt-chart-grid        { stroke: var(--border); stroke-width: 1; }
.rt-chart-line        { stroke: var(--accent); stroke-width: 2; }
.rt-chart-celi-div    { stroke: var(--bg); stroke-width: 2.5; }
.rt-chart-swatch-celi { fill: var(--accent);  opacity: .75; }
.rt-chart-swatch-rrsp { fill: var(--accent2); opacity: .75; }
.rt-chart-lbl         { font-size: 11px; fill: var(--text-dim); text-anchor: middle; font-family: inherit; }
.rt-chart-lbl-y       { text-anchor: end; }
.rt-chart-lbl-legend  { font-size: 11px; fill: var(--text); dominant-baseline: middle; }

/* ── Épargne KPI progress bar ─────────────────────────────── */
.ep-kpi-progress-wrap { background: var(--surface2); border-radius: 20px; height: 6px; margin: 6px 0 12px; overflow: hidden; }
.ep-kpi-progress-bar  { height: 100%; border-radius: 20px; background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899, #f97316, #10b981); transition: width .4s ease; }

/* ── Full-height layout: prevent nav+app overflowing body ─── */
/* nav above #app pushed total height past 100vh; fix by making body a  */
/* flex column capped at viewport height, and letting #app scroll itself */
html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; }
#app { min-height: 0; flex: 1; overflow-y: auto; }
