.top-user-menu {
    position: relative;
}

.top-user-menu__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    inset-inline-start: auto;
    width: min(300px, calc(100vw - 24px));
    background: #fff;
    border: 1px solid #e5e9f2;
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
    padding: 14px;
    z-index: 60;
}

.top-user-menu__dropdown[hidden] {
    display: none !important;
}

.top-user-menu__name {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
}

.top-user-menu__meta {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 12px;
}

.top-user-menu__balance {
    margin: 10px 0 0;
    border-radius: 10px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 8px;
    font-size: 12px;
    font-weight: 700;
}

.top-user-menu__logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 0;
    padding: 10px 12px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fff5f5;
    color: #b91c1c;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.top-user-menu__logout:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.top-user-menu__logout svg {
    flex-shrink: 0;
}

.top-user-menu__body {
    margin-bottom: 0;
}

.top-user-menu__footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e9f2;
}

.top-user-menu__profile-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: none;
    border-radius: 16px;
    background: rgba(0, 192, 154, 0.08);
    color: #00c09a;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.top-user-menu__profile-trigger:hover {
    background: rgba(0, 192, 154, 0.15);
}

.top-user-menu__profile-trigger:active {
    transform: scale(0.95);
}

.top-user-menu__profile-trigger svg {
    flex-shrink: 0;
}

.top-user-menu__profile-trigger-label {
    display: none;
}

@media (min-width: 640px) {
    .top-user-menu__profile-trigger {
        padding: 10px 20px;
    }

    .top-user-menu__profile-trigger-label {
        display: inline;
    }
}

:root {
    --kimia-mobile-tab-inner: clamp(54px, 14vw, 62px);
    --kimia-mobile-tab-offset: calc(var(--kimia-mobile-tab-inner) + env(safe-area-inset-bottom, 0px));
}

.mobile-unified-tabs {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    /* Below sheets/modals (100+) and FAB (40); was 220 and covered modal footers */
    z-index: 48;
    box-sizing: border-box;
    min-height: var(--kimia-mobile-tab-offset);
    padding-inline: max(6px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #d8dee9;
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    touch-action: manipulation;
}

.mobile-unified-tabs.mobile-unified-tabs--two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-unified-tab {
    box-sizing: border-box;
    min-width: 0;
    min-height: var(--kimia-mobile-tab-inner);
    padding: 6px 4px 8px;
    text-decoration: none;
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(3px, 1vw, 5px);
    font-size: clamp(10px, 2.85vw, 12px);
    font-weight: 800;
    line-height: 1.15;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.mobile-unified-tab:active {
    background: #f1f5f9;
}

.mobile-unified-tab__icon {
    width: clamp(20px, 5.5vw, 24px);
    height: clamp(20px, 5.5vw, 24px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-unified-tab__icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mobile-unified-tab__label {
    max-width: 100%;
    padding: 0 2px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-unified-tab.is-active {
    color: #4338ca;
    background: #eef2ff;
    box-shadow: inset 0 2px 0 #6366f1;
}

@media (max-width: 900px) {
    body:has(.mobile-unified-tabs:not(.d-none)) {
        padding-bottom: var(--kimia-mobile-tab-offset);
    }
}

@media (max-width: 360px) {
    .mobile-unified-tab {
        padding-inline: 2px;
        font-size: 10px;
    }

    .mobile-unified-tab__icon {
        width: 20px;
        height: 20px;
    }
}

/* Hide bottom nav while any overlay/sheet/modal is open on mobile */
@media (max-width: 900px) {
    body:has(.products-hub-sheet-overlay.is-open) .mobile-unified-tabs,
    body:has(.products-hub-sheet.is-open) .mobile-unified-tabs,
    body:has(.sheet-overlay:not(.d-none)) .mobile-unified-tabs,
    body:has(.platform-sheet:not(.d-none)) .mobile-unified-tabs,
    body:has(.kimia-channel-sheet-root:not(.d-none)) .mobile-unified-tabs,
    body:has(.apple-modal-overlay:not(.d-none)) .mobile-unified-tabs,
    body:has(.modal-overlay:not(.d-none)) .mobile-unified-tabs,
    body.platform-sheet-open .mobile-unified-tabs {
        display: none !important;
    }
}

@media (min-width: 901px) {
    .mobile-unified-tabs {
        display: none !important;
    }

    body:has(.mobile-unified-tabs) {
        padding-bottom: 0;
    }
}

/* Hamburger nav: narrow desktop window only — hidden on touch phones (bottom tabs instead) */
#mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) and (hover: hover) and (pointer: fine) {
    #mobile-menu-btn {
        display: inline-flex;
    }
}

@media (max-width: 768px) and (hover: none),
(max-width: 768px) and (pointer: coarse) {
    #mobile-menu-btn,
    .mobile-nav-overlay,
    .mobile-nav-drawer {
        display: none !important;
    }
}
