/* NK-Rechner Styles */
:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #e1e4e8;
    --text: #1a1d23;
    --muted: #6a7383;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
    --accent: #eef2ff;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}

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

h1, h2, h3 { color: var(--text); margin-top: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.topbar .wrap {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding-top: .75rem;
    padding-bottom: .75rem;
    flex-wrap: wrap;
}
.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.topbar nav {
    display: flex;
    gap: 1rem;
    flex: 1;
    flex-wrap: wrap;
}
.topbar nav a {
    color: var(--muted);
    padding: .25rem .5rem;
    border-radius: var(--radius);
    font-weight: 500;
}
.topbar nav a:hover, .topbar nav a.active {
    background: var(--accent);
    color: var(--primary);
    text-decoration: none;
}
.user { display: flex; align-items: center; gap: .75rem; }

.content { padding: 2rem 1.5rem; min-height: 70vh; }
footer.wrap { padding: 2rem 1.5rem; text-align: center; }

/* Auth-Seiten */
body.auth {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
body.auth .card {
    background: var(--card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 420px;
    width: 100%;
}

/* Forms */
form label { display: block; margin-bottom: 1rem; font-weight: 500; }
form input[type=text], form input[type=password], form input[type=email],
form input[type=number], form input[type=date], form select, form textarea {
    display: block;
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    margin-top: .25rem;
    font-weight: 400;
}
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
form textarea { resize: vertical; min-height: 70px; }

.form-card {
    background: var(--card);
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 600px) {
    .grid2 { grid-template-columns: 1fr; }
}

/* Buttons */
.btn {
    display: inline-block;
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
}
.btn:hover { background: var(--accent); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn.primary:hover { background: var(--primary-hover); color: #fff; border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fee; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.big { padding: .75rem 1.5rem; font-size: 1rem; }

/* Alerts */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert.error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.warn    { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px; }

/* Tabellen */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 1rem 0;
}
table.data th, table.data td {
    padding: .65rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data thead th {
    background: #f9fafb;
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbff; }
table.data tfoot th { background: #f9fafb; font-weight: 700; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions .btn { margin-left: .25rem; }
table.data input, table.data select {
    margin: 0;
    padding: .35rem .5rem;
    width: 100%;
}
table.data input.num { text-align: right; }

.head-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.row {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Dashboard KPIs */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.kpi {
    display: block;
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    color: var(--text);
}
.kpi:hover { border-color: var(--primary); text-decoration: none; }
.kpi-value { font-size: 2.5rem; font-weight: 700; color: var(--primary); }
.kpi-label { color: var(--muted); margin-top: .25rem; }

/* Abrechnung Form */
.kosten-actions {
    display: flex;
    gap: .5rem;
    margin: .5rem 0 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.kosten-actions select { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); }
details summary { cursor: pointer; }
.vorlagen {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .75rem;
    background: var(--accent);
    border-radius: var(--radius);
    margin-top: .5rem;
}

.mieter-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    background: #fcfcfd;
}
.mieter-block legend {
    padding: 0 .5rem;
    font-size: .95rem;
    background: var(--accent);
    border-radius: var(--radius);
    line-height: 1.6;
}
.verbrauch-block {
    margin-top: .75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .75rem;
}
.verbrauch-block:empty { display: none; }
.verbrauch-input {
    background: #fff;
    border: 1px dashed var(--border);
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: .85rem;
    margin: 0;
}

.vz-block {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0 1rem;
    align-items: end;
    padding: .75rem 1rem;
    background: #f9fafb;
    border-radius: var(--radius);
    margin-top: .75rem;
}
.vz-block label { margin-bottom: 0; }
.vz-block .vz-gesamt {
    font-size: 1.05rem;
    padding-bottom: .55rem;
    white-space: nowrap;
}
.vz-block .vz-gesamt .small { display: block; }
@media (max-width: 600px) {
    .vz-block { grid-template-columns: 1fr; }
}

.plausi {
    margin: .75rem 0 1rem;
    padding: .65rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    border: 1px solid transparent;
}
.plausi.ok    { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.plausi.warn  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.plausi.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.plausi:empty { display: none; }

/* Saldo-Spalten */
.saldo-nach { color: var(--danger); }
.saldo-gut { color: var(--success); }

/* Section Cards */
.card-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}
.card-section > h2:first-child { margin-top: 0; }
.card-section details { margin: .5rem 0; padding: .25rem 0; }
.card-section details summary { padding: .5rem 0; }
.card-section table.data { box-shadow: none; }

/* Print page (Anschreiben) */
.print-page { background: #e5e7eb; padding: 2rem 1rem; }
.toolbar {
    max-width: 800px;
    margin: 0 auto 1rem;
    padding: .75rem;
    background: #fff;
    border-radius: var(--radius);
    display: flex;
    gap: .75rem;
    align-items: center;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.letter {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 2.5cm 2cm 2cm 2.5cm;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    font-family: "Times New Roman", Times, serif;
    font-size: 11pt;
    color: #000;
    line-height: 1.5;
}
.letter h1.letter-title { font-size: 14pt; margin: 1.5em 0 .5em; }
.letter h2 { font-size: 12pt; margin-top: 1.2em; }
.letter p { margin: .8em 0; }

.absender-zeile {
    border-bottom: 1px solid #999;
    font-size: 8pt;
    padding-bottom: 2px;
    margin-bottom: 1.5cm;
    color: #555;
}
.adressen { display: flex; justify-content: space-between; gap: 2rem; }
.empfaenger { width: 60mm; line-height: 1.4; }
.absender-rechts { text-align: right; font-size: 9.5pt; }
.letter-meta {
    background: #f3f4f6;
    padding: .8em 1em;
    border-left: 3px solid var(--primary);
    font-size: 10pt;
}
.signatur { margin-top: 2.5em; }

table.abrechnungstabelle, table.saldo-tabelle {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 10pt;
}
table.abrechnungstabelle th, table.abrechnungstabelle td,
table.saldo-tabelle th, table.saldo-tabelle td {
    padding: .5em .6em;
    border: 1px solid #999;
    text-align: left;
    vertical-align: top;
}
table.abrechnungstabelle thead th { background: #f3f4f6; font-weight: 700; }
table.abrechnungstabelle tfoot th { background: #f3f4f6; font-weight: 700; }
table.abrechnungstabelle .right, table.saldo-tabelle .right { text-align: right; white-space: nowrap; }
table.saldo-tabelle .nachzahlung { background: #fef2f2; color: #991b1b; }
table.saldo-tabelle .nachzahlung th { font-size: 12pt; }
table.saldo-tabelle .guthaben { background: #f0fdf4; color: #166534; }
table.saldo-tabelle .guthaben th { font-size: 12pt; }

.bankverbindung {
    background: #f9fafb;
    padding: .8em 1em;
    border-left: 3px solid var(--primary);
    font-size: 10pt;
}
.footer-info { margin-top: 2.5em; font-size: 9pt; }
.footer-info hr { border: 0; border-top: 1px solid #ccc; margin: 1em 0; }
