.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--primary);
    color: #e4e4e7;
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform .22s ease;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 18px;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .02em;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #fff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex: none;
}
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #a1a1aa;
    font-weight: 540;
    text-decoration: none;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-section { margin: 14px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #71717a; }
.sidebar-footer { padding: 12px 10px calc(12px + var(--safe-bottom)); border-top: 1px solid rgba(255, 255, 255, .08); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3f3f46;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex: none;
}
.user-meta { min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: #a1a1aa; font-size: 12px; }
.sidebar-footer .nav-link { width: 100%; border: none; background: none; font: inherit; cursor: pointer; text-align: left; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    background: rgba(244, 244, 246, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.menu-toggle { display: none; }
.content { flex: 1; padding: 20px 24px 32px; width: 100%; max-width: 1440px; margin: 0 auto; }
.backdrop { display: none; }

.bottom-nav { display: none; }

@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); width: min(300px, 86vw); }
    .sidebar.open { transform: translateX(0); }
    .backdrop { display: block; position: fixed; inset: 0; background: rgba(24, 24, 27, .45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
    .backdrop.show { opacity: 1; pointer-events: auto; }
    .shell { margin-left: 0; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom)); }
    .topbar { padding: 0 12px; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 16px 16px 24px; }
    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        inset: auto 0 0 0;
        height: calc(var(--bottom-nav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 50;
    }
    .bottom-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 11px;
        font-weight: 560;
        color: var(--muted);
        text-decoration: none;
        border: none;
        background: none;
        font-family: inherit;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-link:hover { text-decoration: none; }
    .bottom-link.active { color: var(--text); }
    .bottom-link .icon { width: 22px; height: 22px; }
    .bottom-link.primary .icon-wrap { background: var(--primary); color: #fff; border-radius: 12px; padding: 6px 14px; }
    .toasts { top: auto; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px); right: 12px; left: 12px; max-width: none; }
    body.no-bottom-nav .shell { padding-bottom: 0; }
    body.no-bottom-nav .bottom-nav { display: none; }
}

@media (max-width: 600px) {
    h1 { font-size: 18px; }
    .topbar-actions .btn-label { display: none; }
    .topbar-actions .btn:not(.btn-icon) { padding: 0 12px; }
}

.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--primary); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow-lg); }
.auth-card .brand-mark { width: 48px; height: 48px; font-size: 22px; background: var(--primary); color: #fff; border-radius: 14px; margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .stack { gap: 14px; margin-top: 20px; }
.auth-error { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }

.error-page { max-width: 480px; margin: 48px auto; text-align: center; }
.error-code { font-size: 56px; font-weight: 800; color: var(--border-strong); line-height: 1; margin-bottom: 12px; }
