/* QORE Backtest Lab — V6.6.5 step 3 */

.bt-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1rem;
}
.bt-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 1rem 1.2rem;
}
.bt-card h3 {
    margin: 0 0 0.7rem;
    font-size: 1rem;
    color: #f0f6fc;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.bt-muted { color: #8b949e; font-size: 0.78rem; font-weight: 400; }

.bt-submit { grid-column: 1 / span 2; }
.bt-jobs { grid-column: 1; }
.bt-leaderboard { grid-column: 2; }
.bt-equity { grid-column: 1 / span 2; }

.bt-form-row { display: flex; gap: 0.8rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.bt-form-row label {
    display: flex; flex-direction: column; gap: 0.25rem;
    font-size: 0.78rem; color: #8b949e; flex: 1; min-width: 160px;
}
.bt-form-row input, .bt-form-row select {
    background: #0d1117; border: 1px solid #30363d; color: #c9d1d9;
    padding: 0.45rem 0.6rem; border-radius: 4px; font-size: 0.85rem;
    font-family: "JetBrains Mono", monospace;
}
.bt-form-row input:focus, .bt-form-row select:focus {
    outline: none; border-color: #58a6ff;
}
.bt-params-label { width: 100%; }
.bt-params-label textarea {
    width: 100%; background: #0d1117; border: 1px solid #30363d; color: #c9d1d9;
    padding: 0.55rem 0.7rem; border-radius: 4px; font-size: 0.8rem;
    font-family: "JetBrains Mono", monospace;
}
.bt-params-summary {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: #0d1117;
    border: 1px dashed #30363d;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: "JetBrains Mono", monospace;
    color: #c9d1d9;
    word-break: break-word;
    line-height: 1.5;
}
.bt-params-summary .bt-muted { margin-right: 0.5rem; }
#bt-params-summary-combos { color: #d4a72c; font-weight: 700; margin-left: 0.4rem; }
.bt-form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.5rem; }
.bt-btn {
    background: #238636; color: #fff; border: 1px solid #2ea043;
    padding: 0.5rem 1.2rem; border-radius: 4px; cursor: pointer;
    font-weight: 600; font-size: 0.85rem;
}
.bt-btn:hover { background: #2ea043; }
.bt-btn:disabled { background: #6b7280; cursor: not-allowed; opacity: 0.7; }
.bt-status { font-size: 0.8rem; color: #8b949e; }
.bt-status.bt-ok { color: #3fb950; }
.bt-status.bt-err { color: #ff7b72; }

/* ---- Tables ---- */
.bt-table-wrap {
    max-height: 320px; overflow: auto; border: 1px solid #30363d; border-radius: 4px;
}
.bt-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.bt-table thead { position: sticky; top: 0; background: #0d1117; z-index: 1; }
.bt-table th, .bt-table td {
    padding: 0.4rem 0.55rem; border-bottom: 1px solid #21262d; text-align: right;
    font-family: "JetBrains Mono", monospace; white-space: nowrap;
}
.bt-table th {
    color: #8b949e; font-weight: 600; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.bt-table tr.bt-job-row, .bt-table tr.bt-lb-row { cursor: pointer; }
.bt-table tr:hover { background: #1c2128; }
.bt-table tr.selected { background: #1f6feb33 !important; }
.bt-time { color: #8b949e; font-size: 0.72rem; }
.bt-rank { color: #d4a72c; font-weight: 700; }
.bt-params-cell { text-align: left !important; color: #c9d1d9; }
.bt-pos { color: #3fb950; }
.bt-neg { color: #ff7b72; }

.bt-promote-btn {
    background: #1f6feb;
    color: #fff;
    border: 1px solid #2e7eed;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.bt-promote-btn:hover { background: #2e7eed; }

/* ---- Status pill ---- */
.bt-status-pill {
    display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
}
.bt-status-pending   { background: #312e09; color: #d4a72c; }
.bt-status-scheduled { background: #312e09; color: #d4a72c; }
.bt-status-running   { background: #033a16; color: #3fb950; }
.bt-status-completed { background: #1f6feb33; color: #58a6ff; }
.bt-status-failed    { background: #490202; color: #ff7b72; }
.bt-status-cancelled { background: #21262d; color: #8b949e; }

/* ---- Leaderboard order control ---- */
.bt-lb-controls { margin-left: auto; font-size: 0.74rem; color: #8b949e; }
.bt-lb-controls select {
    background: #0d1117; border: 1px solid #30363d; color: #c9d1d9;
    padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.78rem;
    font-family: "JetBrains Mono", monospace;
}

/* ---- Equity SVG ---- */
.bt-equity-wrap { background: #0d1117; border: 1px solid #30363d; border-radius: 6px; }
.bt-equity-wrap svg { display: block; width: 100%; height: 320px; }
.bt-eq-grid { stroke: #21262d; stroke-width: 0.5; stroke-dasharray: 2 4; }
.bt-eq-zero { stroke: #6e7681; stroke-width: 0.7; }
.bt-eq-axis { fill: #8b949e; font-size: 9px; font-family: "JetBrains Mono", monospace; }
.bt-eq-path { fill: none; stroke: #58a6ff; stroke-width: 1.5; }
.bt-eq-end.pos { fill: #3fb950; }
.bt-eq-end.neg { fill: #ff7b72; }
.bt-eq-empty { fill: #6e7681; font-size: 12px; font-style: italic; }

@media (max-width: 1100px) {
    .bt-layout { grid-template-columns: 1fr; }
    .bt-submit, .bt-jobs, .bt-leaderboard, .bt-equity { grid-column: 1; }
}

/* ---- Header workers counter ---- */
.bt-header {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.6rem 1rem; margin-bottom: 1rem;
    background: #010409; border: 1px solid #30363d; border-radius: 8px;
    font-family: "JetBrains Mono", monospace;
}
.bt-workers-label { color: #8b949e; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
.bt-workers-counts { display: flex; gap: 0.6rem; align-items: baseline; }
.bt-worker-v, .bt-worker-p {
    font-weight: 700; font-size: 1.1rem;
    padding: 0.15rem 0.6rem; border-radius: 4px;
}
.bt-worker-v { color: #58a6ff; background: #1f6feb22; }
.bt-worker-p { color: #d4a72c; background: #312e0944; }
.bt-worker-sep { color: #6e7681; }

/* ---- Job control buttons ---- */
.bt-controls-cell { display: flex; gap: 0.25rem; justify-content: flex-end; padding: 0.3rem; }
.bt-ctrl {
    background: #21262d; color: #c9d1d9; border: 1px solid #30363d;
    width: 24px; height: 24px; padding: 0; border-radius: 3px;
    cursor: pointer; font-size: 0.85rem; line-height: 1;
}
.bt-ctrl:hover { background: #30363d; }
.bt-ctrl-pause:hover  { color: #d4a72c; border-color: #d4a72c; }
.bt-ctrl-resume:hover { color: #3fb950; border-color: #3fb950; }
.bt-ctrl-edit:hover   { color: #58a6ff; border-color: #58a6ff; }
.bt-ctrl-sched:hover  { color: #58a6ff; border-color: #58a6ff; }
.bt-ctrl-cancel:hover { color: #ff7b72; border-color: #ff7b72; }
.bt-ctrl-delete:hover { color: #ff7b72; border-color: #ff7b72; background: #490202; }
.bt-status-pill.bt-status-paused { background: #312e0944; color: #d4a72c; }

/* ---- Modal ---- */
.bt-modal {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.7); display: flex;
    align-items: center; justify-content: center;
}
.bt-modal.hidden { display: none; }
.bt-modal-content {
    background: #161b22; border: 1px solid #30363d; border-radius: 8px;
    padding: 1.5rem; width: min(560px, 92vw); max-height: 90vh; overflow: auto;
}
.bt-modal-content h3 { margin: 0 0 0.5rem; color: #f0f6fc; font-size: 1rem; }
.bt-modal-content label { display: block; color: #8b949e; font-size: 0.78rem; margin-top: 0.6rem; }
.bt-modal-content input[type=datetime-local] {
    width: 100%; background: #0d1117; border: 1px solid #30363d; color: #c9d1d9;
    padding: 0.5rem; border-radius: 4px; font-family: "JetBrains Mono", monospace;
}
.bt-modal-content textarea {
    width: 100%; background: #0d1117; border: 1px solid #30363d; color: #c9d1d9;
    padding: 0.5rem; border-radius: 4px; font-family: "JetBrains Mono", monospace;
    font-size: 0.8rem;
}
.bt-modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; justify-content: flex-end; }
.bt-btn-secondary { background: #21262d; border-color: #30363d; }
.bt-btn-secondary:hover { background: #30363d; }
.bt-btn-warn { background: #5a3a00; border-color: #ffa72f; color: #ffd24a; }
.bt-btn-warn:hover { background: #6c4d00; }

/* ---- Configure params modal (table-based sweep) ---- */
.bt-modal-content.bt-modal-wide {
    width: min(1100px, 95vw);
    max-height: 92vh;
}
.bt-config-header {
    display: flex; justify-content: space-between; align-items: baseline;
    border-bottom: 1px solid #30363d; padding-bottom: 0.6rem; margin-bottom: 0.6rem;
}
.bt-config-totals {
    color: #8b949e; font-size: 0.9rem; font-family: "JetBrains Mono", monospace;
}
.bt-config-totals strong { color: #d4a72c; font-size: 1.1rem; padding: 0 0.3rem; }
.bt-config-table-wrap {
    max-height: 60vh; overflow: auto; border: 1px solid #30363d; border-radius: 4px;
}
.bt-config-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.bt-config-table thead { position: sticky; top: 0; background: #0d1117; z-index: 1; }
.bt-config-table th {
    padding: 0.4rem 0.5rem; border-bottom: 1px solid #21262d;
    color: #8b949e; font-size: 0.7rem; text-transform: uppercase; text-align: left;
}
.bt-config-table td {
    padding: 0.3rem 0.5rem; border-bottom: 1px solid #21262d;
    font-family: "JetBrains Mono", monospace; vertical-align: middle;
}
.bt-config-table tr.bt-cfg-sep td {
    background: #010409; color: #58a6ff; font-weight: 700; font-size: 0.7rem;
    letter-spacing: 0.06em; padding: 0.4rem 0.6rem;
}
.bt-config-table tr.bt-cfg-active { background: #1f6feb15; }
.bt-cfg-name { color: #f0f6fc; font-weight: 600; }
.bt-cfg-desc { color: #8b949e; font-size: 0.74rem; max-width: 320px; white-space: normal; }
.bt-cfg-cat  { color: #6e7681; font-size: 0.7rem; }
.bt-cfg-type { color: #6e7681; }
.bt-cfg-cur  { color: #d4a72c; text-align: right; }
.bt-cfg-ncombo { color: #c9d1d9; text-align: right; min-width: 3em; }
.bt-config-table tr.bt-cfg-active .bt-cfg-ncombo { color: #d4a72c; font-weight: 700; }
.bt-config-table input[type="number"] {
    width: 5.5em; background: #0d1117; border: 1px solid #30363d; color: #c9d1d9;
    padding: 0.25rem 0.35rem; border-radius: 3px; font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
}
.bt-config-table input[type="number"]:focus { outline: none; border-color: #58a6ff; }
