/* Liquiditätsplaner – mobile-first, dark. */

:root {
    --bg: #12130f;
    --surface: #1c1e18;
    --surface-2: #26291f;
    --border: #343829;
    --text: #f0f1e8;
    --text-dim: #a7ac96;
    --accent: #4caf88;
    --accent-strong: #1f6f54;
    --danger: #e2685f;
    --danger-dim: #7a3430;
    --income: #6fcf97;
    --radius: 14px;
    --nav-h: 64px;
    --pad: clamp(0.9rem, 4vw, 1.4rem);
    font-size: clamp(15px, 2.5vw, 17px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;               /* nie horizontal scrollen */
}

body {
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

h1, h2, h3 { margin: 0; font-weight: 650; }
button { font: inherit; cursor: pointer; }

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: calc(env(safe-area-inset-top) + 0.7rem) var(--pad) 0.7rem;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: clamp(1.25rem, 5vw, 1.6rem); }
#logout {
    background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
    width: 2.2rem; height: 2.2rem; border-radius: 50%; font-size: 1.05rem; line-height: 1;
    flex: none;
}
#logout:active { background: var(--surface-2); }

/* Login-Overlay */
#login-overlay {
    position: fixed; inset: 0; z-index: 40;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: var(--pad);
}
#login-form {
    width: 100%; max-width: 340px;
    display: flex; flex-direction: column; gap: 0.9rem;
}
.login-brand {
    font-size: clamp(1.4rem, 7vw, 1.9rem); font-weight: 700; text-align: center;
    margin-bottom: 0.6rem; color: var(--text);
}
#login-form .btn-primary { margin-top: 0.4rem; padding: 0.8rem; }

/* Main / Views */
main { padding: var(--pad); display: block; }
.view { display: flex; flex-direction: column; gap: 0.9rem; }
[hidden] { display: none !important; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
}
.card-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 0.6rem; }

/* Hero (grosse Zahl) */
.hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem 1rem;
    text-align: center;
}
.hero.small { padding: 1rem; }
.hero-label { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.hero-value {
    font-size: clamp(1.9rem, 9vw, 2.7rem);
    font-weight: 750;
    margin-top: 0.25rem;
    line-height: 1.1;
    overflow-wrap: anywhere;          /* riesige Beträge umbrechen statt überlaufen */
}
.hero.small .hero-value { font-size: clamp(1.5rem, 7vw, 2rem); }

/* Stat-Zeilen (Übersicht) */
.stat-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-row.total { margin-top: 0.15rem; border-top: 1px solid var(--border); padding-top: 0.7rem; font-weight: 650; }
.stat-label { color: var(--text-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-val { font-weight: 700; white-space: nowrap; flex: none; }

.pos { color: var(--income); }
.neg { color: var(--danger); }

/* Konten-Auswahl in der Übersicht */
.select-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 0;
    text-align: left;
}
.select-row:last-child { border-bottom: none; }
.select-row .check {
    flex: none;
    width: 1.5rem; height: 1.5rem; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; color: var(--accent);
}
.select-row.on .check { border-color: var(--accent-strong); background: color-mix(in srgb, var(--accent-strong) 30%, var(--surface-2)); }
.select-row .sel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-row:not(.on) .sel-name, .select-row:not(.on) .sel-saldo { opacity: 0.5; }
.select-row .sel-saldo { flex: none; white-space: nowrap; font-weight: 650; }

/* Listen (Debitoren/Kreditoren) */
.list { display: flex; flex-direction: column; }
.list-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.1rem; }
.list-item .li-amount { font-weight: 700; white-space: nowrap; flex: none; }
.li-del { background: none; border: none; color: var(--danger); font-size: 1.1rem; padding: 0.2rem 0.35rem; flex: none; }

.pill { display: inline-block; font-size: 0.68rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); vertical-align: middle; }
.tag-over { color: var(--danger); font-weight: 600; }

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

/* Konten-Zeilen (editierbar) */
.acc-row { padding: 0.75rem 0; border-bottom: 1px solid var(--border); transition: background 0.3s; }
.acc-row:last-child { border-bottom: none; }
.acc-row.saved { background: color-mix(in srgb, var(--accent-strong) 22%, transparent); border-radius: 8px; }
.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.acc-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-edit { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.acc-prefix { color: var(--text-dim); font-size: 0.85rem; flex: none; }
.acc-saldo { flex: 1; min-width: 0; }
.btn-save { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 0.5rem 0.8rem; flex: none; }
.btn-save:active { background: var(--accent-strong); color: #fff; }

/* Formulare */
.stack-form { display: flex; flex-direction: column; gap: 0.6rem; }
.form-row { display: flex; gap: 0.6rem; }
.form-row > * { flex: 1; min-width: 0; }

input, select {
    width: 100%;
    padding: 0.65rem 0.7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent-strong); outline-offset: 1px; }

.btn-primary { background: var(--accent-strong); color: #fff; border: none; border-radius: 10px; padding: 0.7rem 1.1rem; font-weight: 600; }
.btn-primary:active { background: var(--accent); }
.form-error { color: var(--danger); font-size: 0.85rem; margin: 0.1rem 0; }

/* Bottom nav */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
}
.bottom-nav button {
    background: none; border: none; color: var(--text-dim);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 0.68rem;
    min-width: 0;
}
.bottom-nav button span { font-size: 1.15rem; line-height: 1; }
.bottom-nav button.active { color: var(--accent); }

/* Offline banner */
#offline-banner {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 0.6rem);
    background: var(--danger-dim); color: #fff; z-index: 25;
    padding: 0.4rem 0.9rem; border-radius: 999px; font-size: 0.8rem;
    max-width: 90vw; text-align: center;
}

@media (min-width: 640px) {
    main { max-width: 680px; margin: 0 auto; }
    .topbar, .bottom-nav { max-width: 680px; margin-left: auto; margin-right: auto; }
}
