/* Haushaltsbuch: ruhiges Tannengrün, Zahlen in Tabellenziffern, unten Tab-Leiste am Handy, Seitenleiste am Rechner */
:root {
  --bg: #f2f5f3;
  --panel: #ffffff;
  --panel-2: #e8eeeb;
  --ink: #15211e;
  --muted: #5b6a65;
  --line: #d7e0dc;
  --accent: #1f5c4f;
  --accent-ink: #ffffff;
  --head: #16302b;
  --head-ink: #e9f1ee;
  --pos: #2b7a4b;
  --neg: #b23a2e;
  --warn: #9a6410;
  --chart-grid: #e3e9e6;
  --chart-in: #6aa58b;
  --chart-out: #c46a55;
  --chart-line: #16302b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(21, 33, 30, .06), 0 4px 16px rgba(21, 33, 30, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513;
    --panel: #16201d;
    --panel-2: #1e2a26;
    --ink: #e4ece8;
    --muted: #93a49e;
    --line: #2a3833;
    --accent: #5fb39a;
    --accent-ink: #0e1513;
    --head: #0b1110;
    --head-ink: #e4ece8;
    --pos: #6cc58f;
    --neg: #ef8a7c;
    --warn: #e0b060;
    --chart-grid: #24312d;
    --chart-in: #5fa588;
    --chart-out: #d0806c;
    --chart-line: #e4ece8;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
h1, h2 { text-wrap: balance; margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .cap { color: var(--muted); }
.cap { font-size: .85rem; margin: .25rem 0 .75rem; }
.small-text { font-size: .85rem; }
.lead { margin: 0 0 1rem; color: var(--muted); max-width: 62ch; }
.num, .kpi-value, .plan-value, .amount { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
[hidden] { display: none !important; }

/* Buttons und Formulare */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: 0 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 .75rem; font-size: .9rem; }
.btn.danger { color: var(--neg); }
.btn.danger-solid { background: var(--neg); color: #fff; border-color: var(--neg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
input, select { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 .7rem; font-size: 1rem; color: var(--ink); width: 100%; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); flex: none; }
label.check { flex-direction: row; align-items: flex-start; gap: .6rem; color: var(--ink); font-size: .92rem; }
.form-error { color: var(--neg); margin: 0; font-size: .9rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); background: var(--head); }
.auth-card { width: min(100%, 380px); background: var(--panel); border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.05rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .95rem; }

/* Rahmen */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--head); color: var(--head-ink); padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
.topbar .brand-mark { background: var(--head-ink); color: var(--head); }
.topbar .btn { color: var(--head-ink); border-color: rgba(233, 241, 238, .25); }
.topbar-actions { display: flex; gap: .4rem; }
.content { padding: 20px max(16px, env(safe-area-inset-right)) calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); max-width: 1180px; margin: 0 auto; }
.tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar); color: var(--muted); text-decoration: none; font-size: .72rem; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--accent); font-weight: 600; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.select-inline select { min-width: 10rem; font-weight: 500; }
@media (min-width: 900px) {
  #shell { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .tabs { position: sticky; top: 58px; align-self: start; display: flex; flex-direction: column; gap: 2px; border: 0; background: transparent; padding: 20px 0 0 16px; height: auto; }
  .tabs a { flex-direction: row; justify-content: flex-start; gap: .7rem; height: 42px; padding: 0 .8rem; border-radius: 10px; font-size: .95rem; }
  .tabs a.active { background: var(--panel); box-shadow: var(--shadow); }
  .content { padding-bottom: 48px; width: 100%; }
}

/* Karten und Kennzahlen */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid .card { margin: 0; }
@media (min-width: 760px) { .grid { grid-template-columns: 1fr 1fr; } .grid .wide { grid-column: 1 / -1; } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-main { background: var(--head); border-color: var(--head); color: var(--head-ink); }
.kpi-main .kpi-label, .kpi-main .kpi-sub { color: rgba(233, 241, 238, .75); }
.kpi-main .kpi-value.pos { color: #8fdcab; }
.kpi-main .kpi-value.neg { color: #ffb2a6; }

.chart { position: relative; height: 260px; }
.chart-donut { height: 220px; }
.chart-short { height: 200px; }

.cat-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.cat-list li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: .6rem; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.cat-list li button { all: unset; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-list li button:hover { text-decoration: underline; }
.sw { width: 12px; height: 12px; border-radius: 3px; }
.share { color: var(--muted); font-size: .82rem; min-width: 3.2em; text-align: right; }

.delta-list { list-style: none; margin: 0; padding: 0; }
.delta-list li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; padding: 9px 0; border-top: 1px solid var(--line); }
.delta-list .d-name { font-weight: 500; }
.delta-list .d-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.delta-list .d-sub { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); }
.empty { color: var(--muted); padding: 12px 0; }

/* Buchungen */
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 8px; }
@media (min-width: 640px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }
.booking-list, .item-list, .statement-list, .rule-list, .upload-results { list-style: none; margin: 0; padding: 0; }
.booking-list li { border-bottom: 1px solid var(--line); }
.booking-list button.bk { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px .75rem; padding: 11px 4px; }
.booking-list button.bk:hover { background: var(--panel-2); }
.bk-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.bk-meta { font-size: .8rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); font-size: .78rem; color: var(--ink); }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; }
.chip.manual { outline: 1px solid var(--accent); }
.bk-hidden { opacity: .45; }
.bk-hidden .bk-name { text-decoration: line-through; }

/* Planer */
.scenario-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.scenario-bar select, .scenario-bar input { flex: 1 1 11rem; width: auto; min-height: 36px; }
.plan-group { margin-bottom: 16px; }
.plan-group h2 { display: flex; justify-content: space-between; gap: 1rem; padding: 0 4px 6px; }
.plan-group h2 .num { color: var(--muted); font-weight: 500; }
.plan-row { display: grid; grid-template-columns: auto 1fr 7.5rem auto; gap: .6rem; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); }
.plan-row .p-name { min-width: 0; }
.plan-row .p-name strong { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-row .p-name small { color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-row input[type="number"] { text-align: right; min-height: 38px; font-variant-numeric: tabular-nums; }
.plan-row.off .p-name, .plan-row.off input[type="number"] { opacity: .4; }
.plan-row.changed input[type="number"] { border-color: var(--accent); }
.plan-row .x { all: unset; cursor: pointer; color: var(--muted); padding: 4px 6px; font-size: 1.1rem; line-height: 1; }
.plan-row .x:hover { color: var(--neg); }
.plan-result { position: sticky; bottom: calc(var(--tabbar) + 8px + env(safe-area-inset-bottom)); z-index: 10; margin-top: 16px; background: var(--head); color: var(--head-ink); border-radius: var(--radius); padding: 14px 16px; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.plan-result .kpi-label { color: rgba(233, 241, 238, .75); display: block; }
.plan-value { font-size: 1.6rem; font-weight: 700; }
.plan-value.pos { color: #8fdcab; }
.plan-value.neg { color: #ffb2a6; }
.plan-compare { display: flex; flex-direction: column; align-items: flex-end; font-size: .85rem; color: rgba(233, 241, 238, .8); font-variant-numeric: tabular-nums; }
@media (min-width: 900px) { .plan-result { bottom: 12px; } }

/* Fixkosten */
.rec-list, .group-list, .rec-history { list-style: none; margin: 0; padding: 0; }
.rec-list li { border-top: 1px solid var(--line); }
.rec-list button.rec { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px .75rem; padding: 10px 4px; }
.rec-list button.rec:hover { background: var(--panel-2); }
.rec-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.rec-meta, .rec-sub { font-size: .8rem; color: var(--muted); }
.rec-sub { text-align: right; font-variant-numeric: tabular-nums; }
.rec-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 4px 10px; }
.tag { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: .72rem; font-weight: 600; letter-spacing: .02em; }
.tag.fix { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.tag.alltag { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.sparen { background: color-mix(in srgb, #8a7cc0 20%, transparent); color: #8a7cc0; }
.tag.own { background: var(--panel-2); color: var(--muted); }
.group-list li { display: grid; grid-template-columns: 12px 1fr 9.5rem; gap: .6rem; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.group-list select { min-height: 36px; }
.rec-history li { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); padding: 3px 0; font-variant-numeric: tabular-nums; }

/* Eigene Posten */
.item-list li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.item-list button { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 2px 1rem; }
.item-list .i-name { font-weight: 600; }
.item-list .i-amount { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.item-list .i-meta { font-size: .82rem; color: var(--muted); }

/* Auszüge */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel); color: var(--muted); cursor: pointer; margin-bottom: 12px; }
.dropzone strong { color: var(--ink); font-size: 1.05rem; }
.dropzone svg { width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone.drag { border-color: var(--accent); background: var(--panel-2); }
.upload-results { margin-bottom: 16px; }
.upload-results li, .statement-list li, .rule-list li { display: grid; grid-template-columns: 12px 1fr auto; gap: .2rem .7rem; align-items: start; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.dot.ok { background: var(--pos); }
.dot.warnung, .dot.doppelt { background: var(--warn); }
.dot.fehler { background: var(--neg); }
.statement-list .s-meta, .upload-results .s-meta, .rule-list .s-meta { color: var(--muted); font-size: .82rem; }
.rule-list li { grid-template-columns: 1fr auto; }

/* Dialoge */
dialog.sheet { border: 0; padding: 0; border-radius: 16px; background: var(--panel); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.sheet.small { width: min(400px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 20, 17, .45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.dlg-amount { font-size: 1.6rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
details.raw { font-size: .82rem; color: var(--muted); }
details.raw p { word-break: break-word; margin: .4rem 0 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .92rem; max-width: calc(100vw - 32px); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

@media (prefers-reduced-motion: no-preference) {
  .tab { animation: fade .18s ease-out; }
  @keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
