:root {
  --bg: #f3f4f6; --surface: #ffffff; --text: #111827; --muted: #6b7280;
  --line: #e5e7eb; --primary: #3b82f6; --ein: #16a34a; --aus: #ef4444;
  --dark: #111827; --radius: 16px; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --nav-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
.splash { min-height: 100vh; display: grid; place-items: center; background: var(--dark); }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.2); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.app { min-height: 100vh; }
.content { max-width: 680px; margin: 0 auto; padding: 14px 16px calc(var(--nav-h) + 24px); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; }

/* Tabbar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--surface); border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
.tab-icon { font-size: 21px; filter: grayscale(.4); }
.tab.aktiv { color: var(--primary); }
.tab.aktiv .tab-icon { filter: none; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 14px; }
.topbar h2 { margin: 0; font-size: 22px; }
.topbar-gruss { font-size: 15px; color: var(--muted); }
.topbar-monat { font-size: 20px; font-weight: 700; }
.avatar, .profil-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary);
  color: #fff; border: 0; font-weight: 700; display: grid; place-items: center; font-size: 17px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--primary);
  color: #fff; font-size: 22px; line-height: 1; }

/* Saldo-Karten */
.saldo-karten { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.saldo-karte { background: var(--surface); border-radius: 14px; padding: 12px 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 3px; border-left: 4px solid var(--line); }
.saldo-karte.ein { border-left-color: var(--ein); }
.saldo-karte.aus { border-left-color: var(--aus); }
.saldo-karte.plus { border-left-color: var(--ein); }
.saldo-karte.minus { border-left-color: var(--aus); }
.sk-label { font-size: 12px; color: var(--muted); }
.sk-wert { font-size: 16px; font-weight: 700; }

/* Erfassung */
.typ-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.typ-toggle button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 11px; font-size: 15px; font-weight: 600; color: var(--muted); }
.typ-toggle button.aktiv.aus { background: var(--aus); color: #fff; border-color: var(--aus); }
.typ-toggle button.aktiv.ein { background: var(--ein); color: #fff; border-color: var(--ein); }
.typ-toggle button.aktiv { background: var(--primary); color: #fff; border-color: var(--primary); }
.betrag-feld { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px 0 16px; }
.betrag-input { width: 100%; max-width: 260px; border: 0; border-bottom: 2px solid var(--line);
  font-size: 44px; font-weight: 700; text-align: center; background: none; color: var(--text); }
.betrag-input:focus { outline: none; border-bottom-color: var(--primary); }
.betrag-eur { font-size: 30px; color: var(--muted); }
.betrag-feld.shake { animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 13px; font-size: 14px; color: var(--text); display: inline-flex; align-items: center; gap: 5px; }
.chip.aktiv { color: #fff; font-weight: 600; }
.chip-neu { border-style: dashed; color: var(--primary); }
.chips-modal { margin: 10px 0; }

.input, .mini-select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 15px; background: var(--surface); color: var(--text); }
.input:focus { outline: none; border-color: var(--primary); }
.zweck { margin-bottom: 12px; }
.erfassung-zeile { display: flex; gap: 8px; margin-bottom: 10px; }
.mini-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px;
  font-size: 14px; color: var(--text); }
.mini-select { flex: 1; }

/* Buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--primary); }
.btn-block { display: block; width: 100%; }
.btn-gross { padding: 16px; font-size: 17px; }
.btn-aus { background: var(--aus); } .btn-ein { background: var(--ein); }
.btn-primary { background: var(--primary); }
.btn-danger { background: #fff; color: var(--aus); border: 1px solid var(--aus); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .6; }
.link-btn { display: block; width: 100%; background: none; border: 0; color: var(--primary); padding: 10px;
  font-size: 14px; margin-top: 8px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg,#111827,#1f2937);
  padding: 20px; }
.auth-card { background: var(--surface); border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-logo { font-size: 46px; text-align: center; }
.auth-titel { text-align: center; margin: 6px 0 2px; font-size: 24px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.auth-tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600;
  color: var(--muted); }
.auth-tabs button.aktiv { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.auth-form input { font-size: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.hinweis { padding: 11px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 4px; }
.hinweis-ok { background: #dcfce7; color: #166534; }
.hinweis-err { background: #fee2e2; color: #991b1b; }
.feld-hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.zentriert { text-align: center; }

/* Listen / Buchungen */
.filter-leiste { margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.typ-filter, .seg { display: flex; background: var(--surface); border-radius: 10px; padding: 4px; box-shadow: var(--shadow); }
.typ-filter button, .seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px;
  font-size: 14px; color: var(--muted); font-weight: 600; }
.typ-filter button.aktiv, .seg button.aktiv { background: var(--primary); color: #fff; }
.seg { margin-bottom: 14px; }
.filter-summe { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; padding: 0 4px; }
.plus { color: var(--ein); } .minus { color: var(--aus); }
.leer, .leer-mini { text-align: center; color: var(--muted); padding: 30px 10px; }
.leer-mini { padding: 10px; font-size: 14px; }
.tag-gruppe { margin-bottom: 12px; }
.tag-kopf { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 4px; text-transform: uppercase; }
.buchung-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 12px;
  padding: 11px 13px; box-shadow: var(--shadow); margin-bottom: 7px; }
.bi-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; flex: 0 0 auto; }
.bi-mitte { flex: 1; min-width: 0; }
.bi-titel { font-weight: 600; font-size: 15px; }
.bi-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bi-betrag { font-weight: 700; font-size: 15px; white-space: nowrap; }
.monat-wechsel { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.monat-wechsel button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); font-size: 18px; }
.monat-wechsel.zentriert { justify-content: center; margin-bottom: 14px; }
.monat-wechsel.zentriert .input { max-width: 200px; text-align: center; }

/* Kategorien / Konten / generische Zeile */
.abschnitt-titel { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.kat-zeile { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.kat-zeile:last-child { border-bottom: 0; }
.kat-zeile.inaktiv { opacity: .5; }
.kat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 18px;
  background: var(--bg); flex: 0 0 auto; }
.kat-mitte { flex: 1; font-weight: 600; }
.kat-budget { font-size: 12px; color: var(--muted); font-weight: 400; }
.kat-anzahl { font-size: 13px; color: var(--muted); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end;
  justify-content: center; z-index: 100; }
.modal { background: var(--surface); width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 18px;
  max-height: 92vh; overflow-y: auto; animation: up .25s ease; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
@keyframes up { from { transform: translateY(100%); } }
@media (min-width: 520px) { .modal-backdrop { align-items: center; } .modal { border-radius: 20px; } }
.modal-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-kopf h3 { margin: 0; font-size: 18px; }
.x { border: 0; background: none; font-size: 18px; color: var(--muted); padding: 4px 8px; }
.feld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; font-size: 13px; color: var(--muted); font-weight: 600; }
.feld-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 6px 0; }
.modal-aktionen { display: flex; gap: 10px; margin-top: 8px; }
.modal-aktionen .btn { flex: 1; }
.vorschau { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-size: 32px;
  margin: 0 auto 12px; color: #fff; }
.icon-wahl, .farb-wahl { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.icon-wahl button { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 20px; }
.icon-wahl button.aktiv { border-color: var(--primary); border-width: 2px; }
.farb-wahl button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; }
.farb-wahl button.aktiv { border-color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; }

/* Import */
.import-upload { text-align: center; }
.import-hero { font-size: 52px; }
.import-upload p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.upload-btn { display: block; margin-top: 10px; }
.vorschau-tabelle { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; }
.vorschau-tabelle table { border-collapse: collapse; font-size: 12px; width: 100%; }
.vorschau-tabelle th, .vorschau-tabelle td { border: 1px solid var(--line); padding: 5px 7px; white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.vorschau-tabelle th { background: var(--bg); }
.import-fertig { text-align: center; }
.import-stats { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.import-stats li { background: var(--bg); border-radius: 10px; padding: 10px; }

/* Berichte */
.chart-box { position: relative; height: 240px; }
.export-reihe { display: flex; gap: 10px; margin-bottom: 16px; }
.export-reihe .btn { flex: 1; }

/* Einstellungen */
.profil { display: flex; align-items: center; gap: 14px; }
.profil-avatar { width: 52px; height: 52px; font-size: 22px; }
.profil-name { font-weight: 700; font-size: 17px; }
.profil-mail { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; background: var(--primary); color: #fff; font-size: 11px; padding: 2px 8px;
  border-radius: 999px; margin-top: 4px; }
.menu { padding: 4px 16px; }
.menu-zeile { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none;
  padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--text); text-align: left; }
.menu-zeile:last-child { border-bottom: 0; }
.menu-zeile .chev { margin-left: auto; color: var(--muted); }
.abmelden { color: var(--aus); margin-bottom: 10px; }
.version { text-align: center; color: var(--muted); font-size: 12px; }
.regel-zeile { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.regel-neu { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.regel-neu .btn { padding: 10px 14px; }
.user-zeile { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.u-mail { font-weight: 600; font-size: 14px; }
.u-akt { display: flex; align-items: center; gap: 6px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translate(-50%, 140%);
  background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 200;
  transition: transform .28s ease; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast.show { transform: translate(-50%, 0); }
.toast-ok { background: #166534; } .toast-err { background: #991b1b; }

@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1020; --surface: #1a2234; --text: #e5e7eb; --muted: #9ca3af; --line: #2b3448; }
  .btn-ghost { color: var(--text); }
  .hinweis-ok { background: #14532d; color: #bbf7d0; }
  .hinweis-err { background: #7f1d1d; color: #fecaca; }
  .vorschau-tabelle th { background: #0b1020; }
}
