/* Account menu — hover + click, viewport-safe positioning via JS */

.tb-tools {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: nowrap;
    position: relative;
    z-index: 80;
}

.tb-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    height: 42px;
    padding: 0 .9rem 0 .5rem;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 800;
    font-size: .84rem;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}

.tb-ico {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.tb-ico svg { width: 15px; height: 15px; }

.tb-pill.shop {
    background: linear-gradient(180deg, #8fd84f, #62a832);
    color: #fff;
    box-shadow: 0 8px 18px rgba(127, 201, 69, .28);
}

.tb-pill.shop .tb-ico { background: rgba(255,255,255,.22); color: #fff; }
.tb-pill.shop:hover { transform: translateY(-1px); color: #fff; }

.tb-pill.login {
    background: #fff;
    color: #222;
    border-color: #e8ecef;
    box-shadow: 0 4px 12px rgba(0,0,0,.04);
}

.tb-pill.login .tb-ico { background: #f3f4f6; color: #444; }
.tb-pill.login:hover { border-color: #7fc945; color: #62a832; }

.tb-account {
    position: relative;
    z-index: 90;
}

.tb-user {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    height: 44px;
    padding: .22rem .6rem .22rem .28rem;
    border-radius: 12px;
    border: 1px solid #e5e8ec;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
    cursor: pointer;
    font: inherit;
    color: #1f2a1a;
    max-width: min(220px, 42vw);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.tb-user:hover,
.tb-account.is-open .tb-user,
.tb-account.is-hover .tb-user {
    border-color: #d7ebc4;
    box-shadow: 0 0 0 3px rgba(127, 201, 69, .12);
    background: #fff;
}

.tb-user:focus-visible {
    outline: 2px solid #7fc945;
    outline-offset: 2px;
}

.tb-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
}

.tb-avatar img {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: cover;
    display: block;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1.5px #d8efb8;
    background: #f3f5f6;
}

.tb-dot {
    position: absolute;
    left: -1px;
    bottom: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}

.tb-meta {
    min-width: 0;
    display: grid;
    line-height: 1.2;
    text-align: right;
}

.tb-name {
    font-weight: 800;
    font-size: .84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-role {
    font-size: .68rem;
    font-weight: 700;
    color: #8a9198;
}

.tb-chev {
    color: #9aa3af;
    display: inline-flex;
    margin-inline-start: .1rem;
    transition: transform .2s ease, color .15s ease;
}

.tb-chev svg { width: 14px; height: 14px; }

.tb-account.is-open .tb-chev,
.tb-account.is-hover .tb-chev {
    transform: rotate(180deg);
    color: #62a832;
}

/* Bridge so mouse can travel from button → panel without closing */
.tb-account::after {
    content: "";
    position: absolute;
    top: 100%;
    inset-inline: -8px;
    height: 14px;
    display: none;
}

.tb-account.is-open::after,
.tb-account.is-hover::after {
    display: block;
}

.tb-menu {
    position: absolute;
    top: calc(100% + 10px);
    inset-inline-start: 0;
    width: min(304px, calc(100vw - 1.25rem));
    z-index: 360;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px) scale(.98);
    transform-origin: top var(--tb-origin-x, right);
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.tb-menu.is-fixed {
    position: fixed !important;
    margin: 0;
    inset-inline-start: auto;
    z-index: 360;
}

.tb-menu.is-fixed:not([hidden]),
.tb-menu.is-open:not([hidden]),
.tb-menu.is-hover:not([hidden]),
.tb-account.is-open .tb-menu,
.tb-account.is-hover .tb-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.tb-menu.is-sheet:not([hidden]) {
    transform: translateY(0) scale(1);
}

.tb-menu[hidden] {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.tb-menu-card {
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 16px;
    box-shadow:
        0 20px 48px rgba(15, 23, 42, .16),
        0 4px 12px rgba(15, 23, 42, .06);
    overflow: auto;
    max-height: inherit;
    -webkit-overflow-scrolling: touch;
}

.tb-menu.is-sheet .tb-menu-card {
    border-radius: 18px;
    box-shadow:
        0 12px 40px rgba(15, 23, 42, .22),
        0 2px 10px rgba(15, 23, 42, .08);
}

.tb-menu-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .95rem 1rem;
    background:
        radial-gradient(circle at 100% 0%, rgba(127, 201, 69, .16), transparent 55%),
        linear-gradient(180deg, #f7fbf3, #fff 70%);
    border-bottom: 1px solid #eef1f4;
}

.tb-menu-head img {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #d8efb8;
    background: #f3f5f6;
    flex: 0 0 auto;
}

.tb-menu-who {
    min-width: 0;
}

.tb-menu-who strong {
    display: block;
    font-size: .92rem;
    color: #1f2937;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-menu-who span {
    display: block;
    margin-top: .2rem;
    color: #8a9198;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-menu-who b {
    font-weight: 700;
    color: #64748b;
}

.tb-menu-quick {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .35rem;
    padding: .7rem .65rem .45rem;
}

.tb-menu-quick a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .55rem .2rem;
    border-radius: 12px;
    text-decoration: none;
    color: #334155;
    font-weight: 700;
    font-size: .68rem;
    text-align: center;
    transition: background .15s ease, color .15s ease;
}

.tb-menu-quick a:hover,
.tb-menu-quick a:focus-visible {
    background: #f3faeb;
    color: #3f7a18;
}

.tb-menu-quick .mi {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: #f4f6f8;
    color: #64748b;
    display: inline-grid;
    place-items: center;
    transition: background .15s ease, color .15s ease;
}

.tb-menu-quick a:hover .mi,
.tb-menu-quick a:focus-visible .mi {
    background: #e7f6d4;
    color: #62a832;
}

.tb-menu-quick .mi svg {
    width: 16px;
    height: 16px;
}

.tb-menu-links {
    padding: .25rem .5rem .35rem;
    display: grid;
    gap: .1rem;
}

.tb-menu-links a,
.tb-logout button {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 11px;
    padding: .58rem .65rem;
    color: #1f2937;
    font: inherit;
    font-weight: 700;
    font-size: .84rem;
    text-align: right;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.tb-menu-links a:hover,
.tb-menu-links a:focus-visible {
    background: #f3faeb;
    color: #3f7a18;
}

.tb-menu-links .mi,
.tb-logout .mi {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: #f4f6f8;
    color: #64748b;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.tb-menu-links .mi svg,
.tb-logout .mi svg {
    width: 14px;
    height: 14px;
}

.tb-menu-links a:hover .mi,
.tb-menu-links a:focus-visible .mi {
    background: #e7f6d4;
    color: #62a832;
}

.tb-logout {
    margin: 0;
    padding: .35rem .5rem .55rem;
    border-top: 1px solid #eef1f4;
}

.tb-logout button { color: #be123c; }

.tb-logout button:hover,
.tb-logout button:focus-visible {
    background: #fff1f2;
}

.tb-logout button .mi {
    background: #fff1f2;
    color: #e11d48;
}

.tb-scrim {
    position: fixed;
    inset: 0;
    z-index: 350;
    background: rgba(15, 23, 42, .34);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.tb-scrim.is-on {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

html.tb-menu-open,
html.tb-menu-open body {
    overflow: hidden;
}

html.tb-menu-open .tb-menu.is-sheet {
    touch-action: pan-y;
}

/* Site header tweaks */
.rh-actions .tb-tools { gap: .4rem; }
.rh-actions .tb-pill.login { display: none; }
.rh-actions .tb-user {
    min-height: 44px;
    border-radius: 12px;
}

@media (max-width: 900px) {
    .tb-meta { display: none; }
    .tb-chev { display: none; }
    .tb-user {
        padding: .22rem;
        width: 44px;
        height: 44px;
        justify-content: center;
        max-width: none;
    }
    .tb-menu-quick {
        grid-template-columns: repeat(2, 1fr);
    }
    .tb-menu-quick a {
        flex-direction: row;
        justify-content: flex-start;
        gap: .55rem;
        padding: .55rem .65rem;
        font-size: .8rem;
        text-align: right;
    }
}

@media (max-width: 720px) {
    .tb-txt { display: none; }
    .tb-pill {
        padding: 0;
        width: 42px;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tb-menu,
    .tb-user,
    .tb-chev,
    .tb-scrim {
        transition: none !important;
    }
}
