:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1f2328;
    --muted: #6b7280;
    --border: #d9dde3;
    --hover: #eef0f3;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #e8effd;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --success: #15803d;
    --success-soft: #e6f4ea;
    --warning: #b45309;
    --warning-soft: #fdf2e1;
    --radius: 10px;
    color-scheme: light;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

h1 {
    margin: 0 0 1rem;
    font-size: 1.6rem;
}

h1:focus {
    outline: none;
}

a {
    color: var(--primary);
}

/* ---------- Formulare ---------- */

input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
select,
textarea {
    min-width: 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: inherit;
    font: inherit;
}

textarea {
    resize: vertical;
}

    input:not([type=checkbox]):not([type=radio]):focus,
    select:focus,
    textarea:focus {
        border-color: var(--primary);
        outline: 1px solid var(--primary);
    }

input[type=checkbox] {
    width: 1.3rem;
    height: 1.3rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}

button,
.button-link {
    display: inline-block;
    padding: 0.55rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: inherit;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

    button:hover,
    .button-link:hover {
        background: var(--hover);
    }

    button.primary,
    .button-link.primary {
        border-color: var(--primary);
        background: var(--primary);
        color: #fff;
    }

        button.primary:hover,
        .button-link.primary:hover {
            background: var(--primary-hover);
        }

    button.danger {
        border-color: var(--danger);
        color: var(--danger);
    }

        button.danger:hover {
            background: var(--danger-soft);
        }

    button.small {
        padding: 0.3rem 0.7rem;
        font-size: 0.9rem;
    }

    button:disabled {
        opacity: 0.5;
        cursor: default;
    }

.icon-button {
    flex-shrink: 0;
    padding: 0.4rem 0.6rem;
    border: none;
    background: none;
    color: var(--muted);
}

    .icon-button:hover {
        background: var(--hover);
        color: var(--text);
    }

    .icon-button.danger:hover {
        background: var(--danger-soft);
        color: var(--danger);
    }

/* Formularzeile: Felder nebeneinander, am Handy umbrechend. */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

    .form-row > .grow {
        flex: 1 1 12rem;
    }

.field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-weight: 500;
}

    .field > span {
        color: var(--muted);
        font-size: 0.85rem;
    }

/* ---------- Bausteine ---------- */

.muted {
    color: var(--muted);
}

.card {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

    .page-header h1 {
        margin: 0;
    }

/* Liste aus Zeilen in einem Kasten (Einkaufsliste, Vorrat, Aufgaben, ...). */
.panel {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

    .panel > li,
    .panel > .row {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        min-height: 3.25rem;
        padding: 0.4rem 0.5rem 0.4rem 0.9rem;
        border-bottom: 1px solid var(--border);
    }

        .panel > li:last-child,
        .panel > .row:last-child {
            border-bottom: none;
        }

.group-title {
    margin: 1.25rem 0 0.4rem 0.2rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

    .group-title:first-child {
        margin-top: 0;
    }

.grow {
    flex: 1;
    min-width: 0;
}

.empty {
    padding: 2rem 1rem;
    color: var(--muted);
    text-align: center;
}

.form-error {
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger);
}

.notice {
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary-hover);
}

/* Chips: Listen-Reiter, Filter, Vorschläge. */
.chips {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.chip {
    flex-shrink: 0;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
}

    .chip:hover {
        background: var(--hover);
    }

    .chip.active {
        border-color: var(--primary);
        background: var(--primary);
        color: #fff;
    }

.badge {
    flex-shrink: 0;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--hover);
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

    .badge.success {
        background: var(--success-soft);
        color: var(--success);
    }

    .badge.warning {
        background: var(--warning-soft);
        color: var(--warning);
    }

    .badge.danger {
        background: var(--danger-soft);
        color: var(--danger);
    }

    .badge.primary {
        background: var(--primary-soft);
        color: var(--primary);
    }

/* Hinweis unten mit "Rückgängig" – sitzt am Handy über der Navigationsleiste. */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: max-content;
    max-width: calc(100% - 2rem);
    padding: 0.6rem 0.6rem 0.6rem 1rem;
    border-radius: var(--radius);
    background: #1f2328;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%);
}

    .toast button {
        border: none;
        background: none;
        color: #93b4ff;
        font-weight: 600;
    }

        .toast button:hover {
            background: rgba(255, 255, 255, 0.1);
        }

@media (max-width: 640px) {
    .toast {
        bottom: calc(5rem + env(safe-area-inset-bottom));
    }
}

/* ---------- Anmelden / Registrieren ---------- */

.auth-card {
    max-width: 380px;
    margin: 2rem auto 1rem;
}

    /* Formular mit Feldern untereinander (Anmelden, Passwort ändern). */
    .auth-card form,
    .stack-form {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        max-width: 380px;
    }

    .auth-card label,
    .stack-form label {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        font-weight: 500;
    }

    .auth-card button,
    .stack-form button {
        margin-top: 0.5rem;
    }

.auth-switch {
    margin: 1.25rem 0 0;
    color: var(--muted);
}

/* ---------- Finanzen (Haushaltsbuch, Fixkosten, Übersicht) ---------- */

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.8rem 1rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 600;
}

.stat-detail {
    color: var(--muted);
    font-size: 0.82rem;
}

/* Ausgaben nach Kategorie: ein Wert pro Zeile, eine Farbe. */
.category-bars {
    display: grid;
    grid-template-columns: max-content 1fr max-content;
    align-items: center;
    gap: 0.6rem 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

    .category-bars li {
        display: contents;
    }

    .category-bars .category-name {
        font-size: 0.92rem;
    }

    .category-bars .bar-area {
        display: block;
        min-width: 2rem;
    }

    /* Höchstens 24px dick, gerade an der Grundlinie, 4px gerundet am Wertende. */
    .category-bars .bar {
        display: block;
        min-width: 2px;
        height: 14px;
        border-radius: 0 4px 4px 0;
        background: var(--primary);
    }

    .category-bars .category-value {
        font-size: 0.92rem;
        font-variant-numeric: tabular-nums;
        text-align: right;
    }

@media (max-width: 640px) {
    .category-bars {
        gap: 0.5rem;
    }
}

/* Eine Buchung bzw. Fixkosten als Zeile in einer .panel-Liste. */
.expense-icon {
    width: 1.6rem;
    font-size: 1.15rem;
    text-align: center;
}

.expense-main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.35rem 0.25rem;
    border: none;
    background: none;
    text-align: left;
}

    button.expense-main:hover {
        background: none;
    }

        button.expense-main:hover .expense-title {
            text-decoration: underline;
        }

.expense-title {
    overflow-wrap: anywhere;
}

.expense-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

.expense-amount {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

    .expense-amount small {
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 400;
    }

/* ---------- Chat und Hinweise ---------- */

/* Der Chat füllt den Bildschirm bis zur Eingabe (siehe Chat.razor.css) – unten braucht es dafür weniger Abstand.
   "main" davor, damit es die Abstände aus MainLayout.razor.css (dort .content[b-…], später geladen) übertrifft. */
main.content:has(.chat-page) {
    padding-bottom: 1rem;
}

@media (max-width: 640px) {
    main.content:has(.chat-page) {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom));
    }
}

/* Ziel eines Hinweises (z.B. aufgaben#aufgabe-12): kurz hervorgehoben und nicht unter der Leiste oben. */
.panel > li:target {
    background: var(--primary-soft);
    scroll-margin-top: 5rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBh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I5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* Auswahl der Ziel-Einkaufsliste (Vorrat, Rezepte, Essensplan) */
.list-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

    .list-picker select {
        padding: 0.3rem 0.5rem;
    }
