:root {
    --app-shell-topbar: rgba(255, 255, 255, 0.82);
    --app-shell-topbar-text: #0f172a;
    --app-shell-sidebar-bg: linear-gradient(170deg, rgba(255, 255, 255, 0.86) 0%, rgba(241, 245, 249, 0.82) 100%);
    --app-shell-sidebar-text: #1e293b;
    --app-shell-sidebar-muted: #64748b;
    --app-shell-border: rgba(148, 163, 184, 0.35);
    --app-shell-accent: #0284c7;
    --app-shell-accent-soft: rgba(2, 132, 199, 0.14);
    --app-page-border: rgba(148, 163, 184, 0.3);
    --app-page-surface: rgba(255, 255, 255, 0.88);
    --app-page-subtitle: #475569;
}

body.auth-bootstrap-hidden {
    display: none;
}

body[data-page-gate="pending"] #app,
body[data-page-gate="denied"] #app {
    display: none;
}

[v-cloak] {
    display: none;
}

@keyframes app-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-up {
    animation: app-slide-up 0.3s ease-out;
}

body.app-shell-enabled {
    padding-top: 64px;
    padding-left: 280px;
    background: #f1f5f9;
}

#app-shell-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    height: 64px;
    background: var(--app-shell-topbar);
    color: var(--app-shell-topbar-text);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

#app-shell-topbar .brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    min-width: 140px;
    max-width: 320px;
}

#app-shell-topbar .mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    cursor: pointer;
    flex: none;
}

#app-shell-topbar .mobile-menu-toggle svg {
    width: 18px;
    height: 18px;
}

#app-shell-topbar .user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #334155;
    margin-left: auto;
}

@media (min-width: 1025px) {
    #app-shell-topbar .mobile-menu-toggle {
        display: none !important;
    }
}

#app-shell-topbar .auth-company-switch {
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    min-width: 180px;
    max-width: 260px;
}

#app-shell-topbar .auth-company-box {
    display: inline-flex;
    align-items: center;
    max-width: 300px;
}

#app-shell-topbar .auth-welcome-inline {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

#app-shell-topbar .auth-company-logo {
    width: auto;
    height: 45px;
    max-width: 220px;
    object-fit: contain;
    background: transparent;
    overflow: hidden;
}

#app-shell-topbar .auth-company-logo-placeholder {
    min-width: 120px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    font-size: 13px;
    font-weight: 800;
}

#app-shell-topbar .logout-btn {
    border: 0;
    background: #dc2626;
    color: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 700;
}

#app-shell-topbar .logout-btn:hover {
    background: #b91c1c;
}

#app-shell-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 55;
    background: var(--app-shell-sidebar-bg);
    color: var(--app-shell-sidebar-text);
    overflow-y: auto;
    border-right: 1px solid var(--app-shell-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 10px 0 26px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#app-shell-backdrop {
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 54;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#app-shell-sidebar .sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 6px;
}

#app-shell-sidebar .sidebar-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    padding: 8px 0 10px;
    background: transparent;
}

#app-shell-sidebar .sidebar-footer-link {
    width: 100%;
    justify-content: flex-start;
}

#app-shell-sidebar .sidebar-footer-link + .sidebar-footer-link {
    margin-top: 2px;
}

#app-shell-sidebar .sidebar-footer-logout {
    color: #991b1b;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

#app-shell-sidebar .sidebar-footer-logout:hover {
    background: rgba(220, 38, 38, 0.1);
    border-left-color: rgba(220, 38, 38, 0.5);
}

#app-shell-sidebar .group {
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

#app-shell-sidebar .group-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    color: #0f172a;
    border: 0;
    padding: 14px 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    cursor: pointer;
}

#app-shell-sidebar .group-title {
    opacity: 0.95;
}

#app-shell-sidebar .group-title-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

#app-shell-sidebar .group-body {
    padding: 0 0 8px;
}

#app-shell-sidebar .menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--app-shell-sidebar-text);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    border: 0;
    border-left: 3px solid transparent;
}

#app-shell-sidebar .menu-link:hover {
    background: rgba(255, 255, 255, 0.75);
    color: #0f172a;
    border-left-color: rgba(2, 132, 199, 0.35);
    box-shadow: none;
}

#app-shell-sidebar .menu-link.active {
    background: var(--app-shell-accent-soft);
    border-left-color: var(--app-shell-accent);
    color: #0c4a6e;
    box-shadow: none;
}

#app-shell-sidebar .menu-link .menu-page-icon {
    width: 18px;
    text-align: center;
    flex: none;
    font-size: 14px;
    line-height: 1;
}

#app-shell-sidebar .menu-link.active .menu-page-icon {
    transform: scale(1.06);
}

.app-page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 20px 16px 32px;
}

.app-header-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--app-page-surface);
    border: 1px solid var(--app-page-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
}

.app-header-main {
    min-width: 0;
}

.app-header-title {
    font-size: 1.75rem;
    line-height: 1.2;
    font-weight: 800;
    color: #0f172a;
}

.app-header-subtitle {
    margin-top: 6px;
    color: var(--app-page-subtitle);
    font-size: 0.95rem;
}

.app-header-tools {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.app-header-tabs {
    display: inline-flex;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    padding: 4px;
    flex-wrap: wrap;
}

.app-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.app-switch-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.app-switch-track {
    position: relative;
    width: 44px;
    height: 24px;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    background: #e2e8f0;
    transition: background-color 160ms ease, border-color 160ms ease;
    flex: none;
}

.app-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.22);
    transform: translateX(0);
    transition: transform 160ms ease;
}

.app-switch-input:checked + .app-switch-track {
    background: #10b981;
    border-color: #10b981;
}

.app-switch-input:checked + .app-switch-track::after {
    transform: translateX(20px);
}

.app-switch-input:focus-visible + .app-switch-track {
    outline: 2px solid rgba(2, 132, 199, 0.45);
    outline-offset: 2px;
}

.app-switch-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
}

#app-shell-sidebar .chevron {
    transition: transform 0.2s ease;
}

#app-shell-sidebar .group.collapsed .chevron {
    transform: rotate(-90deg);
}

#app-shell-sidebar .group.collapsed .group-body {
    display: none;
}

.login-grid-pattern {
    background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 32px 32px;
}

@media (max-width: 1024px) {
    body.app-shell-enabled {
        padding-left: 0;
        padding-top: 64px;
    }

    #app-shell-topbar .mobile-menu-toggle {
        display: inline-flex;
    }

    #app-shell-sidebar {
        width: 280px;
        height: auto;
        top: 64px;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 56;
    }

    body.app-shell-enabled.app-sidebar-open #app-shell-sidebar {
        transform: translateX(0);
    }

    body.app-shell-enabled.app-sidebar-open #app-shell-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    #app-shell-sidebar .sidebar-footer {
        display: block;
    }

    #app-shell-sidebar .group-body {
        display: block;
        padding: 0 0 8px;
    }

    #app-shell-sidebar .menu-link {
        margin-right: 0;
        border-radius: 0;
        border-left-width: 3px;
    }

    .app-page {
        padding: 14px 10px 22px;
    }

    .app-header-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-header-tools {
        width: 100%;
        justify-content: flex-start;
    }

    #app-shell-topbar .auth-welcome-inline {
        display: none;
    }

    #app-shell-topbar {
        padding: 0 10px;
        gap: 8px;
    }

    #app-shell-topbar .brand {
        min-width: 0;
        max-width: 40vw;
        overflow: hidden;
    }

    #app-shell-topbar .auth-company-logo {
        height: 31px;
        max-width: 40vw;
    }

    #app-shell-topbar .auth-company-logo-placeholder {
        min-width: 84px;
        height: 31px;
        padding: 0 8px;
    }

    #app-shell-topbar .auth-company-switch {
        min-width: 132px;
        max-width: 170px;
    }
}
