/* Iris Benchmarks Dashboard */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --surface3: #2a2e44;
  --border: #2e3248;
  --text: #e8eaf0;
  --text-muted: #8b91a8;
  --accent: #6c63ff;
  --accent-hover: #7d75ff;
  --accent-dim: rgba(108,99,255,0.12);
  --correct: #34c97e;
  --wrong: #e05c6e;
  --warn: #f0a840;
  --running: #4db8ff;
  --sidebar-w: 200px;
  --radius: 10px;
  --font: 'Lexend', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
code { font-family: 'Courier New', monospace; font-size: 11px; background: var(--surface3); padding: 1px 5px; border-radius: 3px; }

/* ─── SHELL ─── */
html, body { height: 100%; overflow: hidden; }
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 20;
}
.topbar__logo { font-size: 17px; font-weight: 700; white-space: nowrap; }
.topbar__logo span { color: var(--accent); }
.topbar__sub { font-size: 12px; color: var(--text-muted); }
.help-btn { padding: 5px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.help-btn:hover { border-color: var(--accent); color: var(--text); }

.app-body {
  display: flex;
  flex-direction: row;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-left: 3px solid transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all .15s;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--text); background: var(--accent-dim); border-left-color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 12px 16px; }
.nav-bench-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .7px; padding: 0 18px 6px; }
.bench-tabs-v { display: flex; flex-direction: column; }
.bench-tab { padding: 7px 18px; font-size: 12px; color: var(--text-muted); background: none; border: none; text-align: left; cursor: pointer; transition: all .15s; }
.bench-tab:hover { color: var(--text); background: var(--surface2); }
.bench-tab.active { color: var(--accent); font-weight: 600; }

/* ─── MAIN ─── */
.main {
  flex: 1 1 0;
  min-width: 0;
  overflow-y: auto;
  padding: 24px 28px;
}
.section { max-width: 1100px; }

/* ─── CARDS ─── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; }
.card__title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 14px; }

/* ─── WIZARD ─── */
.wizard { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .wizard { grid-template-columns: 1fr; } }
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
select, input[type=number], input[type=text] { background: var(--surface2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); padding: 7px 10px; font-size: 13px; font-family: var(--font); width: 100%; }
select:focus, input:focus { outline: none; border-color: var(--accent); }
.dataset-info { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 2px; }
.check-btn { padding: 4px 11px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 12px; }
.check-btn:hover { border-color: var(--accent); color: var(--text); }
.check-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 4px; }
.launch-btn { padding: 9px 26px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; transition: background .15s; }
.launch-btn:hover { background: var(--accent-hover); }
.launch-btn:disabled { opacity: .5; cursor: not-allowed; }
.eval-id-preview { font-size: 11px; color: var(--text-muted); font-family: monospace; }

/* ─── LEADERBOARD ─── */
.leaderboard { display: flex; flex-direction: column; gap: 10px; }
.lb-row { display: grid; grid-template-columns: 26px 1fr 100px 64px 60px; align-items: center; gap: 12px; }
.lb-rank { font-size: 11px; font-weight: 700; color: var(--text-muted); text-align: right; }
.lb-model { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-model small { display: block; color: var(--text-muted); font-size: 11px; }
.lb-bar-wrap { height: 8px; background: var(--surface2); border-radius: 4px; }
.lb-bar { height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s; }
.lb-pct { font-size: 14px; font-weight: 700; text-align: right; }
.lb-runs { font-size: 11px; color: var(--text-muted); text-align: right; }

/* ─── RUNS TABLE ─── */
.runs-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 160px; max-width: 280px; padding: 6px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; font-family: var(--font); }
.search-input:focus { outline: none; border-color: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 7px 12px; text-align: left; font-weight: 600; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; }
thead th:hover { color: var(--text); }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 8px 12px; vertical-align: middle; }
.acc-badge { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.acc-badge.high { background: rgba(52,201,126,.15); color: var(--correct); }
.acc-badge.mid  { background: rgba(240,168,64,.15);  color: var(--warn); }
.acc-badge.low  { background: rgba(224,92,110,.15);  color: var(--wrong); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-pill.running   { background: rgba(77,184,255,.12); color: var(--running); }
.status-pill.completed { background: rgba(52,201,126,.12); color: var(--correct); }
.status-pill.cancelled { background: rgba(240,168,64,.12); color: var(--warn); }
.status-pill.failed    { background: rgba(224,92,110,.12); color: var(--wrong); }
.status-pill.queued    { background: rgba(139,145,168,.12); color: var(--text-muted); }
.status-pill.interrupted { background: rgba(224,92,110,.12); color: var(--wrong); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--running); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ─── LIVE VIEW ─── */
.live-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.back-btn { padding: 5px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; }
.back-btn:hover { border-color: var(--accent); }
.live-title { font-size: 15px; font-weight: 700; }
.live-meta { font-size: 12px; color: var(--text-muted); }
.progress-wrap { margin-bottom: 16px; }
.progress-bar-track { height: 10px; background: var(--surface2); border-radius: 5px; overflow: hidden; margin-bottom: 8px; }
.progress-bar-fill { height: 100%; border-radius: 5px; background: var(--accent); transition: width .4s ease; }
.progress-bar-fill.done { background: var(--correct); }
.progress-bar-fill.cancelled { background: var(--warn); }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.live-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.live-stat { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.live-stat__label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.live-stat__value { font-size: 20px; font-weight: 700; margin-top: 1px; }
.live-stat__value.c { color: var(--correct); }
.live-stat__value.w { color: var(--wrong); }
.live-stat__value.r { color: var(--running); }
.cancel-btn { padding: 7px 18px; border-radius: 8px; border: 1px solid var(--wrong); background: transparent; color: var(--wrong); font-size: 13px; }
.cancel-btn:hover { background: rgba(224,92,110,.1); }
.cancel-btn:disabled { opacity: .4; cursor: not-allowed; }
.live-feed { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.feed-row { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 6px; background: var(--surface2); font-size: 12px; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.feed-icon { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.feed-icon.c { background: rgba(52,201,126,.2); color: var(--correct); }
.feed-icon.w { background: rgba(224,92,110,.2); color: var(--wrong); }
.feed-icon.s { background: rgba(139,145,168,.2); color: var(--text-muted); }
.feed-level { font-size: 10px; font-weight: 700; color: var(--text-muted); background: var(--surface3); padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
.feed-q { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-ans { flex-shrink: 0; font-size: 11px; color: var(--text-muted); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.feed-dur { flex-shrink: 0; font-size: 10px; color: var(--text-muted); }

/* ─── DETAIL VIEW ─── */
.detail-panel { display: none; }
.detail-panel.visible { display: block; }
.detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-title { font-size: 15px; font-weight: 700; }
.detail-meta { font-size: 12px; color: var(--text-muted); }
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 11px 14px; }
.stat-card__label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card__value { font-size: 20px; font-weight: 700; margin-top: 1px; }
.stat-card__value.g { color: var(--correct); }
.stat-card__value.r { color: var(--wrong); }
.level-bars { display: flex; flex-direction: column; gap: 8px; }
.level-row { display: grid; grid-template-columns: 36px 1fr 80px; align-items: center; gap: 10px; }
.level-label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.level-bar-wrap { height: 9px; background: var(--surface2); border-radius: 5px; }
.level-bar { height: 100%; border-radius: 5px; background: var(--accent); transition: width .4s; }
.level-pct { font-size: 12px; font-weight: 700; text-align: right; }
.bucket-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bucket-chip { padding: 4px 12px; border-radius: 8px; font-size: 12px; border: 1px solid var(--border); cursor: pointer; transition: all .15s; }
.bucket-chip:hover, .bucket-chip.active { border-color: var(--accent); color: var(--text); background: var(--accent-dim); }
.filter-strip { display: flex; gap: 7px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.filter-btn { padding: 3px 11px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 12px; }
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── QUESTION ROWS ─── */
.q-row { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 7px; overflow: hidden; }
.q-header { display: flex; align-items: center; gap: 9px; padding: 9px 13px; cursor: pointer; background: var(--surface); transition: background .1s; }
.q-header:hover { background: var(--surface2); }
.q-icon { width: 19px; height: 19px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.q-icon.c { background: rgba(52,201,126,.2); color: var(--correct); }
.q-icon.w { background: rgba(224,92,110,.2); color: var(--wrong); }
.q-icon.s { background: rgba(139,145,168,.2); color: var(--text-muted); }
.q-level { font-size: 10px; font-weight: 600; color: var(--text-muted); background: var(--surface2); padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
.q-text { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.q-pair { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.q-chevron { font-size: 9px; color: var(--text-muted); flex-shrink: 0; transition: transform .2s; }
.q-row.open .q-chevron { transform: rotate(180deg); }
.q-body { display: none; padding: 12px 13px 12px 42px; background: var(--bg); border-top: 1px solid var(--border); }
.q-row.open .q-body { display: block; }
.q-field { margin-bottom: 8px; }
.q-field label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; display: block; margin-bottom: 2px; }
.q-field p { font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.q-status { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 5px; background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.trace-btn { margin-top: 8px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--accent); font-size: 11px; }
.trace-btn:hover { background: var(--surface2); }
.trace-list { margin-top: 8px; display: none; }
.trace-list.open { display: block; }
.trace-step { display: flex; gap: 8px; margin-bottom: 5px; font-size: 11px; }
.trace-step__n { width: 20px; height: 20px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--text-muted); flex-shrink: 0; }
.trace-step__body { flex: 1; }
.trace-type { display: inline-block; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 1px; }
.trace-type.thinking     { background: rgba(108,99,255,.15); color: var(--accent); }
.trace-type.tool_call    { background: rgba(240,168,64,.15); color: var(--warn); }
.trace-type.tool_result  { background: rgba(52,201,126,.15); color: var(--correct); }
.trace-type.final_answer { background: rgba(52,201,126,.2);  color: var(--correct); }
.trace-type.error        { background: rgba(224,92,110,.15); color: var(--wrong); }
.trace-detail { max-height: 100px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 3px 7px; color: var(--text-muted); font-size: 11px; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }

/* ─── UTILITIES ─── */
.empty-state { padding: 36px; text-align: center; color: var(--text-muted); font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 28px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RUN POPUP ─── */
#run-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 90;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 20px;
  overflow-y: auto;
}
#run-popup-overlay.open { display: flex; }

#run-popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.popup-title { font-size: 18px; font-weight: 700; }
.popup-subtitle { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-top: 1px; }
.popup-close { background: none; border: none; color: var(--text-muted); font-size: 26px; line-height: 1; padding: 0 4px; margin-left: 4px; }
.popup-close:hover { color: var(--text); }

.popup-progress-section {
  padding: 18px 26px 0;
  flex-shrink: 0;
}

.popup-stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 14px 26px;
  flex-shrink: 0;
}
.popup-stat { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.popup-stat__label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.popup-stat__value { font-size: 22px; font-weight: 700; margin-top: 2px; }

.popup-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  min-height: 340px;
  border-top: 1px solid var(--border);
}
.popup-feed-col {
  padding: 18px 22px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: 420px;
}
.popup-right-col {
  padding: 18px 22px;
  overflow-y: auto;
  max-height: 420px;
}
.popup-col-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 10px;
}
.popup-feed { display: flex; flex-direction: column; gap: 5px; }
.popup-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ─── HELP MODAL ─── */
#help-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 100; overflow-y: auto; padding: 32px 20px; }
.help-modal { max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.help-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 28px; border-bottom: 1px solid var(--border); }
.help-header h2 { font-size: 18px; font-weight: 700; }
.help-close { background: none; border: none; color: var(--text-muted); font-size: 24px; line-height: 1; padding: 0 4px; }
.help-close:hover { color: var(--text); }
.help-body { padding: 24px 28px; display: flex; flex-direction: column; gap: 24px; font-size: 13px; line-height: 1.7; }
.help-footer { padding: 16px 28px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.help-section h3 { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 10px; }
.help-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.help-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 600px) { .help-grid-2, .help-grid-3 { grid-template-columns: 1fr; } }
.help-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12px; color: var(--text-muted); }
.help-box__title { font-weight: 600; font-size: 12px; color: var(--text); margin-bottom: 3px; }
.level-help-row { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; }
.help-level-badge { font-weight: 700; padding: 3px 10px; border-radius: 6px; text-align: center; font-size: 12px; display: inline-block; }
.help-table { width: 100%; border-collapse: collapse; font-size: 12px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.help-table th { padding: 7px 12px; text-align: left; font-weight: 600; color: var(--text-muted); background: var(--surface2); border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.help-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.help-table tr:last-child td { border-bottom: none; }
.help-scores { display: flex; gap: 10px; flex-wrap: wrap; }
.help-score-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; text-align: center; flex: 1; min-width: 140px; font-size: 11px; color: var(--text-muted); }
.help-score-val { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.help-tips { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.help-datasets-row { display: grid; grid-template-columns: 190px 1fr; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.help-datasets-row:last-child { border-bottom: none; }
