:root {
    color-scheme: light;
    --bg: #f2eee6;
    --surface: #fbf9f5;
    --surface-2: #f1ece3;
    --border: #e5ddcf;
    --text: #0b0b0b;
    --text-2: #52514e;
    --muted: #7a7973;
    --accent: #1f3a5f;
    --accent-ink: #ffffff;
    --link: #1f5fae;
    --pos: #0f7a3d;
    --neg: #b42318;
    --warn-bg: #fff4d6;
    --warn-ink: #7a5200;
    --ok-bg: #e3f5ea;
    --ok-ink: #0f5a2e;
    --err-bg: #fde7e4;
    --err-ink: #8f1d12;
    --grid: #ebe4d8;
    --muted-mark: #a9a79f;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(60,45,20,.05), 0 4px 14px rgba(60,45,20,.05);
    --line-cur: #1f3a5f;
    --line-prev: #b3ab9c;
    --fix: #3d4b5f;
    --var: #c9bfae;
    --heat: 31, 58, 95;
    --good: #0f7a3d;
    --bad: #b42318;
    --ico-bg: #ece5d8;
    --saving: #1f3a5f;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #121211;
        --surface: #1a1a19;
        --surface-2: #232321;
        --border: #2f2f2c;
        --text: #f0efec;
        --text-2: #c3c2b7;
        --muted: #8f8e86;
        --accent: #7fa8de;
        --accent-ink: #0b1626;
        --link: #8db8f0;
        --pos: #4cc27f;
        --neg: #f08a7e;
        --warn-bg: #3a2e10;
        --warn-ink: #f4cf75;
        --ok-bg: #12301f;
        --ok-ink: #8fdcaf;
        --err-bg: #3b1712;
        --err-ink: #f6a99f;
        --grid: #2a2a27;
        --muted-mark: #66655f;
        --shadow: none;
        --line-cur: #7fa8de;
        --line-prev: #66655f;
        --fix: #c3c2b7;
        --var: #55534c;
        --heat: 127, 168, 222;
        --good: #4cc27f;
        --bad: #f08a7e;
        --ico-bg: #262624;
        --saving: #7fa8de;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c; --text: #f0efec; --text-2: #c3c2b7;
    --muted: #8f8e86; --accent: #7fa8de; --accent-ink: #0b1626; --link: #8db8f0; --pos: #4cc27f; --neg: #f08a7e;
    --warn-bg: #3a2e10; --warn-ink: #f4cf75; --ok-bg: #12301f; --ok-ink: #8fdcaf; --err-bg: #3b1712; --err-ink: #f6a99f;
    --grid: #2a2a27; --muted-mark: #66655f; --shadow: none;
    --line-cur: #7fa8de; --line-prev: #66655f; --fix: #c3c2b7; --var: #55534c; --heat: 127, 168, 222;
    --good: #4cc27f; --bad: #f08a7e; --ico-bg: #262624; --saving: #7fa8de;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hide-mobile, .btn.hide-mobile { display: none; }

/* --- Badge & Avatar --- */
.badge { background: var(--neg); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; margin-left: 4px; font-weight: 600; }
.avatar {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}
.avatar:hover { text-decoration: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; flex: none; }

/* --- Tabbar (mobil) --- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: grid; justify-items: center; padding: 8px 0 6px; font-size: 11px; color: var(--text-2); }
.tabbar a span { font-size: 20px; line-height: 1.2; }
.tabbar a:hover { text-decoration: none; }
.tabbar .tab-add span {
    background: var(--accent); color: var(--accent-ink); width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; margin-top: -18px; font-size: 26px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.mobilemenu { display: none; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.35); }
.menu-open .mobilemenu { display: block; }
.mobilemenu > div {
    position: absolute; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); background: var(--surface);
    border-radius: 16px 16px 0 0; padding: 8px; display: grid;
}
.mobilemenu a { padding: 14px 16px; color: var(--text); border-radius: 10px; }
.mobilemenu a:hover { background: var(--surface-2); text-decoration: none; }

/* --- Layout --- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 16px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.pagehead .actions { display: flex; gap: 8px; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.grid { display: grid; gap: 16px; }
.grid > .card { margin-bottom: 0; }
.kpis { grid-template-columns: 1fr; margin-bottom: 16px; }
.split { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
.split > .card { margin-bottom: 0; }
.split + .card, .split + section { margin-top: 16px; }
.stack { display: grid; gap: 12px; }
.two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.three { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr; }
.narrow { max-width: 560px; }
.users { grid-template-columns: 1fr; }

/* --- Formulare --- */
label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
    font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0;
}
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 40px; width: 48px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
    padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--neg); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 14px 18px; font-size: 16px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 6px; }
.iconbtn:hover { background: var(--surface-2); color: var(--neg); }
.inline { display: inline; margin: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters > select, .filters > input { width: auto; flex: 1 1 140px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; text-align: center; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* --- Meldungen --- */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--ok-bg); color: var(--ok-ink); }
.flash.warn { background: var(--warn-bg); color: var(--warn-ink); }
.flash.error { background: var(--err-bg); color: var(--err-ink); }
.notice { display: flex; gap: 8px 20px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); margin-bottom: 16px; }
.notice a { color: var(--warn-ink); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* --- KPIs --- */
.kpi .label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0; font-variant-numeric: tabular-nums; }
.kpi .value.small-value { font-size: 20px; }
.kpi.hero .value { font-size: 36px; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.up { color: var(--neg); }
.down { color: var(--pos); }
.kpi .value.up { color: var(--text); }
.person { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.person:last-of-type { border-bottom: 0; margin-bottom: 6px; }
.person .pname { font-weight: 600; }
.person .amount { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-2); }
.person .amount.up { color: var(--text); }

.cattiles { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
.cattile {
    position: relative; display: flex; gap: 10px; align-items: flex-start; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
    border-top: 4px solid var(--c);
}
.cattile .icon { font-size: 22px; line-height: 1; }
.cattile .name { font-size: 12px; color: var(--text-2); }
.cattile .val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cattile .share { position: absolute; top: 10px; right: 12px; font-size: 12px; color: var(--muted); }
.budget { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 6px; width: 100px; overflow: hidden; }
.budget i { display: block; height: 100%; background: var(--pos); border-radius: 2px; }
.budget.over i { background: var(--neg); }

/* --- Diagramm --- */
.chart { position: relative; width: 100%; min-height: 280px; }
.chart svg { display: block; width: 100%; height: 300px; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .seg { stroke: var(--surface); stroke-width: 2; }
.linechart { position: relative; width: 100%; }
.linechart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.linechart .gridline { stroke: var(--grid); stroke-width: 1; }
.linechart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.crosshair { stroke: var(--muted); stroke-width: 1; }
.key-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.chart .col:hover .seg, .chart .col.hover .seg { opacity: .85; }
.chart .total { fill: var(--text-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip {
    position: absolute; pointer-events: none; z-index: 5; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
    font-size: 13px; min-width: 200px; display: none;
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip div { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tooltip div span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip div em { font-style: normal; font-variant-numeric: tabular-nums; }
.tooltip .tt-total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; font-weight: 700; }

/* --- Matrix --- */
.tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.matrix { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 6px 8px; text-align: right; white-space: nowrap; }
.matrix thead th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix tr.cat th, .matrix tr.cat td { font-weight: 700; border-top: 1px solid var(--grid); padding-top: 10px; }
.matrix tr.cat td a { color: var(--text); }
.matrix tr.sub th { font-weight: 400; color: var(--text-2); padding-left: 24px; }
.matrix tr.sub td, .matrix tr.sub td a { color: var(--text-2); }
.matrix td.sum { font-weight: 700; }
.matrix tr.total th, .matrix tr.total td { border-top: 2px solid var(--text); font-weight: 700; font-size: 14px; padding-top: 10px; }
.matrix tr.warn th a, .matrix tr.warn td { color: var(--warn-ink); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* --- Listen --- */
.list { display: grid; }
.list .row {
    display: grid; grid-template-columns: auto 1fr auto auto; gap: 4px 12px; align-items: center;
    padding: 10px 4px; border-bottom: 1px solid var(--grid); color: var(--text);
}
.list .row:hover { background: var(--surface-2); text-decoration: none; }
.list .row:last-child { border-bottom: 0; }
.list .row.inactive { opacity: .55; }
.row .date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 78px; }
.row .desc { min-width: 0; }
.row .desc b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .desc small { color: var(--muted); font-size: 12px; }
.row .who { font-size: 12px; color: var(--text-2); font-weight: 600; }
.row .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.row .amt.pos { color: var(--pos); }
.row .amt.neg { color: var(--bad); }
.filterbox { margin-bottom: 8px; }

/* --- Erfassen --- */
.bigbutton {
    display: grid; justify-items: center; gap: 4px; padding: 28px 16px; border: 2px dashed var(--border);
    border-radius: 16px; cursor: pointer; color: var(--text); font-size: 17px; font-weight: 600; text-align: center;
}
.bigbutton:hover { background: var(--surface-2); }
.bigbutton .cam { font-size: 44px; }
.bigbutton small { font-weight: 400; color: var(--muted); font-size: 13px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img, .thumbs .pdf { width: 72px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.thumbs .pdf { display: grid; place-items: center; background: var(--surface-2); font-size: 12px; }
.preview img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; border-radius: 8px; object-fit: contain; }
.preview .rotatebar { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.preview iframe { width: 100%; height: 70vh; border: 0; }

/* --- Prüfen --- */
.review .reviewhead { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.reviewgrid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; align-items: end; }
.reviewgrid > label { flex: 1 1 140px; }
.reviewgrid > label.wide { flex: 2 1 240px; }
.reviewgrid .thumb { flex: 0 0 90px; align-self: stretch; }
.reviewgrid .thumb img { width: 90px; height: 120px; object-fit: cover; border-radius: 8px; }
/* Massenscan bestätigen: Ausschnitt ganz und hochkant zeigen statt abgeschnittener Kachel */
.scanbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; position: sticky; top: 8px; z-index: 5; }
.scanbar > div { flex: 1 1 320px; }
.scanreview .reviewgrid .thumb { flex: 0 0 150px; }
.scanreview .reviewgrid .thumb img { width: 150px; height: 260px; object-fit: contain; background: #fff; border: 1px solid var(--border); }

/* --- Kategorien --- */
.catcard { border-left: 5px solid var(--c); }
.catform, .subform { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.catform .icon-input { width: 56px; text-align: center; font-size: 20px; }
.catform .name-input { flex: 1 1 180px; width: auto; font-weight: 700; }
.catform .mini { width: 110px; }
.subs { margin-top: 12px; display: grid; gap: 6px; }
.subform { align-items: center; padding: 4px 0; }
.subform > input { flex: 1 1 140px; width: auto; padding: 6px 8px; font-size: 14px; }
.subform > input.num { flex: 0 0 64px; }
.subform.inactive > input { opacity: .55; }
.subform.new > input { border-style: dashed; }

/* --- Scan --- */
.bignum { font-size: 40px; font-weight: 700; margin: 0; }
.bignum span { font-size: 15px; font-weight: 400; color: var(--muted); }
.steps { padding-left: 20px; margin: 0; display: grid; gap: 8px; }

.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login form { text-align: left; margin-top: 20px; }

@media (min-width: 640px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .cattiles { grid-template-columns: repeat(3, 1fr); }
    .users { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
    body { padding-bottom: 0; }
    .tabbar, .mobilemenu { display: none !important; }
    .hide-mobile, .btn.hide-mobile { display: inline-flex; }
    .wrap { padding: 24px; }
    .split { grid-template-columns: 1.4fr 1fr; }
    .cattiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .kpis { grid-template-columns: 1.2fr 1fr 1.2fr; }
}

/* ===== Dashboard v2 ===== */
.nomargin { margin: 2px 0 0; }
.ico { width: 18px; height: 18px; vertical-align: -3px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.yearpick { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.yearpick button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.yearpick button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
.stat { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stat:first-child { grid-column: 1 / -1; }
.stat-ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--ico-bg); color: var(--text-2); }
.stat-ico .ico { width: 22px; height: 22px; }
.stat > div { min-width: 0; }
.stat .label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat .value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat:first-child .value { font-size: 30px; }
.stat .sub { font-size: 12px; color: var(--muted); }

.dash { display: grid; gap: 16px; grid-template-columns: 1fr; }
.dash > .card { margin: 0; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cardhead h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.cardhead h2 .ico { color: var(--muted); }
.card h3 { font-size: 13px; color: var(--text-2); margin: 16px 0 6px; display: flex; gap: 6px; align-items: center; font-weight: 600; }
.legend b { color: var(--text); font-weight: 600; margin-left: 2px; }

.cashrow { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.cashcard .label { font-size: 12px; color: var(--text-2); }
.bigvalue { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.midvalue { font-size: 18px; font-weight: 700; color: var(--text-2); }
.cashcard .person { flex-wrap: wrap; row-gap: 6px; }
.person .pinfo { display: grid; line-height: 1.2; white-space: nowrap; }
.pill { margin-left: auto; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 20px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.due { background: var(--warn-bg); color: var(--warn-ink); }
.pill.adv { background: var(--surface-2); color: var(--text-2); }

.split-meter { display: grid; gap: 14px; }
.sm-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.sm-bar i { display: block; min-width: 2px; }
.sm-bar .fix, .key.fix { background: var(--fix); }
.sm-bar .var, .key.var { background: var(--var); }
.sm-legend { display: grid; gap: 6px; }
.sm-legend > div { display: grid; grid-template-columns: 12px 1fr auto 44px; gap: 8px; align-items: center; font-size: 14px; }
.sm-legend em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.key { width: 10px; height: 10px; border-radius: 3px; }
.sm-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px solid var(--grid); padding-top: 10px; }
.sm-foot > div { display: grid; }
.sm-foot b { font-size: 16px; }

.calnav a { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--text-2); font-size: 18px; }
.calnav a:hover { background: var(--surface-2); text-decoration: none; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.cal .wd { color: var(--muted); font-weight: 600; font-size: 11px; padding-bottom: 2px; }
.cal .day { display: grid; place-items: center; aspect-ratio: 1; border-radius: 7px; color: var(--text-2); background: var(--surface-2); }
.cal .day:hover { outline: 2px solid var(--line-cur); text-decoration: none; }
.cal .day.l1 { background: rgba(var(--heat), .18); color: var(--text); }
.cal .day.l2 { background: rgba(var(--heat), .38); color: var(--text); }
.cal .day.l3 { background: rgba(var(--heat), .62); color: #fff; }
.cal .day.l4 { background: rgba(var(--heat), .88); color: #fff; }
.cal .day.future { opacity: .4; }
.calstats { display: grid; gap: 4px; margin-top: 12px; font-size: 13px; }
.calstats > div { display: flex; justify-content: space-between; color: var(--text-2); }

.hbars { display: grid; gap: 10px; margin-top: 12px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l v" "t t"; gap: 4px 10px; color: var(--text); }
.hbar:hover { text-decoration: none; }
a.hbar:hover .hl { text-decoration: underline; }
.hbar .hl { grid-area: l; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar b { grid-area: v; font-size: 14px; font-variant-numeric: tabular-nums; }
.hbar .track { grid-area: t; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 0 4px 4px 0; }

.budgets { display: grid; gap: 12px; margin-top: 12px; }
.br-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.meter { height: 8px; border-radius: 4px; background: rgba(var(--heat), .12); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); border-radius: 4px; }
.meter.warn i { background: #eda100; }
.meter.over i { background: var(--bad); }
.emptystate { padding: 8px 0; }
.emptystate p { margin: 0 0 6px; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { display: inline; }
details > summary::after { content: " ▾"; color: var(--muted); }
details:not([open]) > summary::after { content: " ▸"; }
details[open] > summary { margin-bottom: 12px; }

@media (min-width: 640px) {
    .stats { grid-template-columns: repeat(3, 1fr); }
    .stat:first-child { grid-column: auto; }
    .dash { grid-template-columns: repeat(2, 1fr); }
    .dash > .span-8, .dash > .span-6, .dash > .span-12 { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
    .stats { grid-template-columns: repeat(5, 1fr); }
    .stat:first-child .value { font-size: 26px; }
    .dash { grid-template-columns: repeat(12, 1fr); }
    .dash > .span-3 { grid-column: span 3; }
    .dash > .span-4 { grid-column: span 4; }
    .dash > .span-6 { grid-column: span 6; }
    .dash > .span-8 { grid-column: span 8; }
    .dash > .span-12 { grid-column: span 12; }
}

.legend i.key-line { width: 14px; height: 2px; border-radius: 1px; }
@media (max-width: 639px) {
    .stat { padding: 12px; gap: 10px; }
    .stat-ico { width: 32px; height: 32px; border-radius: 10px; }
    .stat-ico .ico { width: 18px; height: 18px; }
    .stat .value { font-size: 19px; white-space: normal; }
}

/* ===== Navigation: Seitenleiste links (Desktop) / Kopfzeile + Tabbar (Handy) ===== */
.sidebar { display: none; }
.mobilebar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; flex: none; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

@media (min-width: 960px) {
    body.app { padding-left: 268px; }
    .mobilebar { display: none; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: 268px; z-index: 20; display: flex; flex-direction: column; gap: 14px;
        padding: 20px 14px 14px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
    }
    .sidebar .brand { padding: 0 8px; line-height: 1.2; }
    .sidebar-add { width: 100%; }
    .sidebar-add .ico { width: 16px; height: 16px; }
    .sidenav { display: grid; gap: 2px; }
    .sidenav a {
        display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px;
        color: var(--text-2); font-weight: 500;
    }
    .sidenav a .ico { color: var(--muted); width: 19px; height: 19px; flex: none; }
    .sidenav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
    .sidenav a.active { background: var(--ico-bg); color: var(--text); font-weight: 600; }
    .sidenav a.active .ico { color: var(--text); }
    .sidenav .badge { margin-left: auto; }
    .navlabel { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 16px 10px 6px; }
    .sidefoot { margin-top: auto; display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--grid); padding-top: 12px; }
    .sidefoot .me { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: 14px; line-height: 1.2; min-width: 0; }
    .sidefoot .me:hover, .sidefoot .me.active { background: var(--surface-2); text-decoration: none; }
    .sidefoot .me small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
    .iconlink { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); }
    .iconlink:hover { background: var(--surface-2); color: var(--neg); }
    .wrap { max-width: 1320px; }
}

.tabbar a .ico { width: 22px; height: 22px; margin-bottom: 2px; }
.tabbar .tab-add span .ico { width: 24px; height: 24px; margin: 0; }

/* Belegliste mit Spalte „Einsparung“ */
.list.receipts .row { grid-template-columns: 78px minmax(0, 1fr) 64px 96px 96px; }
.list.receipts .row.head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 4px; }
.list.receipts .row.head:hover { background: none; }
.row .sav { text-align: right; font-variant-numeric: tabular-nums; color: var(--good); font-size: 14px; }
.list.receipts .row.head .sav, .list.receipts .row.head .amt { color: var(--muted); font-weight: 700; }
@media (max-width: 639px) {
    .list.receipts .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "desc amt" "date sav"; row-gap: 0; }
    .list.receipts .row .desc { grid-area: desc; }
    .list.receipts .row .amt { grid-area: amt; }
    .list.receipts .row .date { grid-area: date; min-width: 0; }
    .list.receipts .row .sav { grid-area: sav; font-size: 12px; }
    .list.receipts .row .who, .list.receipts .row.head { display: none; }
}

/* Einsparung durch Rabatte */
.savings-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
.small-chart { min-height: 200px; }
.savings-stats { display: grid; gap: 12px; align-content: start; }
.savings-stats .label { display: block; font-size: 12px; color: var(--text-2); }
.two-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two-stats b { font-size: 16px; }
.savtop { display: grid; gap: 4px; border-top: 1px solid var(--grid); padding-top: 10px; font-size: 14px; }
.savtop > div { display: flex; justify-content: space-between; gap: 8px; }
@media (min-width: 960px) { .savings-grid { grid-template-columns: minmax(0, 1fr) 280px; } }

/* Kurze Tabelle Ein-/Auszahlungen je Person */
.minitable { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.minitable th, .minitable td { padding: 6px 4px; text-align: right; white-space: nowrap; }
.minitable thead th { font-size: 11px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--grid); }
.minitable tbody th, .minitable tfoot th { text-align: left; font-weight: 600; }
.minitable tbody th .avatar { margin-right: 4px; vertical-align: middle; }
.minitable tbody tr + tr { border-top: 1px solid var(--grid); }
.minitable tfoot th, .minitable tfoot td { border-top: 1px solid var(--text-2); font-weight: 700; }

/* Monatsübersicht im Kassenbuch */
.cashmatrix tr.cat th { padding-top: 14px; }
.cashmatrix tr.cat th .avatar, .cashmatrix tr.cat th .ico { margin-right: 4px; vertical-align: middle; }
.cashmatrix tr.diff th, .cashmatrix tr.diff td { font-weight: 600; color: var(--text); border-top: 1px dashed var(--grid); }
.cashmatrix td.pos { color: var(--text); }
.cashmatrix td.neg { color: var(--muted); }
.cashmatrix th, .cashmatrix td { padding: 5px 6px; font-size: 12.5px; }
.cashmatrix thead th:first-child, .cashmatrix tbody th { min-width: 110px; }

/* Verträge & Kündigungsfristen */
.contractbox { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; display: grid; gap: 10px; margin: 0; min-width: 0; }
.contractbox legend { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 6px; }
.contract { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.contract.soon { color: var(--warn-ink); }
.contract.urgent { color: var(--bad); font-weight: 600; }
.contract.ended { color: var(--muted); text-decoration: line-through; }
p.contract { font-size: 13px; }
.notice.deadlines { flex-direction: column; gap: 4px; }
.notice.deadlines a.urgent { font-weight: 600; }

/* Freigabe offener Kassenbuchungen */
.card.approve { border: 1px solid var(--warn-ink); border-color: color-mix(in srgb, var(--warn-ink) 35%, var(--border)); }
.approvetable { margin: 12px 0; }
.approvetable td { vertical-align: middle; text-align: left; white-space: normal; }
.approvetable th { text-align: left; }
.approvetable td:last-child, .approvetable th:last-child { text-align: right; white-space: nowrap; }
.approvetable input[type=date] { width: 150px; padding: 6px 8px; font-size: 14px; }
.amt-input { width: 100px; text-align: right; padding: 6px 8px; font-size: 14px; }
@media (max-width: 639px) {
    .approvetable thead { display: none; }
    .approvetable tr { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 8px; padding: 8px 0; border-top: 1px solid var(--grid); }
    .approvetable td { padding: 0; }
    .approvetable td:nth-child(2) { grid-column: 2; grid-row: 2; }
    .approvetable td:nth-child(4) { display: none; }
    .approvetable td:nth-child(5) { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
}

/* Initialen-Kreise in Benutzerfarbe */
.avatar.xs { width: 20px; height: 20px; font-size: 9px; vertical-align: middle; flex: none; }
.avatar.none { background: var(--surface-2); color: var(--muted); }
.row .who { display: flex; justify-content: center; }

.userhead { display: flex; align-items: center; gap: 10px; }
.colorpick .label { display: block; font-size: 13px; color: var(--text-2); font-weight: 500; margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { display: inline-block; position: relative; cursor: pointer; }
.swatch input[type=radio] { position: absolute; opacity: 0; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 2px var(--surface); }
.swatch input[type=radio]:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch input[type=radio]:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }
.swatch.custom input[type=color] { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1px dashed var(--muted); cursor: pointer; }
.swatch.custom input[type=radio]:checked ~ input[type=color] { border: 2px solid var(--text); }

.colorpick label { display: block; margin-bottom: 6px; }
.colorrow { display: flex; align-items: center; gap: 12px; }
.colorrow input[type=color] { width: 56px; height: 40px; padding: 2px; cursor: pointer; }

/* Betragsfelder in der Freigabeliste: hellgrün = Einzahlung, hellrot = Auszahlung */
.amt-input.pos { background: #e6f4ea; border-color: #b9dfc4; }
.amt-input.neg { background: #fbe9e7; border-color: #f0c4be; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .amt-input.pos { background: #16301f; border-color: #2a5a3b; }
    :root:not([data-theme="light"]) .amt-input.neg { background: #3a1a17; border-color: #6a2e28; }
}
:root[data-theme="dark"] .amt-input.pos { background: #16301f; border-color: #2a5a3b; }
:root[data-theme="dark"] .amt-input.neg { background: #3a1a17; border-color: #6a2e28; }

/* Vorzeichen vor dem Betragsfeld in passender Farbe */
.sign { display: inline-block; width: 16px; margin-right: 6px; text-align: center; font-size: 18px; font-weight: 700; vertical-align: middle; }
.sign.pos { color: #1e7d45; }
.sign.neg { color: #b42318; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sign.pos { color: #4cc27f; }
    :root:not([data-theme="light"]) .sign.neg { color: #f08a7e; }
}
:root[data-theme="dark"] .sign.pos { color: #4cc27f; }
:root[data-theme="dark"] .sign.neg { color: #f08a7e; }

/* Platzhalter-Hilfe unter Bezeichnungen */
.phhelp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: -4px; }
.phhelp > div { flex-basis: 100%; }
.chip { font: inherit; font-size: 12px; font-family: ui-monospace, Menlo, monospace; padding: 3px 8px; border-radius: 6px;
        border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.chip:hover { background: var(--ico-bg); color: var(--text); }

.contract.ended-ok { color: var(--good); }
.cancelrow { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; border-top: 1px dashed var(--grid); padding-top: 10px; }
.cancelrow label { flex: 1 1 160px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; z-index: 5; }
@media (max-width: 959px) { .sticky-actions { bottom: calc(62px + env(safe-area-inset-bottom)); } }

/* Dubletten-Vergleich */
.dupcard { border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--border)); }
.duppair { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--grid); }
.duppair:first-of-type { border-top: 0; }
.dupwhy { grid-column: 1 / -1; }
.dupside { background: var(--surface-2); border-radius: 10px; padding: 12px; min-width: 0; }
.dupside.suspect { outline: 2px dashed color-mix(in srgb, var(--bad) 45%, transparent); }
.duplabel { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-bottom: 8px; }
.dupthumb { display: block; margin-bottom: 8px; }
.dupthumb img { width: 100%; max-height: 220px; object-fit: contain; background: var(--surface); border-radius: 8px; }
.dupthumb.pdf { padding: 10px; background: var(--surface); border-radius: 8px; text-align: center; }
.dupside dl { display: grid; grid-template-columns: 80px 1fr; gap: 4px 10px; margin: 0; font-size: 14px; }
.dupside dt { color: var(--muted); }
.dupside dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dupactions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.dupscan { margin-top: 16px; }
@media (min-width: 760px) { .duppair { grid-template-columns: 1fr 1fr; } }

/* Logo BudgetBoss (weißer Hintergrund im Bild → im Dark Mode auf heller Karte) */
.brand.logo { display: block; line-height: 0; }
.brand.logo img { display: block; height: auto; border-radius: 10px; }
.sidebar .brand.logo { padding: 0; margin: -6px 0 2px; }
.sidebar .brand.logo img { width: 100%; max-width: 240px; }
.mobilebar .brand.logo img { width: auto; height: 40px; }
.loginlogo { margin: 0; line-height: 0; }
.loginlogo img { width: 100%; max-width: 360px; height: auto; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand.logo img, :root:not([data-theme="light"]) .loginlogo img { background: #fff; padding: 4px 6px; }
}
:root[data-theme="dark"] .brand.logo img, :root[data-theme="dark"] .loginlogo img { background: #fff; padding: 4px 6px; }

/* Claim im Logo: linksbündig unter dem linken Ende des roten Bogens, rechts neben dem Ellenbogen.
   Positionen in % der Logogröße (Bogen beginnt bei 52 % Breite / endet links bei 83 % Höhe),
   Schriftgröße in cqw, damit alles mit dem Logo mitskaliert. */
.loginlogo { position: relative; display: inline-block; width: 100%; max-width: 360px; container-type: inline-size; }
.loginlogo .claim {
    position: absolute; left: 52%; top: 85%;
    font-size: 4.1cqw; font-weight: 700; letter-spacing: .01em; line-height: 1.15; white-space: nowrap;
    color: #0f2340; font-style: italic;
}

/* Drag & Drop Belegerfassung */
.bigbutton { position: relative; transition: background .15s, border-color .15s; }
.bigbutton .drophint { display: none; }
.bigbutton.drag { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: var(--accent); border-style: solid; }
.bigbutton.drag > :not(.drophint):not(input) { visibility: hidden; }
.bigbutton.drag .drophint { display: grid; place-items: center; position: absolute; inset: 0; font-size: 18px; font-weight: 700; color: var(--accent); }
.show-touch { display: none; }
@media (hover: none) { .show-touch { display: inline; } .hide-touch { display: none; } }
.thumbs { gap: 10px; }
.thumb-item { position: relative; display: grid; gap: 4px; width: 84px; }
.thumb-item img, .thumb-item .pdf { width: 84px; height: 108px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.thumb-item .pdf { display: grid; place-items: center; background: var(--surface-2); font-weight: 700; color: var(--bad); }
.thumb-item small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-rm { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
            background: var(--text); color: var(--surface); font-size: 14px; line-height: 1; }

.storagecard { display: grid; gap: 12px; margin-top: 16px; }
.storagecard h2 { display: flex; gap: 8px; align-items: center; margin: 0; }
.storetotal b { font-size: 26px; }
.storagecard .minitable th { font-weight: 500; color: var(--text-2); }
.storagecard .minitable td:nth-child(2) { color: var(--muted); }
.storagecard .two-stats .label { display: block; font-size: 12px; color: var(--text-2); }

/* Einzelpositionen in der Belegansicht */
.itemtable { margin: 8px 0 12px; }
.itemtable th, .itemtable td { text-align: left; vertical-align: middle; white-space: normal; }
.itemtable td.num, .itemtable tfoot td { text-align: right; white-space: nowrap; }
.itemtable td.raw { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-2); }
.itemtable input, .itemtable select { padding: 5px 8px; font-size: 14px; }
.itemtable tr.deposit td { color: var(--muted); }
.itemtable tfoot th { text-align: right; }

.diffwarn { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.codeinput { font-size: 24px; letter-spacing: .2em; text-align: center; font-variant-numeric: tabular-nums; }

/* Zwei-Faktor-Anmeldung */
#zweifaktor h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.qrbox { width: 220px; max-width: 70%; margin: 0 auto; background: #fff; padding: 8px; border-radius: 12px; line-height: 0; }
.qrbox svg { width: 100%; height: auto; }
code.secret { font-size: 14px; letter-spacing: .05em; user-select: all; }
.backupcodes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.backupcodes code { font-size: 15px; text-align: center; padding: 6px; background: var(--surface); }
.tfa-status { font-size: 12px; }
.inline-pw { width: 150px; padding: 5px 8px; font-size: 14px; }
