:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --ink: #1f2733;
    --muted: #7a8699;
    --line: #e3e8ef;
    --brand: #3b6ea5;
    --brand-dark: #2c527c;
    --pos: #1f8a4c;
    --neg: #c0392b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(20,30,50,.08), 0 4px 16px rgba(20,30,50,.05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

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

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    background: var(--brand);
    color: #fff;
    padding: .6rem 1rem;
}
.topbar a { color: #fff; }
.brand a { font-weight: 700; font-size: 1.1rem; }
.brand .who { opacity: .8; font-weight: 400; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.mainnav a {
    padding: .35rem .7rem;
    border-radius: 8px;
    font-size: .95rem;
}
.mainnav a:hover { background: rgba(255,255,255,.15); text-decoration: none; }
.mainnav a.active { background: var(--brand-dark); }
.userbox { display: flex; align-items: center; gap: .75rem; font-size: .85rem; }
.userbox .switcher select {
    border-radius: 6px; border: 0; padding: .2rem .4rem; font-size: .85rem;
}
.userbox .loginname { opacity: .85; }
.userbox .logout { text-decoration: underline; }

/* ---------- Content ---------- */
.content { max-width: 980px; margin: 1.5rem auto; padding: 0 1rem 3rem; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.2rem;
}

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .3rem;
}
.card:hover { text-decoration: none; border-color: var(--brand); }
.card-label { font-size: .85rem; color: var(--muted); }
.card-value { font-size: 1.5rem; font-weight: 700; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* ---------- Amounts ---------- */
.amount.pos, .card-value.pos, .saldo-big.pos { color: var(--pos); }
.amount.neg, .card-value.neg, .saldo-big.neg strong { color: var(--neg); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.saldo-big {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem 1.2rem; font-size: 1.2rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}

/* ---------- Forms ---------- */
label { display: block; font-size: .9rem; margin-bottom: .2rem; }
input, select, textarea, button {
    font: inherit; padding: .5rem .6rem; border: 1px solid var(--line);
    border-radius: 8px; background: #fff; color: var(--ink); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
button {
    background: var(--brand); color: #fff; border: 0; cursor: pointer; font-weight: 600; padding: .55rem 1.1rem;
}
button:hover { background: var(--brand-dark); }

.rowform { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.rowform input[type=text] { flex: 1 1 200px; }
.gridform { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; align-items: end; }
.gridform .wide { grid-column: 1 / -1; }
.gridform label { margin: 0; }
.gridform input, .gridform select, .gridform textarea { width: 100%; }
.gridform button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 640px) { .gridform { grid-template-columns: 1fr 1fr; } }

.inline { display: inline; }
.link-danger {
    background: none; color: var(--neg); border: 0; padding: 0 .2rem; cursor: pointer; font-weight: 600;
}
.link-danger:hover { text-decoration: underline; background: none; }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table.konto { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.konto th, table.konto td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
table.konto th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
table.konto td.r, table.konto th.r { text-align: right; white-space: nowrap; }

/* ---------- Gallery ---------- */
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; }
.thumb img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.galitem { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.galitem img { width: 100%; height: 160px; object-fit: cover; display: block; }
.galitem figcaption { padding: .4rem .6rem; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

/* ---------- Termine ---------- */
.termine { list-style: none; margin: 0; padding: 0; }
.termine li { display: grid; grid-template-columns: 210px 1fr auto; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); align-items: start; }
.termine li:last-child { border-bottom: 0; }
.termine .termin-when { font-weight: 600; color: var(--brand-dark); }
.termine.past { opacity: .7; }
@media (max-width: 640px) { .termine li { grid-template-columns: 1fr; gap: .2rem; } }

/* ---------- Master quicklinks ---------- */
.quicklinks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-top: 1rem; }
.ql-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.ql-card h3 { margin: 0 0 .4rem; font-size: 1rem; }
.ql-card a { margin-right: .6rem; font-size: .9rem; }

/* ---------- Flash ---------- */
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .95rem; }
.flash-success { background: #e6f6ec; color: #1f6b3b; border: 1px solid #b7e4c7; }
.flash-error { background: #fdecea; color: #a4271b; border: 1px solid #f5c6c0; }
.flash-info { background: #eef3fb; color: #2c527c; border: 1px solid #c9dcf3; }

/* ---------- Login ---------- */
.loginpage { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--brand); }
.loginbox { background: #fff; border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.loginbox.wide-box { max-width: 480px; }
.loginbox h1 { margin: 0 0 .3rem; }
.loginbox .sub { color: var(--muted); margin: 0 0 1.2rem; }
.loginbox label { margin: 0 0 .9rem; }
.loginbox input { width: 100%; }
.loginbox button { width: 100%; margin-top: .4rem; }
.loginbox hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- Footer ---------- */
.pagefoot { text-align: center; color: var(--muted); padding: 2rem 0; }
