* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
:root {
    --bg: #0f1117; --bg2: #1a1d28; --bg3: #242836;
    --text: #e1e4ea; --text2: #8b8fa3; --accent: #4f8cff;
    --green: #22c55e; --red: #ef4444; --yellow: #eab308;
    --border: #2d3148; --radius: 6px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
#navbar { display: flex; align-items: center; padding: 0 1.5rem; height: 48px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--accent); margin-right: 2rem; }
.nav-links { display: flex; gap: 0.25rem; flex: 1; }
.nav-right { display: flex; gap: 0.5rem; align-items: center; }
.nav-link { padding: 0.5rem 1rem; color: var(--text2); text-decoration: none; border-radius: var(--radius); font-size: 0.875rem; }
.nav-link:hover { color: var(--text); background: var(--bg3); }
.nav-link.active { color: var(--accent); background: var(--bg3); }
#app { padding: 1rem 1.5rem; }
.page { display: none; }
.page.active { display: block; }
#page-data.active { display: flex; flex-direction: column; height: calc(100vh - 80px); }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-header h2 { font-size: 1.25rem; font-weight: 600; }
.controls { display: flex; gap: 0.5rem; align-items: center; }
.btn { padding: 0.4rem 0.8rem; border: 1px solid var(--border); background: var(--bg3); color: var(--text); border-radius: var(--radius); cursor: pointer; font-size: 0.8rem; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-save { background: #166534; border-color: #166534; color: #fff; }
.btn-save:hover { background: #15803d; }
.btn-lg { padding: 0.6rem 1.5rem; font-size: 0.9rem; }
select, input[type="text"], input[type="number"] { padding: 0.4rem 0.6rem; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); font-size: 0.8rem; }
select:focus, input:focus { outline: none; border-color: var(--accent); }
label { display: block; margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--text2); }
label select, label input { display: block; width: 100%; margin-top: 0.2rem; }
label input[type="checkbox"] { display: inline; width: auto; margin-right: 0.3rem; }
#chart-container { min-height: 200px; flex: 1; height: auto; background: #131722; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1rem; overflow: hidden; }
#signal-chart-container { min-height: 180px; height: calc(30vh); background: #131722; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 0.5rem; overflow: hidden; }
#backtest-chart-container { min-height: 280px; height: calc(50vh - 80px); background: #131722; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 0; display: flex; flex-direction: column; overflow: hidden; resize: vertical; padding-bottom: 8px; }
#backtest-chart-container > div:first-child { flex: 3; min-height: 150px; }
#backtest-chart-container > div:last-child { flex: 2; min-height: 100px; border-top: 1px solid var(--border); }
.split-panel { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; min-height: calc(100vh - 120px); }
.panel-left { background: var(--bg2); padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); max-height: calc(100vh - 120px); overflow-y: auto; }
.panel-right { background: var(--bg2); padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.config-section h3, .config-section h4 { margin-bottom: 0.75rem; font-size: 0.9rem; }
.config-section h4 { margin-top: 1rem; color: var(--text2); }
#feature-checkboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; margin-bottom: 1rem; }
#feature-checkboxes label { font-size: 0.75rem; margin-bottom: 0; }
.training-dashboard { display: flex; flex-direction: column; flex: 1; }
.training-dashboard h3 { margin-bottom: 0.75rem; }
.status-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.75rem; background: var(--bg3); margin-bottom: 0.75rem; }
.status-badge.training { background: var(--accent); color: #fff; }
.status-badge.complete { background: var(--green); color: #fff; }
.progress-bar { position: relative; height: 24px; background: var(--bg); border-radius: 12px; margin-bottom: 0.75rem; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: linear-gradient(90deg, #1e3a5f, #1e40af); border-radius: 12px; transition: width 0.3s, background 0.5s; width: 0%; }
.progress-fill.complete { background: linear-gradient(90deg, #14532d, #064e3b) !important; }
.progress-text { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.7); }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.metric { background: var(--bg); padding: 0.5rem; border-radius: var(--radius); text-align: center; }
.metric-label { display: block; font-size: 0.7rem; color: var(--text2); }
.metric-value { display: block; font-size: 1rem; font-weight: 600; margin-top: 0.2rem; }
#chart-reward { width: 100% !important; height: 100% !important; background: var(--bg); border-radius: var(--radius); }
.chart-title { font-size: 0.8rem; color: var(--text2); padding: 0.4rem 0; }
.inline-label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; color: var(--text2); margin-bottom: 0; }
.inline-label select { margin-top: 0; }
.ind-row { display: flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); font-size: 0.75rem; }
.ind-name { flex: 1; }
.ind-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ind-row input[type="checkbox"] { width: 14px; height: 14px; flex-shrink: 0; cursor: pointer; }
.ind-row input[type="number"] { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 3px; padding: 0.15rem 0.3rem; font-size: 0.7rem; }
.btn-x { background: none; border: none; color: var(--red); cursor: pointer; font-size: 1rem; padding: 0 0.3rem; }
#indicator-list select { width: auto; min-width: 160px; max-width: 280px; margin-top: 0.3rem; }
.info-panel { background: var(--bg2); padding: 0.75rem; border-radius: var(--radius); border: 1px solid var(--border); font-size: 0.8rem; color: var(--text2); }
dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; min-width: 320px; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; }
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h3 { margin-bottom: 1rem; }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 1rem; justify-content: flex-end; }
.trades-table { font-size: 0.8rem; overflow-x: auto; }
.trades-table table { width: 100%; border-collapse: collapse; }
.trades-table th, .trades-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; }
.trades-table th { color: var(--text2); font-weight: 500; }
.signal-list { background: var(--bg2); border-radius: var(--radius); border: 1px solid var(--border); padding: 0.75rem; overflow-x: auto; }
.signal-item { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.signal-buy { color: var(--green); } .signal-sell { color: var(--red); } .signal-hold { color: var(--text2); }
/* Landing */
.landing { max-width: 900px; margin: 0 auto; padding: 2rem 0; }
.hero { text-align: center; margin-bottom: 3rem; }
.hero h1 { font-size: 2.2rem; font-weight: 700; line-height: 1.2; margin-bottom: 1rem; background: linear-gradient(135deg, var(--accent), #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { color: var(--text2); font-size: 1rem; max-width: 600px; margin: 0 auto 1.5rem; line-height: 1.6; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.feature-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.feature-card:hover { border-color: var(--accent); }
.feature-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.feature-card h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.feature-card p { font-size: 0.8rem; color: var(--text2); line-height: 1.5; }
/* Toast */
#toast-container { position: fixed; top: 60px; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.6rem 1rem; border-radius: var(--radius); font-size: 0.8rem; animation: slideIn 0.3s; max-width: 320px; }
.toast-error { background: var(--red); color: #fff; }
.toast-success { background: #15803d; color: #fff; }
.toast-info { background: var(--accent); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.advanced-opts { margin: 0.4rem 0; font-size: 0.8rem; }
.advanced-opts summary { cursor: pointer; color: var(--text2); padding: 0.3rem 0; }
.advanced-opts summary:hover { color: var(--text); }
.help-dialog { max-width: 580px; }
.help-dialog p { font-size: 0.8rem; color: var(--text2); line-height: 1.6; margin-bottom: 0.5rem; }
.bt-tab, .admin-tab, .train-tab { opacity: 0.5; }
.bt-tab.active, .admin-tab.active, .train-tab.active { opacity: 1; background: var(--accent); border-color: var(--accent); color: #fff; }
.sig-row:hover, .trade-row:hover { background: var(--bg3); }
.sig-row.selected, .trade-row.selected { background: var(--accent); color: #fff; }
@media (max-width: 768px) { .split-panel { grid-template-columns: 1fr; } .hero h1 { font-size: 1.5rem; } }
