:root {
    --bg-main: #070913;
    --bg-card: rgba(13, 17, 33, 0.7);
    --bg-card-hover: rgba(22, 28, 54, 0.85);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    
    --primary: #00e676;
    --primary-glow: rgba(0, 230, 118, 0.15);
    --accent: #00b0ff;
    --accent-glow: rgba(0, 176, 255, 0.15);
    --danger: #ff1744;
    --danger-glow: rgba(255, 23, 68, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar Controls */
.sidebar {
    width: 320px;
    background: rgba(10, 12, 26, 0.95);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    box-shadow: 0 0 15px var(--primary-glow);
}

.brand h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(90deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"], input[type="number"] {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.2s;
    outline: none;
    width: 100%;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 176, 255, 0.15);
}

/* ── Custom Dropdown ─────────────────────────────── */
.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-select__trigger:hover,
.custom-select.open .custom-select__trigger {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 176, 255, 0.15);
}

.custom-select__arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.custom-select.open .custom-select__arrow {
    transform: rotate(180deg);
    border-top-color: var(--accent);
}

.custom-select__options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #0d1121;
    border: 1px solid rgba(0, 176, 255, 0.25);
    border-radius: 8px;
    overflow: hidden;
    z-index: 999;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.custom-select.open .custom-select__options {
    display: block;
    animation: dropIn 0.15s ease-out;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.custom-select__option {
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.custom-select__option:last-child {
    border-bottom: none;
}

.custom-select__option:hover {
    background: rgba(0, 176, 255, 0.08);
    color: var(--text-primary);
}

.custom-select__option.selected {
    color: var(--accent);
    background: rgba(0, 176, 255, 0.06);
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #00e676, #00b0ff);
    color: #040814;
    border: none;
    border-radius: 8px;
    padding: 0.8rem;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 230, 118, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 230, 118, 0.35);
}

/* Main Content Pane */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.main-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(7, 9, 19, 0.5);
    backdrop-filter: blur(10px);
}

.tab-nav {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 0.2rem;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Content Area */
.content-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grid layout for stats & charts */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.card-primary { border-left: 3px solid var(--primary); }
.card-accent { border-left: 3px solid var(--accent); }
.card-danger { border-left: 3px solid var(--danger); }

/* Charts & Details Panel */
.panel-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
}

.chart-wrapper {
    flex-grow: 1;
    position: relative;
    height: 320px;
}

/* Lists and Tables */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
}

.table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 0.88rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: #0d1121;
    z-index: 10;
}

td {
    color: var(--text-secondary);
}

tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.01);
}

.text-green { color: var(--primary) !important; font-weight: 600; }
.text-red { color: var(--danger) !important; font-weight: 600; }

/* Live simulator panel styling */
.live-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.live-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.terminal {
    background: #03050a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    height: 300px;
    overflow-y: auto;
    color: #e2e8f0;
}

.terminal-line {
    margin-bottom: 0.35rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--accent);
}

.terminal-line.error {
    border-left-color: var(--danger);
    color: var(--danger);
}

.terminal-line.success {
    border-left-color: var(--primary);
    color: var(--primary);
}

.live-control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.live-btn-group {
    display: flex;
    gap: 1rem;
}

.btn-action {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-buy {
    background: var(--primary);
    color: #040814;
}

.btn-sell {
    background: var(--danger);
    color: #fff;
}

.btn-buy:hover { box-shadow: 0 4px 15px rgba(0, 230, 118, 0.3); }
.btn-sell:hover { box-shadow: 0 4px 15px rgba(255, 23, 68, 0.3); }

/* Quantitative Research Lab Styles */
.research-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.research-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.research-tab-btn.active {
    color: var(--accent);
    background: var(--accent-glow);
    box-shadow: inset 0 0 0 1px rgba(0, 176, 255, 0.15);
}

.research-sub-pane {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.research-sub-pane.active {
    display: grid;
    grid-template-columns: 1.1fr 1.3fr;
    gap: 1.5rem;
}

.research-stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.research-stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.research-stat-val {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Alpha Factor Correlation Heatmap Grid */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    background: rgba(255, 255, 255, 0.01);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.heatmap-cell {
    aspect-ratio: 1.5 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
    cursor: default;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.heatmap-cell:hover {
    transform: scale(1.05);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.heatmap-header-cell {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
