:root {
    --bg: #f2f2f7;
    --karte: #ffffff;
    --text: #1c1c1e;
    --text2: #6e6e73;
    --linie: #e3e3e8;
    --akzent: #0a7d6f;
    --akzent-hell: #e3f3f0;
    --rot: #d70015;
    --gelb: #b25000;
    --gruen: #248a3d;
    --feld: #f2f2f7;
    --schatten: 0 1px 2px rgba(0, 0, 0, .06);
    --radius: 14px;
    --leiste: 64px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --karte: #1c1c1e;
        --text: #f2f2f7;
        --text2: #98989f;
        --linie: #38383a;
        --akzent: #2fbfa9;
        --akzent-hell: #12332e;
        --rot: #ff6961;
        --gelb: #ffb340;
        --gruen: #30d158;
        --feld: #2c2c2e;
        --schatten: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(var(--leiste) + env(safe-area-inset-bottom)); }

a { color: var(--akzent); text-decoration: none; }

button { font: inherit; color: inherit; }

.seite {
    max-width: 980px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}

/* ── Kopf ─────────────────────────────────────────── */
.kopf {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-bottom: 8px;
}
.kopf h1 { font-size: 28px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -.01em; }
.kopf .zurueck { font-size: 17px; display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px 0; }
.kopf .titel-klein { flex: 1; text-align: center; font-weight: 600; }

/* ── Tab-Leiste ───────────────────────────────────── */
.leiste {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--leiste) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: color-mix(in srgb, var(--karte) 88%, transparent);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: .5px solid var(--linie);
    z-index: 20;
}
.leiste a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text2);
}
.leiste a svg { width: 26px; height: 26px; }
.leiste a.aktiv { color: var(--akzent); }
.leiste a.plus svg { width: 34px; height: 34px; }

/* ── Karten & Listen ──────────────────────────────── */
.karte {
    background: var(--karte);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    margin-bottom: 16px;
    overflow: hidden;
}
.karte.innen { padding: 14px 16px; }
.abschnitt { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--text2); margin: 20px 16px 6px; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste > li + li { border-top: .5px solid var(--linie); }
.zeile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    min-height: 48px;
    color: inherit;
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
}
.zeile .haupt { flex: 1; min-width: 0; }
.zeile .titel { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .unter { font-size: 14px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .rechts { text-align: right; flex-shrink: 0; }
.zeile .betrag { font-weight: 600; font-variant-numeric: tabular-nums; }
.zeile .pfeil { color: var(--text2); opacity: .5; }

.thumb {
    width: 52px; height: 52px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--feld);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}

.punkt { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.s-neu { background: var(--rot); }
.s-erfasst { background: var(--gelb); }
.s-kategorisiert { background: var(--akzent); }
.s-abgeglichen { background: var(--gruen); }

/* ── Chips & Filter ───────────────────────────────── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    border: 0;
    background: var(--karte);
    box-shadow: var(--schatten);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 15px;
    white-space: nowrap;
}
.chip.an { background: var(--akzent); color: #fff; }
.kat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kat-chips .chip { background: var(--feld); box-shadow: none; }
.kat-chips .chip.an { background: var(--akzent); color: #fff; }

.suche {
    width: 100%;
    border: 0;
    background: var(--karte);
    box-shadow: var(--schatten);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 17px;
    margin-bottom: 10px;
    color: var(--text);
}

.urlaub-wahl {
    border: 0;
    background: none;
    color: var(--akzent);
    font-size: 15px;
    font-weight: 500;
    padding: 4px 0;
    max-width: 100%;
}

.summe-zeile { display: flex; justify-content: space-between; color: var(--text2); font-size: 14px; margin: 0 4px 8px; }

/* ── Formulare ────────────────────────────────────── */
.feld { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 50px; }
.feld + .feld, .feld + .feld-block, .feld-block + .feld, .feld-block + .feld-block { border-top: .5px solid var(--linie); }
.feld label { width: 38%; max-width: 160px; color: var(--text2); font-size: 15px; flex-shrink: 0; }
.feld input, .feld select, .feld textarea {
    flex: 1;
    min-width: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 17px;
    color: var(--text);
    padding: 13px 0;
    text-align: right;
}
.feld select { -webkit-appearance: none; appearance: none; text-align-last: right; color: var(--akzent); }
.feld input:focus, .feld select:focus, .feld textarea:focus { outline: none; }
.feld .hinweis { font-size: 13px; color: var(--text2); }
.feld-block { padding: 12px 16px; }
.feld-block label { display: block; color: var(--text2); font-size: 15px; margin-bottom: 8px; }
.feld-block textarea {
    width: 100%; border: 0; background: var(--feld); border-radius: 10px; padding: 10px;
    font: inherit; font-size: 17px; color: var(--text); min-height: 70px; resize: vertical;
}

.gross-betrag {
    display: flex; align-items: baseline; gap: 8px; padding: 16px;
}
.gross-betrag input {
    flex: 1; min-width: 0; border: 0; background: none; font-size: 40px; font-weight: 600;
    color: var(--text); font-variant-numeric: tabular-nums; padding: 0;
}
.gross-betrag input:focus { outline: none; }
.gross-betrag input.waehrung { flex: 0 0 90px; font-size: 24px; text-transform: uppercase; text-align: right; color: var(--text2); }

.segment { display: flex; background: var(--feld); border-radius: 10px; padding: 2px; gap: 2px; flex: 1; }
.segment button {
    flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 8px; font-size: 15px;
}
.segment button.an { background: var(--karte); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }

.knopf {
    display: block; width: 100%; border: 0; border-radius: 12px; padding: 15px;
    background: var(--akzent); color: #fff; font-size: 17px; font-weight: 600; text-align: center;
}
.knopf.zwei { background: var(--karte); color: var(--akzent); box-shadow: var(--schatten); }
.knopf.rot { background: var(--karte); color: var(--rot); box-shadow: var(--schatten); }
.knopf:disabled { opacity: .5; }
.knopf + .knopf { margin-top: 10px; }
.text-knopf { border: 0; background: none; color: var(--akzent); font-size: 17px; padding: 8px 0; }

/* ── Beleg-Detail ─────────────────────────────────── */
.detail { display: grid; gap: 0 20px; grid-template-columns: minmax(0, 1fr); }
.detail > * { min-width: 0; }
@media (min-width: 820px) {
    .detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .detail .fotos-spalte { position: sticky; top: 12px; }
}
.fotos {
    display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin-bottom: 16px;
    border-radius: var(--radius);
}
.fotos .foto {
    flex: 0 0 100%; scroll-snap-align: center; background: var(--karte); border-radius: var(--radius);
    aspect-ratio: 3 / 4; overflow: hidden; display: flex; align-items: center; justify-content: center; border: 0; padding: 0;
}
.fotos .foto img { width: 100%; height: 100%; object-fit: contain; }
.fotos .foto.pdf { font-size: 48px; flex-direction: column; color: var(--text2); }
.fotos .foto.pdf span { font-size: 15px; }
.fotos .foto.leer { flex-direction: column; color: var(--text2); font-size: 15px; gap: 8px; aspect-ratio: 3 / 2; }
.fotos-leiste { display: flex; justify-content: space-between; align-items: center; margin: -8px 4px 12px; font-size: 14px; color: var(--text2); }

.eur-box { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; }
.eur-box .wert { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.eur-box .info { font-size: 13px; color: var(--text2); text-align: right; }

.position { display: grid; grid-template-columns: 1fr 110px 36px; gap: 8px; align-items: center; padding: 8px 16px; }
.position select, .position input {
    border: 0; background: var(--feld); border-radius: 8px; padding: 9px 10px; font: inherit; font-size: 16px; color: var(--text); min-width: 0;
}
.position input { text-align: right; }
.position .weg { border: 0; background: none; color: var(--rot); font-size: 22px; }
.position .eur { grid-column: 1 / -1; font-size: 13px; color: var(--text2); text-align: right; margin-top: -4px; }
.positionen-fuss { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-size: 14px; }
.positionen-fuss .fehlt { color: var(--rot); }
.positionen-fuss .passt { color: var(--gruen); }

/* ── Vollbild-Foto ────────────────────────────────── */
.vollbild {
    position: fixed; inset: 0; background: #000; z-index: 50; overflow: auto; display: flex;
    -webkit-overflow-scrolling: touch;
}
.vollbild img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.vollbild.zoom img { max-width: none; max-height: none; width: 250%; }
.vollbild .knoepfe {
    position: fixed; left: 0; right: 0; top: 0; display: flex; justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: linear-gradient(rgba(0,0,0,.6), transparent);
}
.vollbild .knoepfe button, .vollbild .knoepfe a {
    border: 0; background: rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 15px;
}

/* ── Auswertung ───────────────────────────────────── */
.kacheln { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 700px) { .kacheln { grid-template-columns: repeat(4, 1fr); } }
.kachel { background: var(--karte); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--schatten); }
.kachel .label { font-size: 13px; color: var(--text2); }
.kachel .wert { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.balken-zeile { padding: 10px 16px; }
.balken-zeile .oben { display: flex; justify-content: space-between; margin-bottom: 6px; }
.balken-zeile .oben span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.balken { height: 8px; border-radius: 4px; background: var(--feld); overflow: hidden; }
.balken div { height: 100%; background: var(--akzent); border-radius: 4px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--akzent-hell); color: var(--akzent); vertical-align: 3px; }
.badge.gelb { background: color-mix(in srgb, var(--gelb) 18%, transparent); color: var(--gelb); }

/* ── Sonstiges ────────────────────────────────────── */
.leer-hinweis { text-align: center; color: var(--text2); padding: 48px 24px; }
.leer-hinweis .gross { font-size: 48px; margin-bottom: 8px; }
.toast {
    position: fixed; left: 50%; bottom: calc(var(--leiste) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
    background: rgba(28,28,30,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px; z-index: 60;
    max-width: calc(100% - 32px); text-align: center; transition: opacity .3s;
}
.toast.fehler { background: var(--rot); }
.gespeichert { font-size: 13px; color: var(--text2); transition: opacity .4s; }
.code { font: 600 32px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-align: center; padding: 16px; user-select: all; }
.schluessel { font: 15px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; background: var(--feld); padding: 12px; border-radius: 10px; user-select: all; }
.anleitung ol { padding-left: 22px; margin: 8px 0; }
.anleitung li { margin-bottom: 8px; }
.anleitung code { background: var(--feld); padding: 1px 5px; border-radius: 5px; font-size: 15px; word-break: break-all; }
.klein { font-size: 14px; color: var(--text2); }
.login { max-width: 400px; margin: 12vh auto 0; text-align: center; }
.login .logo { width: 88px; height: 88px; border-radius: 20px; margin-bottom: 16px; }
.login input { width: 100%; border: 0; background: var(--karte); border-radius: 12px; padding: 14px; font-size: 20px; text-align: center; letter-spacing: .1em; text-transform: uppercase; margin: 12px 0 10px; color: var(--text); box-shadow: var(--schatten); }
.versteckt { display: none !important; }
.laden { text-align: center; color: var(--text2); padding: 40px; }
.fortschritt { height: 4px; background: var(--feld); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.fortschritt div { height: 100%; background: var(--akzent); width: 0; transition: width .2s; }
.knopf-raster { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.knopf-raster .knopf { margin-top: 0; }
