/* App-style mobile menu uses the same navigation and forms as the desktop bar. */
@media (max-width: 767.98px) {
    #mobileAppMenu {
        --bs-offcanvas-width: 80vw;
        --bs-offcanvas-transition: transform .32s cubic-bezier(.22, .68, .25, 1);
        top: var(--mobile-navbar-height, 68px);
        bottom: 0;
        max-height: calc(100dvh - var(--mobile-navbar-height, 68px));
        overflow: hidden;
        border: 0;
        border-radius: 22px 0 0 22px;
        box-shadow: -12px 0 40px #17243a26;
        background: #f3f5fa;
        color: #25304b;
    }
    #mobileAppMenu .offcanvas-header {
        flex-shrink: 0;
        padding: max(18px, env(safe-area-inset-top)) 18px 14px;
        background: linear-gradient(120deg, #eeebfc, #f3f5fa);
        border-bottom: 1px solid #e5e3f1;
    }
    #mobileAppMenu .offcanvas-title { font-size: 1.65rem; font-weight: 700; letter-spacing: -.04em; }
    .mobile-menu-close {
        display: grid; place-items: center; width: 44px; height: 44px;
        border: 1px solid #dfe3ed; border-radius: 50%; color: #44516b; background: #e9ecf4; font-size: 1.15rem;
    }
    #mobileAppMenu .offcanvas-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 14px max(12px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) 12px;
        overscroll-behavior: contain;
    }
    .mobile-menu-profile {
        display: flex; align-items: center; gap: 10px; padding: 12px;
        border: 1px solid #e3e6f0; border-radius: 18px; background: #fff;
        box-shadow: 0 3px 12px #2839630a;
    }
    .mobile-menu-avatar {
        display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 50%;
        background: linear-gradient(135deg, #6469d5, #8251b9); color: #fff; font-size: 1.3rem; font-weight: 700;
    }
    .mobile-menu-profile-text { min-width: 0; }
    .mobile-menu-profile strong { display: block; font-size: 1rem; overflow-wrap: anywhere; }
    .mobile-menu-profile span { display: block; margin-top: 3px; color: #66718a; font-size: .8125rem; }
    .mobile-menu-caption { margin: 18px 2px 12px; color: #66718a; font-size: .875rem; }
    #mobileAppMenu #mainNav { display: block !important; height: auto !important; }
    #mobileAppMenu .navbar-nav {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch !important; gap: 10px; margin: 0 0 16px !important; padding: 0;
    }
    #mobileAppMenu .nav-item { min-width: 0; margin: 0 !important; }
    #mobileAppMenu .nav-item.dropdown { grid-column: 1 / -1; height: auto; align-self: start; }
    #mobileAppMenu .nav-link {
        display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px;
        min-height: 92px; height: 100%; padding: 14px !important;
        border: 1px solid #e2e6f0; border-radius: 14px; background: #fff;
        box-shadow: 0 2px 7px #28396308; color: #2d3850 !important;
        font-size: .875rem; font-weight: 600; text-decoration: none;
    }
    #mobileAppMenu .nav-link > i {
        display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
        background: #eeebfb; color: #6655b9; font-size: 1.15rem; margin: 0 !important;
    }
    #mobileAppMenu .nav-item:nth-child(even) > .nav-link > i { background: #e6f3f0; color: #267f70; }
    #mobileAppMenu .nav-link.dropdown-toggle { flex-direction: row; align-items: center; justify-content: flex-start; min-height: 60px; height: auto; gap: 10px; }
    #mobileAppMenu .dropdown-toggle::after { margin-left: auto; color: #808ba0; transition: transform .2s ease; }
    #mobileAppMenu .dropdown-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
    #mobileAppMenu .dropdown-toggle[aria-expanded="true"] {
        background: #eeebfc;
        border-color: #c5bcea;
        color: #5946ad !important;
        box-shadow: 0 3px 10px #6353bd12;
    }
    #mobileAppMenu .dropdown-menu {
        position: static !important; transform: none !important; width: 100%; max-width: none;
        min-width: 0; margin: 8px 0 0 !important; padding: 8px;
        border: 1px solid #e5e1f3; border-radius: 14px;
        background: #eeedf7; box-shadow: inset 3px 0 0 #b4a5e6;
    }
    #mobileAppMenu .dropdown-menu.show {
        display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px;
        animation: mobileMenuExpand .2s ease-out;
        transform-origin: top center;
    }
    #mobileAppMenu .dropdown-menu > li { min-width: 0; }
    #mobileAppMenu .dropdown-menu > li:has(.dropdown-divider) { display: none; }
    #mobileAppMenu .dropdown-menu > li:has(.dropdown-header) { grid-column: 1 / -1; }
    #mobileAppMenu .dropdown-header { padding: 8px 4px; color: #69768d; font-size: .75rem; white-space: normal; }
    #mobileAppMenu .dropdown-item {
        display: flex; align-items: center; gap: 10px; min-height: 48px; height: 100%;
        padding: 9px 10px; border: 1px solid #e2e6f0; border-radius: 11px;
        background: #fff; color: #34425a; font-size: .875rem; font-weight: 500; line-height: 1.4; white-space: normal;
    }
    #mobileAppMenu .dropdown-item i {
        display: grid; place-items: center; flex: 0 0 30px; height: 30px;
        margin: 0 !important; border-radius: 9px; background: #efedfb;
        color: #6977bd !important; text-align: center;
    }
    #mobileAppMenu .dropdown-menu form { display: block !important; height: 100%; }
    #mobileAppMenu .dropdown-item.text-danger { color: #af3049 !important; background: #fff5f6; }
    #mobileAppMenu :is(.nav-link, .dropdown-item):is(:hover, .active, [aria-current="page"]) {
        border-color: #b7ace6; color: #5746a5 !important; background: #f0edfc;
    }
    #mobileAppMenu :is(a, button):focus-visible { outline: 3px solid #8573d3; outline-offset: 2px; }
    body:has(#mobileAppMenu:is(.show, .showing, .hiding)) > .offcanvas-backdrop {
        top: var(--mobile-navbar-height, 68px);
        height: calc(100% - var(--mobile-navbar-height, 68px));
        backdrop-filter: blur(2px);
    }
    @keyframes mobileMenuExpand {
        from { opacity: 0; translate: 0 -6px; }
        to { opacity: 1; translate: 0 0; }
    }
}
@media (prefers-reduced-motion: reduce) {
    #mobileAppMenu { --bs-offcanvas-transition: none; }
    #mobileAppMenu .dropdown-menu.show { animation: none; }
    #mobileAppMenu .dropdown-toggle::after { transition: none; }
}
@media print { #mobileAppMenu { display: none !important; } }
