/* ── Single source of truth for sidebar width ──────────────────── */
:root {
    --sidebar-width: 160px;
}

/* ── Top bar ───────────────────────────────────────────────────── */
.topbar {
    box-sizing: border-box;
    position: fixed;
    top: 0; left: 0; width: 100%;
    height: 44px;
    background: #0d0d0d;
    border-bottom: 1px solid #1f1f1f;
    z-index: 200;
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

/* ── Topbar logo ───────────────────────────────────────────────── */
.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

/* Push all body content below the top bar */
body {
    padding-top: 44px;
}

/* ── Left sidebar ──────────────────────────────────────────────── */
#sidebar {
    box-sizing: border-box;
    position: fixed;
    left: 0; top: 44px; bottom: 0;
    width: var(--sidebar-width);
    background: #0d0d0d;
    border-right: 1px solid #1f1f1f;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Section labels */
.sb-section-label {
    font-size: 10px;
    color: #333;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0 12px;
    margin-top: 16px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

/* Nav links */
.sb-nav {
    display: flex;
    flex-direction: column;
    padding: 0 8px;
    flex-shrink: 0;
}

.sb-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    letter-spacing: -0.01em;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 2px solid transparent;
    margin-left: -2px;
}

.sb-link:hover {
    background: #1a1a1a;
    color: #fff;
}

.sb-link.active {
    background: #1a1a1a;
    color: #fff;
    border-left-color: #22c55e;
}

.sb-link.sb-disabled {
    pointer-events: none;
    opacity: 0.35;
    cursor: default;
}


/* ── Topbar universal search ───────────────────────────────────── */
.topbar-search {
    position: relative;
    width: 220px;
    margin-left: 16px;
    flex-shrink: 0;
}

.topbar-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.3);
    pointer-events: none;
    display: flex;
    align-items: center;
}

#tb-search, #tb-search-mobile {
    width: 100%;
    height: 28px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    font-family: inherit;
    padding: 0 10px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

#tb-search { padding-left: 28px; }

/* iOS Safari auto-zooms the page on focus of any input with a computed
   font-size under 16px, which shifts the visual viewport away from the
   autocomplete dropdown's layout position and makes it look like it never
   appeared. Keep the mobile input's font-size at/above that threshold. */
#tb-search-mobile { font-size: 16px; }

#tb-search::placeholder, #tb-search-mobile::placeholder {
    color: rgba(255,255,255,0.35);
}

#tb-search:focus, #tb-search-mobile:focus {
    border-color: rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.08);
}

/* ── Topbar mobile search (shown in place of the desktop search below 768px) ── */
.topbar-search-mobile {
    display: none;
    position: relative;
}

.tb-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    z-index: 9999;
    overflow: hidden;
    display: none;
}

.tb-search-dropdown.open {
    display: block;
}

/* The mobile topbar search dropdown is the only dropdown nested inside a
   position:fixed ancestor (.topbar). iOS Safari has a known rendering bug
   where absolutely-positioned descendants of a fixed ancestor can fail to
   repaint/show after an input-focus viewport change, which is why this one
   (unlike the portfolio/compare dropdowns, which aren't inside anything
   fixed) can fail to appear on a real iPhone even though it's open in the
   DOM. Making it a top-level `fixed` element itself — like .topbar and
   #sb-hamburger, which render reliably on iOS — avoids the bug. sidebar.js
   computes its left/top/width from the input's viewport rect on each render.) */
#tb-search-dropdown-mobile {
    position: fixed;
    right: auto;
}

.tb-search-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tb-search-item:hover,
.tb-search-item.focused {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.tb-si-symbol {
    font-weight: 500;
    color: #fff;
    min-width: 48px;
    flex-shrink: 0;
}

.tb-si-name {
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Topbar actions (auth) ─────────────────────────────────────── */
.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 0 4px;
}

.topbar-actions .nav-auth {
    margin-left: 0;
}

@media (max-width: 1200px) {
    .topbar-actions .nav-auth { margin-left: 0; }
}

@media (max-width: 768px) {
    .topbar { padding-right: 56px; }
    .topbar-search { display: none; }
    .topbar-search-mobile {
        display: block;
        flex: 1;
        min-width: 0;
        margin: 0 10px;
    }
    .topbar-actions { margin-left: 0; }
    .topbar-actions .nav-auth { margin-left: 0; }
}

/* ── Topbar ticker ─────────────────────────────────────────────── */
.topbar-ticker {
    display: flex;
    align-items: center;
    gap: 0;
    overflow: hidden;
    flex-shrink: 1;
}

.topbar-ticker .ntb-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    white-space: nowrap;
}

.topbar-ticker .ntb-sep {
    font-size: 11px;
    color: rgba(255,255,255,0.12);
    user-select: none;
    flex-shrink: 0;
}

.topbar-ticker .ntb-label {
    font-size: 11px;
    font-weight: 300;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.03em;
}

.topbar-ticker .ntb-price {
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,0.6);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.topbar-ticker .tb-change {
    font-size: 11px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
}

.topbar-ticker .tb-change.up   { color: #22c55e; }
.topbar-ticker .tb-change.down { color: #f87171; }
.topbar-ticker .tb-change.flat { color: rgba(255,255,255,0.3); }

@media (max-width: 900px) {
    .topbar-ticker .ntb-item:nth-child(n+6),
    .topbar-ticker .ntb-sep:nth-child(n+5) { display: none; }
}

@media (max-width: 768px) {
    .topbar-ticker { display: none; }
}

/* ── Hamburger button ──────────────────────────────────────────── */
#sb-hamburger {
    display: none;
    position: fixed;
    top: 4px; right: 12px;
    z-index: 201;
    background: transparent;
    border: 1px solid #2a2a2a;
    color: rgba(255,255,255,0.7);
    font-size: 16px;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

#sb-hamburger:hover { background: rgba(255,255,255,0.06); color: #fff; }

#sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99;
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    body {
        padding-left: 0 !important;
    }

    #sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
        transition: transform 0.25s ease;
        z-index: 150;
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sb-hamburger {
        display: flex;
    }

    #sb-overlay.open {
        display: block;
    }
}

