/* ── Training Console Styles ─────────────────────────────────── */

/* Embedded mode: hide chrome when loaded inside an iframe */
.embedded-mode .gn-bar { display: none !important; }
.embedded-mode .container { padding-top: 0.5rem; }
.embedded-mode .landing-footer { display: none !important; }
.embedded-mode .training-back-btn { display: none !important; }

/* Views */
.training-view { display: none; }
.training-view.active { display: block; }

/* ── List View ─────────────────────────────────────────────── */
.training-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.training-list-header .btn { flex: none; }
.training-list-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.training-list-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.training-info-banner {
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.training-info-banner .info-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #4f6dff;
    margin-top: 2px;
}
.training-info-banner h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 0.25rem;
}
.training-info-banner p {
    font-size: 0.85rem;
    color: #3451a3;
    line-height: 1.5;
}

/* Runs Table */
.training-runs-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.training-runs-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.training-runs-card .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Training Runs Table ─────────────────────────────────────── */
.training-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.training-table thead th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary, #5a5568);
    background: var(--bg-secondary, #faf8fc);
    border-bottom: 1px solid var(--border-color, #e8e4ef);
    white-space: nowrap;
}
.training-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}
.training-table tbody tr:hover {
    background: var(--bg-secondary, #faf8fc);
}
.training-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color, #e8e4ef);
    vertical-align: middle;
    color: var(--text-primary, #222);
}
.training-table .tr-name {
    font-weight: 600;
    color: var(--text-primary, #222);
}
@media (max-width: 768px) {
    .training-table { font-size: 0.78rem; }
    .training-table th, .training-table td { padding: 0.5rem 0.6rem; }
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.status-badge.completed { background: #dcfce7; color: #166534; }
.status-badge.running { background: #dbeafe; color: #1e40af; }
.status-badge.failed { background: #fee2e2; color: #991b1b; }
.status-badge.pending { background: #fef3c7; color: #92400e; }

/* Progress bar */
.progress-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.progress-bar {
    width: 60px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.progress-bar-fill.completed { background: #22c55e; }
.progress-bar-fill.running { background: #3b82f6; }
.progress-bar-fill.failed { background: #ef4444; }
.progress-pct {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 36px;
}

/* ── New Training Run View ─────────────────────────────────── */
.training-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 1rem;
    transition: color 0.2s;
}
.training-back-btn:hover { color: var(--primary-color); }

.training-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}
.training-page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Form rows (2-column grid to optimize space) */
.training-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
@media (max-width: 700px) {
    .training-form-row { grid-template-columns: 1fr; }
}

/* Config Sections */
.training-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
}
.training-section--compact {
    padding: 1rem 1.25rem;
    margin-bottom: 0;
}
.training-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}
.t-hint-inline {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Form elements scoped to training */
.training-section .t-field {
    margin-bottom: 0.65rem;
}
.training-section .t-field:last-child { margin-bottom: 0; }
.training-section .t-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.training-section .t-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.training-section input[type="text"],
.training-section input[type="number"],
.training-section input[type="url"],
.training-section select,
.training-section textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.training-section input:focus,
.training-section select:focus,
.training-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(192, 38, 211, 0.1);
}
.training-section textarea { resize: vertical; min-height: 48px; font-family: monospace; }
.training-section .t-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Verifier toggle buttons */
.verifier-toggle {
    display: inline-flex;
    gap: 0;
    margin-bottom: 0.75rem;
}
.verifier-toggle button {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.verifier-toggle button:first-child { border-radius: 10px 0 0 10px; }
.verifier-toggle button:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.verifier-toggle button.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Inline create verifier form */
.verifier-inline-form {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
}

/* Condition / weight table */
.condition-table-header {
    display: grid;
    grid-template-columns: 1fr 100px 36px;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}
.condition-row {
    display: grid;
    grid-template-columns: 1fr 100px 36px;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
}
.condition-row input {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: #fff;
    box-sizing: border-box;
}
.condition-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}
.condition-row .remove-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}
.condition-row .remove-btn:hover { color: #ef4444; background: #fef2f2; }
.condition-row .remove-btn:disabled { opacity: 0.3; pointer-events: none; }

.add-condition-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0;
    margin-top: 0.25rem;
}
.add-condition-btn:hover { text-decoration: underline; }

/* LLM Judge panel */
.llm-judge-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    margin-bottom: 0.75rem;
}
.llm-judge-tab {
    background: none;
    border: none;
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.llm-judge-tab:hover { color: var(--text-primary, #111); }
.llm-judge-tab.active {
    color: var(--primary-color, #7c3aed);
    border-bottom-color: var(--primary-color, #7c3aed);
}
.llm-judge-tab-content {
    display: none;
}
.llm-judge-tab-content.active {
    display: block;
}
.training-section textarea.code-textarea,
textarea.code-textarea {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #2d2d44;
    border-radius: 8px;
    padding: 0.75rem;
    resize: vertical;
    width: 100%;
    box-sizing: border-box;
}
.training-section textarea.code-textarea::placeholder,
textarea.code-textarea::placeholder {
    color: #5a5a7a;
}
.training-section textarea.code-textarea:focus,
textarea.code-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #7c3aed);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

/* Environment preview panel */
.env-preview {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}
.env-preview .ep-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
}
.env-preview .ep-label { color: var(--text-secondary); }
.env-preview .ep-value { color: var(--text-primary); font-weight: 500; }
.env-preview .ep-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}
.env-preview .ep-tool-tag {
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
}

/* Algorithm radio group */
.algo-group { display: flex; flex-direction: column; gap: 0.35rem; }
.algo-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
}
.algo-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    margin-top: 2px;
    flex-shrink: 0;
}
.algo-option .algo-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}
.algo-option .algo-rec {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 400;
    margin-left: 0.35rem;
}
.algo-option .algo-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

/* LoRA collapsible */
.lora-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0;
}
.lora-toggle:hover { color: var(--primary-color); }
.lora-toggle svg { transition: transform 0.2s; }
.lora-toggle.open svg { transform: rotate(90deg); }
.lora-params {
    display: none;
    margin-top: 0.75rem;
    margin-left: 1.25rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
}
.lora-params.open { display: block; }
.lora-params .t-row { margin-bottom: 0.75rem; }
.lora-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Footer actions */
.training-footer .btn { flex: none; }
.training-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    margin-top: 0.25rem;
}

/* ── Training Progress Stepper ─────────────────────────────── */
.training-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding: 1rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow-x: auto;
}
.training-stepper:empty { display: none; }
.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    min-width: 80px;
}
.stepper-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: calc(50% + 16px);
    width: calc(100% - 32px);
    height: 2px;
    background: var(--border-color);
}
.stepper-step.completed:not(:last-child)::after {
    background: #22c55e;
}
.stepper-step.active:not(:last-child)::after {
    background: linear-gradient(90deg, var(--accent-primary) 50%, var(--border-color) 50%);
}
.stepper-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}
.stepper-step.completed .stepper-circle {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}
.stepper-step.active .stepper-circle {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}
.stepper-label {
    margin-top: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}
.stepper-step.active .stepper-label { color: var(--accent-primary); }
.stepper-step.completed .stepper-label { color: #22c55e; }
.stepper-progress {
    font-size: 0.65rem;
    color: var(--accent-primary);
    font-weight: 500;
    margin-top: 2px;
}
@media (max-width: 600px) {
    .training-stepper { padding: 0.75rem 0.25rem; }
    .stepper-step { min-width: 60px; }
    .stepper-label { font-size: 0.65rem; }
}

/* ── Failure Reason Panel ─────────────────────────────────── */
.failure-reason-panel {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}
.failure-reason-panel h4 {
    color: #dc2626;
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.failure-reason-panel .failure-message {
    color: #991b1b;
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.5;
}
.failure-reason-panel code {
    display: block;
    background: #fee2e2;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #7f1d1d;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}

/* ── Details View ──────────────────────────────────────────── */
.details-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.details-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.details-actions .btn { flex: none; }
.details-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.details-actions a.btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Small button variant */
.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
}
/* Ghost button - subtle table action style */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color, #e8e4ef);
    border-radius: 10px;
    color: var(--text-secondary, #5a5568);
    font-weight: 500;
    transition: all 0.2s ease;
}
.btn-ghost:hover {
    background: var(--bg-secondary, #faf8fc);
    border-color: var(--primary-color, #c026d3);
    color: var(--primary-color, #c026d3);
    transform: none;
    box-shadow: none;
}
.btn-ghost svg {
    stroke: currentColor;
}
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 10px;
}
.btn-outline:hover {
    background: var(--primary-color);
    color: #fff;
}

/* State Diagram – SVG flowchart */
.sd-container { padding: 0.5rem 0; }
.sd-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; color: var(--text-primary); }
.sd-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 1rem; }
.sd-scroll { overflow-x: auto; padding-bottom: 0.5rem; }
.sd-scroll svg { display: block; min-height: 100px; }
/* Legend */
.sd-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #e8e4ef);
}
.sd-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.sd-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sd-legend-line {
    width: 22px;
    height: 0;
    border-top: 2px solid currentColor;
    flex-shrink: 0;
}
.sd-legend-line.dashed { border-top-style: dashed; }

/* Sample data banner */
.sample-data-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
}
.sample-data-banner .btn { flex: none; }
.sample-data-banner .sample-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Model artifact download link */
.info-panel a.btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Status badge for awaiting */
.status-badge.awaiting_human_eval {
    background: #fef3c7;
    color: #92400e;
}

/* Metric cards */
.metric-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.metric-card .mc-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}
.metric-card .mc-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.metric-card .mc-value.positive { color: #16a34a; }

/* Info grid */
.details-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.details-full {
    margin-bottom: 1.5rem;
}

/* Info rows */
.info-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.info-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
}
.info-row:last-child { border-bottom: none; }
.info-row .ir-label { color: var(--text-secondary); }
.info-row .ir-value { color: var(--text-primary); font-weight: 500; text-align: right; }

/* Config tabs */
.config-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
}
.config-tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.config-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Performance tables */
.perf-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
}
.perf-row:last-child { border-bottom: none; }
.perf-label { color: var(--text-secondary); }
.perf-values { display: flex; align-items: center; gap: 0.5rem; }
.perf-old { color: #9ca3af; }
.perf-new { font-weight: 700; color: var(--text-primary); }
.perf-delta { font-size: 0.8rem; font-weight: 600; }
.perf-delta.up { color: #16a34a; }
.perf-delta.down { color: #16a34a; }

/* Trade-off note */
.tradeoff-note {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    color: #92400e;
    line-height: 1.5;
}
.tradeoff-note strong { color: #78350f; }

/* ── Training Tabs ────────────────────────────────────────── */
.training-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.training-tab {
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.training-tab:hover { color: var(--text-primary); }
.training-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}
.training-tab-content { display: none; }
.training-tab-content.active { display: block; }

/* ── Rollout List ────────────────────────────────────────── */
.rollout-list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.rollout-meta h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.rollout-meta p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.rollout-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rollout-filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: #fff;
    min-width: 180px;
}
.rollout-filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(192, 38, 211, 0.1);
}

/* Rollout table */
.rollout-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.rollout-table thead th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    background: var(--bg-secondary, #faf8fc);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.rollout-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}
.rollout-table tbody tr:hover {
    background: var(--bg-secondary, #faf8fc);
}
.rollout-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}
.rollout-table .rl-episode { font-weight: 600; }
.rollout-table .rl-issue { color: var(--primary-color); font-weight: 600; }

.policy-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
}
.policy-badge.trained { background: #dbeafe; color: #1d4ed8; }
.policy-badge.baseline { background: #f3f4f6; color: #4b5563; }

.final-state-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
}
.final-state-badge.resolved,
.final-state-badge.done { background: #dcfce7; color: #166534; }
.final-state-badge.open { background: #fef3c7; color: #92400e; }

.rollout-list-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ── Rollout Detail View ─────────────────────────────────── */
.rollout-detail-header {
    margin-bottom: 1rem;
}
.rollout-detail-header h2 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.rollout-detail-meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}
.rollout-detail-meta .rdm-label {
    color: var(--text-secondary);
    font-size: 0.82rem;
}
.rollout-detail-meta .rdm-value {
    font-weight: 700;
    color: var(--text-primary);
    margin-left: 0.35rem;
}

/* Rollout detail tabs */
.rollout-detail-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
}
.rollout-dtab {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.rollout-dtab:first-child { border-radius: 8px 0 0 8px; }
.rollout-dtab:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.rollout-dtab:not(:first-child):not(:last-child) { border-left: 0; }
.rollout-dtab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Rollout detail layout */
.rollout-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    min-height: 400px;
}
@media (max-width: 1024px) {
    .rollout-detail-layout { grid-template-columns: 1fr; }
}

.rollout-detail-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
    overflow: auto;
    max-height: 600px;
}
.rollout-detail-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    line-height: 1.6;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    color: var(--text-primary);
}

.rollout-detail-trajectory {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
    overflow: auto;
    max-height: 600px;
    position: relative;
}

/* Trajectory diagram */
.traj-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.78rem;
}
.traj-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.traj-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.traj-legend-dot.agent { background: #3b82f6; }
.traj-legend-dot.tool { background: #f59e0b; }
.traj-legend-dot.verifier { background: #ec4899; }
.traj-legend-dot.reward { background: #10b981; }

.traj-flow {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.traj-node {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0;
}
.traj-node:not(:last-child) {
    border-bottom: 1px dashed #e5e7eb;
}
.traj-node-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}
.traj-node-icon.system { background: #6b7280; }
.traj-node-icon.agent { background: #3b82f6; }
.traj-node-icon.tool { background: #f59e0b; }
.traj-node-icon.result { background: #8b5cf6; }
.traj-node-icon.verifier { background: #ec4899; }

.traj-node-body {
    flex: 1;
    min-width: 0;
}
.traj-node-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}
.traj-node-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    word-break: break-word;
}
.traj-node-args {
    font-family: monospace;
    font-size: 0.75rem;
    color: #6366f1;
    background: #eef2ff;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.2rem;
}

/* ── Training Empty State ────────────────────────────────────── */
.training-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}
.training-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #f3e8ff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    color: var(--primary-color);
}
.training-empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}
.training-empty-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
    margin: 0 0 1.5rem 0;
}
.training-empty-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    padding: 0.65rem 1.5rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .metric-cards { grid-template-columns: repeat(2, 1fr); }
    .details-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .metric-cards { grid-template-columns: 1fr; }
    .training-list-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .training-section .t-row { grid-template-columns: 1fr; }
    .condition-table-header,
    .condition-row { grid-template-columns: 1fr 80px 32px; }
    .rollout-detail-layout { grid-template-columns: 1fr; }
}

/* ── Dark Mode Overrides ───────────────────────────────────── */
[data-theme="dark"] .tools-display-row {
    background: var(--card-bg, #252236);
    border-color: var(--border-color, #3e3a52);
}

[data-theme="dark"] .training-info-banner {
    background: rgba(30, 58, 138, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
}
[data-theme="dark"] .training-info-banner h4 { color: #93c5fd; }
[data-theme="dark"] .training-info-banner p { color: #a8a2b8; }
[data-theme="dark"] .training-info-banner .info-icon { color: #818cf8; }

[data-theme="dark"] .training-section input[type="text"],
[data-theme="dark"] .training-section input[type="number"],
[data-theme="dark"] .training-section input[type="url"],
[data-theme="dark"] .training-section select,
[data-theme="dark"] .training-section textarea {
    background: var(--card-bg, #252236);
    color: var(--text-primary, #f3f0f9);
    border-color: var(--border-color, #3e3a52);
}

[data-theme="dark"] .verifier-toggle button {
    background: var(--card-bg, #252236);
    color: var(--text-secondary, #a8a2b8);
    border-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .verifier-toggle button.active {
    background: var(--primary-color, #e879f9);
    color: #fff;
    border-color: var(--primary-color, #e879f9);
}

[data-theme="dark"] .verifier-inline-form {
    background: rgba(46, 16, 101, 0.3);
    border-color: rgba(139, 92, 246, 0.3);
}

[data-theme="dark"] .condition-row input {
    background: var(--card-bg, #252236);
    color: var(--text-primary, #f3f0f9);
    border-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .condition-row .remove-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
}

[data-theme="dark"] .env-preview {
    background: var(--card-bg, #252236);
    border-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .env-preview .ep-tool-tag {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

[data-theme="dark"] .rollout-filter-select {
    background: var(--card-bg, #252236);
    color: var(--text-primary, #f3f0f9);
    border-color: var(--border-color, #3e3a52);
}

[data-theme="dark"] .rollout-dtab {
    background: var(--card-bg, #252236);
    color: var(--text-secondary, #a8a2b8);
    border-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .rollout-dtab.active {
    background: var(--primary-color, #e879f9);
    color: #fff;
    border-color: var(--primary-color, #e879f9);
}

[data-theme="dark"] .info-row {
    border-bottom-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .perf-row {
    border-bottom-color: var(--border-color, #3e3a52);
}

[data-theme="dark"] .tradeoff-note {
    background: rgba(146, 64, 14, 0.2);
    border-color: rgba(253, 230, 138, 0.3);
    color: #fde68a;
}
[data-theme="dark"] .tradeoff-note strong { color: #fef3c7; }

[data-theme="dark"] .failure-reason-panel {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(248, 113, 113, 0.3);
    border-left-color: #ef4444;
}
[data-theme="dark"] .failure-reason-panel h4 { color: #f87171; }
[data-theme="dark"] .failure-reason-panel .failure-message { color: #fca5a5; }
[data-theme="dark"] .failure-reason-panel code {
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
}

[data-theme="dark"] .sample-data-banner {
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(74, 222, 128, 0.3);
}

[data-theme="dark"] .training-empty-icon {
    background: rgba(139, 92, 246, 0.2);
}

[data-theme="dark"] .traj-legend {
    background: var(--card-bg, #252236);
    border-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .traj-node:not(:last-child) {
    border-bottom-color: var(--border-color, #3e3a52);
}
[data-theme="dark"] .traj-node-args {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

[data-theme="dark"] .progress-bar {
    background: var(--border-color, #3e3a52);
}

/* Status badges dark mode */
[data-theme="dark"] .status-badge.completed { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
[data-theme="dark"] .status-badge.running { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .status-badge.failed { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
[data-theme="dark"] .status-badge.pending { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
[data-theme="dark"] .status-badge.awaiting_human_eval { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

[data-theme="dark"] .policy-badge.trained { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .policy-badge.baseline { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }

[data-theme="dark"] .final-state-badge { background: rgba(107, 114, 128, 0.2); color: #d1d5db; }
[data-theme="dark"] .final-state-badge.resolved,
[data-theme="dark"] .final-state-badge.done { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
[data-theme="dark"] .final-state-badge.open { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

/* Table header backgrounds */
[data-theme="dark"] .training-table thead th {
    background: var(--card-bg, #252236);
}
[data-theme="dark"] .training-table tbody tr:hover {
    background: rgba(126, 34, 106, 0.12);
}
[data-theme="dark"] .rollout-table thead th {
    background: var(--card-bg, #252236);
}
[data-theme="dark"] .rollout-table tbody tr:hover {
    background: rgba(126, 34, 106, 0.12);
}

/* Ghost button dark mode */
[data-theme="dark"] .btn-ghost:hover {
    background: rgba(126, 34, 106, 0.12);
}

/* ── Advanced Configuration (collapsible) ────────────────────── */
.adv-config-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0;
}
.adv-config-toggle:hover { color: var(--primary-color); }
.adv-config-toggle svg { transition: transform 0.2s; }
.adv-config-toggle.adv-expanded svg { transform: rotate(90deg); }
.adv-config-toggle .t-hint-inline { font-weight: 400; font-size: 0.82rem; }

.adv-config-body {
    display: none;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}
.adv-config-body.adv-open { display: block; }

/* ─── Tools section ─────────────────────────────────────────────── */
.tool-section-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem;
    line-height: 1.4;
}
.tool-section-desc code {
    background: var(--bg-secondary);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}
.tools-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.tools-list:empty { margin-bottom: 0; }
.tool-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
}
.tool-card-info {
    flex: 1;
    min-width: 0;
}
.tool-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-word;
}
.tool-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    word-break: break-word;
}
.tool-card-id {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    font-family: monospace;
    margin-top: 0.15rem;
}
.tool-card-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}
.tool-card-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tool-card-actions button:hover { color: var(--primary-color); background: var(--bg-hover, rgba(255,255,255,0.05)); }
.tool-card-actions button.tool-delete-btn:hover { color: var(--error-color, #e74c3c); }
.tool-editor {
    margin-top: 0.5rem;
}
.tool-editor textarea {
    width: 100%;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    resize: vertical;
    box-sizing: border-box;
}
.tool-editor textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 124, 58, 237), 0.15);
}
.tool-editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.adv-group-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.5rem;
}
.adv-group-label:first-child { margin-top: 0; }

.t-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 768px) {
    .t-row-3 { grid-template-columns: 1fr; }
}

/* ── Tools Display Row (clean read-only display) ────────────── */
.tools-display-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
}
.tools-display-label {
    font-size: 0.92rem;
    color: var(--text-secondary);
}
.tools-display-value {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ── Multi-select checkbox list (Actions / Verifiers) ───────── */
.multi-select-container {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    max-height: 180px;
    overflow-y: auto;
    background: var(--bg-card);
}
.multi-select-all {
    display: block;
    padding: 4px 0;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    font-size: 13px;
    cursor: pointer;
}
.multi-select-options label {
    display: block;
    padding: 3px 0;
    font-size: 13px;
    cursor: pointer;
}
.multi-select-options label:hover {
    background: var(--bg-hover, rgba(0,0,0,0.04));
    border-radius: 4px;
}
.multi-select-options input[type="checkbox"] {
    margin-right: 6px;
    vertical-align: middle;
}
.multi-select-all input[type="checkbox"] {
    margin-right: 6px;
    vertical-align: middle;
}
