/* =========================================================
   Whale — Feuille de style
   ========================================================= */
:root {
  --navy: #0B2545;
  --navy-2: #13315C;
  --ocean: #1B6CA8;
  --teal: #2BB3A3;
  --sand: #E9A53A;
  --coral: #D9534F;
  --amber: #C98A12;
  --green: #238B63;

  --bg: #F3F6FA;
  --card: #FFFFFF;
  --ink: #0F1C2E;
  --muted: #5B6B80;
  --line: #E1E7EF;
  --track: #E7EDF4;
  --soft: #F7F9FC;

  --needs: #1B6CA8;
  --wants: #2BB3A3;
  --savings: #E9A53A;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 37, 69, .05), 0 6px 20px rgba(11, 37, 69, .06);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--ocean); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.txt-bad { color: var(--coral); }
.txt-good { color: var(--green); }
.txt-warn { color: var(--amber); }
.ic { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 256px; overflow-y: auto; z-index: 30;
  background: linear-gradient(180deg, var(--navy) 0%, #0A1F3B 100%);
  color: #C9DAEE; padding: 22px 14px; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 22px; padding: 0 8px 18px; letter-spacing: -.02em; }
.brand svg { color: #7FD3F7; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7D93B2; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: #BCD0E8; text-decoration: none; font-weight: 500; font-size: 14px; white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(43, 179, 163, .18); color: #fff; box-shadow: inset 3px 0 0 var(--teal); }
.nav .step {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 1px solid rgba(255, 255, 255, .22); color: #9FB6D3;
}
.nav .step.done { background: var(--teal); border-color: var(--teal); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 10px; }
.me { display: flex; gap: 10px; align-items: center; min-width: 0; }
.me strong { display: block; color: #fff; font-size: 14px; }
.me small { display: block; color: #8FA6C4; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.btn-link { background: none; border: 0; color: #9FB6D3; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 0; font-size: 13px; }
.btn-link:hover { color: #fff; }

.main { padding: 32px clamp(16px, 4vw, 44px) 72px; max-width: 1180px; width: 100%; margin-left: 256px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(24px, 3vw, 30px); font-weight: 800; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 680px; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--teal); margin-bottom: 6px; }

.stack { display: grid; gap: 20px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; border: 1px solid rgba(225, 231, 239, .7); min-width: 0; }
.card h2 { font-size: 18px; font-weight: 700; }
.card h3 { font-size: 16px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.kpi .kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .kpi-value { font-size: clamp(20px, 2.2vw, 26px); font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .kpi-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 14px; text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: #239b8d; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { border-color: #C4D0DE; background: var(--soft); }
.btn-danger { background: #fff; color: var(--coral); border-color: #F1C9C8; }
.btn-danger:hover { background: #FDF3F3; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--soft); color: var(--ink); }

.input {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.input:focus { border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27, 108, 168, .15); }
.input.num { text-align: right; }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #34465C; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.money { position: relative; display: flex; align-items: center; }
.money .input { padding-right: 52px; }
.money > span { position: absolute; right: 12px; font-size: 12px; color: var(--muted); pointer-events: none; }
.money.lg .input { font-size: 26px; font-weight: 800; padding: 14px 80px 14px 16px; letter-spacing: -.02em; }
.money.lg > span { font-size: 15px; font-weight: 600; right: 16px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tfoot td { font-weight: 800; border-bottom: 0; border-top: 2px solid var(--line); }
.table tr.row-over td { background: #FFF7F6; }
.table td.actions { white-space: nowrap; text-align: right; width: 1%; }
.table .money { min-width: 140px; }
.item-ic { display: inline-block; width: 22px; text-align: center; }
.tag { font-size: 11px; font-weight: 700; background: #E8F1FA; color: var(--ocean); padding: 2px 7px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.ecart { font-weight: 700; font-variant-numeric: tabular-nums; }
.ecart.bad { color: var(--coral); }
.ecart.good { color: var(--green); }

/* ---------- Badges, alerts, progress ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-good { background: #E3F4EC; color: var(--green); }
.badge-warn { background: #FCF1DC; color: #9A6A0C; }
.badge-bad { background: #FBE6E5; color: #B53B37; }
.badge-info { background: #E6F0F8; color: var(--ocean); }

.alert { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: 14px; border: 1px solid; }
.alert strong { display: block; font-size: 15px; }
.alert p { font-size: 14px; margin-top: 2px; }
.alert .ic { margin-top: 2px; }
.alert-good { background: #EFF9F4; border-color: #C6E8D7; color: #135A40; }
.alert-warn { background: #FFF8EB; border-color: #F3DDB0; color: #7A540A; }
.alert-bad { background: #FDF1F0; border-color: #F2CBC9; color: #8E2D2A; }
.alert-info { background: #EEF5FB; border-color: #CFE1F1; color: #174E7C; }
.alert.big { padding: 20px 22px; }
.alert.big strong { font-size: 17px; }

.progress { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--teal); }
.progress.over > i { background: var(--coral); }

.splitbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--track); gap: 2px; }
.splitbar > i { display: block; height: 100%; }

.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.list li .ic { margin-top: 2px; color: var(--teal); }
.bullets { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.bullets li { margin: 3px 0; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: radial-gradient(1200px 600px at 10% 110%, rgba(43, 179, 163, .35), transparent 60%),
              radial-gradient(900px 500px at 100% -10%, rgba(127, 211, 247, .25), transparent 60%),
              linear-gradient(160deg, #0B2545, #0A1A33);
  color: #D7E6F6; padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden;
}
.auth-hero .brand { padding: 0; font-size: 26px; }
.auth-hero h1 { font-size: clamp(30px, 4vw, 46px); color: #fff; font-weight: 800; letter-spacing: -.03em; max-width: 560px; }
.auth-hero p.lead { font-size: 17px; margin-top: 16px; max-width: 520px; color: #BFD3EA; }
.formula { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.formula span { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); padding: 6px 12px; border-radius: 99px; font-size: 13px; color: #E3EEF9; }
.hero-whale { position: absolute; right: -60px; bottom: -30px; width: 380px; opacity: .08; color: #fff; pointer-events: none; }
.auth-panel { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 440px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--track); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.auth-card form { display: grid; gap: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fineprint { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ---------- Dashboard ---------- */
.hero-card { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; background: linear-gradient(135deg, #fff 60%, #EAF6F4); }
.hero-card svg { color: var(--ocean); }
.hero-card h2 { font-size: 24px; margin-bottom: 8px; }
.journey { columns: 2; column-gap: 28px; padding-left: 20px; margin: 16px 0 22px; font-size: 14px; color: #34465C; }
.journey li { margin: 4px 0; break-inside: avoid; }

.score-ring { position: relative; width: 150px; height: 150px; flex: none; }
.score-ring svg { width: 100%; height: 100%; }
.score-ring .val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.score-ring .val b { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.score-ring .val small { color: var(--muted); font-size: 12px; }
.score-ring.lg { width: 210px; height: 210px; }
.score-ring.lg .val b { font-size: 56px; }

.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; flex: 1; min-width: 160px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend li b { margin-left: auto; font-variant-numeric: tabular-nums; }

.bars { display: grid; gap: 16px; }
.bar-group .bar-title { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; gap: 8px; }
.bar-line { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin: 3px 0; }
.bar-line .track { height: 10px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-line .track i { display: block; height: 100%; border-radius: 99px; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.checklist a:hover { background: var(--soft); }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: #fff; }
.checklist .done .tick { background: var(--teal); border-color: var(--teal); }

/* ---------- Rules ---------- */
.rule-card { display: flex; flex-direction: column; gap: 14px; }
.rule-card.chosen { border: 2px solid var(--teal); }
.rule-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rule-card .parts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.rule-card .parts li { display: flex; gap: 8px; align-items: baseline; }
.rule-card .parts .dot { transform: translateY(1px); }
.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pros-cons h4, .rule-card h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.example { background: var(--soft); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.example div { display: flex; justify-content: space-between; gap: 8px; }
.rule-card footer { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.custom-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

/* ---------- Category pages ---------- */
.envelope { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.envelope .big { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.envelope .envelope-bar { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 7px 13px; cursor: pointer; font-size: 14px; transition: all .15s;
}
.chip:hover { border-color: #B9C7D8; }
.chip.on { background: #E8F6F4; border-color: var(--teal); color: #146B61; font-weight: 600; }
.scenarios { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.scenario { border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.scenario h3 { font-size: 15px; }
.scenario .changes { font-size: 13px; display: grid; gap: 4px; }
.scenario .changes div { display: flex; justify-content: space-between; gap: 8px; }
.scenario .changes s { color: var(--muted); }
.scenario footer { margin-top: auto; }

/* ---------- Goals ---------- */
.goal header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.goal-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.goal-nums label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.goal-nums .input { padding: 7px 9px; font-size: 13px; }
.goal-answer { background: var(--soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.goal-answer.done { background: #EFF9F4; color: #135A40; }
.goal-answer.warn { background: #FFF8EB; color: #7A540A; }
.horizon-title { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 12px; }
.horizon-title h2 { font-size: 18px; }

/* ---------- What-if ---------- */
.preset-list { display: grid; gap: 8px; }
.preset { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--navy); }
.preset:hover { border-color: var(--teal); background: #F2FAF9; }
.delta-up { color: var(--green); }
.delta-down { color: var(--coral); }

/* ---------- Score ---------- */
.score-parts { display: grid; gap: 16px; }
.score-part .spread { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.score-part p { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- Plan (document) ---------- */
.doc { max-width: 900px; }
.doc section { margin-bottom: 26px; }
.doc h2 { font-size: 18px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--track); }
.doc .doc-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.doc .kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.doc .kv div { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.doc .kv small { display: block; color: var(--muted); font-size: 12px; }
.doc .kv b { font-size: 15px; }
.path { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.path span { background: #E8F1FA; color: var(--ocean); padding: 4px 10px; border-radius: 99px; font-weight: 600; }

.next { display: flex; justify-content: flex-end; margin-top: 28px; gap: 10px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; left: 20px; display: grid; justify-items: end; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); font-size: 14px; max-width: 420px; animation: toastIn .2s ease-out; transition: opacity .3s, transform .3s; }
.toast-bad { background: #8E2D2A; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: sticky; top: 0; left: auto; bottom: auto; width: auto; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; gap: 8px; }
  .main { margin-left: 0; }
  .brand { padding: 0 6px 0 0; font-size: 18px; }
  .brand svg { width: 28px; height: 28px; }
  .nav { flex-direction: row; }
  .nav-section { display: none; }
  .nav a { padding: 8px 10px; }
  .nav a.active { box-shadow: inset 0 -3px 0 var(--teal); }
  .nav .step { display: none; }
  .sidebar-foot { margin: 0; padding: 0 0 0 8px; border: 0; }
  .sidebar-foot .me { display: none; }
  .auth { grid-template-columns: 1fr; }
  .hero-whale { display: none; }
  .main { padding-top: 22px; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .envelope { grid-template-columns: 1fr; }
  .hero-card { grid-template-columns: 1fr; }
  .journey { columns: 1; }
  .pros-cons { grid-template-columns: 1fr; }
  .goal-nums { grid-template-columns: 1fr; }
  .custom-inputs { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}

/* ---------- Impression / export PDF ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .no-print, #toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .doc section { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
