/* ===========================================================================
   APP SHELL - topbar + sidebar + content
   =========================================================================== */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* dvh fixes Android browser UI cutoff issues */
    overflow: hidden;
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────── */
.topbar {
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 18px 0 0;
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(1.8);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0;
    box-shadow: 0 1px 0 rgba(124,110,248,0.06), 0 4px 30px rgba(0,0,0,0.4);
}

/* Hamburger / menu toggle for mobile */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    border-radius: var(--r-sm);
    margin-left: 8px;
    transition: color var(--t);
    flex-shrink: 0;
}
.menu-toggle:hover { color: var(--text); }
.menu-toggle i { width: 18px; height: 18px; }

/* Hidden by default on desktop */
.mobile-profile, .mobile-only-menu { display: none; }

/* Brand sits inside topbar, aligned to sidebar width */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    width: var(--sidebar-w);
    flex-shrink: 0;
    padding: 0 18px;
    border-right: 1px solid var(--border);
    height: 100%;
}

.brand-mark {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--accent-glow), 0 0 0 1px rgba(124,110,248,0.18);
    border-radius: 9px;
    flex-shrink: 0;
    animation: brand-breathe 4s ease-in-out infinite;
}


@keyframes brand-breathe {
    0%, 100% { box-shadow: 0 4px 20px var(--accent-glow), 0 0 0 1px rgba(124,110,248,0.18); filter: brightness(1); }
    50%       { box-shadow: 0 6px 32px rgba(124,110,248,0.55), 0 0 0 1px rgba(124,110,248,0.35); filter: brightness(1.15); }
}

.brand-mark svg {
    width: 32px;
    height: 32px;
    display: block;
}


.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.brand-name {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 2px;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
}

.brand-name em { color: var(--accent-text); font-style: normal; }

.brand-sub {
    font-size: 9px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Topbar right controls */
.topbar-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    flex-shrink: 1;
    min-width: 0;
}

/* ── WS Status Pill: 3 states - live / reconnecting / offline ───────── */
.live-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color 0.3s ease;
    /* default / live */
    color: var(--profit);
}

.live-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    transition: background 0.3s;
}

/* Live - green pulse (default) */
.live-pill.ws-live { color: var(--profit); }
.live-pill.ws-live .live-dot {
    animation: live-pulse 2.4s ease-in-out infinite;
}

/* Reconnecting - amber slow pulse */
.live-pill.ws-reconnecting { color: var(--warn); }
.live-pill.ws-reconnecting .live-dot {
    animation: live-pulse-warn 1.6s ease-in-out infinite;
}

/* Offline - red, no animation */
.live-pill.ws-offline { color: var(--loss); }
.live-pill.ws-offline .live-dot { animation: none; }

@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 transparent; }
    50%       { opacity: 0.55; box-shadow: 0 0 0 5px var(--profit-dim); }
}
@keyframes live-pulse-warn {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 transparent; }
    50%       { opacity: 0.4; box-shadow: 0 0 0 5px var(--warn-dim); }
}

.utc-clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    white-space: nowrap;
    font-feature-settings: "tnum";
    text-shadow: 0 0 12px rgba(124,110,248,0.15);
}


/* ===========================================================================
   BODY AREA (sidebar + main content)
   =========================================================================== */
.body-area {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}


/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
    white-space: nowrap;
    will-change: width, transform;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--t-slow), width var(--t-slow);
    z-index: 40;
    box-shadow: 2px 0 20px rgba(0,0,0,0.25);
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.22s ease, color 0.22s ease, transform 0.18s var(--ease-out-back), box-shadow 0.22s ease;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

/* Ripple shimmer on hover */
.nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(124,110,248,0.08) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
    pointer-events: none;
    border-radius: inherit;
}
.nav-item:hover::after { transform: translateX(100%); }

.nav-item i {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    transition: color 0.22s ease, transform 0.25s var(--ease-out-back), filter 0.22s;
}

.nav-item .nav-label {
    flex: 1;
    transition: opacity var(--t-slow), transform 0.2s ease;
}

.nav-item:hover {
    background: rgba(124,110,248,0.07);
    color: var(--text-2);
    transform: translateX(3px);
}
.nav-item:hover i { transform: scale(1.15); }

.nav-item:active {
    transform: translateX(1px) scale(0.98);
    transition-duration: 0.08s;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(124,110,248,0.2) 0%, rgba(124,110,248,0.08) 100%);
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px rgba(124,110,248,0.22), 0 2px 16px rgba(124,110,248,0.12);
}

.nav-item.active i {
    color: var(--accent);
    filter: drop-shadow(0 0 6px rgba(124,110,248,0.7));
}

/* Active indicator bar */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 18%; bottom: 18%;
    width: 3px;
    background: linear-gradient(180deg, var(--accent-3), var(--accent-2));
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 12px rgba(124,110,248,0.8);
    animation: active-bar-glow 2s ease-in-out infinite;
}

@keyframes active-bar-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(124,110,248,0.6); }
    50%      { box-shadow: 0 0 16px rgba(124,110,248,1); }
}

/* Staggered nav entrance animation */
.sidebar-nav .nav-item { animation: navSlideIn 0.4s var(--ease-out-expo) both; }
.nav-item:nth-child(1) { animation-delay: 0.05s; }
.nav-item:nth-child(2) { animation-delay: 0.1s; }
.nav-item:nth-child(3) { animation-delay: 0.15s; }
.nav-item:nth-child(4) { animation-delay: 0.2s; }
.nav-item:nth-child(5) { animation-delay: 0.25s; }
.nav-item:nth-child(6) { animation-delay: 0.3s; }

@keyframes navSlideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}


.sidebar-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-md), transparent);
    margin: 10px 10px;
}

.sidebar-section-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 1.4px;
    padding: 8px 12px 4px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 39;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}


/* ─── MAIN CONTENT ───────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 28px 56px;
}


/* ─── PANELS ─────────────────────────────────────────────────────────────── */
.panel { display: none; }
.panel.active {
    display: block;
    animation: panelReveal 0.4s var(--ease-out-expo);
}

@keyframes panelReveal {
    from { opacity: 0; transform: translateY(10px) scale(0.998); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered children reveal inside panels */
.panel.active > .panel-header    { animation: childReveal 0.35s 0.05s var(--ease-out-expo) both; }
.panel.active > .cards-grid,
.panel.active > .exec-positions-layout,
.panel.active > .hist-filters,
.panel.active > .tbl-wrap,
.panel.active > .news-container   { animation: childReveal 0.4s 0.12s var(--ease-out-expo) both; }
.panel.active > .hist-summary     { animation: childReveal 0.4s 0.18s var(--ease-out-expo) both; }

@keyframes childReveal {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Panel header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

.panel-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel-title {
    font-size: 22px;
    font-weight: 900;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--text) 30%, var(--accent-3) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.panel-sub {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.1px;
}


