:root {
    --bg-dark: #0a0b10;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #e0e0e0;
    --text-secondary: #888890;
    --gold: #ffd700;
    --call-cyan: #00f0ff;
    --put-magenta: #ff0055;
    --positive-green: #00ff9d;
    --negative-red: #ff3333;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ... (Skip unchanged headers) ... */

/* Metric Units (Bento Card) */
.metric-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Subtle Contour */
    border-radius: 6px;
    padding: 0.75rem;
    position: relative;
    display: flex;
    flex-direction: column;
    /* width: 100%;  REMOVED TO FIX OVERFLOW */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    /* Clip content */
}

/* Header */
header {
    height: 48px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    color: var(--gold);
}

.tag {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
    margin-left: 0.5rem;
    text-transform: uppercase;
}

.tag.live {
    background: rgba(255, 0, 0, 0.1);
    color: #ff5555;
    border-color: #ff5555;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.7;
    }
}

/* Main Layout - 50/50 Split */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 50% 50%;
    /* SPLIT SCREEN */
    height: calc(100vh - 48px);
    overflow: hidden;
}

/* Unified Sidebar Panel */
#sidebar-panel {
    background: #08090d;
    /* Darker than body */
    border-right: 1px solid var(--glass-border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    /* Tighter gap */
    overflow-y: auto;
    height: 100%;
}

/* Scrollbar Tweaks */
#sidebar-panel::-webkit-scrollbar {
    width: 4px;
}

#sidebar-panel::-webkit-scrollbar-thumb {
    background: #222;
}

/* Widget Internals (Densified Bento) */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.control-group label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.value-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    color: var(--gold);
    font-weight: 700;
}

/* Metric Units (Bento Card) */
.metric-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Subtle Contour */
    border-radius: 6px;
    padding: 0.75rem;
    position: relative;
    display: flex;
    flex-direction: column;
    /* width: 100%; REMOVED */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    /* Modern Depth */
    margin-bottom: 0;
    /* Let flex gap handle it */
    overflow: hidden;
}


/* Dividers */
.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    /* Minimal */
    margin: 0.25rem 0;
}

/* TACTICAL BENTO GRID */
.tactical-zone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.metric-title {
    font-size: 0.6rem;
    color: #666;
    /* Subtler */
    text-transform: uppercase;
    margin-bottom: 0.25rem;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 500;
    color: #eee;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
}

/* Right Side: Charts */
.dashboard {
    padding: 0;
    display: grid;
    grid-template-rows: 40% 60%;
    /* Gamma on Top, TV Bottom */
    height: 100%;
    background: #050505;
}

.chart-container {
    padding: 1rem;
    position: relative;
    border-bottom: 1px solid var(--glass-border);
}

.chart-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
    pointer-events: none;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.chart-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Slider */
input[type=range] {
    -webkit-appearance: none;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    margin-top: -5px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #333;
    border-radius: 2px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #111;
    border: 1px solid var(--glass-border);
    width: 600px;
    max-width: 90vw;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid #333;
    padding-bottom: 1rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.guide-item {
    margin-bottom: 1.5rem;
}

.guide-term {
    display: block;
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.guide-expl {
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.4;
}

/* Heatmap Grid */
.heat-cell {
    flex: 1;
    height: 100%;
    margin: 0 1px;
    background: #333;
    transition: opacity 0.2s;
    cursor: crosshair;
}

.heat-cell:hover {
    opacity: 0.8;
    border: 1px solid white;
}

.heat-green {
    background: #00ff9d !important;
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.3);
}

.heat-red {
    background: #ff3333 !important;
    box-shadow: 0 0 10px rgba(255, 51, 51, 0.3);
}

.heat-grey {
    background: rgba(255, 255, 255, 0.05) !important;
}

#flow-heatmap {
    /* Auto layout in flex container */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 5px;
}

/* -------------------------------------
 * MOBILE RESPONSIVENESS (max-width: 1024px)
 * ------------------------------------- */
@media (max-width: 1024px) {

    body {
        height: auto !important;
        overflow: visible !important;
    }

    /* Use CSS Grid on Main to explicitly place children regardless of nest */
    main {
        height: auto !important;
        overflow: visible !important;
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto auto !important;
        grid-template-areas:
            "gex"
            "sidebar"
            "tv" !important;
        width: 100% !important;
    }

    /* Force the dashboard container to vanish, unleashing its children to the grid */
    .dashboard {
        display: contents !important;
    }

    #gex-chart-frame {
        grid-area: gex !important;
        width: 100% !important;
        min-height: 300px;
        border-bottom: 2px solid #333 !important;
    }

    #sidebar-panel {
        grid-area: sidebar !important;
        border-right: none !important;
        border-bottom: 1px solid var(--glass-border);
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-top: 20px !important;
    }

    #tv-chart-frame {
        grid-area: tv !important;
        width: 100% !important;
        min-height: 500px;
    }

    /* Stack the top Bento metrics */
    .tactical-zone-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    .logo {
        font-size: 0.9rem;
    }

    /* Expand AI Advisor / COT widget containers */
    .metric-card,
    .strategy-card {
        width: 100% !important;
    }
}