:root {
  --bg: #f2f2f7; --card: #fff; --text: #1c1c1e; --muted: #8e8e93; --line: #e5e5ea;
  --accent: #0a84ff; --danger: #ff3b30; --radius: 14px; --tabh: 60px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --muted: #98989f; --line: #2c2c2e; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { padding-top: env(safe-area-inset-top); -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); }
a { color: var(--accent); }

main { padding: 0 16px calc(var(--tabh) + env(safe-area-inset-bottom) + 28px); max-width: 640px; margin: 0 auto; }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 4px; }
header.top h1 { font-size: 32px; margin: 0; font-weight: 700; letter-spacing: -.5px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 40px 0; }
.center { text-align: center; }
.muted, small { color: var(--muted); }
small { font-size: 13px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.total { font-size: 38px; font-weight: 700; letter-spacing: -.5px; }

.monthbar { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.monthbar button { font-size: 30px; width: 44px; height: 44px; color: var(--accent); }
.monthbar span { font-weight: 600; font-size: 17px; }

.seg { display: flex; background: var(--line); border-radius: 10px; padding: 2px; gap: 2px; overflow-x: auto; }
.seg > button, .seg > label { flex: 1; padding: 7px 8px; border-radius: 8px; font-size: 14px; white-space: nowrap; text-align: center; }
.seg > button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }
.seg > label { padding: 0; }
.seg > label input { position: absolute; opacity: 0; pointer-events: none; }
.seg > label span { display: block; padding: 8px; border-radius: 8px; }
.seg > label input:checked + span { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }

.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 14px 0 10px; background: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

.catrow { padding: 8px 0; }
.catrow .l { display: flex; justify-content: space-between; gap: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }

.trend { display: flex; gap: 8px; height: 150px; align-items: stretch; }
.tcol { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); }
.tcol .tv { height: 16px; }
.tcol .tw { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.tcol .tb { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 6px; overflow: hidden; min-height: 2px; background: var(--line); }
.tcol .tb i { display: block; }
.tcol .tl { margin-top: 4px; }
.tcol.cur .tl { color: var(--text); font-weight: 600; }

.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--line); }
.ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; }
.grow { flex: 1; min-width: 0; }
.grow b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 600; white-space: nowrap; }
.evbar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.sectitle { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 20px 4px 6px; display: flex; justify-content: space-between; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: flex-start; justify-content: space-around;
  height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tabbar { background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 8px; font-size: 11px; color: var(--muted); }
.tab svg { width: 25px; height: 25px; }
.tab.active { color: var(--accent); }
.tab-add { width: 54px; height: 54px; margin-top: -16px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(10,132,255,.45); flex: none; }
.tab-add svg { width: 28px; height: 28px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); font-weight: 500; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; margin-top: 12px; }
.btn.small { padding: 7px 12px; font-size: 15px; }
.btn:disabled { opacity: .5; }

/* Bottom-Sheet */
#sheet-root .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .25s; z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; max-height: calc(100% - env(safe-area-inset-top) - 20px);
  background: var(--bg); border-radius: 16px 16px 0 0; transform: translateY(100%); transition: transform .28s ease; z-index: 21;
  display: flex; flex-direction: column; }
#sheet-root.open .overlay { opacity: 1; }
#sheet-root.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 17px; margin: 0; }
.sheet-head .link { color: var(--accent); width: 90px; text-align: left; }
.sheet-head .sp { width: 90px; }
.sheet-body { overflow-y: auto; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

.form .field { margin: 14px 0; }
.form .field > label, .flabel { display: block; font-size: 13px; color: var(--muted); margin: 0 4px 6px; text-transform: uppercase; }
.form input[type=text], .form input[type=password], .form input[type=date], .form input[type=time], .form input:not([type]), .form textarea {
  width: 100%; min-height: 46px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); -webkit-appearance: none; appearance: none; }
.form textarea { min-height: 80px; resize: vertical; }
.form .two { display: flex; gap: 8px; }
.form .two > * { flex: 1; min-width: 0; }
.amount { font-size: 34px !important; font-weight: 700; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 7px 12px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.chip input:checked + span { background: var(--c, var(--accent)); color: #fff; border-color: transparent; }
.switch { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.receipt img { display: block; max-width: 100%; max-height: 280px; border-radius: 10px; margin-bottom: 10px; }
.rbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.rimg { display: block; max-width: 100%; border-radius: 12px; margin: 12px auto; }
.colorrow input[type=color] { width: 60px; height: 46px; border: 0; background: none; padding: 0; }

/* Kalender */
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: var(--card); border-radius: var(--radius); padding: 8px; margin-top: 10px; }
.calgrid .wd { font-size: 12px; text-align: center; color: var(--muted); padding: 2px 0 6px; }
.cday { display: flex; flex-direction: column; align-items: center; padding: 4px 0 6px; border-radius: 10px; font-size: 15px; min-height: 48px; }
.cday .n { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.cday.out { opacity: .35; }
.cday.today .n { background: var(--danger); color: #fff; font-weight: 600; }
.cday.sel { background: var(--line); }
.cday .dots { display: flex; gap: 2px; height: 6px; margin-top: 2px; }
.cday .dots i { width: 6px; height: 6px; border-radius: 50%; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; color: #fff; white-space: nowrap; }

/* Login */
.login { max-width: 360px; margin: 12vh auto 0; padding: 24px; text-align: center; }
.login h1 { margin: 16px 0 24px; }
.login input { width: 100%; margin: 6px 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.login .btn { width: 100%; margin-top: 10px; }
.logo { width: 84px; height: 84px; border-radius: 22px; background: linear-gradient(135deg, #0a84ff, #5e5ce6); color: #fff;
  font-size: 46px; font-weight: 700; display: grid; place-items: center; margin: 0 auto; }
.err { color: var(--danger); min-height: 1.4em; margin-top: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 24px); z-index: 30;
  transform: translate(-50%, 20px); background: rgba(40,40,40,.92); color: #fff; padding: 10px 18px; border-radius: 20px;
  opacity: 0; transition: .25s; pointer-events: none; font-size: 15px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
