/* ============================================================
   Buchly.at - Dark SaaS Design System
   Violett/Indigo Gradient · Glassmorphism · Soft Shadows
   ============================================================ */

:root {
    /* Brand-Farben */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-300: #a5b4fc;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;

    --accent-400: #c084fc;
    --accent-500: #a855f7;
    --accent-600: #9333ea;

    /* Neutrale Hintergründe (Dark) */
    --bg-0:  #0a0a18;
    --bg-1:  #0f1024;
    --bg-2:  #14152e;
    --bg-3:  #1a1c3a;
    --bg-card: rgba(26, 28, 58, 0.55);

    /* Text */
    --text-50:  #f1f5fc;
    --text-100: #e2e8f5;
    --text-200: #cbd5e1;
    --text-300: #94a3b8;
    --text-400: #6b7494;
    --text-500: #4b5267;

    /* Status */
    --success-500: #10b981;
    --success-bg:  rgba(16, 185, 129, 0.12);
    --warning-500: #f59e0b;
    --warning-bg:  rgba(245, 158, 11, 0.12);
    --danger-500:  #ef4444;
    --danger-bg:   rgba(239, 68, 68, 0.12);
    --info-500:    #3b82f6;
    --info-bg:     rgba(59, 130, 246, 0.12);

    /* Glas-Effekte */
    --glass-bg:     rgba(255, 255, 255, 0.04);
    --glass-bg-hi:  rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hi: rgba(255, 255, 255, 0.14);

    /* Schatten */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.20);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.40);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.35);

    /* Geometrie */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 999px;

    /* Layout */
    --sidebar-w: 264px;
    --topbar-h: 68px;

    /* Transitions */
    --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-mid:  250ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Schrift */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    min-height: 100%;
    font-family: var(--font-sans);
    color: var(--text-100);
    background: var(--bg-0);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(at 12% -8%,  rgba(99, 102, 241, 0.22) 0%, transparent 45%),
        radial-gradient(at 92% 0%,   rgba(168, 85, 247, 0.18) 0%, transparent 50%),
        radial-gradient(at 50% 100%, rgba(79, 70, 229, 0.14)  0%, transparent 55%),
        var(--bg-0);
    background-attachment: fixed;
}

a { color: var(--brand-300); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-400); }

img, svg { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 { color: var(--text-50); font-weight: 600; line-height: 1.25; }
h1 { font-size: 2.0rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { color: var(--text-200); }

/* ---------- Utility ---------- */
.text-muted { color: var(--text-300); }
.text-dim   { color: var(--text-400); }
.text-success { color: var(--success-500); }
.text-warning { color: var(--warning-500); }
.text-danger  { color: var(--danger-500); }
.text-info    { color: var(--info-500); }

.gradient-text {
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--accent-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1 1 0; min-width: 0; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 24px; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }

.hidden { display: none !important; }

/* ---------- Card / Glas ---------- */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.card:hover { border-color: var(--glass-border-hi); }

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; gap: 12px;
}
.card-title {
    font-size: 1.05rem; font-weight: 600; color: var(--text-50);
    display: flex; align-items: center; gap: 10px;
}
.card-subtle { font-size: 0.85rem; color: var(--text-400); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px;
    border-radius: var(--radius-md);
    font-weight: 500; font-size: 0.92rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
    user-select: none; line-height: 1; text-decoration: none;
    font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--accent-500) 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.40);
}
.btn-primary:hover {
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55), var(--shadow-glow);
    color: #fff;
}

.btn-secondary {
    background: var(--glass-bg-hi);
    border-color: var(--glass-border-hi);
    color: var(--text-100);
}
.btn-secondary:hover { background: rgba(255,255,255,0.10); color: var(--text-50); }

.btn-ghost {
    background: transparent;
    color: var(--text-200);
    border-color: var(--glass-border);
}
.btn-ghost:hover { background: var(--glass-bg); color: var(--text-50); }

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.30);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); color: #fff; }

.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 22px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block; margin-bottom: 8px;
    font-size: 0.85rem; color: var(--text-200); font-weight: 500;
}
.form-hint { font-size: 0.8rem; color: var(--text-400); margin-top: 6px; }
.form-error { font-size: 0.82rem; color: var(--danger-500); margin-top: 6px; }

.form-control, input.form-control, textarea.form-control, select.form-control {
    width: 100%;
    padding: 11px 14px;
    background: rgba(10, 10, 24, 0.55);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-50);
    font-family: inherit; font-size: 0.94rem;
    transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.20);
    background: rgba(10, 10, 24, 0.75);
}
.form-control::placeholder { color: var(--text-400); }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control, select { appearance: none; cursor: pointer;
    color-scheme: dark;  /* sorgt dafür dass Native-Popups dunkel sind */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 12px; padding-right: 38px;
}

.form-check {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 8px 0;
}
.form-check input[type="checkbox"], .form-check input[type="radio"] {
    width: 18px; height: 18px; accent-color: var(--brand-500); cursor: pointer;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem; font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--glass-bg-hi);
    color: var(--text-200);
    border: 1px solid var(--glass-border);
}
.badge-success { background: var(--success-bg); color: var(--success-500); border-color: rgba(16,185,129,0.25); }
.badge-warning { background: var(--warning-bg); color: var(--warning-500); border-color: rgba(245,158,11,0.25); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-500);  border-color: rgba(239,68,68,0.25); }
.badge-info    { background: var(--info-bg);    color: var(--info-500);    border-color: rgba(59,130,246,0.25); }
.badge-brand   {
    background: linear-gradient(135deg, rgba(99,102,241,0.20), rgba(168,85,247,0.20));
    color: var(--brand-300);
    border-color: rgba(99, 102, 241, 0.30);
}

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
}
.table {
    width: 100%; border-collapse: collapse;
}
.table th, .table td {
    text-align: left; padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.91rem;
}
.table th {
    color: var(--text-400);
    font-weight: 500; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: rgba(0, 0, 0, 0.20);
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: rgba(255,255,255,0.03); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .col-num { font-variant-numeric: tabular-nums; text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- Sidebar ---------- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}
.sidebar {
    grid-column: 1;
    height: 100vh; position: sticky; top: 0;
    padding: 22px 14px;
    background: rgba(10, 10, 24, 0.55);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow-y: auto;
    z-index: 200;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 24px; padding: 4px 8px;
    position: relative;
}
.sidebar-brand .logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
    box-shadow: var(--shadow-glow);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 1.15rem;
    flex-shrink: 0;
}
.sidebar-brand .name { font-weight: 600; font-size: 1.05rem; color: var(--text-50); flex: 1; min-width: 0; }
.sidebar-brand .name small { display:block; font-size:0.68rem; color: var(--text-400); font-weight:400; }
.sidebar-close-btn {
    display: none;
    background: var(--glass-bg-hi); border: 1px solid var(--glass-border);
    color: var(--text-100);
    width: 36px; height: 36px; border-radius: 50%;
    font-size: 1.4rem; line-height: 1;
    align-items: center; justify-content: center;
    cursor: pointer;
}

.nav-section { margin-bottom: 4px; }
.nav-section-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%;
    background: transparent; border: 0;
    color: var(--text-400);
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
    padding: 12px 12px 8px;
    cursor: pointer;
    text-align: left;
    border-radius: var(--radius-sm, 8px);
    transition: color var(--t-fast), background var(--t-fast);
}
.nav-section-toggle:hover { color: var(--text-200); background: rgba(255,255,255,0.03); }
.nav-section-toggle .caret {
    transition: transform var(--t-mid);
    opacity: 0.7;
}
.nav-section-toggle[aria-expanded="false"] .caret { transform: rotate(-90deg); }
.nav-section-body {
    overflow: hidden;
    max-height: 800px;
    transition: max-height 280ms ease, opacity 200ms ease;
}
.nav-section-body[aria-hidden="true"], .nav-section.collapsed .nav-section-body {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-200);
    font-size: 0.91rem; font-weight: 500;
    margin-bottom: 2px;
    transition: background var(--t-fast), color var(--t-fast);
    line-height: 1.2;
}
.nav-link:hover { background: var(--glass-bg-hi); color: var(--text-50); }
.nav-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.18));
    color: var(--text-50);
    border: 1px solid rgba(99, 102, 241, 0.25);
}
.nav-link .ico { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.85; }
.nav-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Backdrop hinter offener Mobile-Sidebar */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 150;
    opacity: 0;
    transition: opacity var(--t-mid);
}
.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px;
    background: rgba(10, 10, 24, 0.50);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--text-50); }
.topbar-meta { display: flex; align-items: center; gap: 14px; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: var(--radius-full);
    background: var(--glass-bg-hi);
    border: 1px solid var(--glass-border);
}
.user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-600), var(--accent-600));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 0.78rem;
}
.user-chip .meta { line-height: 1.2; }
.user-chip .meta .name { font-size: 0.85rem; color: var(--text-50); font-weight: 500; }
.user-chip .meta .role { font-size: 0.72rem; color: var(--text-400); }

/* ---------- Main / Container ---------- */
.main { padding: 28px 32px 64px; }

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 24px;
}
.page-title { font-size: 1.55rem; font-weight: 600; color: var(--text-50); }
.page-subtitle { color: var(--text-300); font-size: 0.92rem; }

/* ---------- KPI Cards ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.kpi {
    padding: 22px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
    transition: border-color var(--t-fast), transform var(--t-fast);
}
.kpi:hover { border-color: var(--glass-border-hi); transform: translateY(-2px); }
.kpi::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.15), transparent 60%);
    pointer-events: none;
}
.kpi .kpi-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-400); margin-bottom: 10px; }
.kpi .kpi-value { font-size: 2.1rem; font-weight: 700; color: var(--text-50); letter-spacing: -0.02em; line-height: 1.1; }
.kpi .kpi-delta { font-size: 0.82rem; color: var(--text-300); margin-top: 8px; display:flex; align-items:center; gap:6px; }
.kpi .kpi-icon {
    position: absolute; top: 18px; right: 18px;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15));
    display: flex; align-items: center; justify-content: center;
    color: var(--brand-300);
}

/* ---------- Auth-Layout ---------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    position: relative;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 38px 36px;
    background: rgba(20, 21, 46, 0.65);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), 0 0 80px rgba(99, 102, 241, 0.18);
}
.auth-card .brand {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-bottom: 28px;
}
.auth-card .brand .logo {
    width: 42px; height: 42px; border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
    box-shadow: var(--shadow-glow);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
}
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 8px; }
.auth-card .auth-sub { text-align: center; color: var(--text-300); font-size: 0.9rem; margin-bottom: 28px; }
.auth-foot { text-align: center; margin-top: 22px; font-size: 0.88rem; color: var(--text-300); }

/* ---------- Flash ---------- */
.flash-stack { margin-bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
.flash {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid;
    background: var(--glass-bg-hi);
    font-size: 0.92rem;
    display: flex; align-items: center; gap: 12px;
}
.flash.success { background: var(--success-bg); border-color: rgba(16,185,129,0.30); color: #6ee7b7; }
.flash.error   { background: var(--danger-bg);  border-color: rgba(239,68,68,0.30);  color: #fca5a5; }
.flash.warning { background: var(--warning-bg); border-color: rgba(245,158,11,0.30); color: #fcd34d; }
.flash.info    { background: var(--info-bg);    border-color: rgba(59,130,246,0.30); color: #93c5fd; }

/* ---------- Empty State ---------- */
.empty {
    text-align: center; padding: 64px 24px;
    color: var(--text-300);
}
.empty .empty-icon {
    width: 56px; height: 56px; margin: 0 auto 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15));
    display: flex; align-items: center; justify-content: center;
    color: var(--brand-300);
}
.empty h3 { color: var(--text-100); margin-bottom: 6px; }

/* ---------- Public/Landing ---------- */
.public-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 22px 8%;
    background: rgba(10,10,24,0.50);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky; top: 0; z-index: 100;
}
.public-nav .links { display: flex; gap: 24px; align-items: center; }
.public-nav .links a { color: var(--text-200); font-size: 0.92rem; font-weight: 500; }
.public-nav .links a:hover { color: var(--text-50); }

.hero {
    padding: 96px 8% 80px;
    text-align: center;
}
.hero h1 {
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 20px;
}
.hero p.lead {
    font-size: 1.15rem; color: var(--text-200);
    max-width: 680px; margin: 0 auto 38px;
}
.hero .cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- Mobile-Menu-Toggle (Hamburger) ---------- */
.mobile-menu-toggle {
    display: none;
    background: var(--glass-bg-hi); border: 1px solid var(--glass-border);
    color: var(--text-50);
    width: 40px; height: 40px; border-radius: 10px;
    align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-menu-toggle:hover { background: rgba(255,255,255,0.10); }

/* ---------- Responsive — Tablet ---------- */
@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; top: 0; left: 0;
        width: 86%; max-width: 320px;
        transform: translateX(-100%);
        transition: transform var(--t-mid);
        height: 100dvh;
        padding-bottom: 80px;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.6); }
    .sidebar-close-btn { display: flex; position: absolute; top: 0; right: 0; }
    .mobile-menu-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; gap: 8px; }
    .topbar-title { font-size: 0.95rem; }
    .topbar-meta { gap: 8px; flex-wrap: nowrap; }
    .main { padding: 18px 16px 48px; }

    /* Topbar-User-Chip kompakter */
    .user-chip { padding: 4px 10px 4px 4px; }
    .user-chip .avatar { width: 28px; height: 28px; font-size: 0.78rem; }
    .user-chip .meta { display: none; }

    /* Page-Header stackbar */
    .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-header > div:first-child { min-width: 0; }
    .page-header .btn, .page-header form { width: 100%; }

    /* Cards/Forms */
    .card { padding: 18px 16px; }
    .row { gap: 12px; }
    .col { flex: 1 1 100%; min-width: 100% !important; }

    /* KPI-Grid passt sich an */
    .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; gap: 12px; }
    .kpi { padding: 16px 14px; }
    .kpi .kpi-value { font-size: 1.5rem; }
    .kpi-label { font-size: 0.78rem; }
    .kpi-delta { font-size: 0.78rem; }
}

/* ---------- Responsive — Phone ---------- */
@media (max-width: 640px) {
    body { font-size: 15px; }
    .topbar { height: 56px; padding: 0 12px; }
    .main { padding: 14px 12px 40px; }
    .page-title { font-size: 1.4rem; }
    .page-subtitle { font-size: 0.85rem; }

    .auth-card { padding: 24px 20px; }
    .public-nav { padding: 14px 5%; }
    .public-nav .links { display: none; }
    .hero { padding: 60px 5% 50px; }

    /* Tabellen → Card-View auf sehr kleinen Screens */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 100%; }
    .table th, .table td { padding: 10px 10px; font-size: 0.85rem; }
    .table .actions { white-space: normal; }
    .table .actions .btn { padding: 6px 10px; font-size: 0.78rem; }

    /* Buttons leicht größer für Touch */
    .btn { padding: 10px 16px; min-height: 40px; }
    .btn-sm { padding: 7px 12px; min-height: 32px; }

    /* Form-Controls Touch-friendly */
    .form-control { min-height: 42px; font-size: 16px; /* verhindert iOS-Zoom */ }
    select.form-control { background-position: right 10px center; }
    textarea.form-control { min-height: auto; }

    /* KPI volle Breite */
    .kpi-grid { grid-template-columns: 1fr 1fr !important; }
    .kpi-grid > .kpi:nth-child(odd):last-child { grid-column: 1 / -1; }

    /* Tabellen-Card-Modus für sehr schmal */
    .table-stack { display: none; }

    /* Flash-Position */
    .flash-stack { margin-bottom: 14px; }
    .flash { padding: 12px 14px; font-size: 0.88rem; }

    /* Sidebar-Brand ohne Untertitel auf phone */
    .sidebar-brand .name small { display: none; }

    /* Bell-Dropdown nicht abgeschnitten */
    .bell-dropdown { right: -8px; width: 280px; max-width: calc(100vw - 24px); }

    /* Pagination kompakt */
    .pagination, [style*="justify-content:center"][style*="flex-wrap"] { gap: 4px !important; }

    /* Code-Blöcke scrollen */
    pre { overflow-x: auto; font-size: 0.78rem; }
}

/* Sehr schmal — Tabellen-Spalten gestapelt darstellen */
@media (max-width: 480px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr { display: block; }
    .table tr {
        background: var(--glass-bg-hi);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        margin-bottom: 10px;
        padding: 10px 12px;
    }
    .table tbody tr:hover { background: var(--glass-bg-hi); }
    .table tbody tr:last-child td { border-bottom: 1px dashed var(--glass-border); }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px dashed var(--glass-border);
        text-align: right;
    }
    .table td:last-child { border-bottom: 0; }
    .table td::before {
        content: attr(data-label);
        color: var(--text-400);
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-weight: 500;
        text-align: left;
        flex-shrink: 0;
    }
    .table td.actions { justify-content: flex-end; }
    .table td.actions::before { display: none; }
    .table td.col-num { justify-content: space-between; }
    .table td input[type="checkbox"] { margin-right: auto; }
}

/* ---------- Footer ---------- */
.footer {
    margin-top: 64px;
    padding: 36px 8%;
    border-top: 1px solid var(--glass-border);
    color: var(--text-400);
    font-size: 0.88rem;
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
}
.footer a { color: var(--text-300); margin-left: 16px; }
.footer a:hover { color: var(--text-50); }

/* ---------- Notification-Bell ---------- */
.notification-bell { position: relative; }
.bell-btn {
    background: var(--glass-bg-hi);
    border: 1px solid var(--glass-border);
    color: var(--text-100);
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.bell-btn:hover { background: rgba(255,255,255,0.10); border-color: var(--glass-border-hi); }
.bell-count {
    position: absolute; top: -4px; right: -4px;
    background: linear-gradient(135deg, var(--danger-500), var(--warning-500));
    color: #fff;
    font-size: 0.65rem; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-1);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
}
.bell-dropdown {
    position: absolute; top: 48px; right: 0;
    min-width: 360px; max-width: 420px;
    background: rgba(20, 21, 46, 0.95);
    border: 1px solid var(--glass-border-hi);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    overflow: hidden;
}
.notification-bell.open .bell-dropdown { display: block; }
.bell-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--glass-border);
}
.bell-item {
    display: flex; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    text-decoration: none; color: inherit;
    transition: background var(--t-fast);
}
.bell-item:hover { background: var(--glass-bg-hi); }
.bell-item:last-child { border-bottom: 0; }
.bell-item.unread { background: rgba(99, 102, 241, 0.06); }

    cursor: pointer; position: relative;
}
.bell-btn:hover { background: rgba(255,255,255,0.10); color: var(--text-50); }
.bell-count {
    position: absolute; top: -4px; right: -4px;
    background: var(--danger-500); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px; padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(10,10,24,0.95);
}
.bell-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 360px; max-height: 480px; overflow-y: auto;
    background: rgba(15,15,35,0.96);
    border: 1px solid var(--glass-border-hi);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    opacity: 0; pointer-events: none;
    transform: translateY(-6px);
    transition: opacity var(--t-fast), transform var(--t-fast);
    z-index: 100;
}
.notification-bell.open .bell-dropdown {
    opacity: 1; pointer-events: auto; transform: translateY(0);
}
.bell-head {
    padding: 14px 16px; border-bottom: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
}
.bell-item {
    display: flex; gap: 10px; padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    transition: background var(--t-fast);
}
.bell-item:hover { background: var(--glass-bg-hi); }
.bell-item.unread { background: rgba(99,102,241,0.06); }
.bell-item:last-child { border-bottom: 0; }

/* ---------- Mobile-Menu-Toggle (Hamburger) ---------- */
.mobile-menu-toggle {
    display: none;
    background: var(--glass-bg-hi); border: 1px solid var(--glass-border);
    color: var(--text-50);
    width: 40px; height: 40px; border-radius: 10px;
    align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-menu-toggle:hover { background: rgba(255,255,255,0.10); }

/* ====================================================================
   RESPONSIVE — Tablet (≤980px)
   ==================================================================== */
@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; top: 0; left: 0;
        width: 86%; max-width: 320px;
        transform: translateX(-100%);
        transition: transform var(--t-mid);
        height: 100dvh;
        padding-bottom: 80px;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.6); }
    .sidebar-close-btn { display: flex; position: absolute; top: 0; right: 0; }
    .mobile-menu-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; gap: 8px; }
    .topbar-title { font-size: 0.95rem; }
    .topbar-meta { gap: 8px; flex-wrap: nowrap; }
    .main { padding: 18px 16px 48px; }

    .user-chip { padding: 4px 10px 4px 4px; }
    .user-chip .avatar { width: 28px; height: 28px; font-size: 0.78rem; }
    .user-chip .meta { display: none; }

    .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-header > div:first-child { min-width: 0; }
    .page-header > .btn,
    .page-header > a.btn,
    .page-header > form { width: 100%; }
    .page-header > form select.form-control { width: 100%; }

    .card { padding: 18px 16px; }
    .row { gap: 12px; }
    .col { flex: 1 1 100%; min-width: 100% !important; }

    .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; gap: 12px; }
    .kpi { padding: 16px 14px; }
    .kpi .kpi-value { font-size: 1.5rem; }
    .kpi-label { font-size: 0.78rem; }
    .kpi-delta { font-size: 0.78rem; }
}

/* ====================================================================
   RESPONSIVE — Phone (≤640px)
   ==================================================================== */
@media (max-width: 640px) {
    body { font-size: 15px; }
    .topbar { height: 56px; padding: 0 12px; }
    .main { padding: 14px 12px 40px; }
    .page-title { font-size: 1.4rem; }
    .page-subtitle { font-size: 0.85rem; }

    .auth-card { padding: 24px 20px; }
    .public-nav { padding: 14px 5%; }
    .public-nav .links { display: none; }
    .hero { padding: 60px 5% 50px; }

    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 100%; }
    .table th, .table td { padding: 10px 10px; font-size: 0.85rem; }
    .table .actions { white-space: normal; }
    .table .actions .btn { padding: 6px 10px; font-size: 0.78rem; }

    .btn { padding: 10px 16px; min-height: 40px; }
    .btn-sm { padding: 7px 12px; min-height: 32px; }

    .form-control { min-height: 42px; font-size: 16px; }

    .kpi-grid { grid-template-columns: 1fr 1fr !important; }
    .kpi-grid > .kpi:nth-child(odd):last-child { grid-column: 1 / -1; }

    .flash-stack { margin-bottom: 14px; }
    .flash { padding: 12px 14px; font-size: 0.88rem; }

    .sidebar-brand .name small { display: none; }

    .bell-dropdown { right: -8px; width: 280px; max-width: calc(100vw - 24px); }

    pre { overflow-x: auto; font-size: 0.78rem; }
}

/* ====================================================================
   RESPONSIVE — Sehr schmal (≤480px) → Tabellen als Karten
   ==================================================================== */
@media (max-width: 480px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr { display: block; }
    .table tr {
        background: var(--glass-bg-hi);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        margin-bottom: 10px;
        padding: 10px 12px;
    }
    .table tbody tr:hover { background: var(--glass-bg-hi); }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px dashed var(--glass-border);
        text-align: right;
    }
    .table td:last-child { border-bottom: 0; }
    .table td::before {
        content: attr(data-label);
        color: var(--text-400);
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-weight: 500;
        text-align: left;
        flex-shrink: 0;
    }
    .table td.actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
    .table td.actions::before { display: none; }
    .table td.col-num { justify-content: space-between; }
    .table td input[type="checkbox"] { margin-right: auto; }
}
}
/* Brackets balanced */
