[hidden] { display: none !important; }
:root {
  --plum: #6B3A5E;
  --plum-dark: #522B48;
  --plum-soft: #EFE1EA;
  --bg: #F4E9DB;
  --card: #FFFDF9;
  --text: #2B2027;
  --muted: #7D6F77;
  --line: #E7DACB;
  --pos: #2F7D55;
  --pos-bg: #DCEFE3;
  --warn: #9A6A12;
  --warn-bg: #F7E8C6;
  --neg: #B23A3A;
  --neg-bg: #F6DADA;
  --zero-bg: #ECE4DA;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E171C; --card: #2A2127; --text: #F2E9EE; --muted: #A9979F; --line: #3B2F37;
    --plum: #C58BB4; --plum-dark: #E0B3D2; --plum-soft: #3C2836;
    --pos: #7FCFA0; --pos-bg: #1F3A2B; --warn: #E8C277; --warn-bg: #3D3120;
    --neg: #F08F8F; --neg-bg: #4A2424; --zero-bg: #352B31;
  }
}
* { box-sizing: border-box; }
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; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--plum); }
.splash { display: grid; place-items: center; height: 100vh; font-weight: 700; color: var(--plum); font-size: 1.4rem; }

/* Layout */
.shell { max-width: 820px; margin: 0 auto; padding: 0 12px calc(84px + var(--safe-b)); }
header.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top, 0px)) 4px 8px;
  display: flex; align-items: center; gap: 8px; }
header.top h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.month-nav { display: flex; align-items: center; gap: 2px; flex: 1; }
.month-nav .label { font-weight: 700; font-size: 1.1rem; min-width: 9.5em; text-align: center; }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%; font-size: 1.25rem; cursor: pointer; color: var(--plum); }
.icon-btn:active { background: var(--plum-soft); }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: var(--safe-b); }
nav.tabs .inner { display: flex; max-width: 820px; width: 100%; }
nav.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: .72rem; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.tabs button .ic { font-size: 1.3rem; line-height: 1.2; }
nav.tabs button.active { color: var(--plum); font-weight: 600; }
nav.tabs button.add .ic { background: var(--plum); color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-top: -14px; box-shadow: 0 3px 10px rgba(0,0,0,.18); }

/* Karten */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.rta { text-align: center; padding: 16px; border-radius: var(--radius); margin-bottom: 12px; }
.rta .amt { font-size: 1.7rem; font-weight: 700; }
.rta .lbl { font-size: .85rem; }
.rta.pos { background: var(--pos-bg); color: var(--pos); }
.rta.zero { background: var(--zero-bg); color: var(--muted); }
.rta.neg { background: var(--neg-bg); color: var(--neg); }
.rta small { display: block; margin-top: 4px; opacity: .85; }
.hint { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; cursor: pointer; }

.group { background: var(--card); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.group-head { display: grid; grid-template-columns: 1fr 6.5em 6.5em; gap: 8px; padding: 10px 14px; background: var(--plum-soft); font-weight: 700; font-size: .9rem; align-items: center; }
.group-head .num { text-align: right; font-weight: 600; color: var(--muted); font-size: .8rem; }
.cat { display: grid; grid-template-columns: 1fr 6.5em 6.5em; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--line); align-items: center; }
.cat .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .name small { display: block; color: var(--muted); font-size: .75rem; }
.assigned-input { width: 100%; text-align: right; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 5px 6px; font-variant-numeric: tabular-nums; }
.assigned-input:hover { border-color: var(--line); }
.assigned-input:focus { outline: none; border-color: var(--plum); background: var(--card); }
.pill { justify-self: end; border: 0; border-radius: 999px; padding: 4px 10px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; font-size: .92rem; white-space: nowrap; }
.pill.pos { background: var(--pos-bg); color: var(--pos); }
.pill.zero { background: var(--zero-bg); color: var(--muted); }
.pill.neg { background: var(--neg-bg); color: var(--neg); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.cols-head { display: grid; grid-template-columns: 1fr 6.5em 6.5em; gap: 8px; padding: 0 14px 6px; font-size: .75rem; color: var(--muted); text-align: right; }
.cols-head span:first-child { text-align: left; }
@media (min-width: 640px) {
  .group-head, .cat, .cols-head { grid-template-columns: 1fr 7.5em 7.5em 7.5em; }
  .only-wide { display: block !important; }
}
.only-wide { display: none !important; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Listen */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .main .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .main .s { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row .amt.in { color: var(--pos); }
.date-sep { font-size: .8rem; color: var(--muted); padding: 10px 4px 4px; font-weight: 600; }
.clr { border: 2px solid var(--line); width: 24px; height: 24px; border-radius: 50%; background: none; flex: none; cursor: pointer; font-size: .7rem; color: transparent; }
.clr.gebucht { border-color: var(--pos); background: var(--pos); color: #fff; }
.clr.abgeglichen { border-color: var(--plum); background: var(--plum); color: #fff; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 4px 6px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Formulare */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input.i, select.i, textarea.i { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; }
input.i:focus, select.i:focus { outline: 2px solid var(--plum); outline-offset: -1px; border-color: transparent; }
.amount-big { font-size: 1.8rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--zero-bg); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--plum); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.btn { border: 0; background: var(--plum); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; width: 100%; }
.btn:active { background: var(--plum-dark); }
.btn.sec { background: var(--zero-bg); color: var(--text); }
.btn.danger { background: var(--neg-bg); color: var(--neg); }
.btn.small { width: auto; padding: 7px 12px; font-size: .9rem; }
.btn-row { display: flex; gap: 8px; margin-top: 6px; }
.btn-row .btn { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--neg); font-size: .9rem; margin-bottom: 10px; }

/* Sheet */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(20,10,18,.4); z-index: 20; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg); border-radius: 18px 18px 0 0;
  max-height: 92vh; overflow-y: auto; padding: 8px 16px calc(16px + var(--safe-b)); max-width: 560px; margin: 0 auto; box-shadow: 0 -4px 20px rgba(0,0,0,.2); }
#sheet .grab { width: 40px; height: 5px; background: var(--line); border-radius: 3px; margin: 4px auto 10px; }
#sheet h2 { font-size: 1.1rem; margin: 0 0 14px; text-align: center; }
@media (min-width: 640px) { #sheet { bottom: auto; top: 8vh; border-radius: 18px; } }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); z-index: 30; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: .92rem; max-width: 90vw; }

.auth { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.auth .logo { text-align: center; margin-bottom: 18px; }
.auth .logo img { width: 72px; height: 72px; }
.auth .logo h1 { margin: 8px 0 0; color: var(--plum); }
.muted { color: var(--muted); }
.mgr-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); }
.mgr-row input { flex: 1; }
.mgr-row.grp { background: var(--plum-soft); font-weight: 700; }
.hidden-cat { opacity: .5; }

/* Import */
.imp-row.off { opacity: .45; }
.imp-row .main { display: flex; flex-direction: column; gap: 4px; }
.imp-row .s { white-space: normal; }
.imp-payee, .imp-cat { padding: 6px 10px; font-size: .95rem; }
.imp-payee { font-weight: 600; }
.imp-cat.missing { border-color: var(--warn); background: var(--warn-bg); }
.badge { align-self: flex-start; font-size: .7rem; background: var(--plum-soft); color: var(--plum); border-radius: 6px; padding: 1px 6px; }
.imp-bar { position: sticky; bottom: calc(70px + var(--safe-b)); padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); z-index: 4; }
.btn:disabled { opacity: .5; cursor: default; }
header.top .btn.small { white-space: nowrap; }
