/* styles/components.css — cards, badges, dashboard, sandbox, models, billing */

/* ── Plan / tier badges ──────────────────────────────────────────────────── */
.plan-badge, .tier-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.tier-0, .plan-badge.tier-0 { background: rgba(107,112,128,0.18); color: #9ba3b5; border: 1px solid #3a3f52; }
.tier-1, .plan-badge.tier-1 { background: rgba(79,142,247,0.15);  color: #7eb5f9; border: 1px solid #2e4a7a; }
.tier-2, .plan-badge.tier-2 { background: rgba(160,110,240,0.15); color: #c398f5; border: 1px solid #52327a; }
.tier-3, .plan-badge.tier-3 { background: rgba(240,164,74,0.15);  color: #f5c98e; border: 1px solid #7a5220; }

/* ── Generic card ───────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 36px;
}
.card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.card-value {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 14px;
    word-break: break-all;
}

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 28px;
}

.usage-bar-track {
    background: rgba(255,255,255,0.06);
    border-radius: 20px;
    height: 10px;
    margin: 14px 0 8px;
    overflow: hidden;
}
.usage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 20px;
    transition: width 0.4s ease;
}
.usage-text { font-size: 0.88rem; color: var(--text-muted); }

.quick-links { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.quick-link  { font-size: 1rem; color: var(--accent); }

/* ── Section ────────────────────────────────────────────────────────────── */
.section { margin-bottom: 52px; }
.section h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 22px; }
.section-header {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-header h2 { margin-bottom: 0; }

/* ── Info rows ──────────────────────────────────────────────────────────── */
.info-row {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
}
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--text-muted); font-size: 0.875rem; min-width: 80px; }
.info-val { font-size: 0.9rem; }

/* ── API key list ───────────────────────────────────────────────────────── */
.key-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.key-row:last-child { border-bottom: none; }
.key-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.key-label { font-size: 0.9rem; font-weight: 500; }
.key-meta  { font-size: 0.78rem; color: var(--text-muted); }

.key-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-top: 10px;
    overflow: hidden;
}
.key-display code {
    flex: 1;
    font-size: 0.8rem;
    font-family: 'SFMono-Regular', Consolas, monospace;
    word-break: break-all;
    color: var(--success);
}

/* ── Model grid ─────────────────────────────────────────────────────────── */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 22px;
}
.model-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s;
}
.model-card:hover { border-color: #556; }
.model-card-locked { opacity: 0.6; }
.model-card-locked:hover { border-color: var(--border); }
.model-card-header { display: flex; }
.model-name  { font-size: 1.1rem; font-weight: 600; }
.model-desc  { font-size: 0.85rem; color: var(--text-muted); flex: 1;
               display: -webkit-box; -webkit-line-clamp: 3;
               -webkit-box-orient: vertical; overflow: hidden; }
.model-desc-more { color: var(--accent); text-decoration: none; white-space: nowrap; font-size: 0.82rem; }
.model-desc-more:hover { text-decoration: underline; }
.model-card-footer { margin-top: auto; }
.btn-locked {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: border-color 0.15s, color 0.15s;
}
.btn-locked:hover { border-color: #7c6fcd; color: #7c6fcd; }

/* ── Sandbox ────────────────────────────────────────────────────────────── */
.sandbox-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 32px;
    align-items: start;
}
@media (max-width: 900px) {
    .sandbox-layout { grid-template-columns: 1fr; }
}

.sandbox-left  { display: flex; flex-direction: column; gap: 16px; }
.sandbox-right {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    min-height: 260px;
}
.sandbox-right h2 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

/* ── Image file upload drop zone ────────────────────────────────────────── */
.image-upload-wrapper { display: flex; flex-direction: column; gap: 0; }
.image-upload-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}
.image-upload-drop:hover,
.image-upload-drop.drag-over {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--text);
}

.canvas-wrapper { display: flex; flex-direction: column; gap: 10px; }
.draw-canvas {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: crosshair;
    display: block;
    max-width: 100%;
    image-rendering: pixelated;
    touch-action: none;
}
.canvas-buttons { display: flex; align-items: center; gap: 12px; }
.canvas-hint    { font-size: 0.8rem; color: var(--text-muted); }

/* ── Sample images row (sandbox) ────────────────────────────────────────── */
.image-samples-row { margin-top: 14px; }
.image-samples-label { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 8px; }
.image-samples-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.image-sample-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--surface-alt, var(--bg-card));
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s;
}
.image-sample-thumb:hover  { border-color: var(--accent); }
.image-sample-thumb.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.image-sample-img { width: 80px; height: 54px; object-fit: contain; border-radius: 2px; display: block; }
.image-sample-lbl { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

/* ── Preprocessed image in result ───────────────────────────────────────── */
.preprocessed-result { margin-top: 20px; }
.preprocessed-result-label { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 8px; font-weight: 600; }
.preprocessed-result-img {
    display: block;
    max-width: 300px;
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(79,142,247,0.4);
    image-rendering: pixelated;
}

/* ── Preprocessing pipeline panel ──────────────────────────────────────── */
.prep-pipeline-details {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.prep-pipeline-summary {
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    background: var(--surface-alt, var(--surface));
    color: var(--text-muted);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.prep-pipeline-summary:hover { color: var(--text); }
.prep-steps-list { padding: 4px 0; }
.prep-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 12px;
    border-top: 1px solid var(--border);
}
.prep-step:first-child { border-top: none; }
.prep-step-num {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.prep-step-body { display: flex; flex-direction: column; gap: 1px; font-size: 0.83rem; }
.prep-step-body strong { color: var(--text); }
.prep-step-desc { color: var(--text-muted); font-size: 0.78rem; }

/* ── Named-column input form (user-trained polynomial models) ───────────── */
.sandbox-layout-wide {
    grid-template-columns: 1fr !important;
}
.named-input-form  { display: flex; flex-direction: column; gap: 14px; }
.paste-row         { display: flex; flex-direction: column; gap: 5px; }
.paste-field-row   { display: flex; gap: 8px; align-items: center; }
.paste-input {
    flex: 1;
    font-family: monospace;
    font-size: 0.82rem;
    padding: 6px 10px;
    background: var(--bg-input, var(--bg-card));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    min-width: 0;
}
.paste-input:focus { outline: none; border-color: var(--accent); }
.paste-hint { font-size: 0.75rem; color: var(--text-muted); margin: 0; }
.input-columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px 12px;
}
.input-col-field { display: flex; flex-direction: column; gap: 3px; }
.col-label {
    font-size: 0.71rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
    user-select: none;
}
.col-input {
    padding: 5px 8px;
    font-size: 0.85rem;
    background: var(--bg-input, var(--bg-card));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.col-input:focus        { outline: none; border-color: var(--accent); }
.col-input-filled       { border-color: rgba(79,142,247,0.45); }
.col-input-error        { border-color: var(--error, #e05c5c) !important; background: rgba(224,92,92,0.06); }
/* Categorical column select inherits col-input styling */
.col-select { cursor: pointer; padding-right: 24px; }
.col-select option[value=""] { color: var(--text-muted); }

.latency-label   { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px; }
.prediction-badge {
    display: inline-block;
    background: rgba(79,142,247,0.12);
    border: 1px solid rgba(79,142,247,0.3);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 1.1rem;
    margin-bottom: 16px;
}
.prediction-badge strong { color: var(--accent); font-size: 1.4rem; margin-left: 6px; }
.confidence-badge {
    display: inline-block;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 2px 9px;
    margin-left: 10px;
    vertical-align: middle;
    font-weight: 500;
}

/* ── Trainer hyperparameter descriptions ─────────────────────────────────── */
.param-hint {
    margin: 3px 0 0;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.result-chart  { display: block; max-width: 100%; }
.result-pre    { font-size: 0.82rem; font-family: monospace; color: var(--success); white-space: pre-wrap; word-break: break-all; }

/* ── Billing / plans ────────────────────────────────────────────────────── */
.billing-intro   { margin-bottom: 24px; font-size: 0.95rem; }
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
}
.plan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}
.plan-card.plan-current    { border-color: var(--accent); }
.plan-current-label {
    position: absolute; top: -11px; left: 16px;
    background: var(--accent); color: #fff;
    font-size: 0.72rem; font-weight: 700;
    padding: 2px 8px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.plan-name   { font-size: 1.15rem; font-weight: 700; }
.plan-price  { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.plan-features {
    list-style: none;
    display: flex; flex-direction: column; gap: 7px;
    flex: 1;
}
.plan-features li {
    font-size: 0.9rem; color: var(--text-muted);
    padding-left: 18px; position: relative;
}
.plan-features li::before {
    content: '✓'; position: absolute; left: 0;
    color: var(--success); font-size: 0.75rem;
}
.plan-upgrade-btn,
.plan-manage-btn,
.plan-contact-btn { align-self: stretch; margin-top: auto; }

.plan-card.plan-enterprise {
    border-color: rgba(240,164,74,0.45);
    background: linear-gradient(145deg, var(--bg-card) 80%, rgba(240,164,74,0.05) 100%);
}
.plan-card.plan-enterprise .plan-price { color: #f5c98e; }
.plan-enterprise-label {
    position: absolute; top: -11px; left: 16px;
    background: linear-gradient(90deg, #b45309, #d97706);
    color: #fff;
    font-size: 0.72rem; font-weight: 700;
    padding: 2px 8px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 0.07em;
}
.plan-contact-btn {
    background: linear-gradient(90deg, #b45309, #d97706);
    border: none;
}

/* ── Labs placeholder ───────────────────────────────────────────────────── */
.placeholder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 52px 40px;
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
}
.placeholder-icon { font-size: 3rem; margin-bottom: 16px; }
.placeholder-card h2 { font-size: 1.2rem; margin-bottom: 10px; }
.placeholder-card p  { color: var(--text-muted); font-size: 0.9rem; }

/* ── ML Labs ─────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
}
.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 18px;
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.labs-section { margin-bottom: 36px; }
.labs-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

/* Labs paywall */
.labs-paywall {
    max-width: 560px;
    margin: 40px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
}
.labs-paywall-icon { font-size: 3rem; margin-bottom: 16px; }
.labs-paywall h2   { font-size: 1.6rem; margin-bottom: 10px; }
.labs-paywall-sub  { color: var(--text-muted); margin-bottom: 24px; }
.labs-feature-list {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 0 0 28px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.labs-feature-list li { font-size: 0.95rem; }
.labs-trial-box {
    background: var(--bg);
    border: 1px solid #7c6fcd44;
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
    text-align: left;
}
.labs-upgrade-btn {
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-weight: 600;
}
.labs-paywall-note { font-size: 0.82rem; color: var(--text-muted); margin: 0; }

.labs-trial-badge {
    display: inline-block;
    background: rgba(79, 142, 247, 0.15);
    color: #4f8ef7;
    border: 1px solid rgba(79, 142, 247, 0.35);
    border-radius: 20px;
    padding: 3px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-left: 12px;
    vertical-align: middle;
}

/* Labs quota bar */
.labs-quota-bar {
    display: flex;
    gap: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.quota-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}
.quota-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.quota-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    min-width: 60px;
}
.quota-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.4s ease;
}
.quota-fill--warn { background: #e0613a; }
.quota-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 40px;
    text-align: right;
}
.quota-reset {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Upload drop zone */
.labs-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px;
    text-align: center;
    margin-bottom: 24px;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.labs-upload-zone:hover, .labs-upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79,142,247,0.04);
}
.upload-icon { font-size: 2rem; margin-bottom: 8px; color: var(--accent); }
.upload-label { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* Labs card list */
.labs-list { display: flex; flex-direction: column; gap: 14px; }
.labs-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.labs-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
}
.labs-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* Column chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 500;
}
.chip-num { background: rgba(79,142,247,0.12); color: #7eb5f9; border: 1px solid #2e4a7a; }
.chip-str { background: rgba(107,112,128,0.12); color: #9ba3b5; border: 1px solid #3a3f52; }
.chip-cat { background: rgba(168,85,247,0.12);  color: #c084fc; border: 1px solid #6b3fa0; font-size: 0.7em; vertical-align: middle; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-done    { background: rgba(30,75,44,0.5);  color: #6ee89f; border: 1px solid #2d5a3e; }
.status-failed  { background: rgba(58,30,30,0.5);  color: #f08080; border: 1px solid #5a2d2d; }
.status-running { background: rgba(79,142,247,0.12); color: #7eb5f9; border: 1px solid #2e4a7a; }
.status-queued  { background: rgba(107,112,128,0.15); color: #9ba3b5; border: 1px solid #3a3f52; }

/* Progress bar */
.progress-bar-wrap {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px 0;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Column selector checkboxes */
.col-checklist { display: flex; flex-direction: column; gap: 6px; }
.col-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}
.col-check input { accent-color: var(--accent); }
.btn-link { background: none; border: none; padding: 0; margin-left: 8px; color: var(--accent); font-size: 0.78em; cursor: pointer; text-decoration: underline; vertical-align: middle; }

/* Form rows */
.form-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-row .form-group.narrow { max-width: 140px; }

/* Inline error */
.error-inline { color: var(--danger); font-size: 0.85rem; }

/* Preview table */
.table-scroll { overflow-x: auto; }
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.preview-table th, .preview-table td {
    padding: 7px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.preview-table th { color: var(--text-muted); font-weight: 600; background: var(--bg-sidebar); }

/* Labs modal (separate from main #modal-overlay) */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 600;
}
.modal-overlay.visible { display: flex; }
.labs-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    margin: 0 16px;
    animation: modal-in 0.18s ease;
}

/* ── API Reference page ──────────────────────────────────────────────────── */
.api-page-layout { display: flex; flex-direction: column; }

/* Endpoint catalogue */
.api-group { margin-bottom: 36px; }
.api-group-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.api-endpoint {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    background: var(--bg-card);
}
.api-endpoint-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}
.api-method {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 52px;
    text-align: center;
}
.method-get    { background: rgba(52,199,89,0.15);  color: #5ddf7a; border: 1px solid rgba(52,199,89,0.3); }
.method-post   { background: rgba(79,142,247,0.15); color: #7eb5f9; border: 1px solid rgba(79,142,247,0.3); }
.method-delete { background: rgba(224,92,92,0.15);  color: #e07a7a; border: 1px solid rgba(224,92,92,0.3); }
.method-put    { background: rgba(240,164,74,0.15); color: #f5c98e; border: 1px solid rgba(240,164,74,0.3); }

.api-path {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
    color: var(--text);
    flex: 1;
}
.api-auth-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
    white-space: nowrap;
}
.api-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 0 0 10px;
}
.api-schemas { display: flex; flex-wrap: wrap; gap: 14px; }
.api-schema-block { flex: 1; min-width: 200px; }
.api-schema-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.api-code {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.8rem;
    background: var(--bg-input, #1a1d27);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--success, #5ddf7a);
    margin: 0;
}
.api-code-curl { color: var(--text); }
.api-code-err  { color: var(--error, #e07a7a); }

/* Tester */
.api-tester-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.api-tester-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.tester-row { display: flex; flex-direction: column; gap: 6px; }

.tester-input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.tester-input-tabs {
    display: flex;
    gap: 2px;
}
.tester-tab {
    padding: 3px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.tester-tab.active,
.tester-tab:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tester-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
}
.tester-label-hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* File drop zone */
.tester-file-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
}
.tester-file-zone:hover,
.tester-file-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79,142,247,0.05);
}
.tester-file-icon { font-size: 1.8rem; opacity: 0.7; }
#tester-file-label { font-size: 0.88rem; color: var(--text); }
.tester-file-hint  { font-size: 0.75rem; color: var(--text-muted); }

.tester-file-preview {
    margin-top: 8px;
    font-size: 0.78rem;
    padding: 8px 12px;
}
.form-select,
.form-input,
.form-textarea {
    background: var(--bg-input, #1a1d27);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.88rem;
    padding: 8px 12px;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.form-select:focus,
.form-input:focus,
.form-textarea:focus { outline: none; border-color: var(--accent); }
.api-inputs-area { font-family: 'SFMono-Regular', Consolas, monospace; resize: vertical; }

/* Response block */
.api-response-block {
    background: var(--bg-input, #1a1d27);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.api-resp-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.82rem;
}
.api-resp-ok      { font-weight: 700; color: var(--success, #5ddf7a); }
.api-resp-err     { font-weight: 700; color: var(--error, #e07a7a); }
.api-resp-latency { color: var(--text-muted); }

/* ── Admin panel ─────────────────────────────────────────────────────────── */

/* Nav section label */
.nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 16px 20px 4px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* Admin nav group */
.nav-admin .nav-link { color: #f0a44a; }
.nav-admin .nav-item.active .nav-link { background: rgba(240,164,74,0.12); color: #f5c98e; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(42,45,58,0.5);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.025); }

/* Small button variant */
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Danger button */
.btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}
.btn-danger:hover { background: rgba(224,82,82,0.12); }
.btn-danger.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Toolbar row */
.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── CSV Preprocessor modal ──────────────────────────────────────────────── */
#pp-overlay {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 14px;
    color: var(--text, #e2e8f0);
}
.pp-modal {
    background: var(--bg-card, #1a1d27);
    border: 1px solid var(--border, #2a2d3e);
    border-radius: 10px;
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.pp-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}
.pp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border, #2a2d3e);
    background: var(--bg, #11131c);
}
.pp-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 24px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border, #2a2d3e);
}
.pp-stat {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid transparent;
}
.pp-stat-warn { background: rgba(251,191,36,0.12); color: #fbbf24; border-color: #7a5e10; }
.pp-stat-info { background: rgba(6,182,212,0.12);  color: #22d3ee; border-color: #0e5a6a; }
.pp-stat-ok   { background: rgba(34,197,94,0.10);  color: #4ade80; border-color: #1a5c30; }
.pp-bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 24px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border, #2a2d3e);
}
.pp-bulk-label {
    font-size: 0.78rem;
    color: var(--text-muted, #888);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 4px;
}
.pp-bulk-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.pp-bulk-section {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-right: 3px;
}
.pp-section {
    padding: 20px 24px;
}
.pp-section + .pp-section {
    border-top: 1px solid var(--border, #2a2d3e);
}
.pp-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #888);
    margin: 0 0 14px;
}
.pp-muted { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
/* Column cards */
.pp-col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.pp-col-card {
    background: var(--bg, #11131c);
    border: 1px solid var(--border, #2a2d3e);
    border-radius: 7px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.pp-col-name {
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pp-col-type {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pp-col-type-date,
.pp-col-type-datetime { color: #a78bfa; }  /* violet — distinct from numeric/categorical */
.pp-date-strategy {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.pp-date-select {
    font-size: 0.72rem;
    background: rgba(167,139,250,0.08);
    border: 1px solid rgba(167,139,250,0.3);
    color: #c4b5fd;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.pp-col-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted, #888);
}
.pp-col-stats strong { color: var(--text, #e2e8f0); }
.pp-col-issues { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.pp-issue-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 20px;
    border: 1px solid transparent;
}
.pp-issue-miss { background: rgba(251,191,36,0.12); color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.pp-issue-out  { background: rgba(6,182,212,0.12);  color: #22d3ee; border-color: rgba(6,182,212,0.3); }
.pp-issue-ok   { background: rgba(34,197,94,0.10);  color: #4ade80; border-color: rgba(34,197,94,0.25); }
.pp-col-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pp-action-label { font-size: 0.68rem; color: var(--text-muted, #888); }
.pp-btn-xs {
    padding: 2px 7px;
    font-size: 0.68rem;
    background: rgba(79,142,247,0.1);
    border: 1px solid rgba(79,142,247,0.3);
    color: #7eb5f9;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
}
.pp-btn-xs:hover { background: rgba(79,142,247,0.2); }
.pp-btn-danger-xs {
    background: rgba(224,82,82,0.1);
    border-color: rgba(224,82,82,0.3);
    color: #f87171;
}
.pp-btn-danger-xs:hover { background: rgba(224,82,82,0.2); }
.pp-btn-secondary {
    background: rgba(79,142,247,0.1);
    border: 1px solid rgba(79,142,247,0.3);
    color: #7eb5f9;
}
.pp-btn-secondary:hover { background: rgba(79,142,247,0.2); }
.pp-btn-danger {
    background: rgba(224,82,82,0.1);
    border: 1px solid rgba(224,82,82,0.3);
    color: #f87171;
}
.pp-btn-danger:hover { background: rgba(224,82,82,0.2); }
.pp-btn-zero {
    background: rgba(107,114,128,0.12);
    border: 1px solid rgba(107,114,128,0.3);
    color: #9ca3af;
}
.pp-btn-zero:hover { background: rgba(107,114,128,0.25); }
/* Data grid */
.pp-grid-wrap { overflow-x: auto; max-height: 440px; overflow-y: auto; border-radius: 6px; border: 1px solid var(--border, #2a2d3e); }
.pp-grid { border-collapse: collapse; width: 100%; font-size: 0.78rem; }
.pp-grid th, .pp-grid td {
    border: 1px solid var(--border, #2a2d3e);
    padding: 3px 6px;
    white-space: nowrap;
    max-width: 180px;
}
.pp-grid thead th {
    background: var(--bg, #11131c);
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    overflow: hidden;
}
.pp-th-warn { color: #fbbf24; }
.pp-row-num {
    background: var(--bg, #11131c);
    color: var(--text-muted, #888);
    font-size: 0.68rem;
    text-align: right;
    position: sticky;
    left: 0;
    z-index: 1;
    white-space: nowrap;
    padding: 2px 5px;
    min-width: 52px;
}
.pp-grid thead th.pp-row-num { z-index: 3; }
.pp-row-del-btn {
    background: none;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 3px;
    margin-right: 2px;
    border-radius: 3px;
    transition: color 0.12s, background 0.12s;
}
.pp-row-del-btn:hover { color: #f87171; background: rgba(224,82,82,0.12); }
.pp-row-del-btn.active { color: #4ade80; }
.pp-row-deleted td { opacity: 0.35; text-decoration: line-through; }
.pp-cell-miss { background: rgba(251,191,36,0.1) !important; }
.pp-cell-out  { background: rgba(6,182,212,0.08) !important; }
.pp-cell-input {
    background: none;
    border: none;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    width: 100%;
    min-width: 40px;
    padding: 0;
    outline: none;
}
.pp-cell-input:focus {
    background: rgba(79,142,247,0.08);
    border-radius: 2px;
    outline: 1px solid rgba(79,142,247,0.4);
}
.pp-grid-note {
    font-size: 0.76rem;
    color: var(--text-muted, #888);
    text-align: center;
    margin: 8px 0 0;
}

/* ── Preprocessor v2: histograms, suggestions, transforms ─────────────── */

/* Column card header (name + drop button) */
.pp-col-card-hdr {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
}
.pp-drop-btn {
    flex-shrink: 0;
    font-size: 0.63rem;
    padding: 1px 5px;
    border-radius: 3px;
    cursor: pointer;
    background: rgba(224,82,82,0.08);
    border: 1px solid rgba(224,82,82,0.22);
    color: #f87171;
    transition: background 0.12s;
    white-space: nowrap;
}
.pp-drop-btn:hover { background: rgba(224,82,82,0.2); }
.pp-drop-btn--dropped {
    background: rgba(34,197,94,0.1);
    border-color: rgba(34,197,94,0.3);
    color: #4ade80;
}
.pp-drop-btn--dropped:hover { background: rgba(34,197,94,0.22); }
.pp-col-dropped { opacity: 0.42; }

/* Distribution histogram */
.pp-col-hist {
    margin: 6px 0 2px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(0,0,0,0.18);
    line-height: 0;
}
.pp-hist-svg { display: block; width: 100%; height: auto; }

/* Extra diagnostic badges */
.pp-badge-skewed   { background: rgba(251,146,60,0.12); color: #fb923c; border-color: rgba(251,146,60,0.3); }
.pp-badge-constant { background: rgba(167,139,250,0.12); color: #a78bfa; border-color: rgba(167,139,250,0.3); }
.pp-badge-zero     { background: rgba(107,114,128,0.12); color: #9ca3af; border-color: rgba(107,114,128,0.3); }

/* Categorical distribution micro-bars */
.pp-cat-dist { margin: 5px 0 2px; display: flex; flex-direction: column; gap: 2px; }
.pp-cat-row  { display: flex; align-items: center; gap: 4px; font-size: 0.67rem; }
.pp-cat-label    { flex: 0 0 52px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted,#888); }
.pp-cat-bar-wrap { flex: 1; height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.pp-cat-bar      { height: 100%; background: linear-gradient(90deg, #4f8ef7, #a78bfa); border-radius: 3px; transition: width 0.3s; }
.pp-cat-pct  { flex: 0 0 28px; text-align: right; color: var(--text-muted,#888); }
.pp-cat-more { font-size: 0.64rem; color: var(--text-muted,#888); text-align: right; margin-top: 1px; }

/* Transform action buttons on column cards */
.pp-col-transforms { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.pp-btn-transform {
    font-size: 0.67rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid;
    transition: background 0.12s, transform 0.08s;
}
.pp-btn-transform:active { transform: scale(0.96); }
.pp-btn-transform--log1p  { background: rgba(251,146,60,0.1);  border-color: rgba(251,146,60,0.4);  color: #fb923c; }
.pp-btn-transform--log1p:hover  { background: rgba(251,146,60,0.22); }
.pp-btn-transform--clip   { background: rgba(34,211,238,0.08); border-color: rgba(34,211,238,0.3);  color: #22d3ee; }
.pp-btn-transform--clip:hover   { background: rgba(34,211,238,0.2); }
.pp-btn-transform--merge  { background: rgba(167,139,250,0.1); border-color: rgba(167,139,250,0.35);color: #a78bfa; }
.pp-btn-transform--merge:hover  { background: rgba(167,139,250,0.22); }
.pp-btn-transform--drop   { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.35); color: #f87171; }
.pp-btn-transform--drop:hover   { background: rgba(248,113,113,0.2); }
.pp-btn-transform--balance{ background: rgba(52,211,153,0.08);  border-color: rgba(52,211,153,0.35);  color: #34d399; }
.pp-btn-transform--balance:hover{ background: rgba(52,211,153,0.2); }

/* Smart suggestions panel */
.pp-suggest-panel {
    border-bottom: 1px solid var(--border,#2a2d3e);
    background: rgba(6,182,212,0.025);
}
.pp-suggest-toggle {
    width: 100%;
    padding: 10px 24px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text,#e2e8f0);
    cursor: pointer;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pp-suggest-toggle:hover { background: rgba(255,255,255,0.03); }
.pp-suggest-icon    { font-size: 1rem; flex-shrink: 0; }
.pp-suggest-chevron { margin-left: auto; font-size: 0.75rem; color: var(--text-muted,#888); }
.pp-suggest-body    { padding: 0 24px 14px; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.pp-suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    border: 1px solid transparent;
    line-height: 1.45;
}
.pp-suggest-item--error { background: rgba(224,82,82,0.08);  border-color: rgba(224,82,82,0.2); }
.pp-suggest-item--warn  { background: rgba(251,191,36,0.07); border-color: rgba(251,191,36,0.2); }
.pp-suggest-item--info  { background: rgba(6,182,212,0.07);  border-color: rgba(6,182,212,0.18); }
.pp-suggest-emoji { font-size: 1rem; flex-shrink: 0; }
.pp-suggest-msg   { flex: 1; }
.pp-suggest-apply {
    flex-shrink: 0;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    background: rgba(79,142,247,0.12);
    border: 1px solid rgba(79,142,247,0.35);
    color: #7eb5f9;
    transition: background 0.12s;
    white-space: nowrap;
}
.pp-suggest-apply:hover { background: rgba(79,142,247,0.25); }
.pp-suggest-bulk-apply {
    align-self: flex-start;
    padding: 5px 16px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 5px;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(79,142,247,0.14), rgba(167,139,250,0.14));
    border: 1px solid rgba(167,139,250,0.4);
    color: #c4b5fd;
    transition: background 0.15s;
    margin-bottom: 4px;
}
.pp-suggest-bulk-apply:hover {
    background: linear-gradient(135deg, rgba(79,142,247,0.28), rgba(167,139,250,0.28));
}

/* flash-highlight a column card after a suggestion is applied */
@keyframes pp-col-flash {
    0%   { box-shadow: 0 0 0 2px rgba(79,142,247,0.7), 0 0 20px rgba(79,142,247,0.2);
           background: rgba(79,142,247,0.1); }
    100% { box-shadow: none; background: transparent; }
}
.pp-col-card--flash { animation: pp-col-flash 1.5s ease-out forwards; }

/* ── Outline button (used on model cards) ───────────────────────────────── */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-explain {
    background: rgba(99,102,241,0.12);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-explain:hover { background: var(--accent); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   Model Detail Page  (md- prefix)
   ══════════════════════════════════════════════════════════════════════════ */

.md-page { max-width: 1080px; padding-bottom: 60px; }

/* Back link */
.md-back { margin-bottom: 20px; }
.md-back-link {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.md-back-link:hover { color: var(--accent); text-decoration: none; }

/* Header */
.md-header { margin-bottom: 36px; }
.md-header-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.md-title { font-size: 2rem; font-weight: 700; margin-bottom: 6px; }
.md-slug { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.md-slug code { font-family: 'SFMono-Regular', Consolas, monospace; color: var(--text-muted); }
.md-description {
    font-size: 0.975rem;
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 820px;
    white-space: pre-line;
}

/* Section wrapper */
.md-section { margin-bottom: 40px; }

/* ── Collapsible sections — <details>/<summary> ──────────────────────────── */
/* details.md-section inherits margin-bottom from .md-section above */
details.md-section { display: block; }

/* summary acts as the heading — remove native triangle on all browsers */
summary.md-section-title {
    cursor: pointer;
    user-select: none;
    list-style: none;      /* Firefox */
}
summary.md-section-title::-webkit-details-marker { display: none; } /* Chrome/Safari */

/* Chevron immediately after the title text */
summary.md-section-title::after {
    content: '▾';
    margin-left: 8px;
    font-size: 1.2em;
    color: var(--accent, #4f8ef7);
    opacity: 0.85;
    transition: transform 0.18s ease, opacity 0.15s;
    display: inline-block;
    flex-shrink: 0;
}
details.md-section:not([open]) > summary.md-section-title::after {
    transform: rotate(-90deg);
}
summary.md-section-title:hover        { color: var(--text); }
summary.md-section-title:hover::after { opacity: 1; }
summary.md-section-title:focus-visible { outline: 2px solid var(--accent); border-radius: 3px; }
summary.md-section-title:focus:not(:focus-visible) { outline: none; }

/* ── Preprocessing pipeline (model detail) ─────────────────────── */
.md-prep-list { display: flex; flex-direction: column; }
.md-prep-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.md-prep-step:last-child { border-bottom: none; }
.md-prep-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}
.md-prep-body   { display: flex; flex-direction: column; gap: 2px; }
.md-prep-name   { font-size: 0.9rem; color: var(--text); }
.md-prep-desc   { font-size: 0.8rem; color: var(--text-muted); }

.md-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.md-count {
    font-size: 0.75em;
    font-weight: 500;
    background: rgba(79,142,247,0.12);
    color: var(--accent);
    border: 1px solid rgba(79,142,247,0.35);
    border-radius: 20px;
    padding: 1px 9px;
    text-transform: none;
    letter-spacing: 0;
}

/* Metrics */
.md-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.md-metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.md-metric-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.md-metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.md-metric-accent { color: var(--accent); }

/* Specs grid */
.md-specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.md-spec {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}
.md-spec-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.md-spec-value { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Class labels */
.md-label-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.md-label-chip {
    background: rgba(79,142,247,0.1);
    border: 1px solid #2e4a7a;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.md-label-idx {
    background: rgba(79,142,247,0.2);
    border-radius: 20px;
    padding: 0 7px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #7eb5f9;
    font-variant-numeric: tabular-nums;
}
.md-label-merged {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 4px;
}
.md-label-orig {
    background: rgba(168,85,247,0.12);
    border: 1px solid rgba(168,85,247,0.3);
    border-radius: 4px;
    padding: 0 5px;
    font-size: 0.72rem;
    color: #c084fc;
    font-weight: 500;
}

/* Feature table */
.md-table-wrap { overflow-x: auto; }
.md-feat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.md-feat-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}
.md-feat-table td {
    padding: 7px 12px;
    border-bottom: 1px solid rgba(42,45,58,0.5);
    vertical-align: middle;
}
.md-feat-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.md-feat-name { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.85rem; }
.md-cats-cell { font-size: 0.8rem; color: var(--text-muted); }
.md-cats { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.8rem; }
.md-xf-cell { white-space: nowrap; }
.md-xf-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: default;
}
.md-xf-log1p { background: rgba(16,185,129,0.12); color: #34d399; border-color: rgba(16,185,129,0.3); }
.md-xf-clip  { background: rgba(251,191,36,0.10);  color: #fbbf24; border-color: rgba(251,191,36,0.28); }
.md-xf-merge { background: rgba(168,85,247,0.10);  color: #c084fc; border-color: rgba(168,85,247,0.28); }

/* Explanation note */
.md-explanation-note {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 18px;
    max-width: 820px;
}

/* Top-terms table */
.md-terms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.md-terms-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}
.md-term-row td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.md-term-row:hover td { background: rgba(127,127,127,0.06); }
.md-term-top td { background: rgba(79,142,247,0.06); }
.md-term-rank {
    color: var(--text-muted);
    font-size: 0.8rem;
    width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.md-term-name {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
    white-space: nowrap;
}
/* Term name token colouring */
.tn-feat { color: var(--text); }
.tn-eq   { color: var(--text-muted); }
.tn-val  { color: var(--accent); }   /* accent — indicates a category value */
.tn-exp  { color: var(--text-muted); }   /* dim — exponent */
.tn-sep  { color: var(--text-muted); opacity: 0.6; }   /* very dim — multiplier */
.md-term-deg  { white-space: nowrap; }
.md-term-bar-cell { min-width: 120px; }
.md-bar-wrap {
    height: 8px;
    background: rgba(127,127,127,0.12);
    border-radius: 4px;
    overflow: hidden;
}
.md-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.md-term-pos     { color: #4ade80; }
.md-term-neg     { color: #f87171; }
.md-bar.md-term-pos { background: rgba(74,222,128,0.55); }
.md-bar.md-term-neg { background: rgba(248,113,113,0.55); }
.md-term-coeff {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.md-sign { font-weight: 700; margin-right: 1px; }
.md-term-dir { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Per-class explanation tabs (md-classtab- prefix) ───────────────────── */
.md-classtab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.md-classtab-btn {
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.md-classtab-btn:hover { background: rgba(79,142,247,0.12); color: var(--text); border-color: var(--accent); }
.md-classtab-btn.active { background: rgba(79,142,247,0.18); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.md-classtab-panel.hidden { display: none; }

/* Actions bar */
.md-actions { margin-top: 16px; display: flex; gap: 12px; }
.md-actions-header { margin-top: 20px; }

/* ── Feature importance chart (md-fi- prefix) ───────────────────────────── */
.md-fi-chart { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.md-fi-row {
    display: grid;
    grid-template-columns: 140px 1fr 72px;
    align-items: center;
    gap: 10px;
}
.md-fi-label {
    font-size: 0.82rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}
.md-fi-bar-wrap {
    height: 10px;
    background: rgba(127,127,127,0.12);
    border-radius: 5px;
    overflow: hidden;
}
.md-fi-bar-wrap .md-bar { height: 100%; border-radius: 5px; }
.md-fi-score {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Degree complexity breakdown (md-deg- prefix) ───────────────────────── */
.md-deg-bar {
    display: flex;
    height: 22px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    gap: 2px;
}
.md-deg-seg { height: 100%; border-radius: 3px; transition: opacity 0.15s; }
.md-deg-seg:hover { opacity: 0.8; }
.deg-linear { background: #4f8ef7; }
.deg-self   { background: #a78bfa; }
.deg-cross  { background: #f59e0b; }
.deg-higher { background: #f87171; }

.md-deg-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 2px;
}
.md-deg-leg-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.md-deg-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
.md-deg-leg-item strong { color: var(--text); }

/* ── "The Equation" section (md-eq- prefix) ─────────────────────────────── */
.md-eq-note {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 8px;
}
.md-eq-display {
    font-family: 'JetBrains Mono', 'Fira Mono', 'Courier New', monospace;
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 10px 0 12px;
    user-select: text;
}
.md-eq-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.md-eq-copy-confirm {
    font-size: 0.8rem;
    color: var(--success, #4ade80);
    min-width: 60px;
}

  (md-explain- prefix) ─────────────────────── */
.md-explain-controls { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.md-explain-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}
.md-explain-upload-area:hover,
.md-explain-upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(99,102,241,0.06);
    color: var(--accent);
}
.md-explain-upload-area.has-image {
    border-color: var(--accent);
    color: var(--text);
}

.md-explain-samples-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0 0 8px;
}
.md-explain-samples-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.md-explain-sample-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.md-explain-sample-thumb:hover        { border-color: var(--accent); }
.md-explain-sample-thumb.selected     { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.md-explain-sample-img                { width: 80px; height: 54px; object-fit: contain; border-radius: 2px; display: block; }
.md-explain-sample-lbl                { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

.md-explain-btn-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.md-explain-status {
    font-size: 0.82rem;
    color: var(--danger, #f87171);
}

.md-explain-result {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}
.md-explain-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 600px) {
    .md-explain-images { grid-template-columns: 1fr; }
}
.md-explain-img-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.md-explain-img-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.md-explain-img {
    width: 100%;
    border-radius: var(--radius-sm);
    image-rendering: pixelated;
    border: 1px solid var(--border);
}
.md-explain-prediction {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    border: 1px solid var(--border);
}

/* ── Polynomial score decomposition panel ───────────────────────────────── */
.md-poly-breakdown {
    margin-top: 18px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.md-poly-breakdown-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Score breakdown (linear vs quadratic) */
.poly-sbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.82rem;
}
.poly-sbar-lbl {
    width: 110px;
    flex-shrink: 0;
    color: var(--text-dim, var(--text-muted));
    font-size: 0.8rem;
}
.poly-sbar-track {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}
.poly-sbar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s;
}
.poly-sbar-fill.pos { background: #d73027; }
.poly-sbar-fill.neg { background: #4575b4; }
.poly-sbar-val {
    width: 100px;
    flex-shrink: 0;
    text-align: right;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
.poly-sbar-pct {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 3px;
}

/* PCA component bar chart */
.md-poly-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.poly-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
}
.poly-bar-lbl {
    width: 36px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.poly-bar-track {
    flex: 1;
    position: relative;
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.poly-bar-center {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--text-muted);
    opacity: 0.4;
}
.poly-bar-fill {
    position: absolute;
    top: 0;
    height: 100%;
    min-width: 2px;
    border-radius: 3px;
    transition: width 0.3s, left 0.3s;
}
.poly-bar-fill.pos { background: #d73027; }
.poly-bar-fill.neg { background: #4575b4; }
.poly-bar-val {
    width: 58px;
    flex-shrink: 0;
    text-align: right;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}
.poly-bar-val.pos { color: #d73027; }
.poly-bar-val.neg { color: #4575b4; }

/* ── Learned filters grid ───────────────────────────────────────────────── */
.md-weights-loading {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}
.md-weights-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}
.md-weight-filter-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 6px;
    border: 2px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}
.md-weight-filter-col:hover { background: rgba(79,142,247,0.07); }
.md-weight-filter-col.selected { border-color: var(--accent); background: rgba(79,142,247,0.10); }
.md-weight-filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.04em;
}
.md-weight-filter-img {
    width: 120px;
    height: auto;
    image-rendering: pixelated;
    border-radius: 3px;
    border: 1px solid var(--border);
    display: block;
}
.md-weights-barchart {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* Side-by-side layout: bar chart left, eigenimage panel right */
.md-weights-bar-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-top: 8px;
}
.md-weights-bar-layout .md-poly-bar-chart {
    flex: 1;
    min-width: 0;
}

/* Clickable bar rows that have an eigenimage */
.poly-bar-row.has-eigenimage {
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.12s;
}
.poly-bar-row.has-eigenimage:hover { background: rgba(79,142,247,0.08); }
.poly-bar-row.has-eigenimage.active { background: rgba(79,142,247,0.14); outline: 1px solid var(--accent); }

/* Eigenimage panel (right column) */
.md-eigenimage-panel {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.md-eigenimage-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}
.md-eigenimage-img {
    width: 160px;
    height: auto;
    image-rendering: pixelated;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: block;
}
.md-eigenimage-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}


/* ══════════════════════════════════════════════════════════════════════════
   Image Labs — wizard, pipeline builder, preview, upload progress
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Secondary button ────────────────────────────────────────────────────── */
.btn-secondary {
    background: rgba(79,142,247,0.10);
    color: var(--accent);
    border: 1px solid rgba(79,142,247,0.28);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}
.btn-secondary:hover:not(:disabled) { background: rgba(79,142,247,0.22); }
.btn-secondary:disabled { opacity: 0.45; cursor: default; }
.btn-secondary.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Icon/remove button ──────────────────────────────────────────────────── */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--danger); background: rgba(224,82,82,0.12); }

/* ── Chip color variants ─────────────────────────────────────────────────── */
.chip-green { background: rgba(52,201,122,0.12);  color: #5ddf7a; border: 1px solid rgba(52,201,122,0.28); }
.chip-blue  { background: rgba(79,142,247,0.12);  color: #7eb5f9; border: 1px solid rgba(79,142,247,0.28); }
.chip-gray  { background: rgba(107,112,128,0.10); color: #9ba3b5; border: 1px solid #3a3f52; }
.chip-red   { background: rgba(224,82,82,0.12);   color: #f08080; border: 1px solid rgba(224,82,82,0.28); }

/* ── Alert banners ───────────────────────────────────────────────────────── */
.alert {
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    margin: 8px 0;
    font-size: 0.9em;
    line-height: 1.5;
}
.alert-error { background: rgba(224,82,82,0.08);  color: #f08080; border: 1px solid rgba(224,82,82,0.25); }
.alert-warn  { background: rgba(240,164,74,0.08); color: #f5c98e; border: 1px solid rgba(240,164,74,0.25); }
.alert-info  { background: rgba(79,142,247,0.08); color: #7eb5f9; border: 1px solid rgba(79,142,247,0.25); }

/* ── Progress track (upload + job cards) ─────────────────────────────────── */
.progress-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.progress-count {
    font-size: 0.85em;
    color: var(--text-muted);
    text-align: right;
}

/* ── Wizard stepper ──────────────────────────────────────────────────────── */
.wizard-steps {
    display: flex;
    align-items: center;
    padding: 4px 0 20px;
    margin-bottom: 4px;
}
.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}
/* Connector line between steps */
.wizard-step-connector {
    flex: 1;
    height: 1px;
    background: var(--border);
    margin: 0 10px;
    min-width: 14px;
}
.wizard-step.active { color: var(--text); font-weight: 500; }
.wizard-step.done   { color: var(--text-muted); }

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.wizard-step.active .step-num {
    border-color: var(--accent);
    background: rgba(79,142,247,0.18);
    color: var(--accent);
}
.wizard-step.done .step-num {
    border-color: var(--success);
    background: rgba(52,201,122,0.15);
    color: var(--success);
}

/* Wizard body section */
.wizard-section { padding: 4px 0 8px; }
.wizard-section h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; }

/* Wizard action row */
.wizard-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Folder drop zone ────────────────────────────────────────────────────── */
.folder-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-input);
    margin: 12px 0;
    transition: border-color 0.2s, background 0.2s;
}
.folder-drop-zone:hover,
.folder-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79,142,247,0.05);
}
.folder-drop-zone .upload-icon { font-size: 2.2rem; display: block; margin-bottom: 10px; }
.folder-drop-zone .upload-label { color: var(--accent); cursor: pointer; }
.folder-drop-zone .upload-label:hover { text-decoration: underline; }

/* ── Scan result ─────────────────────────────────────────────────────────── */
.scan-result {
    margin: 12px 0;
    padding: 12px 16px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.scan-table {
    margin: 8px 0;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
.scan-table th {
    text-align: left;
    padding: 5px 10px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.scan-table td { padding: 6px 10px; border-bottom: 1px solid rgba(42,45,58,0.4); }
.scan-table tbody tr:last-child td { border-bottom: none; }
.scan-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Pipeline builder ────────────────────────────────────────────────────── */
.pipeline-step {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.pipeline-step:hover { border-color: rgba(79,142,247,0.3); }

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
}
.step-drag {
    color: var(--text-muted);
    cursor: grab;
    font-size: 1.05rem;
    user-select: none;
    flex-shrink: 0;
    opacity: 0.55;
    letter-spacing: 0.08em;
}
.step-drag:active { cursor: grabbing; }
.step-desc { flex: 1; font-size: 0.82em; color: var(--text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.step-params {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    padding: 8px 14px 12px 44px;
    border-top: 1px solid rgba(42,45,58,0.45);
    background: rgba(0,0,0,0.12);
}
.step-params label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.83em;
    color: var(--text-muted);
    white-space: nowrap;
}
.step-params input[type=range] { width: 100px; cursor: pointer; accent-color: var(--accent); }
.step-params input[type=number],
.step-params select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 3px 6px;
    font-size: 0.83em;
    width: 66px;
}
.step-params select { width: auto; }

.pipeline-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 10px 0 6px;
}
.pipeline-add-row select {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 7px 10px;
    font-size: 0.9em;
}

.pipeline-presets {
    display: flex;
    gap: 14px;
    margin-bottom: 6px;
}

/* ── Pipeline editor two-column layout (step 2) ──────────────────────────── */
.pipeline-editor-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 8px;
}
.pipeline-left {
    flex: 0 0 240px;
    min-width: 0;
}
.pipeline-right {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
@media (max-width: 760px) {
    .pipeline-editor-layout { flex-direction: column; }
    .pipeline-right { flex: none; width: 100%; }
}
.panel-section-title {
    font-size: 0.82em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.live-preview-panel,
.ecg-reference-panel {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.live-preview-slot {
    min-height: 60px;
}
.live-preview-pair {
    display: flex;
    align-items: center;
    gap: 10px;
}
.live-preview-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 0;
}
.live-preview-img {
    max-width: 100%;
    max-height: 200px;
    display: block;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #000;
    image-rendering: pixelated;
    object-fit: contain;
}
.live-preview-processed {
    border-color: rgba(79,142,247,0.5);
    max-height: 400px;
    min-height: 200px;
}
.live-preview-name {
    margin-top: 6px;
    font-size: 0.72em;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* ECG reference grid */
.ecg-ref-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.ecg-ref-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ecg-ref-img {
    width: 100%;
    max-height: 80px;
    min-height: 40px;
    display: block;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #000;
    image-rendering: pixelated;
    object-fit: contain;
}
.ecg-ref-label {
    font-size: 0.68em;
    text-align: center;
    line-height: 1.3;
}

/* ── Preview pairs (original → preprocessed) ─────────────────────────────── */
.preview-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
    max-height: 440px;
    overflow-y: auto;
    padding-right: 4px;
}
.preview-pair {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}
.preview-label {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 7px;
    font-style: italic;
}
.preview-images {
    display: flex;
    align-items: center;
    gap: 14px;
}
.preview-arrow { color: var(--text-muted); font-size: 1.3rem; flex-shrink: 0; }
.preview-img {
    max-width: 160px;
    max-height: 110px;
    display: block;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #000;
    image-rendering: pixelated;
}
.preview-caption { font-size: 0.73em; color: var(--text-muted); text-align: center; margin-top: 4px; }

/* ── Upload progress block ───────────────────────────────────────────────── */
.upload-progress-block {
    padding: 28px 20px;
    text-align: center;
}
.upload-progress-block .progress-track { margin: 14px auto; max-width: 400px; }
.upload-progress-block .progress-count { text-align: center; color: var(--text); font-size: 0.95em; }

/* ── Code hint (folder structure) ────────────────────────────────────────── */
.code-hint {
    display: block;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-size: 0.83em;
    color: var(--text-muted);
    line-height: 1.75;
    white-space: pre;
    overflow-x: auto;
    text-align: left;
    margin: 8px auto 14px;
    max-width: max-content;
}

/* ── Trainer form (create job section) ───────────────────────────────────── */
/* Note: visual card framing (bg/border) is added via .labs-card on the parent
   wrapper when needed; .trainer-form itself is just a layout / spacing utility. */
.trainer-form {
    padding: 4px 0;
}
.trainer-form h3 { margin: 0 0 16px; font-size: 1rem; font-weight: 600; }

/* Image Labs job-creation card (trainer-form with card chrome) */
.image-job-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.image-job-card h3 { margin: 0 0 16px; font-size: 1rem; font-weight: 600; }
.ij-section-label  { font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
                     letter-spacing: 0.06em; color: var(--text-muted); margin: 18px 0 10px; }
.ij-hint { display: block; font-size: 0.75rem; color: var(--text-muted);
           font-weight: 400; margin-top: 3px; line-height: 1.45; }

.form-row.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 580px) { .form-row.two-col { grid-template-columns: 1fr; } }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Checkbox label row */
.col-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--text);
}
.col-check input[type=checkbox] { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }

/* labs-card-body */
.labs-card-body { margin: 4px 0 6px; font-size: 0.9em; color: var(--text-muted); }

/* Image job card — training log */
.job-log-snippet {
    margin: 8px 0 0;
    font-size: 10px;
    color: #9ab;
    background: #111;
    border-radius: 4px;
    padding: 6px 10px;
    overflow: hidden;
    max-height: 80px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}
.job-log-details {
    margin: 8px 0 0;
}
.job-log-details summary {
    font-size: 0.8em;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
}
.job-log-details summary:hover { color: var(--text); }
.job-log-full {
    margin: 6px 0 0;
    font-size: 10px;
    color: #9ab;
    background: #111;
    border-radius: 4px;
    padding: 8px 10px;
    overflow: auto;
    max-height: 200px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Image job card — result summary */
.job-result-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 8px 0 4px;
    padding: 8px 10px;
    background: rgba(80,200,120,0.08);
    border-radius: 6px;
    border-left: 3px solid var(--success, #4caf50);
}
.job-result-item {
    font-size: 0.88em;
    color: var(--text);
}
.job-result-item strong {
    color: var(--success, #4caf50);
}

/* ── Feedback Widget ──────────────────────────────────────────────────────── */

/* Floating action button */
.feedback-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99,102,241,0.45);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.feedback-fab:hover  { background: #4f46e5; box-shadow: 0 6px 20px rgba(99,102,241,0.55); }
.feedback-fab:active { transform: scale(0.96); }

.feedback-fab-icon { display: flex; align-items: center; }
.feedback-fab-label { white-space: nowrap; }

@media (max-width: 700px) {
    .feedback-fab { padding: 11px; border-radius: 50%; }
    .feedback-fab-label { display: none; }
}

/* Modal overlay */
.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9001;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 24px 80px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    overflow-y: auto;
}
.feedback-modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Modal box */
.feedback-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
    overflow: hidden;
    transform: translateY(16px);
    transition: transform 0.2s;
}
.feedback-modal-overlay.visible .feedback-modal {
    transform: translateY(0);
}

@media (max-width: 700px) {
    .feedback-modal-overlay {
        align-items: flex-end;
        justify-content: center;
        padding: 0 0 70px;
    }
    .feedback-modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
}

.fb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
}
.fb-modal-title { font-size: 0.95rem; font-weight: 600; }
.fb-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: color 0.12s, background 0.12s;
}
.fb-close-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.fb-modal-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; flex: 1; min-height: 0; }

/* Type pills */
.fb-type-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.fb-type-pill {
    cursor: pointer;
    user-select: none;
}
.fb-type-pill input { display: none; }
.fb-type-pill span {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.fb-type-pill.active span,
.fb-type-pill:hover span {
    border-color: #6366f1;
    color: #a5b4fc;
    background: rgba(99,102,241,0.12);
}

/* Fields */
.fb-field { display: flex; flex-direction: column; gap: 4px; }
.fb-label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.fb-optional { font-weight: 400; font-size: 0.75rem; }
.fb-input, .fb-textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
    padding: 8px 10px;
    width: 100%;
    transition: border-color 0.12s;
    font-family: inherit;
    resize: vertical;
}
.fb-input:focus, .fb-textarea:focus {
    outline: none;
    border-color: #6366f1;
}
.fb-char-counter { font-size: 0.72rem; color: var(--text-muted); text-align: right; }
.fb-hint  { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.fb-error { font-size: 0.82rem; color: var(--danger); padding: 6px 0; }

/* Actions */
.fb-actions { display: flex; gap: 10px; margin-top: 4px; }
.fb-actions .btn-primary { flex: 1; }

/* Success state */
.fb-success-body {
    padding: 32px 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.fb-success-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(52,201,122,0.15);
    border: 2px solid var(--success);
    color: var(--success);
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fb-success-text { font-size: 0.95rem; font-weight: 500; }

/* ── Admin Inbox ────────────────────────────────────────────────────────────── */
.inbox-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 10px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    margin-left: 5px;
    line-height: 1;
}
.inbox-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
    min-height: 400px;
}
@media (max-width: 760px) { .inbox-layout { grid-template-columns: 1fr; } }

.inbox-filters { display: flex; flex-direction: column; gap: 4px; }
.inbox-filter-btn {
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.12s, color 0.12s;
}
.inbox-filter-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.inbox-filter-btn.active { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.inbox-filter-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.inbox-message-list { display: flex; flex-direction: column; gap: 0; }
.inbox-message-row {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: start;
}
.inbox-message-row:hover { background: rgba(255,255,255,0.03); }
.inbox-message-row.unread .inbox-msg-subject { font-weight: 600; color: var(--text); }
.inbox-message-row.selected { background: rgba(99,102,241,0.08); }

.inbox-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}
.inbox-dot-bug_report      { background: var(--danger); }
.inbox-dot-feature_request { background: #818cf8; }
.inbox-dot-suggestion      { background: var(--warning); }
.inbox-dot-other           { background: var(--text-muted); }

.inbox-msg-subject { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 2px; }
.inbox-msg-meta    { font-size: 0.76rem; color: var(--text-muted); }
.inbox-msg-ts      { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.inbox-status-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.inbox-status-unread   { background: var(--accent); }
.inbox-status-read     { background: transparent; }
.inbox-status-archived { background: transparent; }

.inbox-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.inbox-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.inbox-detail-subject { font-size: 1.05rem; font-weight: 600; }
.inbox-detail-actions { display: flex; gap: 8px; flex-shrink: 0; }
.inbox-detail-body {
    white-space: pre-wrap;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text);
    padding: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.inbox-meta-row { display: flex; gap: 8px; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.inbox-meta-key { min-width: 80px; }
.inbox-empty { padding: 40px 0; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* ── Page tabs (md-tabs-root / md-tab-*) ─────────────────────────────── */
/* Pure-CSS radio hack: hidden radios + sibling label selectors.          */
/* All panel content stays in DOM — display:none is still indexed by      */
/* search engines, satisfying the SEO requirement.                         */

.md-tr { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

/* All panels hidden by default */
.md-tab-panel { display: none; }

/* Show panel whose radio is checked */
#md-tr-0:checked ~ .md-tab-panels #md-tp-0 { display: block; }
#md-tr-1:checked ~ .md-tab-panels #md-tp-1 { display: block; }
#md-tr-2:checked ~ .md-tab-panels #md-tp-2 { display: block; }
#md-tr-3:checked ~ .md-tab-panels #md-tp-3 { display: block; }
#md-tr-4:checked ~ .md-tab-panels #md-tp-4 { display: block; }

/* Style the active tab label */
#md-tr-0:checked ~ .md-tab-bar label[for="md-tr-0"],
#md-tr-1:checked ~ .md-tab-bar label[for="md-tr-1"],
#md-tr-2:checked ~ .md-tab-bar label[for="md-tr-2"],
#md-tr-3:checked ~ .md-tab-bar label[for="md-tr-3"],
#md-tr-4:checked ~ .md-tab-bar label[for="md-tr-4"] {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    font-weight: 600;
}

.md-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}
.md-tab-bar::-webkit-scrollbar { display: none; }

.md-tab-lbl {
    padding: 10px 18px;
    font-size: 0.88rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.md-tab-lbl:hover { color: var(--text); }

.md-tab-panels { min-height: 120px; }

.md-tab-empty {
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* ── Retrain panel (md-retrain-*) ─────────────────────────────────────── */
.md-retrain-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}
.md-retrain-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.md-retrain-label {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text);
}
.md-retrain-field-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.md-retrain-select,
.md-retrain-input {
    background: var(--bg-input, rgba(127,127,127,0.08));
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 6px 10px;
    font-size: 0.875rem;
    max-width: 380px;
    outline: none;
    transition: border-color 0.15s;
}
.md-retrain-select:focus,
.md-retrain-input:focus {
    border-color: var(--accent);
}
.md-retrain-hp-details {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}
.md-retrain-hp-summary {
    cursor: pointer;
    padding: 9px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    list-style: none;
    user-select: none;
}
.md-retrain-hp-summary::-webkit-details-marker { display: none; }
.md-retrain-hp-summary::before {
    content: '▸ ';
    font-size: 0.75em;
    color: var(--text-muted);
    transition: transform 0.15s;
}
.md-retrain-hp-details[open] .md-retrain-hp-summary::before {
    content: '▾ ';
}
.md-retrain-hp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    padding: 12px 14px 14px;
    border-top: 1px solid var(--border);
}
@media (max-width: 500px) {
    .md-retrain-hp-grid { grid-template-columns: 1fr; }
}
.md-retrain-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 16px;
}
.md-retrain-chip {
    font-size: 0.82rem;
    background: var(--bg-input, rgba(127,127,127,0.08));
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    color: var(--text-muted);
    word-break: break-all;
}
.md-retrain-chip strong {
    color: var(--text);
    margin-right: 4px;
}
.md-retrain-actions {
    margin-bottom: 4px;
}
.md-retrain-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.md-retrain-note-admin {
    color: var(--accent);
}
.md-retrain-status-wrap {
    margin: 12px 0 16px;
}
.md-retrain-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.md-retrain-pct {
    font-weight: 600;
    color: var(--accent);
}
.md-retrain-bar-track {
    height: 6px;
    border-radius: 4px;
    background: var(--bg-input, rgba(127,127,127,0.12));
    overflow: hidden;
}
.md-retrain-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}
.md-retrain-history {
    margin-top: 20px;
}
.md-retrain-hist-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 10px;
}
.md-retrain-hist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}
.md-retrain-hist-table th,
.md-retrain-hist-table td {
    text-align: left;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}
.md-retrain-hist-table th {
    color: var(--text);
    font-weight: 600;
}
.md-retrain-hist-table tr:last-child td {
    border-bottom: none;
}
.md-runhist-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    opacity: 0.85;
    vertical-align: middle;
}
.md-runhist-subtitle {
    font-size: 0.83rem;
    color: var(--text-muted);
    margin: 4px 0 0;
}

/* ── What-If panel (md-wi-*) ──────────────────────────────────────────── */
.md-wi-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 700px) {
    .md-wi-layout { grid-template-columns: 1fr; }
}

.md-wi-controls { display: flex; flex-direction: column; gap: 10px; }

.md-wi-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: center;
    gap: 10px;
}
.md-wi-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.md-wi-slider-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.md-wi-slider {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
}
.md-wi-val {
    font-size: 0.8rem;
    color: var(--text);
    min-width: 56px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.md-wi-select {
    width: 100%;
    background: var(--bg-input, var(--bg-card));
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.82rem;
}

/* Right-side output panel */
.md-wi-output {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.md-wi-output-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.md-wi-prediction {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    word-break: break-word;
    margin-bottom: 16px;
    min-height: 2.2rem;
}

/* Per-class score bars (classification) */
.md-wi-scores { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.md-wi-score-row {
    display: grid;
    grid-template-columns: 80px 1fr 44px;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
}
.md-wi-score-label { color: var(--text-muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-wi-score-bar-wrap {
    height: 8px;
    background: var(--bg-input, rgba(255,255,255,0.06));
    border-radius: 4px;
    overflow: hidden;
}
.md-wi-score-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.15s ease;
    width: 0%;
}
.md-wi-score-num { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }

/* ── Contribution Waterfall (md-wf-*) ──────────────────────────────────── */
.md-wf-section {
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.md-wf-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.md-wf-rows {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.md-wf-row {
    display: grid;
    grid-template-columns: 180px 22px 1fr 72px 72px;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    min-height: 22px;
}
@media (max-width: 640px) {
    .md-wf-row { grid-template-columns: 120px 20px 1fr 64px; }
    .md-wf-running { display: none; }
}
.md-wf-name {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
    font-size: 0.78rem;
}
.md-wf-deg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 3px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.md-wf-deg1 { background: rgba(94,175,120,0.18); color: #5eaf78; }
.md-wf-deg2 { background: rgba(100,160,230,0.18); color: #64a0e6; }
.md-wf-deg3 { background: rgba(200,130,200,0.18); color: #c882c8; }
.md-wf-bar-cell {
    position: relative;
    height: 10px;
    display: flex;
    align-items: center;
}
.md-wf-bar {
    height: 8px;
    border-radius: 3px;
    transition: width 0.18s ease;
    min-width: 2px;
}
.md-wf-bar-pos { background: #5ab87a; }
.md-wf-bar-neg { background: #e06060; }
.md-wf-val {
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    text-align: right;
    font-family: monospace;
}
.md-wf-val-pos { color: #5ab87a; }
.md-wf-val-neg { color: #e06060; }
.md-wf-running {
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    font-family: monospace;
}
.md-wf-total-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 0.83rem;
}
.md-wf-total-label {
    font-weight: 700;
    color: var(--text);
    flex: 0 0 auto;
}
.md-wf-total-val {
    font-weight: 700;
    color: var(--accent);
    font-family: monospace;
    font-variant-numeric: tabular-nums;
}



/* ── Counterfactual Flipper ─────────────────────────────────────────────── */
.md-cf-section {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}
.md-cf-title {
    font-weight: 700;
    font-size: 0.97rem;
    color: var(--text);
    margin-bottom: 6px;
}
.md-cf-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0 14px;
}
.md-cf-label {
    font-size: 0.83rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.md-cf-select {
    font-size: 0.83rem;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}
.md-cf-btn {
    font-size: 0.8rem;
    padding: 5px 14px;
    border-radius: 5px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}
.md-cf-btn:hover { background: var(--accent); color: #fff; }
.md-cf-btn:disabled { opacity: 0.5; cursor: wait; }
.md-cf-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 4px 0;
}
.md-cf-summary {
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.md-cf-class-cur {
    font-weight: 700;
    color: #e07050;
}
.md-cf-class-tgt {
    font-weight: 700;
    color: #5ab87a;
}
.md-cf-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.md-cf-row {
    display: grid;
    grid-template-columns: 160px 1fr auto 110px;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--bg-alt, rgba(120,120,120,0.05));
    font-size: 0.82rem;
}
.md-cf-feat {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.md-cf-arrow {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: monospace;
    font-size: 0.8rem;
}
.md-cf-from { color: var(--text-muted); }
.md-cf-to-arrow { color: var(--text-muted); font-size: 0.75rem; }
.md-cf-to { color: var(--text); font-weight: 600; }
.md-cf-delta {
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: right;
    min-width: 70px;
}
.md-cf-delta-pos { color: #5ab87a; }
.md-cf-delta-neg { color: #e06060; }
.md-cf-tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(100,170,230,0.13);
    color: #64a0e6;
    white-space: nowrap;
    text-align: center;
}
.md-cf-apply-btn {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}
.md-cf-apply-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Polynomial Sparsity Map ────────────────────────────────────────────── */
.md-sp-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.87rem;
    margin: 10px 0 8px;
}
.md-sp-stat { color: var(--text); }
.md-sp-sep  { color: var(--text-muted); }
.md-sp-bullet { color: var(--text-muted); }
.md-sp-pruned strong { color: #e06060; }
.md-sp-bar-wrap {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-alt, rgba(120,120,120,0.1));
    margin-bottom: 6px;
}
.md-sp-bar-active {
    background: #5ab87a;
    transition: width 0.3s ease;
    min-width: 2px;
}
.md-sp-bar-pruned {
    background: rgba(224,96,96,0.3);
    transition: width 0.3s ease;
}
.md-sp-bar-legend {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.md-sp-legend-active { color: #5ab87a; }
.md-sp-legend-pruned { color: #e06060; opacity: 0.7; }
.md-sp-bottom-section {
    margin-top: 14px;
}
.md-sp-bottom-title {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.md-sp-bottom-rows {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.md-sp-bottom-row {
    display: grid;
    grid-template-columns: 48px 1fr 22px 90px;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 5px;
    background: var(--bg-alt, rgba(120,120,120,0.05));
    font-size: 0.79rem;
}
.md-sp-rank {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.md-sp-name {
    color: var(--text);
    font-family: monospace;
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.md-sp-coeff {
    font-family: monospace;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.md-sp-dead {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(224,96,96,0.07);
    border: 1px solid rgba(224,96,96,0.2);
}
.md-sp-dead-title {
    font-size: 0.83rem;
    font-weight: 700;
    color: #e06060;
    margin-bottom: 8px;
}
.md-sp-dead-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.md-sp-dead-chip {
    font-size: 0.75rem;
    padding: 2px 9px;
    border-radius: 10px;
    background: rgba(224,96,96,0.15);
    color: #e06060;
    font-family: monospace;
}
.md-sp-dead-note {
    font-size: 0.79rem;
    color: var(--text-muted);
    margin: 0;
}
