* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: #0e1117;
    color: #e6e6e6;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
}

/* ============ HEADER ============ */
header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #131722;
    border-bottom: 1px solid #1f2937;
    gap: 20px;
    z-index: 10;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}
.subtitle {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.header-center { display: flex; align-items: center; }

.view-switcher {
    display: flex;
    gap: 4px;
    background: #0e1117;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #1f2937;
}
.view-btn {
    background: transparent;
    color: #888;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.view-btn:hover { color: #e6e6e6; background: #1f2937; }
.view-btn.active { background: #26a69a; color: #ffffff; }

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

#symbolSelector,
#tfSelector {
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#symbolSelector {
    background: #26a69a;
    color: #ffffff;
    font-weight: 700;
}

.price-box { text-align: right; }
.price-label {
    font-size: 10px; color: #888;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.price-value {
    font-size: 20px; font-weight: 600; color: #26a69a;
    font-variant-numeric: tabular-nums;
}

.status-box {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: #888;
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #666; transition: background 0.2s;
}
.status-dot.connected { background: #26a69a; box-shadow: 0 0 8px #26a69a; }
.status-dot.error { background: #ef5350; }

.icon-btn {
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.icon-btn:hover { background: #2a2e39; }

/* ============ REPLAY BAR ============ */
.replay-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: #0e1117;
    border-bottom: 1px solid #1f2937;
    gap: 16px;
    z-index: 9;
    min-height: 44px;
    font-size: 12px;
}

.replay-mode-switch {
    display: flex;
    gap: 4px;
    background: #131722;
    padding: 3px;
    border-radius: 4px;
    border: 1px solid #2a2e39;
}

.mode-btn {
    background: transparent;
    color: #888;
    border: none;
    padding: 6px 14px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.15s;
}
.mode-btn:hover { color: #e6e6e6; }
.mode-btn.active { background: #26a69a; color: #ffffff; }

.replay-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.replay-label {
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.replay-select {
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    min-width: 120px;
}

.replay-select-small {
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.replay-slider {
    flex: 1;
    max-width: 400px;
    min-width: 150px;
    accent-color: #26a69a;
    cursor: pointer;
}

.replay-time {
    font-family: monospace;
    color: #26a69a;
    font-weight: 700;
    min-width: 55px;
    font-size: 13px;
}

.replay-btn {
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 40px;
}
.replay-btn:hover { background: #26a69a; color: #ffffff; }
.replay-btn.playing { background: #ef5350; }

.replay-info {
    color: #888;
    font-size: 11px;
    font-family: monospace;
    min-width: 200px;
    text-align: right;
}

/* ============ MAIN LAYOUT (3 Panes) ============ */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    min-height: 0;
    height: 100%;
}

.pane {
    position: relative;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    flex: 1;
    background: #0e1117;
}

#orderflow-pane { border-right: 1px solid #1f2937; }
#footprint-pane { }
#heatmap-pane { }

#chart { width: 100%; height: 100%; position: relative; z-index: 1; }
#footprint-canvas, #heatmap-canvas {
    width: 100%; height: 100%;
    display: block; position: absolute; top: 0; left: 0;
    z-index: 1;
}
.bubble-overlay {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none; z-index: 2;
}

/* --- SPLIT VIEW: Orderflow + Footprint (Hidden: Heatmap) --- */
body.view-split #heatmap-pane { display: none !important; }
body.view-split #orderflow-pane { width: 50%; }
body.view-split #footprint-pane { width: 50%; }

/* --- FULL SCREEN: Only one pane --- */
body.view-orderflow #footprint-pane,
body.view-orderflow #heatmap-pane { display: none !important; }
body.view-orderflow #orderflow-pane { width: 100%; border-right: none; }

body.view-footprint #orderflow-pane,
body.view-footprint #heatmap-pane { display: none !important; }
body.view-footprint #footprint-pane { width: 100%; }

body.view-heatmap #orderflow-pane,
body.view-heatmap #footprint-pane { display: none !important; }
body.view-heatmap #heatmap-pane { width: 100%; }

/* ============ PLACEHOLDER & MISC ============ */
.placeholder-msg {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center; color: #555;
    z-index: 1; pointer-events: none;
}
.placeholder-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.placeholder-title { font-size: 16px; font-weight: 600; color: #666; margin-bottom: 4px; }
.placeholder-sub { font-size: 12px; color: #444; }

.reset-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(31, 41, 55, 0.85);
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    z-index: 5;
    transition: all 0.15s;
    opacity: 0.6;
}
.reset-btn:hover {
    background: #26a69a;
    color: #ffffff;
    opacity: 1;
}

.loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(14, 17, 23, 0.9);
    color: #26a69a;
    padding: 16px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #26a69a;
    display: none;
    z-index: 500;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(38, 166, 154, 0.3);
}

/* ============ FOOTER ============ */
footer {
    flex-shrink: 0;
    padding: 6px 24px;
    background: #131722;
    border-top: 1px solid #1f2937;
    font-size: 11px;
    color: #666;
    z-index: 10;
}

/* ============ SETTINGS PANEL ============ */
.settings-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 999;
}
.settings-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.settings-panel {
    position: fixed;
    top: 0; right: 0;
    width: 380px;
    height: 100vh;
    background: #131722;
    border-left: 1px solid #2a2e39;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}
.settings-panel.active { transform: translateX(0); }

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #1f2937;
}
.settings-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}
.settings-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}
.settings-close:hover { background: #1f2937; color: #e6e6e6; }

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.settings-section {
    margin-bottom: 24px;
}
.settings-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #26a69a;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #1f2937;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
    color: #c6c6c6;
    cursor: pointer;
    user-select: none;
}

.settings-row input[type="checkbox"] {
    order: 2;
    width: 36px;
    height: 20px;
    appearance: none;
    background: #2a2e39;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}
.settings-row input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #888;
    border-radius: 50%;
    transition: all 0.2s;
}
.settings-row input[type="checkbox"]:checked { background: #26a69a; }
.settings-row input[type="checkbox"]:checked::after {
    left: 18px;
    background: #ffffff;
}

.settings-row span:first-child {
    flex: 1;
    order: 1;
}

.label-indent {
    padding-left: 4px;
    color: #888;
    font-size: 12px;
}

.settings-number {
    order: 2;
    width: 70px;
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    text-align: center;
}

.settings-select {
    order: 2;
    background: #1f2937;
    color: #e6e6e6;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}

.settings-footer {
    padding: 16px 20px;
    border-top: 1px solid #1f2937;
    display: flex;
    gap: 10px;
    background: #0e1117;
}

.btn-save, .btn-cancel {
    flex: 1;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}
.btn-save { background: #26a69a; color: #ffffff; }
.btn-save:hover { background: #22c4b7; }
.btn-cancel { background: #2a2e39; color: #e6e6e6; }
.btn-cancel:hover { background: #3a3e49; }

.snap-live-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #26a69a;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    z-index: 6;
    transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(38, 166, 154, 0.4);
}
.snap-live-btn:hover {
    background: #22c4b7;
    transform: translateY(-1px);
}

/* ============ USER PROFILE DROPDOWN ============ */
.user-profile {
    position: relative;
    display: inline-block;
    margin-left: 15px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #26a69a;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: 0.2s;
}

.user-avatar:hover {
    background: #22c4b7;
    transform: scale(1.05);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 45px;
    background: #131722;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    width: 220px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    z-index: 100;
}

.user-dropdown.active {
    display: block;
}

.user-info {
    padding: 15px;
}

.user-name {
    font-weight: bold;
    color: #e6e6e6;
    font-size: 14px;
    margin-bottom: 4px;
}

.user-email {
    color: #888;
    font-size: 12px;
    margin-bottom: 8px;
}

.user-plan {
    font-size: 11px;
    color: #26a69a;
    background: rgba(38, 166, 154, 0.1);
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
}

.user-dropdown hr {
    border: 0;
    border-top: 1px solid #2a2e39;
    margin: 0;
}

.logout-btn {
    display: block;
    padding: 12px 15px;
    color: #ef5350;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 83, 80, 0.1);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}