:root {
  --bg: #0f1412;
  --card: #171d1a;
  --raised: #1e2521;
  --hover: #232b27;
  --line: #262f2a;
  --field-line: #323d37;
  --text: #e8eeea;
  --muted: #8a9a92;
  --accent: #3fbf86;
  --accent-soft: rgba(63, 191, 134, .12);
  --gold: #f2c14e;
  --track: #252e29;
  --good: #3fbf86;
  --bad: #f07a74;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

::selection { background: var(--accent-soft); }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px 56px; }

.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 19px; font-weight: 600; }
.today { color: var(--muted); font-size: 14px; margin-left: auto; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; }
h2 { font-size: 18px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.eyebrow { font-size: 14px; font-weight: 600; color: var(--muted); }
.muted-small { color: var(--muted); font-size: 13px; }

.notice {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 14px; font-size: 15px;
  background: rgba(240, 122, 116, .1); border: 1px solid rgba(240, 122, 116, .35); color: var(--bad);
}
.notice[hidden] { display: none; }
.review {
  margin: 0 0 14px; padding: 16px 18px; border-radius: 14px; font-size: 16px;
  background: rgba(242, 193, 78, .12); border: 2px solid var(--gold); color: var(--text);
}
.review[hidden] { display: none; }
.review strong { display: block; font-family: var(--display); font-size: 19px; color: var(--gold); margin-bottom: 4px; }
.review .why { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- hero: savings ---------- */
.hero { padding: 22px 20px 20px; text-align: center; margin-bottom: 14px; display: flex; flex-direction: column; align-items: center; }
.big-number {
  font-family: var(--display); font-weight: 700; font-size: clamp(40px, 11vw, 60px); line-height: 1.1; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.pill {
  margin-top: 8px; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); animation: pop-in .4s ease-out both;
}
.pill[hidden] { display: none; }
.as-of { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.on-the-way { margin: 8px 0 0; font-size: 15px; font-weight: 600; color: var(--gold); cursor: help; }
.on-the-way[hidden] { display: none; }
.on-the-way.none { color: var(--muted); font-size: 13px; font-weight: 400; }
.bar { width: 100%; height: 12px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #7fd1a8);
  transition: width 1s cubic-bezier(.2, .8, .2, 1);
}
.ms-text { margin: 8px 0 0; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.chips:empty { display: none; }
.chip {
  padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--gold); background: rgba(242, 193, 78, .1); border: 1px solid rgba(242, 193, 78, .3);
}

/* ---------- forecast chart ---------- */
.chart-card { padding: 16px 18px 14px; margin-bottom: 14px; }
.chart-card[hidden] { display: none; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0;
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-read { margin: 8px 0 4px; font-size: 15px; min-height: 1.6em; }
.chart-read strong { font-family: var(--display); font-size: 18px; font-variant-numeric: tabular-nums; }
.chart { display: block; width: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .fill-top { stop-color: var(--accent); stop-opacity: .28; }
.chart .fill-bottom { stop-color: var(--accent); stop-opacity: 0; }
.chart .past { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .future { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 6 5; stroke-linejoin: round; }
.chart .now { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart .ms-dot { fill: var(--gold); }
.chart .stop-dot { fill: var(--bad); stroke: var(--card); stroke-width: 2; }
.chart .cursor line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .cursor circle { fill: var(--text); stroke: var(--card); stroke-width: 2; }
.chart-note { margin: 6px 0 0; }
.chart-stops { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.chart-stops[hidden] { display: none; }
.chart-stops li::before { content: "●"; color: var(--bad); margin-right: 6px; }

/* ---------- tiles: leefgeld and streak ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.tile { padding: 16px 18px; }
.mid-number { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.2; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.mid-number.neg { color: var(--bad); }
.mid-number .unit { font-size: 18px; font-weight: 600; color: var(--muted); }
.tile-line { margin: 2px 0 0; font-size: 14px; }
.tile-line:empty { display: none; }

/* ---------- recent transactions ---------- */
.list-card { padding: 16px 18px 8px; }
.tx { list-style: none; margin: 10px 0 0; padding: 0; }
.tx li {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: baseline;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px;
}
.tx li:first-child { border-top: 0; }
.tx-date { color: var(--muted); font-size: 13px; }
.tx-what { overflow-wrap: anywhere; }
.tx-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.tx li.in .tx-amount { color: var(--good); }
.tx li.empty { display: block; color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 0; }

/* ---------- controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input {
  font: inherit; font-weight: 400; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--field-line);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 12px; padding: 11px 20px;
  border: 1px solid var(--line);
  background: var(--raised); color: var(--text);
  transition: transform .12s, background .2s, border-color .2s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.primary { background: var(--accent); color: #0b1a12; border-color: transparent; }
.btn.primary:hover { background: #4ccf94; }
.icon-btn {
  font: inherit; cursor: pointer; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--raised); color: var(--muted);
  display: inline-grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }

/* ---------- toast ---------- */
.toast {
  position: fixed; inset: auto auto 24px 50%; margin: 0; transform: translateX(-50%);
  background: var(--raised); color: var(--text); border: 1px solid var(--field-line);
  padding: 12px 18px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  max-width: calc(100vw - 32px); width: max-content;
}
.toast.err { border-color: var(--bad); color: var(--bad); }
.toast.big { background: var(--accent); color: #0b1a12; border-color: transparent; font-weight: 600; }
.toast:popover-open { animation: toast-in .3s ease-out both; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login { width: min(360px, 100%); display: grid; gap: 16px; justify-items: center; padding: 32px 24px; }
.login h1 { font-size: 26px; }
.login .field { width: 100%; }
.login .btn { width: 100%; }
.login-error { color: var(--bad); margin: 0; font-size: 15px; text-align: center; }

/* ---------- celebrations ---------- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 520px) {
  .wrap { padding-top: 14px; }
  .today { display: none; }
  .brand { margin-right: auto; }
  .tiles { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
