:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --sidebar-bg: #0b1120;
    --sidebar-bg-2: #111827;
    --sidebar-text: #cbd5e1;
    --sidebar-text-muted: #64748b;
    --sidebar-active: #6366f1;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-soft: #eef2ff;

    --success: #10b981;
    --success-soft: #ecfdf5;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --danger: #ef4444;
    --danger-soft: #fef2f2;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

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

button { font-family: inherit; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

.btn-danger-ghost { color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  }
.badge-muted   { background: #f1f5f9; color: var(--text-muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.25rem 1.5rem; }

.input, .select, .textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.data-table th, .data-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.data-table thead th {
    background: var(--surface-alt);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.data-table tbody tr:hover { background: var(--surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease-out;
}
.modal {
    background: var(--surface);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.18s ease-out;
}
.modal h3 { margin-bottom: 1.25rem; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.5rem; }

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.4; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: none; } }

#blazor-error-ui {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.8rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
#blazor-error-ui.show { display: block; }
#blazor-error-ui .reload, #blazor-error-ui .dismiss { cursor: pointer; text-decoration: underline; }

.blazor-error-boundary {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--danger);
}
.blazor-error-boundary::after { content: "Ein Fehler ist aufgetreten."; }

/* --------- Layout (MainLayout) --------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand-mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
    flex-shrink: 0;
}
.brand-name { color: white; font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.72rem; color: #94a3b8; letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar .nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 1rem 0.75rem;
    flex: 1;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.05); color: white; }
.sidebar .nav-item.active { background: rgba(99, 102, 241, 0.18); color: white; }
.sidebar .nav-item.active::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 18px;
    background: var(--sidebar-active);
    border-radius: 0 3px 3px 0;
}

.sidebar .nav-icon {
    width: 18px; height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar .nav-icon svg { width: 18px; height: 18px; display: block; }

.sidebar-foot {
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-foot .nav-item { font-size: 0.88rem; }
.sidebar-foot .ext { margin-left: auto; font-size: 0.8rem; color: var(--sidebar-text-muted); }

.logout-form { margin: 0; }
.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 0.88rem;
    cursor: pointer;
    border-radius: 8px;
    text-align: left;
    font-family: inherit;
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.35rem; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text);
}
.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    display: grid; place-items: center;
    font-weight: 600;
    font-size: 0.8rem;
}
.page { padding: 1.75rem 2rem; flex: 1; }

@media (max-width: 820px) {
    .sidebar { width: 64px; padding-top: 1rem; }
    .brand-text, .sidebar .nav-label, .sidebar-foot .ext, .sidebar-foot .nav-item span:not(.nav-icon):not(.ext), .logout-btn .nav-label {
        display: none;
    }
    .brand { justify-content: center; padding: 0 0 1rem; }
    .sidebar .nav-item { justify-content: center; padding: 0.6rem; }
    .page { padding: 1.25rem; }
    .topbar { padding: 1rem; }
}
