/* Liquidity Map — Dark Theme */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2234;
    --bg-hover: #243048;
    --border: #2a3550;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --sell-pressure: #ef4444;
    --sell-light: #fca5a5;
    --buy-pressure: #22c55e;
    --buy-light: #86efac;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #06b6d4;
    --cascade: #a855f7;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-sans: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Layout */
#app {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    grid-template-rows: 48px 1fr 200px;
    height: 100vh;
    gap: 1px;
    background: var(--border);
}

#header {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 100;
}

#header h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

#header .status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

#header .status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

#header .status .dot.connected { background: var(--buy-pressure); }
#header .status .dot.running { background: var(--buy-pressure); animation: pulse 1.5s infinite; }
#header .status .dot.paused { background: var(--warning); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Controls */
#controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

#controls button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-sans);
    transition: all 0.15s;
}

#controls button:hover { background: var(--bg-hover); border-color: var(--accent); }
#controls button.active { background: var(--accent); border-color: var(--accent); }

#controls select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 12px;
    font-family: var(--font-sans);
}

/* Left Panel */
#left-panel {
    background: var(--bg-secondary);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Right Panel */
#right-panel {
    background: var(--bg-secondary);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Main View */
#main-view {
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

#terrain-canvas {
    width: 100%;
    height: 100%;
}

/* Bottom Panel */
#bottom-panel {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    display: flex;
    overflow: hidden;
}

/* Panel Sections */
.panel-section {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Market Tree */
.tree-node {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.1s;
}

.tree-node:hover { background: var(--bg-hover); }

.tree-node .symbol { font-family: var(--font-mono); font-weight: 500; }
.tree-node .price { font-family: var(--font-mono); margin-left: auto; font-size: 12px; }
.tree-node .change { font-family: var(--font-mono); font-size: 11px; min-width: 55px; text-align: right; }
.tree-node .change.positive { color: var(--buy-pressure); }
.tree-node .change.negative { color: var(--sell-pressure); }

/* Participant Cards */
.participant-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 12px;
}

.participant-card .header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.participant-card .archetype {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.participant-card .state-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.state-badge.active { background: rgba(34,197,94,0.15); color: var(--buy-pressure); }
.state-badge.stressed { background: rgba(245,158,11,0.15); color: var(--warning); }
.state-badge.triggered { background: rgba(239,68,68,0.15); color: var(--sell-pressure); }
.state-badge.liquidating { background: rgba(220,38,38,0.25); color: #f87171; animation: pulse 0.8s infinite; }

.constraint-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.constraint-bar .fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

.constraint-bar .fill.safe { background: var(--buy-pressure); }
.constraint-bar .fill.warning { background: var(--warning); }
.constraint-bar .fill.danger { background: var(--sell-pressure); }

/* Opportunity Cards */
.opportunity-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 12px;
}

.opportunity-card .type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    font-weight: 600;
}

.opportunity-card .edge {
    font-family: var(--font-mono);
    color: var(--buy-pressure);
    font-weight: 600;
}

.opportunity-card .confidence {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Heatmap Legend */
.heatmap-legend {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 11px;
    z-index: 10;
}

.heatmap-legend .gradient {
    width: 120px;
    height: 12px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--sell-pressure), var(--bg-primary), var(--buy-pressure));
    margin: 4px 0;
}

.heatmap-legend .labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
}

/* Bottom Charts */
.chart-container {
    flex: 1;
    padding: 12px;
    border-right: 1px solid var(--border);
    min-width: 0;
}

.chart-container:last-child { border-right: none; }

.chart-container h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.chart-container canvas, .chart-container svg {
    width: 100%;
    height: calc(100% - 24px);
}

/* Signal Indicators */
.signal-list {
    max-height: 200px;
    overflow-y: auto;
}

.signal-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
    font-family: var(--font-mono);
}

.signal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.signal-dot.volume { background: var(--info); }
.signal-dot.impact { background: var(--warning); }
.signal-dot.imbalance { background: var(--sell-pressure); }
.signal-dot.scheduled { background: var(--cascade); }

/* Cascade Indicator */
.cascade-indicator {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid var(--cascade);
    border-radius: var(--radius);
    padding: 4px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cascade);
    z-index: 10;
    display: none;
}

.cascade-indicator.active {
    display: block;
    animation: cascadePulse 0.5s infinite;
}

@keyframes cascadePulse {
    0%, 100% { box-shadow: 0 0 8px rgba(168,85,247,0.3); }
    50% { box-shadow: 0 0 20px rgba(168,85,247,0.6); }
}

/* Tick Counter */
.tick-counter {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Regime Badge */
.regime-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.regime-badge.calm { background: rgba(34,197,94,0.15); color: var(--buy-pressure); }
.regime-badge.trending { background: rgba(59,130,246,0.15); color: var(--accent); }
.regime-badge.volatile { background: rgba(245,158,11,0.15); color: var(--warning); }
.regime-badge.crisis { background: rgba(239,68,68,0.2); color: var(--sell-pressure); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 1200px) {
    #app {
        grid-template-columns: 240px 1fr 280px;
    }
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow);
    max-width: 280px;
}

.tooltip .title { font-weight: 600; margin-bottom: 4px; }
.tooltip .value { font-family: var(--font-mono); }
