:root {
  --bg: #0a0710;
  --card: #151020;
  --card2: #1c1530;
  --line: #2a1f40;
  --text: #f4effa;
  --muted: #9a8fb0;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --grad: linear-gradient(90deg, #8b5cf6, #ec4899);
  --bad: #ff5c8a;
  --tabh: 72px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 0;
  min-height: 100vh;
}
main { padding: 20px 16px calc(var(--tabh) + env(safe-area-inset-bottom) + 28px); max-width: 560px; margin: 0 auto; }
h1 { font-size: 28px; margin: 4px 0 2px; letter-spacing: -.02em; }
h2 { font-size: 13px; margin: 26px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.muted { color: var(--muted); }
.bad-text { color: var(--bad); }
.small { font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; margin: 0 0 12px;
}
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--card2); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 10px; }

.hero { text-align: center; padding: 28px 16px 24px; }
.hero .label { color: var(--muted); font-size: 14px; }
.hero .big {
  font-size: 46px; font-weight: 700; letter-spacing: -.03em; margin: 6px 0 4px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}
.hero .big.neg { background: none; color: var(--bad); }

.bar { height: 8px; border-radius: 99px; background: #241a38; overflow: hidden; margin-top: 8px; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--grad); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar-fill.warn { background: linear-gradient(90deg, #ec4899, #ff3d5a); }

.env-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.env-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

.entry { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.entry:last-child { border-bottom: 0; }
.entry .sub { color: var(--muted); font-size: 13px; }

button, input, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
.btn {
  background: var(--grad); color: #fff; font-weight: 600; padding: 14px 18px; border-radius: 14px; width: 100%;
}
.btn.ghost { background: var(--card2); border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn + .btn { margin-top: 10px; }

input, select, textarea {
  width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none;
}
input:focus, select:focus { border-color: var(--violet); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.field-row { display: grid; grid-template-columns: 1fr 110px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-row.two { grid-template-columns: 1fr 120px; }
.x { background: transparent; color: var(--muted); font-size: 20px; padding: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); font-size: 14px;
}
.chip.on { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }

.amount-input { font-size: 38px; font-weight: 700; text-align: center; padding: 16px; background: transparent; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; }
.amount-input:focus { border-color: var(--pink); }

.notice { border-radius: 14px; padding: 12px 14px; background: #2a1226; border: 1px solid #5b2450; margin: 12px 0; }
.summary-line { display: flex; justify-content: space-between; padding: 6px 0; }
.summary-line.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 700; }

.seg { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.seg button { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 36px; font-size: 18px; }
.seg button:disabled { opacity: .3; }

/* Tab-Leiste */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: rgba(16, 11, 26, .88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#tabs button {
  background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; padding: 4px 0; min-height: 52px; justify-content: center;
}
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: var(--pink); }
#tabs button#fab {
  width: 58px; height: 58px; border-radius: 50%; margin: -22px auto 4px; min-height: 0;
  background: var(--grad); color: #fff; box-shadow: 0 8px 24px rgba(236, 72, 153, .4);
}
#tabs button#fab svg { width: 28px; height: 28px; stroke-width: 2.4; }
#tabs[hidden] { display: none; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(4, 2, 8, .65); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-panel {
  background: var(--card); border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.sheet-panel .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Design-Paket: Schimmer, Glas, Ringe, Wochen-Diagramm ---- */
body::before {
  content: ''; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(45% 35% at 20% 10%, rgba(139, 92, 246, .30), transparent 70%),
    radial-gradient(40% 30% at 85% 25%, rgba(236, 72, 153, .22), transparent 70%),
    radial-gradient(50% 40% at 50% 95%, rgba(124, 58, 237, .20), transparent 70%);
  animation: aurora 18s ease-in-out infinite alternate;
}
@keyframes aurora { from { transform: translate3d(-2%, -1%, 0) scale(1); } to { transform: translate3d(3%, 2%, 0) scale(1.08); } }

.card {
  background: linear-gradient(160deg, rgba(32, 22, 52, .78), rgba(18, 12, 30, .78));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-color: rgba(139, 92, 246, .22);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .05);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
main > :nth-child(2) { animation-delay: .04s; } main > :nth-child(3) { animation-delay: .08s; }
main > :nth-child(4) { animation-delay: .12s; } main > :nth-child(5) { animation-delay: .16s; }
main > :nth-child(6) { animation-delay: .2s; }  main > :nth-child(7) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.streak {
  font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 99px; white-space: nowrap;
  background: rgba(236, 72, 153, .14); border: 1px solid rgba(236, 72, 153, .4); color: #ffc1de;
}
.hero.glow { position: relative; overflow: hidden; }
.hero.glow::before {
  content: ''; position: absolute; left: 50%; top: 40%; width: 280px; height: 200px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(236, 72, 153, .35), rgba(139, 92, 246, .18) 60%, transparent);
  filter: blur(20px); animation: pulse 5s ease-in-out infinite alternate; z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
@keyframes pulse { from { opacity: .6; transform: translate(-50%, -50%) scale(.95); } to { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } }

.banner {
  border-radius: 16px; padding: 12px 14px; margin: 0 0 12px;
  background: rgba(139, 92, 246, .14); border: 1px solid rgba(139, 92, 246, .4);
}
.banner .small { color: var(--muted); margin-top: 3px; }
.banner.ok { border-color: rgba(236, 72, 153, .4); background: rgba(236, 72, 153, .1); font-size: 14px; }

/* Ring */
.ring { position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #2a1f40; stroke-width: 6; }
.ring-fg { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1); filter: drop-shadow(0 0 4px rgba(236, 72, 153, .5)); }
.ring-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.card.env { display: flex; align-items: center; gap: 14px; }
.env-body { flex: 1; min-width: 0; }
.card.env.over { border-color: rgba(255, 61, 90, .5); }

/* Wochen-Diagramm */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 14px 12px 10px; }
.week-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week-val { font-size: 11px; color: var(--muted); height: 14px; font-variant-numeric: tabular-nums; }
.week-track { width: 100%; max-width: 28px; height: 90px; border-radius: 10px; background: #221838; display: flex; align-items: flex-end; overflow: hidden; }
.week-fill { width: 100%; border-radius: 10px; background: linear-gradient(180deg, #a78bfa, #7c3aed); transition: height .8s cubic-bezier(.2, .8, .2, 1); }
.week-fill.today { background: linear-gradient(180deg, #f472b6, #ec4899); box-shadow: 0 0 14px rgba(236, 72, 153, .6); }
.week-day { font-size: 12px; color: var(--muted); }
.week-day.on { color: #ffc1de; font-weight: 700; }

.field-row.two { grid-template-columns: 1fr 120px; align-items: start; }
.field-row.two input { margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  body::before, .hero.glow::before, .card { animation: none; }
}

.top h1 { font-size: 24px; white-space: nowrap; }

.field-row.env { align-items: start; }
.field-row.env .x { margin-top: 4px; }
.field-row.add { grid-template-columns: 1fr auto; margin-top: 12px; margin-bottom: 0; }

.field-row.env { grid-template-columns: 1fr 92px auto; }
.row-actions { display: flex; gap: 0; align-items: center; min-width: 8px; }
.lock { background: transparent; font-size: 16px; padding: 6px 4px; opacity: .55; }
.lock.on { opacity: 1; }
.period { margin: -2px 0 12px; }
input[type=date] { min-height: 46px; }

.field-row > * { min-width: 0; }
.field-row.env { grid-template-columns: minmax(0, 1fr) 88px 66px; }
.field-row.add { grid-template-columns: minmax(0, 1fr) auto; }
.field-row.env input { padding: 12px 10px; }
.row-actions { justify-content: flex-end; }
html, body { overflow-x: hidden; }

.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.mode button { background: transparent; color: var(--muted); padding: 10px; border-radius: 10px; font-weight: 600; }
.mode button.on { background: var(--grad); color: #fff; }
.num.income { color: #f9a8d4; }
