/* Haushaltskasse – Fabio & Jana */
:root {
    --accent: #2a4bd7;          /* Royalblau */
    --accent-dark: #1d36a8;
    --accent-soft: #e9eefc;
    --fabio: #2a4bd7;
    --jana: #c2407a;
    --bg: #f5f7fc;
    --card: #ffffff;
    --text: #1c2233;
    --muted: #6b7388;
    --border: #e1e6f2;
    --success: #1f9d6b;
    --success-soft: #e6f6ef;
    --danger: #d64545;
    --danger-soft: #fdeaea;
    --warning-soft: #fff6e0;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 4px 16px rgba(20, 30, 60, 0.06);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h2 { font-size: 1.15rem; margin: 0 0 1rem; font-weight: 650; letter-spacing: -0.01em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(760px, 100% - 2rem); margin-inline: auto; }

main.container { padding-block: 1.5rem 3rem; display: grid; gap: 1.25rem; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.muted { color: var(--muted); }
.count { font-size: 0.9rem; margin: 0 0 0.75rem; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; }
.back { font-size: 0.95rem; }

/* Topbar */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.brand { font-weight: 750; color: var(--text); font-size: 1.1rem; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card-narrow { max-width: 420px; margin: 3rem auto 0; width: 100%; }

/* Dashboard */
.dashboard { background: linear-gradient(180deg, #ffffff, #f8faff); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.stat {
    background: var(--accent-soft);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    display: flex; flex-direction: column; gap: 0.2rem;
}
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value small, .entry-amount small { font-size: 0.7em; font-weight: 500; color: var(--muted); }

.saldo {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
    border-radius: 12px; padding: 0.9rem 1rem; font-weight: 600;
}
.saldo-open { background: var(--warning-soft); color: #7a5300; }
.saldo-even { background: var(--success-soft); color: #14704c; }
.saldo-value { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.saldo-value small { font-size: 0.7em; font-weight: 500; }

/* Forms */
.form-grid, .filter-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.field-wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field label, .field legend { font-size: 0.85rem; font-weight: 600; color: var(--muted); padding: 0; }

input[type="text"], input[type="search"], input[type="date"],
input[type="number"], input[type="password"], select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid #cfd6e6;
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    min-height: 44px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, .btn:focus-visible, .entry:focus-visible, .suggestions li:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(42, 75, 215, 0.2);
}
.btn:focus-visible, .entry:focus-visible { outline: 3px solid rgba(42, 75, 215, 0.35); outline-offset: 2px; }

fieldset.field { border: 0; margin: 0; padding: 0; }

.choice { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
.choice legend { margin-bottom: 0.35rem; width: 100%; }
.choice-option {
    flex: 1 1 220px;
    display: flex; align-items: center; gap: 0.6rem;
    border: 1px solid #cfd6e6; border-radius: 10px;
    padding: 0.6rem 0.75rem; cursor: pointer; min-height: 44px;
    font-weight: 500;
}
.choice-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-option input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.choice-option small { color: var(--muted); }

/* Autocomplete */
.autocomplete { position: relative; }
.suggestions {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
    margin: 0; padding: 0.3rem; list-style: none;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(20, 30, 60, 0.15);
    max-height: 260px; overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestions li {
    padding: 0.6rem 0.75rem; border-radius: 8px; cursor: pointer; min-height: 40px;
    display: flex; align-items: center;
}
.suggestions li:hover, .suggestions li.active { background: var(--accent-soft); color: var(--accent-dark); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 600; font-size: 0.95rem;
    min-height: 44px; padding: 0.6rem 1.1rem;
    border-radius: 10px; border: 1px solid transparent; cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn-small { min-height: 38px; padding: 0.45rem 0.9rem; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-dark); }
.btn-secondary:hover { background: #d9e2fb; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.form-actions { margin-top: 1.25rem; display: flex; justify-content: flex-end; gap: 0.5rem; }
.form-actions-split { justify-content: space-between; flex-wrap: wrap; }

/* Filter */
.filter { display: grid; gap: 1rem; }
.filter-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; }
.filter-buttons { display: flex; gap: 0.5rem; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; cursor: pointer; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* Entries */
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.entry {
    display: grid;
    grid-template-columns: 5.5rem 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.entry:hover { border-color: #b9c6ee; box-shadow: 0 4px 14px rgba(42, 75, 215, 0.1); text-decoration: none; transform: translateY(-1px); }
.entry-date { font-size: 0.88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-main { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.entry-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.entry-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
    display: inline-block; font-size: 0.75rem; font-weight: 600;
    padding: 0.15rem 0.55rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent-dark);
}
.badge-fabio { background: #e6ecfc; color: var(--fabio); }
.badge-jana { background: #fbe7f0; color: var(--jana); }
.badge-ausgleich { background: var(--success-soft); color: #14704c; }

/* Alerts */
.alert { border-radius: 10px; padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.95rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert-success { background: var(--success-soft); color: #14704c; }
.alert-error { background: var(--danger-soft); color: #a12d2d; }

/* Login */
.login form { display: grid; gap: 1rem; }

/* Footer */
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.5rem 0 2rem; }

/* Mobile */
@media (max-width: 560px) {
    .stats, .form-grid, .filter-grid { grid-template-columns: 1fr; }
    .card { padding: 1rem; }
    .entry { grid-template-columns: 1fr auto; }
    .entry-date { grid-column: 1 / -1; order: -1; }
    .filter-actions { flex-direction: column; align-items: stretch; }
    .filter-buttons { justify-content: flex-end; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn, .form-actions-split .btn { width: 100%; }
    .form-actions-split { flex-direction: column-reverse; }
}

/* Reduzierte Bewegung */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Kopfzeile der Einträge-Karte */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.list-head h2 { margin: 0; }

/* Auswahlfelder Art: eigener Innenabstand, nicht vom allgemeinen Label-Stil überschrieben */
.field .choice-option {
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
}
