:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #7b8794;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --border: #e2e8f0;
    --gruen: #16a34a;
    --rot: #dc2626;
    --gelb: #d97706;
    --blau: #2563eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

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

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

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    padding: 0 24px;
    height: 56px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.brand a { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--text); font-size: 0.92rem; }
.topbar nav .user { color: var(--muted); font-size: 0.9rem; }
.topbar nav .logout { color: var(--danger); }

.container { max-width: 1100px; margin: 28px auto; padding: 0 24px; }
.footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 28px 0; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.92rem; }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
    background: var(--card); border: 1px solid var(--border); border-radius: 10px;
    padding: 18px; text-align: center; box-shadow: var(--shadow); color: var(--text);
}
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.stat-num { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-label { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

/* Warnbox */
.warnbox {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
    padding: 16px 20px; margin-bottom: 24px;
}
.warnbox h2 { margin: 0 0 10px; font-size: 1rem; color: #92400e; }
.warnbox ul { margin: 0; padding-left: 18px; }
.warnbox li { margin-bottom: 6px; font-size: 0.92rem; }

/* Suchleiste */
.searchbar { display: flex; gap: 10px; margin-bottom: 22px; }
.searchbar input[type=search] {
    flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.95rem; font-family: inherit;
}
.searchbar input[type=search]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.searchbar .btn { white-space: nowrap; }

/* Table */
.table-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.table-head .count { font-size: 0.85rem; font-weight: 400; }
.head-actions { display: flex; gap: 10px; }
td.betrag { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Sortierbare Spaltenköpfe */
th.sortable { padding: 0; }
th.sortable a {
    display: block; padding: 11px 14px; color: var(--muted);
    font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em;
}
th.sortable a:hover { color: var(--primary); text-decoration: none; background: #eef2f7; }
th.sortable .pfeil { color: var(--primary); }
.table-head h1 { margin: 0; font-size: 1.3rem; }
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td.grund { max-width: 240px; color: var(--muted); }
td.actions { white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-blau { background: #dbeafe; color: #1e40af; }
.badge-gelb { background: #fef3c7; color: #92400e; }
.badge-rot { background: #fee2e2; color: #991b1b; }
.muted { color: var(--muted); }

/* Toggle buttons */
.toggle { border: none; border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 0.9rem; font-weight: 700; }
.toggle.ja { background: #dcfce7; color: var(--gruen); }
.toggle.nein { background: #fee2e2; color: var(--rot); }
.toggle:hover { opacity: 0.8; }
.inline { display: inline; margin: 0; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
       background: var(--card); color: var(--text); cursor: pointer; font-size: 0.9rem; text-decoration: none; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-small { padding: 5px 10px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* Forms */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 24px; max-width: 720px; box-shadow: var(--shadow); margin-bottom: 24px; }
.form-card h1 { margin-top: 0; }
.form-card h2 { margin-top: 0; font-size: 1.1rem; }
label { display: block; margin-bottom: 16px; font-size: 0.9rem; font-weight: 600; }
input[type=text], input[type=password], input[type=date], select, textarea {
    width: 100%; padding: 9px 11px; margin-top: 5px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.92rem; font-family: inherit; font-weight: 400;
}
input[type=file] { margin-top: 6px; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 0; }
.check input { width: auto; margin: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.hint { display: block; font-weight: 400; font-size: 0.82rem; margin-top: 6px; color: var(--muted); }
.pw-form input { width: 140px; display: inline-block; margin: 0 6px 0 0; }
.rolle-form select { width: auto; margin: 0; padding: 6px 8px; font-size: 0.85rem; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Fehlerseite */
.error-wrap { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.error-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 40px; text-align: center; box-shadow: var(--shadow); max-width: 420px; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--primary); line-height: 1; }
.error-card h1 { margin: 12px 0 8px; font-size: 1.3rem; }
.error-card p { color: var(--muted); margin-bottom: 20px; }

/* Microsoft-SSO-Button */
.btn-ms {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: #2f2f2f; color: #fff; border-color: #2f2f2f; margin-bottom: 6px;
}
.btn-ms:hover { background: #1f1f1f; text-decoration: none; color: #fff; }
.ms-logo { display: inline-grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-logo span { width: 9px; height: 9px; display: block; }
.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }
.btn-secondary { background: #f1f5f9; color: var(--text); }
.btn-secondary:hover { background: #e2e8f0; }

/* Trenner "oder" */
.trenner { display: flex; align-items: center; text-align: center; color: var(--muted); margin: 16px 0; font-size: 0.82rem; }
.trenner::before, .trenner::after { content: ""; flex: 1; border-bottom: 1px solid var(--border); }
.trenner span { padding: 0 12px; }

/* Login */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 70vh; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 36px; width: 360px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 1.3rem; text-align: center; }
.login-card .subtitle { text-align: center; color: var(--muted); margin: 0 0 24px; }

@media (max-width: 720px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; height: auto; padding: 10px; gap: 8px; }
}
