/* ==========================================================================
   Site header — self-contained (no Tailwind rebuild required)
   ========================================================================== */
.hd {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255, 255, 255, .97);
    border-bottom: 1px solid #e6ecf5;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.hd *, .hd *::before, .hd *::after { box-sizing: border-box; }
.hd a { text-decoration: none; color: inherit; }
.hd button { font-family: inherit; }

.hd-inner {
    max-width: 80rem; margin: 0 auto; height: 64px; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

/* Brand */
.hd-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hd-logo { height: 36px; width: auto; flex-shrink: 0; object-fit: contain; }
.hd-logo-fallback {
    width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #2563eb, #60a5fa); box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}
.hd-name { font-size: 19px; font-weight: 800; letter-spacing: -.025em; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Desktop nav */
.hd-nav { display: none; flex: 1; justify-content: center; align-items: center; gap: 2px; }
.hd-link {
    position: relative; padding: 8px 14px; border-radius: 10px; font-size: 14.5px; font-weight: 500; color: #475569;
    transition: color .15s, background .15s;
}
.hd-link:hover { color: #0f172a; background: #f3f6fa; }
.hd-link.is-active { color: #2563eb; font-weight: 600; background: #eff4ff; }

/* Right tools */
.hd-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hd-icons { display: flex; align-items: center; gap: 2px; }
.hd-icons .mr-1 { margin-right: 0 !important; }
.hd-icon-btn {
    position: relative; width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: #475569; cursor: pointer;
    transition: color .15s, background .15s;
}
.hd-icon-btn:hover { color: #0f172a; background: #f1f5f9; }
.hd-more[aria-expanded="true"] { background: #f1f5f9; color: #0f172a; }
.hd-icon-btn:focus-visible, .hd-avatar:focus-visible, .hd-item:focus-visible, .hd-link:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.hd-dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 999px; background: #ef4444; box-shadow: 0 0 0 2px #fff; }

.hd-balance {
    display: flex; align-items: center; gap: 10px; height: 42px; padding: 4px 4px 4px 12px;
    border: 1px solid #e6ecf5; border-radius: 12px; background: #fff;
}
.hd-balance-text { display: flex; flex-direction: column; line-height: 1.1; }
.hd-balance-text small { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #94a3b8; }
.hd-balance-text b { font-size: 14px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.hd-balance-add {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff !important;
    background: #2563eb; box-shadow: 0 2px 6px rgba(37, 99, 235, .3); transition: background .15s, transform .15s;
}
.hd-balance-add:hover { background: #1d4ed8; }
.hd-balance-add:active { transform: scale(.94); }

.hd-avatar {
    width: 38px; height: 38px; padding: 0; border-radius: 999px; overflow: hidden; cursor: pointer;
    border: 2px solid #fff; box-shadow: 0 0 0 1px #e2e8f0; background: #4f46e5; transition: box-shadow .15s;
}
.hd-avatar:hover { box-shadow: 0 0 0 2px #c7d7fb; }
.hd-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.hd-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px;
    border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.hd-btn-primary { background: #2563eb; color: #fff !important; box-shadow: 0 1px 2px rgba(37, 99, 235, .3); }
.hd-btn-primary:hover { background: #1d4ed8; }
.hd-btn-ghost { background: #fff; color: #334155 !important; border-color: #e2e8f0; }
.hd-btn-ghost:hover { background: #f8fafc; border-color: #d5dce7; }

/* Account / navigation menu */
.hd-acc { position: relative; display: flex; align-items: center; }
.hd-overlay { position: fixed; inset: 64px 0 0 0; z-index: 110; background: rgba(15, 23, 42, .32); }
.hd-menu {
    position: fixed; z-index: 120; top: 72px; left: 12px; right: 12px;
    max-height: calc(100vh - 72px - 80px); max-height: calc(100dvh - 72px - 80px); overflow-y: auto; overscroll-behavior: contain;
    background: #fff; border: 1px solid #e6ecf5; border-radius: 18px;
    box-shadow: 0 24px 48px -16px rgba(15, 23, 42, .28), 0 2px 6px rgba(15, 23, 42, .05);
    transform-origin: top right;
}
.hd-t-in { transition: opacity .16s ease, transform .18s cubic-bezier(.2, .8, .2, 1); }
.hd-t-out { transition: opacity .12s ease, transform .12s ease; }
.hd-t-from { opacity: 0; transform: translateY(-6px) scale(.98); }
.hd-t-to { opacity: 1; transform: none; }

.hd-menu-user { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; }
.hd-menu-user > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hd-menu-user b { font-size: 15px; font-weight: 700; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-menu-user small { font-size: 12.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-menu-av {
    width: 42px; height: 42px; border-radius: 999px; flex-shrink: 0; display: grid; place-items: center;
    background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; font-size: 17px; font-weight: 700;
}

.hd-menu-bal {
    position: relative; overflow: hidden; isolation: isolate; min-height: 112px; margin: 0 12px 6px; padding: 14px 16px;
    border-radius: 16px; color: #fff; background: linear-gradient(90deg, #6366f1 0%, #7a5cf4 52%, #6b4fe3 100%);
    box-shadow: 0 10px 22px -12px rgba(99, 102, 241, .75);
}
.hd-menu-bal-text { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 64%; }
.hd-menu-bal small { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, .9); }
.hd-menu-bal b { font-size: 22px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hd-menu-bal .hd-btn { margin-top: 8px; height: 30px; padding: 0 12px; gap: 5px; font-size: 12.5px; border-radius: 9px; background: #fff; color: #4f46e5 !important; box-shadow: none; }
.hd-menu-bal .hd-btn:hover { background: #eef2ff; }
.hd-menu-bal-art {
    position: absolute; z-index: 0; right: -14px; bottom: -22px; width: 128px; height: 128px; object-fit: cover; pointer-events: none;
    -webkit-mask-image: radial-gradient(closest-side, #000 70%, transparent 100%);
    mask-image: radial-gradient(closest-side, #000 70%, transparent 100%);
}

.hd-menu-list { display: flex; flex-direction: column; padding: 6px 8px 8px; }
.hd-cap { padding: 12px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #94a3b8; }
.hd-item {
    display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px;
    font-size: 14.5px; font-weight: 500; color: #334155; transition: background .12s, color .12s;
}
.hd-item span { flex: 1; min-width: 0; }
.hd-item svg { flex-shrink: 0; color: #94a3b8; transition: color .12s; }
.hd-item:hover { background: #f5f7fb; color: #0f172a; }
.hd-item:hover svg { color: #2563eb; }
.hd-item.is-active { background: #eff4ff; color: #2563eb; font-weight: 600; }
.hd-item.is-active svg { color: #2563eb; }
.hd-badge {
    font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
}

.hd-menu-foot { margin: 0; padding: 8px; border-top: 1px solid #eef2f7; }
.hd-logout {
    width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 10px; background: none; cursor: pointer;
    font-size: 14.5px; font-weight: 600; color: #dc2626; text-align: left; transition: background .12s;
}
.hd-logout:hover { background: #fef2f2; }

.hd-menu-guest { padding: 16px; border-bottom: 1px solid #eef2f7; }
.hd-menu-guest b { display: block; font-size: 16px; font-weight: 700; color: #0f172a; }
.hd-menu-guest small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.5; color: #64748b; }
.hd-menu-guest-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.hd-menu-guest-btns .hd-btn { padding: 0 10px; }

/* Language switch */
.hd-lang { display: inline-flex; align-items: center; padding: 3px; border-radius: 10px; background: #f1f5f9; }
.hd-lang a { display: grid; place-items: center; min-width: 34px; height: 28px; padding: 0 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: #64748b !important; transition: background .15s, color .15s; }
.hd-lang a:hover { color: #0f172a !important; }
.hd-lang a.is-on { background: #fff; color: #0f172a !important; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.hd-menu-lang { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 8px 8px; padding: 10px; border-radius: 12px; background: #f8fafc; }
.hd-menu-lang > span { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 500; color: #334155; }
.hd-menu-lang > span svg { color: #94a3b8; }
.hd-menu-lang .hd-lang { background: #e9eef5; }

/* Visibility helpers (scoped so they win over component display rules) */
.hd .hd-sm-up, .hd .hd-md-up { display: none; }
.hd .hd-md-down, .hd .hd-md-down-flex, .hd .hd-lg-down, .hd .hd-lg-down-flex { display: flex; }

@media (min-width: 640px) {
    .hd-inner { padding: 0 24px; }
    .hd .hd-sm-up { display: flex; }
    /* Notification panel opens right under the header */
    body .notif-panel { top: 72px; }
}
@media (min-width: 768px) {
    .hd .hd-md-up { display: flex; }
    .hd .hd-md-down, .hd .hd-md-down-flex { display: none; }
    .hd-overlay { display: none !important; }
    .hd-menu { position: absolute; top: calc(100% + 12px); left: auto; right: 0; width: 300px; max-height: calc(100vh - 100px); }
}
@media (min-width: 1024px) {
    .hd { background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); }
    .hd-inner { height: 72px; padding: 0 32px; }
    .hd-logo { height: 40px; }
    .hd-logo-fallback { width: 40px; height: 40px; }
    .hd-name { font-size: 20px; }
    .hd-nav { display: flex; }
    .hd .hd-lg-down, .hd .hd-lg-down-flex { display: none; }
    body .notif-panel { top: 80px; }
}
@media (max-width: 380px) {
    .hd-name { font-size: 17px; }
    .hd-logo { height: 32px; }
    .hd-tools { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
    .hd-t-in, .hd-t-out { transition: none; }
}
