/* Finanzplaner – Sparbuch-Grün auf kühlem Papier, iPhone zuerst */
:root {
  --paper: #EBF0EE;
  --surface: #FFFFFF;
  --ink: #142C26;
  --muted: #5D706A;
  --line: #D5DEDA;
  --accent: #0E6B57;
  --accent-soft: #D6EAE3;
  --neg: #B23A2E;
  --unsafe: #B67C0E;
  --spent: #B9C7C2;
  --figures: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  --r-lg: 18px;
  --r-sm: 10px;
  --tab-h: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0D1513;
    --surface: #17221F;
    --ink: #E5EEEA;
    --muted: #8FA39C;
    --line: #26332F;
    --accent: #45B496;
    --accent-soft: #1D3A32;
    --neg: #F0796A;
    --unsafe: #E2B04A;
    --spent: #3A4A45;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font: 16px/1.45 var(--text);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

#app {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px);
}
.num { font-family: var(--figures); font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
h1 { font-size: 28px; line-height: 1.15; margin: 6px 0 14px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 26px 4px 8px; }

/* Kopfzeile Monat */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.monthbar h1 { margin: 0; text-align: center; flex: 1; font-size: 24px; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface);
  display: grid; place-items: center; color: var(--accent);
}
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Segment-Umschalter für Konten */
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px;
  font-size: 15px; font-weight: 500; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(20,44,38,.12); }

/* Spielraum – das Herzstück */
.room { background: var(--surface); border-radius: var(--r-lg); padding: 18px 18px 16px; }
.room-label { font-size: 15px; color: var(--muted); }
.room-value { font-family: var(--figures); font-variant-numeric: tabular-nums; font-size: 46px; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; margin: 2px 0 4px; }
.room-max { font-size: 15px; color: var(--muted); }
.room-max .num { color: var(--unsafe); font-weight: 600; }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 16px 0 10px; background: var(--line); }
.bar span { display: block; height: 100%; min-width: 0; transition: flex-grow .35s ease; }
.bar .b-spent { background: var(--spent); }
.bar .b-min { background: var(--accent); }
.bar .b-unsafe { background: repeating-linear-gradient(-45deg, var(--unsafe) 0 4px, transparent 4px 8px); box-shadow: inset 0 0 0 1.5px var(--unsafe); border-radius: 0 7px 7px 0; }
.bar.over .b-spent { background: var(--neg); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.stats div { font-size: 13px; color: var(--muted); }
.stats b { display: block; font-size: 17px; color: var(--ink); font-family: var(--figures); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Listen */
.list { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 6px 16px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.group-head .add { border: 0; background: transparent; color: var(--accent); width: 36px; height: 30px; border-radius: 8px; font-size: 22px; line-height: 1; }
.group-head .sum { margin-left: auto; margin-right: 4px; font-weight: 600; }
.group + .group { border-top: 6px solid var(--paper); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px;
  padding: 8px 16px; border: 0; background: transparent; text-align: left; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.row.has-check + .row.has-check::before { left: 56px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-family: var(--figures); font-variant-numeric: tabular-nums; font-weight: 500; }
.row.done .title, .row.done .amt { color: var(--muted); }
.row.inactive { opacity: .5; }
.row.readonly { cursor: default; }
.check {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line);
  background: transparent; display: grid; place-items: center; padding: 0; margin-left: -4px;
}
.check svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"] svg { opacity: 1; }
.empty-row { padding: 4px 16px 12px; font-size: 14px; color: var(--muted); }
.pill { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; margin-left: 6px; }

.note-card { background: var(--accent-soft); border-radius: var(--r-lg); padding: 14px 16px; margin-top: 14px; font-size: 15px; }
.note-card b { display: block; margin-bottom: 4px; }
.note-card ul { margin: 0; padding: 0; list-style: none; }
.note-card li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }

/* Leerer Monat */
.empty { background: var(--surface); border-radius: var(--r-lg); padding: 28px 20px; text-align: center; }
.empty p { margin: 0 0 18px; color: var(--muted); }

/* Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--neg); }
.btn.link { background: transparent; color: var(--accent); min-height: 40px; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1; }

.fab {
  position: fixed; right: max(18px, calc(50% - 302px)); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  box-shadow: 0 6px 18px rgba(14,107,87,.35); display: grid; place-items: center; z-index: 5;
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; fill: none; }

/* Tab-Leiste */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 0;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 150px; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 500; padding: 4px 0;
}
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--accent); }

/* Bottom-Sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8,20,17,.42); animation: fade .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px);
  animation: rise .25s cubic-bezier(.2,.8,.2,1);
}
.sheet-panel::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* Formulare */
.form { display: grid; gap: 12px; }
.field { background: var(--surface); border-radius: var(--r-sm); padding: 8px 14px; display: block; }
.field > span { display: block; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 0; background: transparent; padding: 4px 0; font-size: 17px; outline: none;
  -webkit-appearance: none; appearance: none; border-radius: 0;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%); background-position: right 6px center, right 0 center; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 18px; }
.field:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.field.big input { font-family: var(--figures); font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: var(--r-sm); padding: 12px 14px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin: -4px 4px 0; }
.error { color: var(--neg); font-size: 14px; min-height: 1em; margin: 0 4px; }

/* Login */
.login { min-height: 80vh; display: grid; align-content: center; gap: 16px; max-width: 360px; margin: 0 auto; }
.login .mark { width: 64px; height: 64px; border-radius: 16px; }

/* Vermögen */
.chart { background: var(--surface); border-radius: var(--r-lg); padding: 14px 10px 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: var(--muted); font-family: var(--text); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart-head { padding: 0 8px 6px; }
.chart-head .room-value { font-size: 34px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 15px;
  max-width: 90vw; animation: fade .2s ease;
}

/* Formularfelder dürfen im Raster schrumpfen (lange Auswahltexte, Monatsfelder) */
.two > * { min-width: 0; }
.field input, .field select { min-width: 0; text-overflow: ellipsis; }
.sheet-panel { overflow-x: hidden; }
