:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 700;
}

.sidebar-header small {
    color: #64748b;
    font-size: 11px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #94a3b8;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    font-size: 13px;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: #334155;
    color: #f1f5f9;
}

.sidebar nav a .icon { font-size: 16px; }

/* Main content */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    max-width: calc(100vw - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 { font-size: 18px; font-weight: 600; }

.content {
    padding: 24px;
    flex: 1;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }
.stat-value.blue { color: var(--primary); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Table */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 12px;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-neutral  { background: #dbeafe; color: #1e40af; }
.badge-incoming       { background: #dbeafe; color: #1e40af; }
.badge-outgoing       { background: #f3e8ff; color: #6b21a8; }
.badge-refund_income  { background: #d1fae5; color: #065f46; }
.badge-refund_expense { background: #fed7aa; color: #92400e; }
.badge-free           { background: #f1f5f9; color: #334155; }
.badge-email          { background: #e0f2fe; color: #075985; }
.badge-csv            { background: #ecfdf5; color: #065f46; }
.badge-manual         { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn-primary   { background: var(--primary); color: white; }
.btn-success   { background: var(--success); color: white; }
.btn-danger    { background: var(--danger); color: white; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-sm        { padding: 4px 10px; font-size: 12px; }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

/* Erklaerung und Wirkzeitpunkt unter einem Einstellungsfeld. Der
   Wirkzeitpunkt steht bewusst an jedem Feld: dieselbe Aenderung greift im Web
   sofort und im Chat erst nach einem Neustart des Buchhalter-Dienstes. */
.form-group .hinweis,
.form-group .wirkt {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.form-group .wirkt {
    font-style: italic;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--text);
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* Alerts / Flash */

.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}

.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.filter-bar select, .filter-bar input {
    width: auto;
    min-width: 120px;
}

/* Spalten-Filterzeile im Tabellenkopf (Buchungen, Bankbuchungen, Belege) */
.filter-row td {
    padding: 4px 6px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
}
.filter-row input, .filter-row select {
    width: 100%;
    min-width: 0;          /* darf unter die intrinsische Input-Breite schrumpfen */
    box-sizing: border-box;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
}
/* Anzahl-Auswahl + Filter-Buttons in der Aktionsspalte nicht auf 100% strecken */
.filter-row td:last-child select,
.filter-row td:last-child { width: auto; min-width: 0; white-space: nowrap; }
.filter-row td:last-child select { display: inline-block; width: auto; }

/* Amount */
.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }

/* Responsive */
@media (max-width: 900px) {
    .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 100%; position: relative; height: auto; }
    .main { margin-left: 0; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; gap: 8px; }
    .topbar h1 { font-size: 15px; }
    .content { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card { padding: 14px; }
    table { font-size: 12px; }
    th, td { padding: 7px 8px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select, .filter-bar input { width: 100%; }
}

/* Anmeldeseite */
.anmelden-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.anmelden-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    width: 320px;
}

.anmelden-box h1 {
    margin-bottom: 16px;
    font-size: 20px;
}

.anmelden-box form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.anmelden-box label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

.anmelden-box input {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}

.anmelden-box button {
    margin-top: 16px;
    padding: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.anmelden-box button:hover {
    background: var(--primary-dark);
}

/* Sidebar-Fuss (Abmelden) */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #cbd5e1;
    font-size: 13px;
}

.sidebar-footer form button {
    background: none;
    border: none;
    color: #cbd5e1;
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}
