.header-menu-container {
    position: relative;
    margin-left: 10px;
}

.desktop-side-menu {
    display: none;
}

.mobile-tabbar {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.header-user-id {
    max-width: 16rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(203, 213, 225, 0.9);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.header-user-avatar {
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .03em;
    color: #ffffff;
    background: linear-gradient(180deg, #0ea5e9 0%, #1d4ed8 100%);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .32);
    flex: 0 0 auto;
}

.header-user-info {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.header-user-text {
    color: #0f172a;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.header-user-company {
    color: #64748b;
    font-size: 0.67rem;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(203, 213, 225, 0.9);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.6rem;
    transition: transform .14s ease, box-shadow .2s ease, border-color .2s ease, color .2s ease;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
}
.menu-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(30, 64, 175, 0.2);
    border-color: rgba(59, 130, 246, 0.46);
}
.menu-icon {
    font-size: 1.7rem;
    color: #222;
}
.menu-mosaic {
    display: grid;
    position: absolute;
    top: 54px;
    right: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.28) 100%);
    border: 1px solid rgba(255, 255, 255, 0.52);
    border-radius: 18px;
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.24), inset 0 1px 1px rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    padding: 18px 24px 10px 24px;
    min-width: 260px;
    z-index: 100;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    grid-auto-rows: 70px;
    animation: fadeInMenu 0.18s;
}

@keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-tile {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(203, 213, 225, 0.9);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.92rem;
    font-weight: 500;
    color: #222;
    cursor: pointer;
    transition: transform .14s ease, box-shadow .2s ease, border-color .2s ease, color .2s ease;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
    padding: 6px 0 2px 0;
    text-decoration: none;
}
.menu-tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(30, 64, 175, 0.2);
    border-color: rgba(59, 130, 246, 0.46);
    color: #1d4ed8;
}
.menu-tile-icon {
    font-size: 1.7rem;
    margin-bottom: 2px;
    color: #0ea5e9;
}
.menu-tile-label {
    font-size: 0.82rem;
    color: #222;
    font-weight: 400;
    margin-top: 2px;
    letter-spacing: 0.01em;
}

.menu-tile-logout {
    border-color: rgba(248, 113, 113, 0.38);
    color: #b91c1c;
}

.menu-tile-logout .menu-tile-icon,
.menu-tile-logout .menu-tile-label {
    color: #b91c1c;
}

.menu-tile-logout:hover {
    border-color: rgba(239, 68, 68, 0.62);
    box-shadow: 0 8px 18px rgba(220, 38, 38, 0.16);
    color: #991b1b;
}
.status-island {
    display: flex;
    gap: 18px;
    background: #f8fafc;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 8px 24px;
    align-items: center;
    min-height: 40px;
    border: 1.5px solid #e5e7eb;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #222;
}

.status-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.status-label {
    padding-right: 6px;
}

.status-count {
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 .35rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
    font-size: 0.73rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}
/* Header styles for floating effect */
.app-header {
    background: transparent;
    border-radius: 18px;
    margin: 5px 24px 0 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    padding: 8px 18px;
    display: flex;
    align-items: center;
    min-height: 52px;
    z-index: 1200;
    position: relative;
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border: 1.5px solid rgba(210, 210, 215, 0.18);
}

.header-logo {
    height: 32px;
    max-width: 138px;
    width: auto;
    object-fit: contain;
    margin-right: 12px;
}

@media (min-width: 992px) {
    .header-menu-container {
        display: none;
    }

    .desktop-side-menu {
        position: fixed;
        top: calc(1rem + 3.4rem + .55rem);
        left: 1rem;
        bottom: 1rem;
        width: 3.75rem;
        z-index: 1100;
        border-radius: 1.15rem;
        padding: .65rem .5rem;
        display: flex;
        flex-direction: column;
        gap: .55rem;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.62);
        box-shadow: 0 18px 34px rgba(15, 23, 42, 0.22), inset 0 1px 1px rgba(255, 255, 255, 0.72);
        backdrop-filter: blur(18px) saturate(180%);
        -webkit-backdrop-filter: blur(18px) saturate(180%);
    }

    .desktop-side-menu-item {
        position: relative;
        width: 2.7rem;
        height: 2.7rem;
        border-radius: .85rem;
        border: 1px solid rgba(203, 213, 225, 0.92);
        background: rgba(255, 255, 255, 0.86);
        box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        text-decoration: none;
        color: #334155;
        transition: transform .14s ease, box-shadow .2s ease, border-color .2s ease, color .2s ease;
    }

    .desktop-side-menu-item:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 20px rgba(30, 64, 175, 0.2);
        border-color: rgba(59, 130, 246, 0.46);
        color: #1d4ed8;
    }

    .desktop-side-menu-item.active {
        border-color: rgba(37, 99, 235, 0.72);
        box-shadow: 0 10px 20px rgba(37, 99, 235, 0.26);
        background: rgba(239, 246, 255, 0.88);
    }

    .desktop-side-menu-item img {
        width: 1.35rem;
        height: 1.35rem;
        object-fit: contain;
        pointer-events: none;
        filter: brightness(0) saturate(100%) invert(25%) sepia(22%) saturate(521%) hue-rotate(176deg) brightness(93%) contrast(89%);
        transition: filter .2s ease;
    }

    .desktop-side-menu-item i {
        font-size: 1rem;
        color: inherit;
    }

    .desktop-side-menu-item:hover img,
    .desktop-side-menu-item.active img,
    .desktop-side-menu-item:focus-visible img {
        filter: brightness(0) saturate(100%) invert(24%) sepia(63%) saturate(2067%) hue-rotate(218deg) brightness(93%) contrast(88%);
    }

    .desktop-side-menu-item::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + .65rem);
        top: 50%;
        transform: translateY(-50%);
        opacity: 0;
        pointer-events: none;
        background: rgba(15, 23, 42, 0.92);
        color: #fff;
        font-size: .72rem;
        font-weight: 600;
        line-height: 1;
        padding: .38rem .5rem;
        border-radius: .5rem;
        white-space: nowrap;
        transition: opacity .16s ease;
    }

    .desktop-side-menu-item:hover::after,
    .desktop-side-menu-item:focus-visible::after {
        opacity: 1;
    }

    .desktop-side-menu-logout {
        margin-top: auto;
        color: #b91c1c;
        border-color: rgba(248, 113, 113, 0.38);
        background: rgba(254, 242, 242, 0.84);
        cursor: pointer;
    }

    .desktop-side-menu-logout:hover {
        color: #991b1b;
        border-color: rgba(239, 68, 68, 0.62);
        box-shadow: 0 10px 20px rgba(220, 38, 38, 0.16);
    }
}

@media (max-width: 820px) {
    :root {
        --header-safe-top: env(safe-area-inset-top, 0px);
        --mobile-tabbar-safe-bottom: env(safe-area-inset-bottom, 0px);
        --mobile-tabbar-height: 5rem;
        --mobile-tabbar-space: calc(var(--mobile-tabbar-height) + var(--mobile-tabbar-safe-bottom) + .8rem);
    }

    .app-header {
        margin-top: calc(5px + var(--header-safe-top));
    }

    .app-shell.map-mode .app-header {
        display: none !important;
    }

    .header-right {
        position: static;
        top: auto;
        right: auto;
        z-index: auto;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: .45rem;
        margin-left: auto;
    }

    .header-right.header-right-map {
        top: auto;
        right: auto;
    }

    .header-user-id {
        width: 40px;
        height: 40px;
        max-width: none;
        padding: 0;
        border-radius: 999px;
        justify-content: center;
        border: 1px solid rgba(203, 213, 225, 0.85);
        background: rgba(255, 255, 255, 0.8);
    }

    .header-user-id .header-user-text {
        display: none;
    }

    .header-user-id .header-user-avatar {
        width: 1.65rem;
        height: 1.65rem;
        font-size: .68rem;
    }

    .menu-btn {
        width: 40px;
        height: 40px;
    }

    .header-menu-container {
        display: none;
    }

    .header-right.header-right-map .header-menu-container .menu-mosaic {
        right: 0;
        top: 48px;
    }

    .header-center {
        display: none;
    }

    .header-center .status-island {
        width: 100vw;
        max-width: 100vw;
        min-height: 2.5rem;
        border-radius: 0;
        padding: .4rem .45rem;
        gap: .35rem;
        justify-content: center;
        flex-wrap: nowrap;
        overflow: hidden;
        background: transparent;
        box-shadow: none;
        border: 0;
        pointer-events: auto;
    }

    .header-center .status-item {
        flex: 0 0 auto;
        justify-content: center;
        min-width: 0;
        gap: .22rem;
        white-space: nowrap;
        overflow: hidden;
        padding: .28rem .3rem;
        border-radius: 999px;
        border: 1px solid color-mix(in srgb, var(--status-color, #94a3b8) 45%, white 55%);
        background: color-mix(in srgb, var(--status-color, #94a3b8) 16%, white 84%);
        color: color-mix(in srgb, var(--status-color, #94a3b8) 72%, #0f172a 28%);
    }

    .header-center .status-label {
        font-size: .64rem;
        padding-right: .15rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-center .status-count {
        min-width: 1.08rem;
        height: 1.08rem;
        font-size: .62rem;
        padding: 0 .22rem;
        background: color-mix(in srgb, var(--status-color, #94a3b8) 26%, white 74%);
        border: 1px solid color-mix(in srgb, var(--status-color, #94a3b8) 40%, white 60%);
        color: color-mix(in srgb, var(--status-color, #94a3b8) 70%, #0f172a 30%);
    }

    .header-center .status-dot {
        display: none;
    }

    .mobile-tabbar {
        --map-sheet-drag-progress: 0;
        --mobile-tabbar-padding: .54rem;
        --mobile-tabbar-gap: .46rem;
        --mobile-tabbar-pill-width: calc((100% - (var(--mobile-tabbar-padding) * 2) - (var(--mobile-tabbar-gap) * 4)) / 5);
        position: fixed !important;
        left: 50%;
        width: min(96vw, 29rem);
        bottom: max(.38rem, calc(var(--mobile-tabbar-safe-bottom) + .38rem));
        transform: translateX(-50%);
        z-index: 9999;
        height: var(--mobile-tabbar-height);
        border-radius: 1.45rem;
        padding: var(--mobile-tabbar-padding);
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: var(--mobile-tabbar-gap);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.66) 0%, rgba(247, 251, 255, 0.52) 100%);
        border: 1px solid rgba(255, 255, 255, 0.84);
        box-shadow: 0 24px 44px rgba(15, 23, 42, 0.28), 0 8px 18px rgba(37, 99, 235, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.82);
        backdrop-filter: blur(20px) saturate(175%);
        -webkit-backdrop-filter: blur(20px) saturate(175%);
        animation: mobileTabbarLift .28s ease-out;
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        isolation: isolate;
        will-change: transform;
        transition: opacity .2s ease, transform .24s cubic-bezier(.2, .7, .2, 1);
    }

    body.mobile-tabbar-hidden .mobile-tabbar {
        opacity: 0;
        pointer-events: none;
        /* Morph effect: tabbar expands upward as if becoming the sheet */
        transform: translateX(-50%) translateY(-18%) scaleX(1.04) scaleY(1.18);
        transform-origin: bottom center;
    }

    body.mobile-detail-open .mobile-tabbar {
        opacity: 0;
        pointer-events: none;
        transform: translateX(-50%) translateY(12%) scale(0.98);
    }

    body.map-sheet-dragging .mobile-tabbar {
        opacity: calc(1 - var(--map-sheet-drag-progress, 0));
        pointer-events: none;
        transform: translateX(-50%)
            translateY(calc(var(--map-sheet-drag-progress, 0) * -18%))
            scaleX(calc(1 + (var(--map-sheet-drag-progress, 0) * 0.04)))
            scaleY(calc(1 + (var(--map-sheet-drag-progress, 0) * 0.18)));
        transform-origin: bottom center;
    }

    /* Drag-indicator pill rendered above the tabbar when sheet is collapsed (peek) */
    body.map-sheet-peek .mobile-tabbar::before {
        content: "";
        position: absolute;
        top: .08rem;
        left: 50%;
        transform: translateX(-50%);
        width: 2.3rem;
        height: .28rem;
        border-radius: 999px;
        background: rgba(100, 116, 139, 0.55);
        box-shadow: none;
        opacity: calc(1 - var(--map-sheet-drag-progress, 0));
        pointer-events: none;
    }

    .mobile-tabbar-active-pill {
        position: absolute;
        top: var(--mobile-tabbar-padding);
        left: calc(var(--mobile-tabbar-padding) + (var(--mobile-active-index, 0) * (var(--mobile-tabbar-pill-width) + var(--mobile-tabbar-gap))));
        width: var(--mobile-tabbar-pill-width);
        bottom: var(--mobile-tabbar-padding);
        border-radius: .9rem;
        border: 1px solid rgba(37, 99, 235, 0.62);
        background: linear-gradient(180deg, rgba(239, 246, 255, 0.96) 0%, rgba(219, 234, 254, 0.88) 100%);
        box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
        transition: left .32s cubic-bezier(.22, .9, .22, 1), opacity .2s ease;
        pointer-events: none;
    }

    .mobile-tabbar.no-active-pill .mobile-tabbar-active-pill {
        opacity: 0;
    }

    .mobile-tabbar-item {
        position: relative;
        border: 0;
        border-radius: .9rem;
        background: transparent;
        color: #526179;
        box-shadow: none;
        z-index: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: .14rem;
        padding: .3rem .28rem;
        font-size: .64rem;
        font-weight: 700;
        letter-spacing: .015em;
        transition: transform .14s ease, color .2s ease, opacity .2s ease;
    }

    .mobile-tabbar-item-icon {
        width: 1.38rem;
        height: 1.38rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: inherit;
    }

    .mobile-tabbar-item-icon i {
        font-size: 1rem;
    }

    .mobile-tabbar-item-icon img {
        width: 1.24rem;
        height: 1.24rem;
        object-fit: contain;
        pointer-events: none;
        filter: brightness(0) saturate(100%) invert(25%) sepia(22%) saturate(521%) hue-rotate(176deg) brightness(93%) contrast(89%);
        transition: filter .2s ease;
    }

    .mobile-tabbar-item-label {
        line-height: 1;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-tabbar-item.active {
        color: #1d4ed8;
        background: transparent;
        box-shadow: none;
    }

    .mobile-tabbar-item.active .mobile-tabbar-item-icon img {
        filter: brightness(0) saturate(100%) invert(24%) sepia(63%) saturate(2067%) hue-rotate(218deg) brightness(93%) contrast(88%);
    }

    .mobile-tabbar-item:active {
        transform: scale(.97);
    }

    .mobile-tabbar-item-search {
        padding: .3rem;
    }

    .mobile-tabbar-item-search .mobile-tabbar-item-label {
        display: none;
    }

    .mobile-tabbar-item-search .mobile-tabbar-item-icon {
        width: 1.5rem;
        height: 1.5rem;
    }

    .mobile-tabbar-item-search .mobile-tabbar-item-icon i {
        font-size: 1.16rem;
    }

    .mobile-tabbar-item-avatar {
        padding: .3rem;
    }

    .mobile-tabbar-item-avatar .mobile-tabbar-item-label {
        display: none;
    }

    .mobile-tabbar-item-avatar-badge {
        width: 1.6rem;
        height: 1.6rem;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: .64rem;
        font-weight: 800;
        letter-spacing: .03em;
        text-transform: uppercase;
        color: #ffffff;
        background: linear-gradient(180deg, #0ea5e9 0%, #1d4ed8 100%);
        box-shadow: inset 0 1px 1px rgba(255, 255, 255, .32), 0 4px 10px rgba(15, 23, 42, 0.18);
    }

    @keyframes mobileTabbarLift {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(12px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
}
