:root {
    --bg0: #070A12;
    --bg1: #0B1020;
    --panel: #0E1630CC;
    --panel2: #0B1226CC;
    --stroke: #FFFFFF1A;
    --text: #EAF0FF;
    --muted: #AAB6D9;
    --accent: #8A5BFF;
    --accent2: #22D3EE;
    --danger: #FF4D6D;
    --warn: #FFB020;
    --ok: #1ED760;
    --r: 18px;
    --shadow: 0 18px 60px rgba(0,0,0,.55);
    --shadow2: 0 10px 28px rgba(0,0,0,.45);
    --ring: 0 0 0 4px rgba(34,211,238,.12);
}

html, body {
    height: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans";
    color: var(--text);
    background: radial-gradient(1000px 700px at 15% 10%, rgba(138,91,255,.22), transparent 55%), radial-gradient(900px 600px at 80% 15%, rgba(34,211,238,.14), transparent 60%), radial-gradient(900px 700px at 60% 85%, rgba(138,91,255,.10), transparent 60%), linear-gradient(180deg, var(--bg0), var(--bg1));
    overflow-x: hidden;
}

    /* Ambient Layer (ruhig, ohne „bunte Spielerei“) */
    body::before {
        content: "";
        position: fixed;
        inset: -20%;
        pointer-events: none;
        background: radial-gradient(600px 420px at 18% 22%, rgba(138,91,255,.18), transparent 60%), radial-gradient(520px 380px at 82% 26%, rgba(34,211,238,.14), transparent 62%), radial-gradient(520px 420px at 55% 86%, rgba(255,176,32,.07), transparent 65%);
        filter: blur(18px);
        opacity: .9;
        transform: translate3d(0,0,0);
        animation: ambientFloat 14s ease-in-out infinite;
    }

    body::after {
        content: "";
        position: fixed;
        inset: 0;
        pointer-events: none;
        background-image: repeating-linear-gradient( 0deg, rgba(255,255,255,.03), rgba(255,255,255,.03) 1px, transparent 1px, transparent 3px );
        opacity: .05;
        mix-blend-mode: overlay;
    }

@keyframes ambientFloat {
    0%, 100% {
        transform: translate3d(0,0,0) scale(1);
    }

    50% {
        transform: translate3d(-1.2%, 1.2%, 0) scale(1.02);
    }
}

a {
    color: inherit;
    text-decoration: none;
}

/* =========================
   Layout
   ========================= */

/* WICHTIG: dvh statt vh, damit keine „Viewport + Padding + Header“-Scroll-Fallen entstehen */
.shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100dvh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
    border-right: 1px solid var(--stroke);
    backdrop-filter: blur(16px);
}

.main {
    padding: 22px 22px 44px 22px;
    display: flex;
    flex-direction: column;
    /* absichtlich KEIN min-height: 100vh;
       das war die Hauptquelle für „oben leer / unten kleben / Scroll erforderlich“ in Kombination mit Topbar + Padding */
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--stroke);
    border-radius: var(--r);
    background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow2);
}

/* Page container (Standardseiten) */
.page {
    flex: 1;
    padding-top: 18px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

    /* Wenn du die Login-Seite bereits mit .auth markierst */
    .page.auth {
        padding-top: 0;
        align-items: center;
    }

/* =========================
   Login: kompromisslos fixiert
   - Kein Scroll beim Start
   - Zentriert im Viewport
   - Sidebar/Topbar raus
   - Unabhängig davon, welche Wrapper sonst noch drin sind
   ========================= */

@supports selector(body:has(input[type="password"])) {
    /* Sobald irgendwo ein Passwortfeld existiert -> Login-Modus */
    body:has(input[type="password"]) .shell {
        grid-template-columns: 1fr !important;
        min-height: 100dvh !important;
    }

    body:has(input[type="password"]) .sidebar {
        display: none !important;
    }

    body:has(input[type="password"]) .topbar {
        display: none !important;
    }
    /* Der entscheidende Teil: main wird zu einer echten Fullscreen-Zentrierfläche */
    body:has(input[type="password"]) .main {
        padding: 0 !important;
        min-height: 100dvh !important;
        display: grid !important;
        place-items: center !important;
    }

    body:has(input[type="password"]) .page {
        padding: clamp(18px, 5vh, 56px) !important;
        min-height: 100dvh !important;
        display: grid !important;
        place-items: center !important;
        position: relative !important;
    }
        /* Spotlight hinter dem Login (dezenter Premium-Look) */
        body:has(input[type="password"]) .page::before {
            content: "";
            position: absolute;
            inset: -30%;
            background: radial-gradient(600px 420px at 35% 35%, rgba(34,211,238,.14), transparent 60%), radial-gradient(640px 460px at 65% 55%, rgba(138,91,255,.16), transparent 62%);
            filter: blur(22px);
            opacity: .9;
            pointer-events: none;
        }
        /* Login-Container-Breite (egal welcher Wrapper) */
        body:has(input[type="password"]) .page > * {
            position: relative;
            width: min(980px, 100%);
        }
}

/* =========================
   UI-Bausteine
   ========================= */

.card {
    border-radius: var(--r);
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,.03);
    box-shadow: var(--shadow2);
    padding: 16px;
}

    /* Glass + Gradient-Border (wirkt „gebaut“, nicht Bootstrap) */
    .card.glass {
        border: 1px solid transparent;
        background: linear-gradient(180deg, var(--panel), var(--panel2)) padding-box, linear-gradient(135deg, rgba(255,255,255,.16), rgba(34,211,238,.18), rgba(138,91,255,.22), rgba(255,176,32,.10) ) border-box;
        backdrop-filter: blur(18px);
        position: relative;
        overflow: hidden;
    }

        .card.glass::after {
            content: "";
            position: absolute;
            inset: -40%;
            background: radial-gradient(closest-side at 30% 30%, rgba(34,211,238,.18), transparent 60%), radial-gradient(closest-side at 70% 50%, rgba(138,91,255,.18), transparent 60%);
            filter: blur(28px);
            opacity: .55;
            pointer-events: none;
            transform: translate3d(0,0,0);
        }

.h1 {
    font-size: 22px;
    font-weight: 850;
    letter-spacing: .2px;
}

.h2 {
    font-size: 15px;
    font-weight: 720;
}

.muted {
    color: var(--muted);
}

hr.sep {
    border: 0;
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 12px 0;
}

.grid {
    display: grid;
    gap: 14px;
}

    .grid.cols2 {
        grid-template-columns: 1fr 1fr;
    }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.05);
    color: var(--text);
    cursor: pointer;
    user-select: none;
    transition: transform .12s ease, background .12s ease, box-shadow .12s ease, border-color .12s ease;
}

    .btn:hover {
        background: rgba(255,255,255,.08);
        transform: translateY(-1px);
    }

    .btn:active {
        transform: translateY(0);
    }

    .btn.primary {
        background: linear-gradient(135deg, rgba(138,91,255,.88), rgba(34,211,238,.32));
        border-color: rgba(255,255,255,.16);
        box-shadow: 0 18px 40px rgba(138,91,255,.18);
    }

        .btn.primary:hover {
            box-shadow: 0 22px 54px rgba(138,91,255,.22);
        }

.input {
    width: 100%;
    padding: 11px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.20);
    color: var(--text);
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

    .input::placeholder {
        color: rgba(170,182,217,.70);
    }

    .input:focus {
        border-color: rgba(34,211,238,.45);
        box-shadow: var(--ring);
        background: rgba(0,0,0,.26);
    }

/* Responsive */
@media (max-width: 1100px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: relative;
    }

    .grid.cols2 {
        grid-template-columns: 1fr;
    }
}

/* Motion reduzieren */
@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none;
    }

    .btn, .input {
        transition: none;
    }
}
