/* ===== Dashboard Trading — Thème Sombre ===== */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --bg-hover: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --green: #4CAF50;
    --green-dim: #238636;
    --red: #F44336;
    --red-dim: #da3633;
    --blue: #2196F3;
    --orange: #FF9800;
    --yellow: #f0c000;
    --purple: #a371f7;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

/* ===== Login Overlay ===== */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    text-align: center;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.15s;
}

.login-input:focus {
    border-color: var(--blue);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.login-btn:hover {
    background: #1976D2;
}

.login-error {
    margin-top: 12px;
    font-size: 13px;
    color: var(--red);
    min-height: 20px;
}

/* ===== Header / Status Bar ===== */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.status-bar .status-left,
.status-bar .status-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.status-dot.stopped { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.paused { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.stat-item {
    font-size: 13px;
    color: var(--text-secondary);
}
.stat-item .value {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.stat-item .positive { color: var(--green); }
.stat-item .negative { color: var(--red); }

/* ===== Main Grid ===== */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto auto auto auto auto;
    gap: 1px;
    background: var(--border);
    min-height: calc(100vh - 50px);
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    padding: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* ===== Chart Area ===== */
.chart-area {
    grid-column: 1;
    grid-row: 1 / 3;
    min-height: 500px;
}

#chart-container {
    width: 100%;
    height: 400px;
}

.tf-buttons {
    display: flex;
    gap: 4px;
}

.tf-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
}
.tf-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tf-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ===== Activity Ticker ===== */
.activity-ticker {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    overflow: hidden;
}

.ticker-row {
    display: flex;
    gap: 8px;
    padding: 4px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
    border-bottom: 1px solid rgba(48, 54, 61, 0.4);
}
.ticker-row:last-child { border-bottom: none; }
.ticker-row::-webkit-scrollbar { display: none; }
.ticker-row.older { opacity: 0.55; }

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.ticker-item.muted { color: var(--text-muted); }
.ticker-item.price-up { background: rgba(76,175,80,0.12); color: var(--green); }
.ticker-item.price-down { background: rgba(244,67,54,0.12); color: var(--red); }
.ticker-item.score-up { background: rgba(33,150,243,0.12); color: var(--blue); }
.ticker-item.score-down { background: rgba(255,152,0,0.12); color: var(--orange); }
.ticker-item.signal { background: rgba(76,175,80,0.15); color: var(--green); }
.ticker-item.no-signal { background: var(--bg-secondary); color: var(--text-muted); }
.ticker-item.alert { background: rgba(244,67,54,0.15); color: var(--red); }
.ticker-item.info { background: rgba(163,113,247,0.12); color: var(--purple); }
.ticker-item.neutral { background: var(--bg-secondary); color: var(--text-secondary); }

.ticker-item .ticker-icon { font-size: 11px; }

/* ===== Indicators Panel ===== */
.indicators-panel {
    grid-column: 2;
    grid-row: 1;
}

.indicator-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.indicator-row:last-child { border-bottom: none; }

.indicator-label { color: var(--text-secondary); }
.indicator-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 500;
}

.trend-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}
.trend-badge.bullish { background: var(--green-dim); color: var(--green); }
.trend-badge.bearish { background: rgba(244,67,54,0.2); color: var(--red); }
.trend-badge.neutral { background: var(--bg-card); color: var(--text-secondary); }

/* ===== Scoring Panel ===== */
.scoring-panel {
    grid-column: 1;
    grid-row: 3;
}

.score-global {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.score-number {
    font-size: 48px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
    line-height: 1;
}

.score-bar-container {
    flex: 1;
}

.score-bar {
    height: 12px;
    background: var(--bg-card);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
}

.score-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}

.score-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.score-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.score-item-label { color: var(--text-secondary); }
.score-item-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
}

.score-item-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
}

.score-item-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.signal-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
}
.signal-badge.strong { background: var(--green-dim); color: var(--green); }
.signal-badge.medium { background: rgba(255,152,0,0.2); color: var(--orange); }
.signal-badge.no-trade { background: var(--bg-card); color: var(--text-muted); }

/* ===== Sentiment Panel ===== */
.sentiment-panel {
    grid-column: 2;
    grid-row: 2 / 4;
}

/* ===== ML Panel ===== */
.ml-panel {
    grid-column: 2;
    grid-row: 4;
}

.ml-mode-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}
.ml-mode-badge.off { background: var(--text-muted); color: var(--bg-primary); }
.ml-mode-badge.shadow { background: var(--orange); color: var(--bg-primary); }
.ml-mode-badge.active { background: var(--green); color: var(--bg-primary); }

.ml-prob-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}
.ml-prob-gauge {
    display: flex;
    align-items: baseline;
}
.ml-prob-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.ml-prob-unit {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 2px;
}
.ml-prob-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.ml-separator {
    border-top: 1px solid var(--border);
    margin: 8px 0;
}
.ml-features-title {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}
.ml-feature-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 11px;
}
.ml-feature-name {
    color: var(--text-secondary);
    width: 100px;
    flex-shrink: 0;
}
.ml-feature-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}
.ml-feature-bar-fill {
    height: 100%;
    background: var(--purple);
    border-radius: 3px;
    transition: width 0.3s;
}
.ml-feature-pct {
    color: var(--text-muted);
    width: 35px;
    text-align: right;
    flex-shrink: 0;
}

/* ===== ML Tab ===== */
.ml-page {
    padding: 0;
}

/* --- Hero Evolution Block --- */
.ml-evo-hero {
    background: linear-gradient(135deg, #1a1f2e 0%, #1c2128 100%);
    border-bottom: 2px solid var(--border);
    padding: 24px 28px;
}
.ml-evo-hero-top {
    margin-bottom: 20px;
}
.ml-evo-hero-verdict {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.ml-evo-hero-badge {
    font-size: 14px;
    font-weight: 800;
    padding: 6px 20px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.ml-evo-hero-badge.improving { background: #238636; color: #fff; }
.ml-evo-hero-badge.stable { background: var(--orange); color: #000; }
.ml-evo-hero-badge.degrading { background: #da3633; color: #fff; }
.ml-evo-hero-badge.waiting { background: #484f58; color: #ccc; }
.ml-evo-hero-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.ml-evo-hero-grid {
    display: flex;
    align-items: stretch;
    gap: 20px;
}
.ml-evo-hero-col {
    flex: 1;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.ml-evo-col-title {
    width: 100%;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}
.ml-evo-before { border-left: 3px solid var(--text-muted); }
.ml-evo-after { border-left: 3px solid var(--blue); }

.ml-evo-metric {
    min-width: 80px;
}
.ml-evo-metric-val {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.ml-evo-metric-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ml-evo-hero-arrow {
    display: flex;
    align-items: center;
    font-size: 36px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

.ml-evo-hero-changes {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Secondary Grid --- */
.ml-grid-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
}
.ml-pred-card { grid-column: 1; grid-row: 1; }
.ml-feat-card { grid-column: 2; grid-row: 1; }
.ml-hist-card { grid-column: 1 / 3; grid-row: 2; }

.ml-status-grid {
    display: flex;
    gap: 24px;
    padding: 16px 0;
}
.ml-big-stat {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
}
.ml-big-number {
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.ml-big-unit {
    font-size: 16px;
    color: var(--text-secondary);
}
.ml-big-label {
    width: 100%;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.ml-info-grid {
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.ml-history-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.ml-feature-bar-lg {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.ml-feature-bar-lg .ml-feature-name {
    width: 120px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.ml-feature-bar-lg .ml-feature-bar-track {
    flex: 1;
    height: 10px;
    background: var(--bg-hover);
    border-radius: 5px;
    overflow: hidden;
}
.ml-feature-bar-lg .ml-feature-bar-fill {
    height: 100%;
    background: var(--purple);
    border-radius: 5px;
    transition: width 0.3s;
}
.ml-feature-bar-lg .ml-feature-pct {
    width: 50px;
    text-align: right;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 600;
    flex-shrink: 0;
}

.ml-verdict-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ml-verdict-badge.improving { background: #238636; color: #fff; }
.ml-verdict-badge.stable { background: var(--orange); color: var(--bg-primary); }
.ml-verdict-badge.degrading { background: #da3633; color: #fff; }
.ml-verdict-badge.waiting { background: var(--text-muted); color: var(--bg-primary); }

.ml-evo-comparison {
    display: flex;
    align-items: stretch;
    gap: 16px;
    padding: 8px 0;
}
.ml-evo-col {
    flex: 1;
    background: var(--bg-hover);
    border-radius: 6px;
    padding: 12px;
}
.ml-evo-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 8px;
}
.ml-evo-arrow {
    display: flex;
    align-items: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .ml-evo-hero-grid { flex-direction: column; }
    .ml-evo-hero-arrow { transform: rotate(90deg); justify-content: center; }
    .ml-grid-secondary { grid-template-columns: 1fr; }
    .ml-pred-card, .ml-feat-card, .ml-hist-card { grid-column: 1; grid-row: auto; }
}

/* ===== Positions ===== */
.positions-section {
    grid-column: 1 / 3;
    grid-row: 4;
}

.positions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.positions-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.positions-table td {
    padding: 10px 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.positions-table tr:hover td {
    background: var(--bg-hover);
}

/* ===== Trade History ===== */
.history-section {
    grid-column: 1 / 3;
    grid-row: 5;
}

/* ===== Performance ===== */
.performance-section {
    grid-column: 1 / 3;
    grid-row: 6;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1px;
    background: var(--border);
}

.perf-stats {
    background: var(--bg-secondary);
    padding: 16px;
}

.perf-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.perf-stat-row:last-child { border-bottom: none; }

.perf-charts {
    background: var(--bg-secondary);
    padding: 16px;
}

#equity-chart {
    width: 100%;
    height: 200px;
}

/* ===== Logs ===== */
.logs-section {
    grid-column: 1 / 3;
    grid-row: 7;
    max-height: 250px;
}

.logs-container {
    max-height: 200px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.8;
}

.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.log-time { color: var(--text-muted); }
.log-level-INFO { color: var(--blue); }
.log-level-SCAN { color: var(--purple); }
.log-level-TRADE { color: var(--green); }
.log-level-RISK { color: var(--orange); }
.log-level-WARNING { color: var(--yellow); }
.log-level-ERROR { color: var(--red); }
.log-level-DATA { color: var(--text-secondary); }
.log-level-INDIC { color: var(--text-secondary); }

/* ===== Controls ===== */
.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-start { background: var(--green-dim); color: var(--green); border-color: var(--green-dim); }
.btn-start:hover { background: var(--green); color: white; }
.btn-stop { background: rgba(244,67,54,0.15); color: var(--red); border-color: var(--red-dim); }
.btn-stop:hover { background: var(--red); color: white; }
.btn-default { background: var(--bg-card); color: var(--text-secondary); }
.btn-default:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-logout { background: rgba(158,158,158,0.15); color: var(--text-muted); border-color: var(--border); font-size: 11px; padding: 4px 10px; }
.btn-logout:hover { background: var(--red-dim); color: var(--red); border-color: var(--red-dim); }

.btc-price-display {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #ff9800;
    white-space: nowrap;
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.mode-switch select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
}

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

/* ===== Tab Bar ===== */
.tab-bar {
    display: flex;
    gap: 0;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    padding: 0 16px;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.5px;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); background: transparent; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Backtest Dashboard Grid ===== */
.backtest-dashboard {
    display: grid;
    grid-template-columns: 340px 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 1px;
    background: var(--border);
    min-height: calc(100vh - 90px);
}

.bt-config { grid-column: 1; grid-row: 1 / 3; }
.bt-kpis { grid-column: 2; grid-row: 1; }
.bt-equity { grid-column: 2; grid-row: 2; }
.bt-trades { grid-column: 1 / 3; grid-row: 3; }
.bt-optimizer { grid-column: 1 / 3; grid-row: 4; }

/* Backtest form */
.bt-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bt-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.bt-input {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}
.bt-input:focus { outline: none; border-color: var(--blue); }

.bt-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.bt-run-btn { width: 100%; }

.bt-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Progress bar */
.bt-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bt-progress-bar {
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}

.bt-progress-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.bt-status-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* Walk-forward section */
.bt-wf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bt-wf-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

/* Equity chart */
#bt-equity-chart {
    width: 100%;
    height: 250px;
}

/* Trades scroll */
.bt-trades-scroll {
    max-height: 350px;
    overflow-y: auto;
}

/* ===== News Dashboard ===== */
.news-dashboard {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1px;
    background: var(--border);
    min-height: calc(100vh - 90px);
}

.news-summary { grid-column: 1; grid-row: 1; }
.news-log { grid-column: 2; grid-row: 1; }

/* Risk badge */
.news-risk-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    background: var(--bg-card);
    color: var(--text-muted);
}
.news-risk-badge.low { background: var(--bg-card); color: var(--text-muted); }
.news-risk-badge.medium { background: rgba(255,152,0,0.15); color: var(--orange); }
.news-risk-badge.high { background: rgba(244,67,54,0.15); color: var(--red); }
.news-risk-badge.critical { background: rgba(244,67,54,0.3); color: #ff6b6b; }

/* Score display */
.news-score-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.news-gauge {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 8px;
}

.news-score-number {
    font-size: 48px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
    line-height: 1;
}

.news-score-label {
    font-size: 18px;
    color: var(--text-muted);
}

.news-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.news-source-bar {
    display: grid;
    grid-template-columns: 90px 1fr 30px;
    align-items: center;
    gap: 8px;
}

.news-bar-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.news-bar-track {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.news-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--blue);
    transition: width 0.5s ease;
}
.news-bar-fill.liq { background: var(--orange); }
.news-bar-fill.ob { background: var(--purple); }
.news-bar-fill.sec { background: var(--red); }

.news-bar-value {
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
    text-align: right;
}

/* Event log */
.news-log-scroll {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

/* Source badges in table */
.news-src-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}
.news-src-badge.mempool { background: rgba(33,150,243,0.15); color: var(--blue); }
.news-src-badge.liquidation { background: rgba(255,152,0,0.15); color: var(--orange); }
.news-src-badge.orderbook { background: rgba(163,113,247,0.15); color: var(--purple); }
.news-src-badge.sec { background: rgba(244,67,54,0.15); color: var(--red); }

/* Score cell coloring */
.news-score-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .chart-area { grid-column: 1; grid-row: auto; }
    .indicators-panel { grid-column: 1; grid-row: auto; }
    .scoring-panel { grid-column: 1; grid-row: auto; }
    .ml-panel { grid-column: 1; grid-row: auto; }
    .sentiment-panel { grid-column: 1; grid-row: auto; }
    .positions-section { grid-column: 1; grid-row: auto; }
    .history-section { grid-column: 1; grid-row: auto; }
    .performance-section { grid-column: 1; grid-row: auto; grid-template-columns: 1fr; }
    .logs-section { grid-column: 1; grid-row: auto; }

    .backtest-dashboard {
        grid-template-columns: 1fr;
    }
    .bt-config { grid-column: 1; grid-row: auto; }
    .bt-kpis { grid-column: 1; grid-row: auto; }
    .bt-equity { grid-column: 1; grid-row: auto; }
    .bt-trades { grid-column: 1; grid-row: auto; }
    .bt-optimizer { grid-column: 1; grid-row: auto; }

    .news-dashboard { grid-template-columns: 1fr; }
    .news-summary { grid-column: 1; grid-row: auto; }
    .news-log { grid-column: 1; grid-row: auto; }
}

/* ===== Status Action Badge ===== */
.status-action {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}
.status-action.no-move {
    background: rgba(139, 148, 158, 0.15);
    color: #8b949e;
}
.status-action.long-signal {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}
.status-action.short-signal {
    background: rgba(244, 67, 54, 0.2);
    color: #F44336;
}

/* ===== Trades Tab ===== */
.trades-kpis {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.kpi-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.kpi-label {
    font-size: 0.7rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kpi-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.trades-table-container {
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}
.trades-full-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.trades-full-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.trades-full-table th {
    background: var(--bg-primary);
    color: #8b949e;
    text-align: left;
    padding: 8px 8px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}
.trades-full-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.trades-full-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
.trades-full-table .status-open {
    color: #FF9800;
    font-weight: 700;
}
.trades-full-table .status-closed {
    color: #8b949e;
}

/* ===== Scan Logs Tab ===== */
.scan-logs-container {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}
.scan-logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.scan-logs-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.scan-logs-table th {
    background: var(--bg-primary);
    color: #8b949e;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}
.scan-logs-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.scan-logs-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
.scan-logs-table .action-no-move {
    color: #8b949e;
}
.scan-logs-table .action-long {
    color: #4CAF50;
    font-weight: 700;
}
.scan-logs-table .action-short {
    color: #F44336;
    font-weight: 700;
}
.scan-logs-table .score-high {
    color: #4CAF50;
}
.scan-logs-table .score-medium {
    color: #FF9800;
}
.scan-logs-table .score-low {
    color: #8b949e;
}

/* ===== Trade Grade Colors ===== */
.grade-A { color: #4CAF50; font-weight: 700; }
.grade-B { color: #2196F3; font-weight: 700; }
.grade-C { color: #FF9800; font-weight: 600; }
.grade-D { color: #F44336; font-weight: 600; }
.grade-F { color: #ff6b6b; font-weight: 700; }

/* ===== Review Button ===== */
.btn-review {
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(33, 150, 243, 0.15);
    color: var(--blue);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.btn-review:hover {
    background: var(--blue);
    color: white;
}

/* ===== Review Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 20px;
}

/* Review content inside modal */
.review-grade-big {
    font-size: 56px;
    font-weight: 800;
    font-family: 'SF Mono', 'Fira Code', monospace;
    text-align: center;
    line-height: 1;
    margin-bottom: 4px;
}

.review-category {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.review-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.review-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-card);
    padding: 10px 12px;
    border-radius: 6px;
}

.review-metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.review-metric-value {
    font-size: 16px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.review-metric-value.positive { color: #4CAF50; }
.review-metric-value.negative { color: #F44336; }

.review-context {
    display: flex;
    gap: 16px;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
}

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

.insight {
    padding: 8px 12px;
    background: var(--bg-card);
    border-left: 3px solid var(--blue);
    border-radius: 0 4px 4px 0;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.5;
}
