html,
body,
#app {
    min-height: 100%;
}

body {
    margin: 0;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background: #fff;
}

.app-sidebar {
    box-sizing: border-box;
    flex: 0 0 12.5rem;
    width: 12.5rem;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
    overflow-x: hidden;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    transition: flex-basis 180ms ease, width 180ms ease, padding 180ms ease;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.5rem;
    margin-bottom: 0.75rem;
}

.sidebar-brand {
    color: #212529;
    font-size: 1.35rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.app-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    color: #2459a6;
    line-height: 1.35;
    text-decoration: none;
}

.nav-icon {
    display: inline-grid;
    flex: 0 0 1.35rem;
    place-items: center;
    width: 1.35rem;
    font-size: 1.1rem;
    line-height: 1;
}

.nav-label {
    min-width: 0;
}

.app-nav-link:hover,
.app-nav-link:focus-visible {
    background: #e9ecef;
    color: #173d75;
}

.app-nav-link.active {
    background: #e7f0ff;
    color: #174ea6;
    font-weight: 600;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
}

.app-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
}

.app-toolbar-title {
    color: #495057;
    font-weight: 600;
}

.navigation-toggle,
.mobile-close-toggle {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid #ced4da;
    border-radius: 0.5rem;
    background: #fff;
    color: #343a40;
    font: inherit;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.navigation-toggle:hover,
.mobile-close-toggle:hover {
    background: #f1f3f5;
}

.navigation-toggle:focus-visible,
.mobile-close-toggle:focus-visible,
.app-nav-link:focus-visible {
    outline: 3px solid #86b7fe;
    outline-offset: 2px;
}

.mobile-navigation-toggle,
.mobile-close-toggle,
.sidebar-backdrop {
    display: none;
}

.app-content {
    min-width: 0;
    padding: 1.25rem;
    overflow-wrap: anywhere;
}

@media (min-width: 768px) {
    .sidebar-collapsed .app-sidebar {
        flex-basis: 4.5rem;
        width: 4.5rem;
        min-width: 4.5rem;
        padding: 0.875rem 0.5rem;
    }

    .sidebar-collapsed .sidebar-heading {
        justify-content: center;
    }

    .sidebar-collapsed .sidebar-brand,
    .sidebar-collapsed .nav-label {
        display: none;
    }

    .sidebar-collapsed .app-nav-link {
        justify-content: center;
        width: 3.5rem;
        min-height: 3rem;
        padding: 0.5rem 0;
        gap: 0;
    }

    .sidebar-collapsed .nav-icon {
        flex-basis: auto;
        width: 1.5rem;
        font-size: 1.25rem;
    }
}

@media (max-width: 767.98px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        z-index: 1050;
        inset: 0 auto 0 0;
        width: min(84vw, 18rem);
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
        box-shadow: 0.5rem 0 1.5rem rgb(0 0 0 / 14%);
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 180ms ease, visibility 180ms ease;
    }

    .mobile-menu-open .app-sidebar {
        transform: translateX(0);
        visibility: visible;
    }

    .mobile-close-toggle,
    .mobile-navigation-toggle {
        display: inline-grid;
    }

    .desktop-navigation-toggle {
        display: none;
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 1040;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgb(17 24 39 / 45%);
    }

    .mobile-menu-open .sidebar-backdrop {
        display: block;
    }

    .app-toolbar {
        position: sticky;
        z-index: 10;
        top: 0;
        min-height: 3.5rem;
        padding: 0.5rem 0.75rem;
    }

    .app-content {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
