:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #2f2a2a;
  --muted: #756f6b;
  --line: #ebe5df;
  --rose: #c8697e;
  --rose-soft: #f8e7ec;
  --sage: #739276;
  --sage-soft: #e8f1e8;
  --blue: #5e83a6;
  --blue-soft: #e7eef6;
  --gold: #b88642;
  --gold-soft: #f5ead7;
  --danger-soft: #f8e3e3;
  --shadow: 0 16px 42px rgba(76, 55, 44, 0.1);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #fbfaf7 0%, #f4f0eb 100%);
}
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 480px); min-height: 100vh; margin: 0 auto; padding: 20px 16px 92px; }
.topbar, .panel-heading, .section-title, .account-card, .charge-row, .movement-row, .import-row, .scenario-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.topbar { margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--rose); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.5rem, 7vw, 2.05rem); line-height: 1.06; }
h2 { margin-bottom: 0; font-size: 1.9rem; line-height: 1.05; }
h3 { margin-bottom: 0; font-size: 1rem; }

.icon-button, .ghost-button, .scenario-tab, .nav-item { border: 0; }
.icon-button { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--rose); background: var(--surface); box-shadow: var(--shadow); font-weight: 900; }
.screen { display: none; }
.screen.is-active { display: block; animation: rise 220ms ease-out; }

.health-card, .metric-card, .panel, .forecast-card, .total-card, .import-zone, .charge-group, .tip-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.health-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 18px; }
.health-card h2 { margin: 0 0 8px; font-size: 3rem; }
.health-card small { color: var(--muted); font-size: 1.1rem; }
.soft-text { max-width: 28ch; margin: 12px 0 0; color: var(--muted); line-height: 1.45; }
.soft-text.wide { max-width: 100%; }
.status-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 0 11px; border-radius: 999px; font-size: .82rem; font-weight: 800; }
.status-watch { color: #60431d; background: var(--gold-soft); }
.health-ring { display: grid; width: 88px; aspect-ratio: 1; place-items: center; border-radius: 50%; background: conic-gradient(var(--gold) 0 74%, #efe7df 74% 100%); }
.health-ring span { display: grid; width: 64px; aspect-ratio: 1; place-items: center; border-radius: 50%; color: var(--gold); font-size: 1.3rem; font-weight: 900; background: var(--surface); }

.metric-grid, .horizon-grid, .charges-groups { display: grid; gap: 12px; margin-top: 14px; }
.metric-card, .forecast-card, .total-card, .tip-card { padding: 15px; }
.metric-card { position: relative; overflow: hidden; }
.metric-card::before { position: absolute; inset: 0 auto 0 0; width: 6px; content: ""; }
.green::before { background: var(--sage); }
.blue::before { background: var(--blue); }
.rose::before { background: var(--rose); }
.metric-card p, .forecast-card span, .total-card span, .charge-row span, .movement-row span, .import-row span { margin: 0; color: var(--muted); font-size: .88rem; }
.metric-card strong, .forecast-card strong, .total-card strong { display: block; margin: 5px 0; font-size: 1.65rem; line-height: 1.1; }
.metric-card span { color: var(--muted); font-size: .84rem; }

.panel, .charge-group, .tip-card { margin-top: 14px; }
.panel, .charge-group { padding: 14px; }
.tip-card { background: #fffaf2; }
.tip-card strong { display: block; margin-bottom: 8px; font-size: 1.08rem; }
.tip-card p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.45; }
.panel-heading { margin-bottom: 12px; }
.panel-heading span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.stack-list { display: grid; gap: 10px; }

.alert-row, .movement-row, .import-row { border-radius: 8px; padding: 12px; background: #fbf8f4; }
.alert-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.dot-icon { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--rose); font-weight: 900; background: var(--rose-soft); }
.alert-row strong, .movement-row strong, .import-row strong, .charge-row strong { display: block; margin-bottom: 2px; }
.alert-row p, .forecast-card p, .scenario-card p { margin: 0; color: var(--muted); line-height: 1.45; }

.section-title { align-items: end; margin: 8px 0 14px; }
.account-list { display: grid; gap: 10px; }
.account-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--surface); }
.account-card strong { display: block; font-size: 1.32rem; }
.account-card span { color: var(--muted); font-size: .84rem; }
.account-badge { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-weight: 900; }
.total-card { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; background: #2f2a2a; color: #fff; }
.total-card span { color: rgba(255,255,255,.76); }
.total-card strong { margin: 0; font-size: 1.38rem; }

.forecast-card p { margin-top: 8px; }
.mini-bar { height: 9px; overflow: hidden; border-radius: 999px; background: #eee6dd; }
.mini-bar i { display: block; height: 100%; border-radius: inherit; background: var(--sage); }
.mini-bar.risk i { background: var(--rose); }
.forecast-chart { display: block; width: 100%; height: auto; margin: 2px 0 4px; overflow: visible; }
.chart-area { fill: rgba(200, 105, 126, .14); }
.chart-line { fill: none; stroke: var(--rose); stroke-width: 5; stroke-linecap: round; }
.chart-points circle { fill: var(--surface); stroke: var(--rose); stroke-width: 3; }
.scenario-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; border-radius: 8px; background: #f5eee7; }
.scenario-tab { min-height: 40px; border-radius: 8px; color: var(--muted); font-size: .84rem; font-weight: 800; background: transparent; }
.scenario-tab.is-selected { color: var(--ink); background: var(--surface); box-shadow: 0 4px 12px rgba(76,55,44,.1); }
.scenario-card { margin-top: 12px; border-radius: 8px; padding: 13px; background: #fbf8f4; }
.scenario-head { margin-bottom: 8px; }
.scenario-head strong { font-size: 1.35rem; }
.scenario-head span { color: var(--sage); font-weight: 900; }

.charge-group h3 { margin-bottom: 10px; }
.charge-row { min-height: 62px; border-top: 1px solid var(--line); }
.charge-row:first-of-type { border-top: 0; }
.charge-row em { color: var(--rose); font-style: normal; font-weight: 900; white-space: nowrap; }
.status-label { display: inline-flex; margin-top: 6px; border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 900; }
.status-prevu { color: #36573d; background: var(--sage-soft); }
.status-urgent { color: #7b2f2f; background: var(--danger-soft); }
.status-paye { color: #315d7d; background: var(--blue-soft); }
.status-a-provisionner { color: #60431d; background: var(--gold-soft); }

.import-zone { display: grid; min-height: 160px; place-items: center; padding: 24px; color: var(--muted); text-align: center; border-style: dashed; }
.import-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.import-zone strong { color: var(--ink); font-size: 1.1rem; }
.import-zone span { max-width: 27ch; font-size: .87rem; line-height: 1.4; }
.import-row { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.category { min-width: 88px; border-radius: 999px; padding: 7px 9px; color: #60431d; font-size: .76rem; font-weight: 900; text-align: center; background: var(--gold-soft); }
.category.transfer { color: #315d7d; background: var(--blue-soft); }
.amount { font-weight: 900; text-align: right; }
.positive { color: var(--sage); }
.negative { color: var(--rose); }
.neutral { color: var(--blue); }

.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(100%, 480px); margin: 0 auto; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.nav-item { display: grid; min-width: 0; min-height: 58px; place-items: center; border-radius: 8px; color: var(--muted); background: transparent; }
.nav-item span { max-width: 100%; overflow: hidden; font-size: .7rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.is-active { color: var(--rose); background: var(--rose-soft); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 700px) {
  .app-shell { padding-top: 28px; }
  .metric-grid, .horizon-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid .metric-card:first-child { grid-column: 1 / -1; }
}
