@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(fonts/inter-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: Sora; font-weight: 500; font-display: swap; src: url(fonts/sora-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Sora; font-weight: 600; font-display: swap; src: url(fonts/sora-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Sora; font-weight: 700; font-display: swap; src: url(fonts/sora-latin-700-normal.woff2) format('woff2'); }

:root, :root[data-theme="dark"] {
  --bg: #0E1116; --surface: #171B22; --surface2: #1D222B; --surface3: #12161C;
  --border: #262C36; --border2: #343B47; --grid: #1F242D;
  --text: #E8ECF1; --text2: #C3CAD5; --muted: #9AA4B2; --faint: #8B95A4; --dim: #6F7987;
  --accent: #5EEAD4; --accent-soft: rgba(94,234,212,0.14); --on-accent: #0E1116;
  --danger: #F87171; --danger-soft: rgba(248,113,113,0.16);
  --income: #60A5FA; --expense: #FB923C; --warn: #FBBF24;
  --overlay: rgba(4,6,10,0.66); --shadow: 0 10px 30px rgba(0,0,0,0.45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F4F6F8; --surface: #FFFFFF; --surface2: #EEF1F4; --surface3: #F8FAFB;
  --border: #E3E7EC; --border2: #D5DBE2; --grid: #E8ECF0;
  --text: #12161C; --text2: #2E3540; --muted: #5B6472; --faint: #626B78; --dim: #7A8390;
  --accent: #0F766E; --accent-soft: rgba(15,118,110,0.12); --on-accent: #FFFFFF;
  --danger: #C0262D; --danger-soft: rgba(192,38,45,0.1);
  --income: #1D4ED8; --expense: #C2410C; --warn: #B45309;
  --overlay: rgba(18,22,28,0.45); --shadow: 0 10px 30px rgba(18,22,28,0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #F4F6F8; --surface: #FFFFFF; --surface2: #EEF1F4; --surface3: #F8FAFB;
    --border: #E3E7EC; --border2: #D5DBE2; --grid: #E8ECF0;
    --text: #12161C; --text2: #2E3540; --muted: #5B6472; --faint: #626B78; --dim: #7A8390;
    --accent: #0F766E; --accent-soft: rgba(15,118,110,0.12); --on-accent: #FFFFFF;
    --danger: #C0262D; --danger-soft: rgba(192,38,45,0.1);
    --income: #1D4ED8; --expense: #C2410C; --warn: #B45309;
    --overlay: rgba(18,22,28,0.45); --shadow: 0 10px 30px rgba(18,22,28,0.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.4 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
main { padding: calc(20px + env(safe-area-inset-top)) 18px calc(110px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.h-display { font-family: Sora, Inter, sans-serif; font-weight: 600; letter-spacing: -0.02em; }
h1.page { margin: 0; font-family: Sora, Inter, sans-serif; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .tnum { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; } .stack { display: flex; flex-direction: column; gap: 10px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 16px; }
.card.tight { padding: 6px 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); min-width: 0; }
.tile .big { font-family: Sora, Inter, sans-serif; font-size: 20px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }

/* Buttons & Chips */
.btn { min-height: 44px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; border-radius: 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: none; background: transparent; color: var(--text2); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn.boxed { border: 1px solid var(--border2); background: var(--surface2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border2); background: var(--surface2); color: var(--accent); font-weight: 700; flex: none; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px; padding: 0 18px 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border2); background: transparent; color: var(--text2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"], .chip.on { background: var(--surface2); border-color: var(--accent); color: var(--text); }
.chip.solid[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.off .dot { background: var(--border2) !important; }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface2); }
.seg > * { min-height: 34px; padding: 0 12px; border-radius: 9px; border: none; background: transparent; color: var(--text2); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }
.seg > [aria-current="page"], .seg > [aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--surface2); color: var(--text2); }
.badge.shared { background: rgba(251,191,36,0.16); color: var(--warn); }
.badge.fix { background: var(--accent-soft); color: var(--accent); }

/* Navigation */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); width: min(528px, calc(100% - 32px)); height: 64px; border-radius: 22px; background: var(--surface2); border: 1px solid var(--border2); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; z-index: 20; box-shadow: var(--shadow); }
.nav a, .nav button { height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 600; border: none; background: transparent; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav .plus { justify-self: center; width: 52px; height: 52px; border-radius: 17px; background: var(--accent); color: var(--on-accent); }

/* Heute */
.now-card { border-radius: 22px; padding: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; gap: 16px; align-items: center; }
.ring { flex: none; width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ring > div { width: 62px; height: 62px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 2px; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 12px; bottom: 12px; width: 2px; background: var(--border); }
.tl-item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 54px; }
.tl-item .pin { position: absolute; left: -24px; width: 10px; height: 10px; border-radius: 50%; }
.tl-item.current .pin { left: -26px; width: 14px; height: 14px; box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-item.past { opacity: 0.55; }
.tl-item .t { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; text-align: right; min-width: 44px; }
.tl-gap { position: relative; margin: 6px 0; padding: 12px 14px; border-radius: 16px; border: 1px dashed var(--border2); display: flex; flex-direction: column; gap: 8px; }
.tl-gap .pin { position: absolute; left: -24px; top: 16px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border2); background: var(--bg); }
.check { width: 44px; height: 44px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; }
.check > span { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--dim); display: flex; align-items: center; justify-content: center; color: transparent; }
.check.round > span { border-radius: 50%; }
.check[aria-pressed="true"] > span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.done-text { color: var(--faint); text-decoration: line-through; }

/* Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.daystrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.daystrip a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0; border-radius: 14px; text-decoration: none; color: var(--text2); }
.daystrip a .n { font-family: Sora, Inter, sans-serif; font-size: 16px; font-weight: 600; }
.daystrip a .w { font-size: 11px; font-weight: 600; }
.daystrip a.sel { background: var(--accent); color: var(--on-accent); }
.daystrip a.today:not(.sel) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dayview { position: relative; margin-left: 42px; }
.dayview .hr { position: absolute; left: -42px; right: 0; border-top: 1px solid var(--grid); }
.dayview .hr span { position: absolute; left: 0; top: -8px; padding-right: 6px; background: var(--bg); font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.dayview .slot { position: absolute; left: 0; right: 0; }
.ev { position: absolute; box-sizing: border-box; border-radius: 10px; padding: 4px 8px; overflow: hidden; display: flex; justify-content: space-between; gap: 6px; text-align: left; border: none; border-left: 3px solid; color: var(--text); }
.ev .ti { font-size: 13px; font-weight: 600; line-height: 1.2; }
.ev .me { font-size: 11px; color: var(--muted); }
.ev .tm { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gap { position: absolute; left: 0; right: 0; box-sizing: border-box; border: 1px dashed var(--border2); border-radius: 12px; padding: 5px 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--faint); }
.nowline { position: absolute; left: -6px; right: 0; border-top: 2px solid var(--accent); z-index: 3; pointer-events: none; }
.nowline::before { content: ''; position: absolute; left: -4px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.allday { display: flex; flex-wrap: wrap; gap: 6px; }
.allday .ad { padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; border: none; border-left: 3px solid; text-align: left; color: var(--text); }
.week { display: grid; grid-template-columns: 26px repeat(7, minmax(0, 1fr)); gap: 3px; }
.week .col { position: relative; border-radius: 10px; }
.week .col.today { background: var(--surface3); }
.week .wev { position: absolute; left: 1px; right: 1px; border-radius: 6px; padding: 2px 3px; overflow: hidden; border: none; border-top: 2px solid; text-align: left; font-size: 9.5px; line-height: 1.15; font-weight: 600; color: var(--text); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.week .whead { min-height: 46px; border: none; border-radius: 12px; background: transparent; color: var(--text2); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; }
.week .whead.sel { background: var(--accent); color: var(--on-accent); }
.week .whead.today:not(.sel) { background: var(--surface2); }
.month { background: var(--surface3); border: 1px solid var(--border); border-radius: 20px; padding: 8px 4px; }
.month .mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.month .wd { text-align: center; font-size: 11px; font-weight: 600; color: var(--faint); padding-bottom: 4px; }
.mcell { height: 100px; min-width: 0; border-radius: 10px; border: 1.5px solid transparent; background: var(--surface); display: flex; flex-direction: column; gap: 2px; padding: 3px 2px; overflow: hidden; text-align: left; }
.mcell.other { background: transparent; opacity: 0.45; }
.mcell.past { background: transparent; }
.mcell.sel { border-color: var(--accent); background: var(--accent-soft); }
.mcell .num { align-self: center; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 600 12px Sora, Inter, sans-serif; color: var(--text); }
.mcell.past .num { color: var(--dim); }
.mcell.today .num { background: var(--accent); color: var(--on-accent); }
.mcell .pv { display: block; min-width: 0; padding: 1px 3px; border-radius: 4px; border-left: 2px solid; font: 500 9.5px/13px Inter, sans-serif; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcell .more { padding-left: 3px; font: 600 9.5px/12px Inter, sans-serif; color: var(--muted); }
.agenda-item { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; color: var(--text); }
.agenda-item .stripe { width: 4px; align-self: stretch; border-radius: 2px; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .flabel { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 13px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); font-size: 16px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); }
.big-input { display: flex; align-items: center; gap: 8px; border: 2px solid var(--accent); border-radius: 16px; padding: 0 6px 0 16px; min-height: 60px; background: var(--surface); }
.big-input input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 19px; font-weight: 500; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.switch { position: relative; width: 52px; height: 32px; border-radius: 16px; border: none; background: var(--border2); flex: none; padding: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: left 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 23px; }
.weekday-pick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekday-pick button { min-height: 40px; border-radius: 10px; border: 1px solid var(--border2); background: transparent; color: var(--text2); font-weight: 600; font-size: 13px; padding: 0; }
.weekday-pick button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.error { color: var(--danger); font-size: 13px; }
.help { font-size: 13px; color: var(--muted); line-height: 1.5; }
.help ol { margin: 6px 0 0; padding-left: 20px; }

/* Bottom Sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: var(--overlay); }
.sheet { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.sheet .grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--border2); }
.sheet h2 { margin: 0; font-family: Sora, Inter, sans-serif; font-size: 21px; font-weight: 600; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* Budget & Auswertung */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .v { font-family: Sora, Inter, sans-serif; font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saldo { background: var(--text); color: var(--bg); border-radius: 16px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.saldo .v { font-family: Sora, Inter, sans-serif; font-size: 20px; font-weight: 600; }
.bars { display: grid; gap: 8px; align-items: end; border-bottom: 1px solid var(--border2); }
.bars .b { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.hbar { display: grid; grid-template-columns: 104px minmax(0, 1fr) 76px; align-items: center; gap: 10px; font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.logo { width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.empty { border: 1px dashed var(--border2); border-radius: 16px; padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }
.spinner { padding: 40px; text-align: center; color: var(--muted); }
