/* ══════════════════════════════════════════════
   Betriebskostenabrechnung – App Styles
   ══════════════════════════════════════════════ */

:root {
    --primary: #1a3c5e;
    --primary-light: #2e7d9b;
    --primary-xlight: #e8f4f8;
    --accent: #2e7d9b;
    --success: #198754;
    --success-light: #d4edda;
    --warning: #ffc107;
    --warning-light: #fff3cd;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --info: #0dcaf0;
    --text: #212529;
    --text-muted: #6c757d;
    --bg: #f0f4f8;
    --surface: #ffffff;
    --border: #dee2e6;
    --border-light: #f1f3f5;
    --sidebar-width: 240px;
    --header-height: 64px;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0,0,0,0.2);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.15);
}
.brand-icon { font-size: 28px; }
.brand-title { font-size: 14px; font-weight: 700; display: block; }
.brand-sub { font-size: 11px; opacity: 0.7; display: block; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    text-decoration: none; color: rgba(255,255,255,0.8);
    font-size: 13px; transition: all 0.15s;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.12); color: white; }
.nav-item.active { background: rgba(255,255,255,0.2); color: white; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-divider { border-top: 1px solid rgba(255,255,255,0.1); margin: 8px 0; }

.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 10px; opacity: 0.6; text-align: center;
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.top-header {
    background: var(--surface);
    height: var(--header-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.top-header h1 { font-size: 20px; font-weight: 600; color: var(--primary); }
.legal-badge {
    background: var(--primary-xlight); color: var(--primary-light);
    font-size: 11px; font-weight: 600; padding: 4px 10px;
    border-radius: 20px; border: 1px solid var(--primary-light);
}
.page-content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--primary); }

/* ── Dashboard Stats ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
.stat-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-light);
    transition: transform 0.1s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.success { border-left-color: var(--success); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.warning .stat-value { color: #856404; }
.stat-card.danger { border-left-color: var(--danger); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: var(--primary); color: white;
    padding: 11px 14px; text-align: left; font-weight: 600;
    font-size: 12px; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-light); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--primary-xlight); }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:nth-child(even):hover { background: var(--primary-xlight); }
td { padding: 10px 14px; vertical-align: middle; }
.td-right { text-align: right; font-variant-numeric: tabular-nums; }
.td-center { text-align: center; }
.td-mono { font-family: 'SF Mono', monospace; font-size: 12px; }

/* ── Badges ── */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #856404; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-xlight); color: var(--primary-light); }
.badge-secondary { background: #f1f3f5; color: var(--text-muted); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 7px; border: none;
    cursor: pointer; font-size: 13px; font-weight: 500;
    transition: all 0.15s; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(0.9); }
.btn-warning { background: var(--warning); color: #212529; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-icon {
    background: none; border: none; cursor: pointer; padding: 6px;
    border-radius: 6px; font-size: 16px;
}
.btn-icon:hover { background: var(--bg); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
input, select, textarea {
    padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 7px;
    font-size: 13px; color: var(--text); background: white;
    transition: border-color 0.15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,125,155,0.1);
}
input.error { border-color: var(--danger); }
.field-error { font-size: 11px; color: var(--danger); }
textarea { resize: vertical; min-height: 80px; }

/* ── Alerts ── */
.alert {
    padding: 12px 16px; border-radius: 8px; font-size: 13px;
    display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.alert-warning { background: var(--warning-light); color: #856404; border-left: 4px solid var(--warning); }
.alert-danger { background: var(--danger-light); color: #842029; border-left: 4px solid var(--danger); }
.alert-success { background: var(--success-light); color: #155724; border-left: 4px solid var(--success); }
.alert-info { background: var(--primary-xlight); color: var(--primary); border-left: 4px solid var(--primary-light); }

/* ── Result Box ── */
.result-box {
    padding: 20px 24px; border-radius: var(--radius);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 16px; font-weight: 700;
}
.result-box.positive { background: var(--success-light); color: var(--success); border: 1.5px solid #b8ddc7; }
.result-box.negative { background: var(--danger-light); color: var(--danger); border: 1.5px solid #f1aeb5; }

/* ── Modal ── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: white; border-radius: 14px; width: 90%; max-width: 640px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--primary); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; }

/* ── Toast ── */
#toast-container {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 10px; z-index: 9999;
}
.toast {
    padding: 13px 18px; border-radius: 9px; font-size: 13px;
    font-weight: 500; max-width: 360px; box-shadow: var(--shadow-md);
    animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { transform: translateX(80px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { background: #1a5c2e; color: white; }
.toast-error { background: #7c1d2a; color: white; }
.toast-warning { background: #856404; color: white; }
.toast-info { background: var(--primary); color: white; }

/* ── Misc ── */
.section-title { font-size: 17px; font-weight: 700; color: var(--primary); margin-bottom: 16px; }
.muted { color: var(--text-muted); }
.eur { font-variant-numeric: tabular-nums; font-weight: 600; }
.positive-amount { color: var(--success); font-weight: 700; }
.negative-amount { color: var(--danger); font-weight: 700; }
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--primary); margin-bottom: 8px; }

.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--primary); }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.filter-bar {
    display: flex; gap: 12px; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
    padding: 7px 11px; font-size: 13px;
    border-radius: 7px; border: 1.5px solid var(--border);
}
.filter-bar input { min-width: 200px; }

.ampel-row { display: flex; align-items: center; gap: 8px; }
.ampel-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.ampel-red { background: var(--danger); }
.ampel-yellow { background: var(--warning); }
.ampel-green { background: var(--success); }

.legal-note {
    background: #fffdf0; border: 1px solid #f0d97c;
    border-radius: 8px; padding: 12px 16px; font-size: 12px;
    color: #6b5a00; margin-top: 12px;
}
.legal-note strong { color: #856404; }

.summary-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.summary-item {
    background: var(--bg); border-radius: 8px; padding: 12px 16px;
    flex: 1; min-width: 140px;
}
.summary-item label { font-size: 11px; display: block; margin-bottom: 4px; }
.summary-item span { font-size: 18px; font-weight: 700; color: var(--primary); }

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .brand-text, .nav-item span:not(.nav-icon) { display: none; }
    .main-content { margin-left: 60px; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Fehlende Unterlagen (Soll-Ist, Spec 2026-10-28 § 7) ── */
.doc-group {
    border: 1px solid var(--border-light); border-radius: 8px;
    background: #fafbfc; padding: 10px 14px; margin-bottom: 12px;
}
.doc-group-title {
    font-size: 13px; font-weight: 600; color: var(--primary);
    margin-bottom: 4px;
}
.doc-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 4px; min-height: 44px;
    border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}
.doc-row:last-child { border-bottom: none; }
.doc-row-label { flex: 1 1 auto; font-size: 13px; min-width: 150px; }
.doc-row-side { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.doc-badge-fehlt { background: #ffe4cc; color: #c25e0e; }   /* orange */
.doc-badge-paperless { background: #d4f4fa; color: #0b85a6; } /* cyan */
.doc-badge-vorhanden { background: var(--success-light); color: var(--success); }
.badge.doc-badge-paperless.doc-badge-link {
    color: #0b85a6; text-decoration: none; font-weight: 600;
}
.badge.doc-badge-paperless.doc-badge-link:hover { background: #b3ecf7; }
.doc-upload-btn { min-height: 44px; }
.doc-type-select { min-height: 38px; }
.doc-summary {
    font-size: 12px; font-weight: 600; color: #c25e0e;
    margin-bottom: 10px;
}
.doc-summary.doc-summary-ok { color: var(--success); }
.doc-filter { display: flex; gap: 6px; }
.doc-filter-btn {
    padding: 8px 14px; min-height: 44px;
    border: 1.5px solid var(--border); border-radius: 7px;
    background: var(--surface); color: var(--text);
    font-size: 12px; font-weight: 500; cursor: pointer;
    transition: all 0.15s;
}
.doc-filter-btn:hover { background: var(--bg); }
.doc-filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Mobile-first: Zeilen stapeln, Status als Zeilenteil, Touch >= 44px */
@media (max-width: 699px) {
    .doc-group { padding: 8px 10px; }
    .doc-row { flex-direction: column; align-items: stretch; gap: 6px; }
    .doc-row-label { min-width: 0; flex: none; }
    .doc-row-side { margin-left: 0; }
    .doc-row-side .btn, .doc-filter-btn { min-height: 44px; }
    .doc-row-side .doc-upload-btn { flex: 1 1 auto; justify-content: center; }
    .doc-type-select { min-height: 44px; font-size: 12px; }
    .doc-filter { width: 100%; }
    .doc-filter-btn { flex: 1 1 auto; }
}

/* ── Energieverwaltung (2026-10-28) ─────────────────────────── */
.doc-row-label .badge { margin-right: 8px; }
.doc-row[role="button"] { cursor: pointer; }
.doc-row[role="button"]:hover { background: #f4f7f9; }
.doc-row[role="button"]:focus-visible { outline: 2px solid var(--accent); background: #eef5f8; }
#energy-dashboard-card .doc-row { min-height: 40px; }
@media (max-width: 699px) {
    .doc-row[role="button"] { flex-direction: column; align-items: stretch; }
}
