/* ================================================================
   MODEL PLAYGROUND v2 — DARK ML STUDIO
   Deep navy dark mode with amber accent glow system
   ================================================================ */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Brand — amber orange (matches header icon) */
  --mp-brand:         #e9a23b;
  --mp-brand-dark:    #d97706;
  --mp-brand-glow:    rgba(233,162,59,.22);
  --mp-brand-muted:   rgba(233,162,59,.09);

  /* Surfaces — true charcoal, no blue tint */
  --mp-bg-root:       #0a0a0a;
  --mp-bg-surface:    #141414;
  --mp-bg-card:       #1a1a1a;
  --mp-bg-raised:     #222222;
  --mp-bg-input:      #090909;
  --mp-bg-header-row: #111111;

  /* Borders */
  --mp-border:        #2b2b2b;
  --mp-border-dim:    rgba(255,255,255,.04);
  --mp-border-bright: rgba(255,255,255,.13);

  /* Text */
  --mp-text:          #ebebeb;
  --mp-text-muted:    #636363;
  --mp-text-dim:      #525252;
  --text-muted:       #636363;

  /* Accents */
  --mp-amber:         #f59e0b;
  --mp-blue:          #3b82f6;
  --mp-green:         #10b981;
  --mp-red:           #ef4444;
  --mp-violet:        #8b5cf6;
  --mp-teal:          #2dd4bf;
  --mp-cyan:          #22d3ee;

  /* Radius + Shadow */
  --mp-radius-sm:     5px;
  --mp-radius-md:     8px;
  --mp-radius-lg:     13px;
  --mp-shadow-card:   0 4px 24px rgba(0,0,0,.65), 0 1px 4px rgba(0,0,0,.4);
  --mp-shadow-glow:   0 0 0 1px rgba(233,162,59,.3), 0 4px 20px rgba(233,162,59,.15);

  /* Backward-compat aliases */
  --mp-slate-900: #ebebeb;
  --mp-slate-600: #636363;
  --mp-slate-400: #2e2e2e;
  --mp-slate-200: #2b2b2b;
  --mp-slate-100: #1a1a1a;
  --mp-slate-50:  #141414;
  --mp-bg-page:   #0a0a0a;
  --mp-border-subtle: rgba(255,255,255,.04);
  --border: #2b2b2b;

  /* Pos/neg scatter colors */
  --mp-pos: #e9a23b;
  --mp-neg: #ef4444;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0 !important;
  background: var(--mp-bg-root) !important;
  color: var(--mp-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mp-border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ── Page Header ─────────────────────────────────────────────────── */
.mp-page-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--mp-bg-surface);
  border-bottom: 1px solid var(--mp-border);
  /* amber accent line at bottom edge */
  box-shadow:
    0 2px 24px rgba(0,0,0,.6),
    inset 0 -1px 0 rgba(233,162,59,.3);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 54px;
}

.mp-header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  text-decoration: none;
  transition: transform .15s ease;
}
.mp-header-logo:hover { transform: scale(1.08) rotate(-4deg); }
.mp-header-logo svg { width: 28px; height: 28px; }

/* Title + subtitle stacked group */
.mp-header-title-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}
.mp-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-text);
  white-space: nowrap;
  letter-spacing: .015em;
}
.mp-header-subtitle {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--mp-text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  font-family: 'Roboto Mono', monospace;
}

.mp-header-divider {
  width: 1px;
  height: 20px;
  background: var(--mp-border);
  flex-shrink: 0;
}
.mp-header-meta { display: flex; align-items: center; gap: 6px; }

.mp-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--mp-border);
  background: var(--mp-bg-card);
  font-size: 10px;
  font-weight: 500;
  color: var(--mp-text-muted);
  font-family: 'Roboto Mono', monospace;
}
.mp-header-badge-label {
  opacity: .5;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 9px;
}

.mp-run-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--mp-border);
  background: var(--mp-bg-card);
  font-size: 11px;
  font-weight: 500;
  color: var(--mp-text-muted);
  font-family: 'Roboto Mono', monospace;
}

.mp-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mp-text-dim);
  flex-shrink: 0;
  transition: background .25s, box-shadow .25s;
}
.mp-status-dot.running {
  background: var(--mp-brand);
  box-shadow: 0 0 0 3px var(--mp-brand-muted), 0 0 10px var(--mp-brand-glow);
  animation: mp-pulse 1.2s ease infinite;
}
.mp-status-dot.done {
  background: var(--mp-brand);
  box-shadow: 0 0 8px var(--mp-brand-glow);
}

@keyframes mp-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .2; }
}

/* ── Page Body ─────────────────────────────────────────────────── */
.mp-page-body {
  padding: 22px 24px 60px;
  /* subtle dot grid */
  background-image: radial-gradient(rgba(255,255,255,.028) 1px, transparent 0);
  background-size: 26px 26px;
}

/* ── Two-column Grid ────────────────────────────────────────────── */
.mp-grid {
  display: grid;
  grid-template-columns: minmax(0, 1220px) minmax(380px, 1fr);
  gap: 18px;
  align-items: start;
}

/* ── Panel wrappers ─────────────────────────────────────────────── */
.mp-left-panel,
.mp-right-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mp-panel-header {
  padding: 0 2px 12px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mp-panel-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--mp-text-dim);
}

/* ── Accordion ─────────────────────────────────────────────────── */
.mp-acc {
  margin-top: 8px;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-card);
  overflow: hidden;
}
.mp-acc-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--mp-bg-header-row);
  border-bottom: 1px solid transparent;
  transition: background .12s;
}
.mp-acc:not(.is-collapsed) .mp-acc-h { border-bottom-color: var(--mp-border); }
.mp-acc-h:hover { background: var(--mp-bg-raised); }
.mp-acc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--mp-text);
  letter-spacing: .01em;
}
.mp-acc-right { display: flex; align-items: center; gap: 8px; }
.mp-acc-chev {
  opacity: .35;
  color: var(--mp-text-muted);
  transition: transform .12s ease;
  font-size: 10px;
}
.mp-acc.is-collapsed .mp-acc-chev { transform: rotate(-90deg); }
.mp-acc-b { padding: 12px 14px 14px; }
.mp-acc.is-collapsed .mp-acc-b { display: none; }
.mp-acc .btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Actions Bar ────────────────────────────────────────────────── */
.mp-actions-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--mp-bg-card);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--mp-border);
  background: var(--mp-bg-raised);
  border-radius: var(--mp-radius-sm);
  padding: 6px 13px;
  font-size: 12px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  cursor: pointer;
  color: var(--mp-text);
  line-height: 1.4;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover {
  background: var(--mp-bg-card);
  border-color: var(--mp-border-bright);
}
.btn.primary, .btn-primary {
  background: var(--mp-brand);
  border-color: var(--mp-brand-dark);
  color: #080c14;
  font-weight: 700;
}
.btn.primary:hover, .btn-primary:hover {
  background: #ffe066;
  border-color: var(--mp-brand);
}
#runBtn {
  background: linear-gradient(135deg, var(--mp-brand), var(--mp-brand-dark));
  border: none;
  color: #1a0a00;
  font-weight: 800;
  padding: 7px 22px;
  font-size: 13px;
  letter-spacing: .01em;
  border-radius: var(--mp-radius-sm);
  box-shadow:
    0 0 0 1px rgba(233,162,59,.35),
    0 4px 16px rgba(233,162,59,.25),
    inset 0 1px 0 rgba(255,255,255,.15);
  transition: background .15s, box-shadow .15s;
}
#runBtn:hover {
  background: linear-gradient(135deg, #fbbf24, var(--mp-brand));
  box-shadow:
    0 0 0 2px rgba(233,162,59,.55),
    0 6px 22px rgba(233,162,59,.38),
    inset 0 1px 0 rgba(255,255,255,.2);
}
.promoteBtn {
  background: var(--mp-brand);
  border-color: var(--mp-brand-dark);
  color: #1a0a00;
  font-weight: 600;
}
.promoteBtn:hover { background: #fbbf24; }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Form Fields ────────────────────────────────────────────────── */
.mp-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--mp-text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
}
input[type="number"],
input[type="text"]:not([class*="col-filter"]) {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  padding: 6px 9px;
  font-size: 12px;
  background: var(--mp-bg-input);
  color: var(--mp-text);
  font-family: 'Roboto Mono', monospace;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .12s, box-shadow .12s;
}
input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--mp-brand);
  box-shadow: 0 0 0 3px var(--mp-brand-muted);
}
input[disabled] { opacity: .3; cursor: not-allowed; }

select.mp-run-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  background: var(--mp-bg-input);
  color: var(--mp-text);
}
input[type="range"] { accent-color: var(--mp-brand); }

/* ── Result Cards ───────────────────────────────────────────────── */
.mp-result-card {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-card);
  box-shadow: var(--mp-shadow-card);
  overflow: hidden;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
}

/* Each result card gets a different colored left-rail indicator */
.mp-result-card-h {
  padding: 9px 16px 9px 12px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--mp-text-muted);
  border-bottom: 1px solid var(--mp-border);
  background: var(--mp-bg-header-row);
  display: flex;
  align-items: center;
  gap: 10px;
}
.mp-result-card-h::before {
  content: '';
  display: block;
  width: 3px;
  height: 14px;
  background: var(--mp-amber);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Color the indicator per card position */
.mp-result-card:nth-child(2) .mp-result-card-h::before { background: var(--mp-blue); }
.mp-result-card:nth-child(3) .mp-result-card-h::before { background: var(--mp-green); }
.mp-result-card:nth-child(4) .mp-result-card-h::before { background: var(--mp-violet); }

.mp-result-card-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* Charts that are direct children of a flex card-body expand to fill remaining space */
.mp-result-card-body > .mp-chart { flex: 1; height: auto; min-height: 240px; }
/* The side-by-side ROC+PR pair container also expands */
.mp-result-card-body > .mp-chart-pair { flex: 1; min-height: 0; }

.mp-chart-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--mp-text-muted);
  margin-bottom: 6px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── Metrics KPI Chips ──────────────────────────────────────────── */
.chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  padding: 14px 14px 11px;
  background: var(--mp-bg-surface);
  position: relative;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.chip:hover {
  border-color: rgba(240,180,41,.3);
  box-shadow: 0 0 0 1px rgba(240,180,41,.1);
}

/* Thin colored bottom border instead of top stripe */
.chip::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--mp-amber);
  border-radius: 0;
}
.chip:nth-child(2)::after { background: var(--mp-blue); }
.chip:nth-child(3)::after { background: var(--mp-green); }
.chip:nth-child(4)::after { background: var(--mp-violet); }

.chip-k {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--mp-text-muted);
}
.chip-v {
  font-size: 26px;
  font-weight: 700;
  margin-top: 7px;
  color: var(--mp-text);
  font-variant-numeric: tabular-nums;
  font-family: 'Roboto Mono', monospace;
  line-height: 1.1;
}
.chip-info {
  float: right;
  margin-top: -2px;
  font-size: 12px;
  opacity: .25;
  cursor: help;
  transition: opacity .12s;
}
.chip-info:hover { opacity: .8; }

/* ── Charts ─────────────────────────────────────────────────────── */
.mp-chart {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-surface);
  padding: 12px;
  height: 320px;
  overflow: hidden;
}
#rocCurveChart, #prCurveChart { height: auto; aspect-ratio: 1 / 1; }

.mp-svg { width: 100%; height: 100%; display: block; }
.mp-axis text { font-size: 11px; fill: var(--mp-text-muted); opacity: 1; }
.mp-axis path, .mp-axis line { stroke: var(--mp-border); opacity: .7; }

/* ── Feature Groups ─────────────────────────────────────────────── */
.feature-groups {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  overflow: auto;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  padding: 12px;
  background: var(--mp-bg-surface);
}
.feature-groups-4-4 { grid-template-columns: 1fr 1fr; }
.feature-family { display: flex; flex-direction: column; gap: 6px; }
.feature-family-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--mp-text-dim);
  margin-top: 4px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--mp-border);
}
.feature-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  transition: background .08s;
}
.feature-item:hover { background: var(--mp-bg-raised); }
.feature-meta { display: flex; flex-direction: column; gap: 2px; }
.feature-name { font-size: 12px; color: var(--mp-text); }
.feature-desc { font-size: 11px; color: var(--mp-text-muted); }

/* ── Pattern Grid ───────────────────────────────────────────────── */
.mp-pattern-grid { display: grid; gap: 0; font-size: 11px; }
.mp-pattern-grid-head {
  display: grid;
  grid-template-columns: .9fr .6fr 1.8fr 62px 92px minmax(80px, 200px);
  gap: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--mp-text-dim);
  padding: 0 4px 8px 4px;
  border-bottom: 2px solid var(--mp-border);
}
/* "Saved runs" header spans select + Load + Promote columns */
.mp-pattern-grid-head > :nth-child(3) { grid-column: 3 / 6; }
.mp-pattern-row {
  display: grid;
  grid-template-columns: .9fr .6fr 1.8fr 62px 92px minmax(80px, 200px);
  gap: 10px;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 1px solid var(--mp-border-dim);
  transition: background .08s;
}
.mp-pattern-row:hover { background: var(--mp-bg-raised); }
.mp-pattern-row:last-child { border-bottom: 0; }
.mp-pattern-count {
  display: grid;
  gap: 10px;
  grid-template-columns: 30px 1fr;
}
.mp-pattern-promoted { text-align: left; }
.alert-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240,180,41,.1);
  border-radius: 5px;
  width: 22px;
  height: 14px;
  border: 1px solid rgba(240,180,41,.3);
  padding: 2px;
}
.alert-icon { height: 13px; stroke: var(--mp-brand); stroke-width: 1.5px; }

/* ── KV Groups ──────────────────────────────────────────────────── */
/* Metrics KV: Overall spans full row 1, then 2-col */
#metricsKv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#metricsKv .kv-group:first-child {
  grid-column: 1 / -1;
}
#metricsKv .kv-group {
  margin-bottom: 0;
}
.kv-group {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-card);
  margin-bottom: 8px;
  overflow: hidden;
}
.kv-group-title {
  padding: 9px 13px;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--mp-text-muted);
  cursor: pointer;
  user-select: none;
  background: var(--mp-bg-header-row);
}
.kv-group-body { padding: 8px 13px 12px; }
.kv-v {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-family: 'Roboto Mono', monospace;
  color: var(--mp-text);
}
.kv-k { color: var(--mp-text-muted); font-size: 11px; }
/* kv-v inside metrics groups must not be washed out by .meta opacity */
.kv-group-body .kv-v {
  color: var(--mp-text) !important;
  opacity: 1 !important;
  font-size: 12px !important;
}
.kv-group-body .kv-v.kv-v--better { color: var(--mp-green, #34a85a) !important; }
.kv-group-body .kv-v.kv-v--worse  { color: var(--mp-red,   #e05252) !important; }
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--mp-border-dim);
}
.kv-row:last-child { border-bottom: 0; }
/* 3-col layout when comparing to promoted: label | current | promoted */
.kv-row--delta {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  column-gap: 12px;
}
.kv-promo {
  color: var(--mp-text-muted);
  font-family: 'Roboto Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 500;
  text-align: right;
  opacity: 0.6;
  min-width: 44px;
}
.kv-v--better { color: var(--mp-green, #34a85a) !important; }
.kv-v--worse  { color: var(--mp-red,   #e05252) !important; }

/* ── Save card ──────────────────────────────────────────────────── */
.mp-card {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-card);
  overflow: hidden;
  margin-top: 8px;
}
.mp-card-h {
  padding: 9px 16px 9px 12px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--mp-text-muted);
  border-bottom: 1px solid var(--mp-border);
  background: var(--mp-bg-header-row);
  display: flex;
  align-items: center;
  gap: 10px;
}
.mp-card-h::before {
  content: '';
  display: block;
  width: 3px;
  height: 14px;
  background: var(--mp-teal);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Details / Debug  ───────────────────────────────────────────── */
.mp-details {
  background: var(--mp-bg-card);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  padding: 8px 13px;
}
.mp-details summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--mp-text-muted);
  user-select: none;
  padding: 2px 0;
}
.mp-details summary:hover { color: var(--mp-text); }
.mp-pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  color: var(--mp-text-muted);
  font-family: 'Roboto Mono', monospace;
}

/* ── Placeholder ────────────────────────────────────────────────── */
.placeholder {
  font-size: 12px;
  color: var(--mp-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100% - 20px);
}

/* ── Threshold UI ───────────────────────────────────────────────── */
.mp-threshold-ui {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 0 0 8px 0;
}
/* Perf-tab slider: no stats column — 2-col grid */
.mp-thr-perf {
  grid-template-columns: auto 1fr;
  margin: 0 0 10px 0;
}
#thrSlider { width: 92%; accent-color: var(--mp-brand); }
#thrSliderPerf { accent-color: var(--mp-brand); }
label.mp-threshold-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--mp-text-muted);
}
.mp-threshold-stats {
  white-space: nowrap;
  justify-self: end;
  color: var(--mp-text-muted);
}

/* ── Promoted-run delta badges ───────────────────────────────────── */
/* Chip delta row — block element below the chip value */
.chip-delta-line {
  min-height: 16px;
  margin-top: 5px;
  line-height: 1;
}
.chip-delta {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.chip-delta--good    { background: color-mix(in srgb, var(--mp-green, #34a85a) 15%, transparent); color: var(--mp-green, #34a85a); }
.chip-delta--bad     { background: color-mix(in srgb, var(--mp-red,   #e05252) 15%, transparent); color: var(--mp-red,   #e05252); }
.chip-delta--neutral { background: color-mix(in srgb, var(--mp-text-muted, #888) 12%, transparent); color: var(--mp-text-muted, #888); }

/* KV row deltas (Overall group) */
.kv-delta {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 6px;
  white-space: nowrap;
}
.kv-delta--good    { color: var(--mp-green, #34a85a); background: color-mix(in srgb, var(--mp-green, #34a85a) 12%, transparent); }
.kv-delta--bad     { color: var(--mp-red,   #e05252); background: color-mix(in srgb, var(--mp-red,   #e05252) 12%, transparent); }
.kv-delta--neutral { color: var(--mp-text-muted, #888); background: color-mix(in srgb, var(--mp-text-muted, #888) 10%, transparent); }

/* "vs promoted" label in group summary */
.kv-vs-promo {
  font-size: 10px;
  font-weight: 400;
  color: var(--mp-text-muted);
  margin-left: 6px;
  opacity: 0.7;
}

/* ── Score v2 Controls ──────────────────────────────────────────── */
.score_v2 {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  padding: 4px 12px;
  background: var(--mp-bg-surface);
  font-size: 12px;
  color: var(--mp-text);
}

/* ── Legend ─────────────────────────────────────────────────────── */
.legend { display: flex; flex-direction: row; gap: 12px; margin-right: 16px; align-items: center; }
.legend-item { display: flex; align-items: center; color: var(--mp-text-muted); font-size: 11px; }
.legend-item .bar-dark,
.legend-item .bar-not-dark {
  width: 13px;
  height: 13px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 2px;
}
.bar-dark     { background: var(--mp-brand); }
.bar-not-dark { background: var(--mp-blue); opacity: .6; }
.toggle-checkbox { margin: 0; padding: 0; accent-color: var(--mp-brand); }

/* ── Spark bars ─────────────────────────────────────────────────── */
.mp-pattern-spark {
  display: flex;
  align-items: flex-end;
  height: 28px;
  overflow: hidden;
}
.mp-spark {
  display: flex !important;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
  width: 100%;
  border-bottom: 1px solid var(--mp-border);
  background: transparent;
}
.mp-spark-bar {
  flex: 1;
  min-width: 3px;
  max-width: 16px;
  border-radius: 1px 1px 0 0;
  background: var(--mp-text-muted);
  opacity: .45;
  transition: opacity .12s, background .12s;
}
.mp-spark-bar:hover { opacity: 1; }
.mp-spark-bar.promoted { background: var(--mp-brand); opacity: 1; }
.mp-spark-bar.loaded   { background: var(--mp-blue); opacity: .9; }

/* ── Meta / Muted text ──────────────────────────────────────────── */
.meta {
  font-family: 'Roboto Mono', monospace;
  font-size: 9px !important;
  opacity: .6;
  color: var(--mp-text-muted);
}
.muted { color: var(--mp-text-muted); }
.mono  { font-family: 'Roboto Mono', monospace; }

/* ── Layout Helpers ─────────────────────────────────────────────── */
.kv {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 100px 1fr 100px 1fr;
  gap: 4px 0;
  font-size: 12px;
  padding-bottom: 20px;
  color: var(--mp-text);
}
.mp-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mp-field { display: flex; flex-direction: column; gap: 5px; }
.mp-results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.flex-1 { display: flex; flex-direction: column; gap: 0; }
.lbl { font-weight: 700; }
.lbl::after { content: ":"; }
.mp-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--mp-text);
}
.mp-row-label { font-size: 12px; color: var(--mp-text-muted); }

/* ── KV Collapse ────────────────────────────────────────────────── */
.kv-collapse { display: contents; }
.kv-collapse-header { cursor: pointer; user-select: none; }
.kv-collapse.is-collapsed .kv-collapse-body { display: none; }
.kv-collapse-chev {
  margin-left: auto;
  opacity: .7;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}
.kv-collapse.is-collapsed .kv-collapse-chev { transform: rotate(-90deg); }

/* ── Feature misc ───────────────────────────────────────────────── */
.feature-k-header { display: flex; flex-direction: column; gap: 6px; }
.feature-k-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-direction: column; }
.feature-actions { display: flex; gap: 6px; flex-direction: column; flex: 1; }
.feature-k-sub { font-size: 11px; color: var(--mp-text-muted); }

/* ── Importance list ────────────────────────────────────────────── */
.mp-imp {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-surface);
  padding: 8px 10px;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
  color: var(--mp-text);
}
.mp-imp-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.mp-imp-row:last-child { border-bottom: 0; }
.mp-imp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.mp-imp-val { font-family: 'Roboto Mono', monospace; opacity: .7; }

/* ── Table ──────────────────────────────────────────────────────── */
.mp-table {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-surface);
  padding: 10px;
  color: var(--mp-text);
}

/* ── Threshold line in chart ────────────────────────────────────── */
.mp-thr-line {
  stroke: var(--mp-red);
  stroke-width: 1;
  stroke-dasharray: 6 6;
  stroke-opacity: .75;
}
.mp-thresholds line { stroke: currentColor; opacity: .22; }

/* ── Drawer ─────────────────────────────────────────────────────── */
/* Drawer dark-theme text overrides */
.mp-drawer .kv .k { color: var(--mp-text) !important; }
.mp-drawer .kv .v { color: var(--mp-text) !important; }
.mp-drawer .placeholder { color: var(--mp-text-muted) !important; background: var(--mp-bg-raised) !important; }
.mp-drawer h3 { color: var(--mp-text) !important; }

.mp-drawer {
  background: var(--mp-bg-surface) !important;
  border-right: 1px solid var(--mp-border) !important;
  left: 0;
  right: auto;
  border-left: none;
  transform: translateX(-102%);
  color: var(--mp-text);
}
.mp-drawer.open { transform: translateX(0); }
#mpPointKv.kv { grid-template-columns: 140px 1fr; margin-top: 8px; padding-bottom: 0; }
#mpPointKv .v { word-break: break-word; }
#mpPointKv .mono { font-family: 'Roboto Mono', monospace; }
.mp-point-image-wrap { display: flex; flex-direction: column; gap: 6px; }
.mp-point-image {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 240px;
  object-fit: contain;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: var(--mp-bg-input);
}
.mp-point-image-caption { font-size: 11px; color: var(--mp-text-muted); word-break: break-word; }
.mp-point-image-empty   { font-size: 12px; color: var(--mp-text-dim); }

/* ── Drawer shared overrides (from app.css) ─────────────────────── */
.drawer-title  { color: var(--mp-text) !important; }
.drawer-sub    { color: var(--mp-text-muted) !important; }
.drawer-header { border-bottom: 1px solid var(--mp-border) !important; background: var(--mp-bg-header-row) !important; }
.drawer-body   { background: var(--mp-bg-surface) !important; color: var(--mp-text) !important; }
.drawer-actions .btn { background: var(--mp-bg-raised); color: var(--mp-text); border-color: var(--mp-border); }

/* ── Section headings inside drawer ────────────────────────────── */
.section h3 { color: var(--mp-text); }
.section { background: transparent !important; border: none !important; }

/* ── Accordion pair (Loader + XGBoost) — full width stacked ── */
.mp-acc-pair {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0;
}
.mp-acc-pair > .mp-acc {
  margin-top: 8px;
}

/* ── Chart grid — full width stacked ── */
.mp-chart-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.mp-chart-grid > .mp-result-card {
  margin-top: 0;
}

/* ── Fix: importance chart bar color ────────────────────────────── */
#importanceChart svg rect { fill: var(--mp-brand); }
#importanceChart svg .mp-axis rect { fill: none !important; }
#importanceChart svg text { fill: var(--mp-text-muted); }

/* ── ROC/PR axis visibility ─────────────────────────────────────── */
#rocCurveChart text, #prCurveChart text { fill: var(--mp-text-muted); }
#rocCurveChart path.domain, #prCurveChart path.domain,
#rocCurveChart line, #prCurveChart line { stroke: var(--mp-border); }

/* ── Header Metrics Bar ─────────────────────────────────────────── */
.mp-header-metrics {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.mp-hm-item {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--mp-border);
  background: var(--mp-bg-raised);
  font-size: 10px;
  font-family: 'Roboto Mono', monospace;
  color: var(--mp-text-muted);
  white-space: nowrap;
}
.mp-hm-item .mp-hm-v {
  color: var(--mp-brand);
  font-weight: 700;
}

/* ── Run Comparison Strip ───────────────────────────────────────── */
.mp-comparison-strip {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-card);
  padding: 10px 16px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.mp-cmp-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--mp-text-muted);
  white-space: nowrap;
  border-right: 1px solid var(--mp-border);
  padding-right: 16px;
  min-width: 70px;
}
.mp-cmp-metrics {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.mp-cmp-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.mp-cmp-k {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--mp-text-muted);
  font-family: 'Inter', system-ui, sans-serif;
}
.mp-cmp-delta {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  line-height: 1;
}
.mp-cmp-delta.pos { color: #4ade80; }
.mp-cmp-delta.neg { color: var(--mp-red); }
.mp-cmp-delta.neu { color: var(--mp-text-muted); }
.mp-cmp-vals {
  font-size: 9px;
  font-family: 'Roboto Mono', monospace;
  color: var(--mp-text-dim);
}

/* ── Feature Ablation Panel ─────────────────────────────────────── */
.mp-ablation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 160px;
  overflow-y: auto;
  padding: 2px 0;
}
.mp-abl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--mp-border);
  border-radius: 999px;
  background: var(--mp-bg-surface);
  font-size: 11px;
  font-family: 'Roboto Mono', monospace;
  color: var(--mp-text);
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s;
}
.mp-abl-item:hover { border-color: var(--mp-brand); }
.mp-abl-item.excluded {
  border-color: var(--mp-red);
  background: rgba(239,68,68,.08);
  color: var(--mp-red);
}
.mp-abl-item input[type=checkbox] {
  accent-color: var(--mp-red);
  cursor: pointer;
  padding: 0 !important;
  width: 12px !important;
  height: 12px;
  border: none !important;
  box-shadow: none !important;
}
.mp-abl-gain {
  font-size: 9px;
  opacity: .5;
}

/* ── Ablation / Feature-Exclusion results comparison ────────────── */
.mp-abl-results {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-surface);
}
.mp-abl-results-h {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--mp-text-muted);
  margin-bottom: 8px;
}
.mp-abl-results-h em { text-transform: none; font-style: normal; color: var(--mp-text); }
.mp-abl-cmp-row {
  display: grid;
  grid-template-columns: 90px 1fr 1fr 60px;
  gap: 4px 8px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--mp-border-dim);
  font-size: 11px;
}
.mp-abl-cmp-row:last-child { border-bottom: none; }
.mp-abl-cmp-head { font-size: 9px; font-weight: 700; color: var(--mp-text-muted); letter-spacing: .06em; }
.mp-abl-cmp-k { font-size: 10px; color: var(--mp-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.mp-abl-cmp-base,
.mp-abl-cmp-new  { font-family: 'Roboto Mono', monospace; color: var(--mp-text); }
.mp-abl-cmp-delta { font-family: 'Roboto Mono', monospace; font-weight: 700; text-align: right; }
.mp-abl-cmp-delta.up   { color: var(--mp-green); }
.mp-abl-cmp-delta.down { color: var(--mp-red);   }
.mp-abl-cmp-delta.flat { color: var(--mp-text-muted); }

/* ── Pattern grid: select column, button columns ───────────────── */
.mp-pattern-runs {
  display: flex;
  align-items: center;
}
.mp-pattern-runs .mp-run-select {
  width: 100%;
  min-width: 0;
}
.mp-grid-load-cell,
.mp-grid-promote-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}
.mp-grid-load-cell .loadRunBtn  { width: 100%; white-space: nowrap; }
.mp-grid-promote-cell .promoteBtn { width: 100%; white-space: nowrap; }

/* ── Bigger, bolder KPI metric values ───────────────────────────── */
.chip-v {
  font-size: 28px !important;
  letter-spacing: -.02em;
}

/* ── Chip accent indicator (bottom stripe) ──────────────────────── */
/* First chip: amber; overrides previously set var(--mp-amber) to match new scheme */
.chip::after     { background: var(--mp-amber); }
.chip:nth-child(2)::after { background: var(--mp-blue); }
.chip:nth-child(3)::after { background: var(--mp-brand); }
.chip:nth-child(4)::after { background: var(--mp-violet); }

/* (ROC/PR axis rules moved up) */

/* ── Analysis Accordion ─────────────────────────────────────────── */
.mp-analysis-acc { margin-top: 6px; }

/* Full-width actions bar (outside the two-column grid) */
.mp-actions-bar--full {
  margin-top: 12px;
}

/* ── Tab bar ────────────────────────────────────────────────────── */
.mp-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--mp-border);
  margin: 0 0 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.mp-tab-bar::-webkit-scrollbar { display: none; }

.mp-tab-btn {
  flex: 0 0 auto;
  padding: 7px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--mp-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .1s, border-color .1s;
}
.mp-tab-btn:hover { color: var(--mp-text); }
.mp-tab-btn.is-active {
  color: var(--mp-brand);
  border-bottom-color: var(--mp-brand);
}

/* ── Tab panels ─────────────────────────────────────────────────── */
.mp-tab-panel { display: none; }
.mp-tab-panel.is-active { display: block; }

/* Fixed-height tab content area — keeps accordion height stable across tabs */
.mp-tab-body {
  min-height: 520px;
}

/* ── Actions bar save controls ──────────────────────────────────── */
.mp-bar-sep {
  width: 1px;
  height: 22px;
  background: var(--mp-border-bright);
  flex-shrink: 0;
  margin: 0 4px;
}
.mp-save-field {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.mp-notes-field { flex: 1; min-width: 120px; }
.mp-notes-field input { width: 100%; }
.mp-save-field input {
  padding: 4px 7px;
  font-size: 12px;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  background: var(--mp-bg-raised);
  color: var(--mp-text);
}

/* ── Card badge ─────────────────────────────────────────────────── */
.mp-card-badge {
  font-size: 9px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--mp-text-muted);
  margin-left: 8px;
  opacity: .75;
}

/* ── Confidence Distribution Histogram ──────────────────────────── */
.mp-conf-legend {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 10px;
}
.mp-conf-leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.mp-conf-leg-item::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
}
.mp-conf-leg-pos::before { background: var(--mp-brand); }
.mp-conf-leg-neg::before { background: var(--mp-blue); }

/* ── Calibration Curve ──────────────────────────────────────────── */
/* chart uses mp-chart + D3 inline; no extra layout needed */

/* ── Feature Importance Delta ───────────────────────────────────── */
.mp-imp-delta-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.mp-imp-delta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: 'Roboto Mono', monospace;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--mp-bg-raised);
}
.mp-imp-delta-rank {
  color: var(--mp-text-muted);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}
.mp-imp-delta-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--mp-text);
}
.mp-imp-delta-arrow {
  font-size: 12px;
  width: 30px;
  text-align: center;
  flex-shrink: 0;
}
.mp-imp-delta-arrow.up   { color: #22c55e; }
.mp-imp-delta-arrow.down { color: var(--mp-red); }
.mp-imp-delta-arrow.new  { color: var(--mp-brand); }
.mp-imp-delta-arrow.gone { color: var(--mp-text-muted); }
.mp-imp-delta-gain {
  font-size: 9px;
  color: var(--mp-text-muted);
  text-align: right;
  width: 50px;
  flex-shrink: 0;
}

/* ── Hardest Cases Spotlight ────────────────────────────────────── */
.mp-hard-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 260px;
  overflow-y: auto;
}
.mp-hard-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--mp-border);
  background: var(--mp-bg-raised);
  cursor: pointer;
  transition: border-color .1s, background .1s;
}
.mp-hard-item:hover { border-color: var(--mp-brand); background: var(--mp-bg-card); }
.mp-hard-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mp-hard-dot.pos { background: var(--mp-brand); }
.mp-hard-dot.neg { background: var(--mp-blue); }
.mp-hard-domain {
  font-family: 'Roboto Mono', monospace;
  color: var(--mp-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-hard-prob {
  font-family: 'Roboto Mono', monospace;
  color: var(--mp-brand);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.mp-hard-dist {
  font-size: 9px;
  color: var(--mp-text-muted);
  flex-shrink: 0;
  width: 40px;
  text-align: right;
}

/* ── Dataset Drift Indicator ────────────────────────────────────── */
.mp-drift-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-left: 8px;
}
.mp-drift-badge.ok   { background: rgba(34,197,94,.15); color: #22c55e; }
.mp-drift-badge.warn { background: rgba(233,162,59,.15); color: var(--mp-brand); }
.mp-drift-badge.crit { background: rgba(239,68,68,.15);  color: var(--mp-red);   }
.mp-drift-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mp-drift-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--mp-bg-raised);
}
.mp-drift-label {
  color: var(--mp-text-muted);
  width: 120px;
  flex-shrink: 0;
}
.mp-drift-val {
  color: var(--mp-text);
  font-family: 'Roboto Mono', monospace;
  flex: 1;
}
.mp-drift-change {
  font-size: 10px;
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
}
.mp-drift-change.ok   { color: #22c55e; }
.mp-drift-change.warn { color: var(--mp-brand); }
.mp-drift-change.crit { color: var(--mp-red); }
