/* Haushaltsbuch – mobil zuerst, folgt dem Hell/Dunkel-Modus des Geräts */
:root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --text: #17202e;
    --muted: #5d6878;
    --border: #d8dee8;
    --accent: #2f6fdf;
    --accent-text: #ffffff;
    --income: #1e8a4c;
    --expense: #c93434;
    --warn-bg: #fff4d6;
    --warn-text: #6b4e00;
    --error-bg: #fde7e7;
    --error-text: #8a1c1c;
    --radius: 14px;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1726;
        --surface: #182338;
        --text: #e8edf5;
        --muted: #9aa7ba;
        --border: #2a3953;
        --accent: #5b8ff0;
        --income: #2fae66;
        --expense: #e0534f;
        --warn-bg: #3b3218;
        --warn-text: #f3d98b;
        --error-bg: #3d1d22;
        --error-text: #ffb4b4;
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-variant-numeric: tabular-nums;
    padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.page { max-width: 560px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px 20px;
}
.narrow { max-width: 420px; margin: 0 auto; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
input {
    font: inherit; min-height: 48px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-input { font-size: 1.5rem; letter-spacing: .2em; text-align: center; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 700; padding: 0 6px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 48px; padding: 0 20px; border-radius: 12px;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; border: 0;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.link-button { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; min-height: 44px; }
.inline { margin: 0; }
.alert { background: var(--error-bg); color: var(--error-text); padding: 10px 12px; border-radius: 10px; }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.qr { background: #fff; border-radius: 12px; padding: 12px; width: 232px; margin: 14px auto; }
.qr svg { display: block; width: 100%; height: auto; }
.manual summary { cursor: pointer; color: var(--accent); }
.secret { display: block; margin-top: 8px; font-size: 1.05rem; word-break: break-all; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 20px; }
.codes li { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; }
.config-snippet { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: .85rem; }
.home { display: flex; flex-direction: column; gap: 16px; }
.greeting { font-size: 1.15rem; margin: 4px 0; color: var(--muted); }
.big-button {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    min-height: 120px; border-radius: 20px; color: #fff;
    font-size: 1.6rem; font-weight: 700; text-decoration: none;
}
.big-button .sign { font-size: 2.4rem; line-height: 1; }
.big-button.income { background: var(--income); }
.big-button.expense { background: var(--expense); }
.big-button:active { transform: scale(.98); }

/* ── Phase 3: Navigation, Meldungen ─────────────────────────────── */
.topnav { display: flex; align-items: center; gap: 14px; font-size: .92rem; }
.topnav a { color: var(--accent); text-decoration: none; }
.flash { background: var(--surface); border-left: 4px solid var(--income); padding: 10px 12px; border-radius: 8px; margin: 0 0 16px; }
.flash.error { border-left-color: var(--expense); }
.small { font-size: .85rem; }
.center { text-align: center; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
select {
    font: inherit; min-height: 48px; padding: 10px 12px; width: 100%;
    border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
}
[hidden] { display: none !important; }

/* ── Erfassen ───────────────────────────────────────────────────── */
.booking h1 { margin-bottom: 4px; }
.booking.is-income h1 { color: var(--income); }
.booking.is-expense h1 { color: var(--expense); }
.amount-wrap { display: flex; align-items: center; gap: 8px; }
.amount-wrap input { font-size: 2rem; font-weight: 700; text-align: right; flex: 1; min-width: 0; }
.currency { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile { position: relative; font-weight: 500; }
.tile input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.tile span {
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: 52px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); font-size: .9rem; line-height: 1.2; hyphens: auto; cursor: pointer;
}
.tile input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.tile input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.is-income .tile input:checked + span { background: var(--income); border-color: var(--income); }
.is-expense .tile input:checked + span { background: var(--expense); border-color: var(--expense); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-title { font-weight: 600; font-size: .95rem; }
.receipt { display: flex; flex-direction: column; gap: 10px; }
.receipt-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.file-btn { position: relative; overflow: hidden; font-size: .95rem; padding: 0 10px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.receipt-preview, .receipt-thumb { max-width: 100%; max-height: 320px; border-radius: 10px; border: 1px solid var(--border); object-fit: contain; align-self: flex-start; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.check input { min-height: 0; width: 20px; height: 20px; }
.big-submit { min-height: 56px; font-size: 1.1rem; }
.is-income .big-submit { background: var(--income); }
.is-expense .big-submit { background: var(--expense); }
.delete-form { margin-top: 28px; }
.btn.danger-outline { background: transparent; color: var(--expense); border: 1px solid var(--expense); width: 100%; }
.back-link { display: inline-block; margin-top: 18px; color: var(--accent); text-decoration: none; }

/* ── Monatsliste ────────────────────────────────────────────────── */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav h1 { margin: 0; }
.month-nav a { font-size: 2rem; line-height: 1; text-decoration: none; color: var(--accent); padding: 4px 14px; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.totals div { display: flex; flex-direction: column; align-items: center; }
.pos { color: var(--income); }
.neg { color: var(--expense); }
.day { font-size: .9rem; color: var(--muted); margin: 20px 0 6px; font-weight: 600; }
.entries { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.entries li + li { border-top: 1px solid var(--border); }
.entry { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; color: var(--text); text-decoration: none; }
.entry-main { display: flex; flex-direction: column; min-width: 0; }
.entry-desc { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta { font-size: .8rem; color: var(--muted); }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.amount { font-weight: 700; white-space: nowrap; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.open { background: var(--warn-bg); color: var(--warn-text); }
.badge.sent { background: color-mix(in srgb, var(--income) 18%, transparent); color: var(--income); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.month .btn { margin-top: 20px; width: 100%; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* ── Einstellungen ──────────────────────────────────────────────── */
.settings { display: flex; flex-direction: column; gap: 16px; }
.list-block { border-top: 1px solid var(--border); padding: 10px 0; }
.list-block summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; gap: 6px; }
.list-items { list-style: none; padding: 0; margin: 8px 0; }
.list-items li { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; }
.list-items li.inactive span { color: var(--muted); text-decoration: line-through; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; }

/* ── Logo ───────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { display: block; }
.login-logo { display: block; margin: 8px auto 18px; width: 128px; height: 128px; }
/* Schmale Handys: nur das Logo als Link zur Startseite, damit die Navigation in eine Zeile passt */
@media (max-width: 480px) {
    .brand-text { display: none; }
    .topnav { gap: 12px; }
}
