/* ChartLite × BODHI Benchmark — design system
   ─────────────────────────────────────────────
   Layout: centered 1260-max column, generous whitespace, clear sections.
   Type scale: 12 · 13 · 14 · 16 · 20 · 28 · 40
   Color: one accent (indigo), arms color-coded (amber/slate/emerald).
   Density: comfortable — let the data breathe. */

:root {
  /* Neutrals */
  --bg: #f8fafc;
  --panel: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-soft: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Accents */
  --accent: #4338ca;
  --accent-soft: #eef2ff;
  --accent-hover: #3730a3;

  /* Arms (semantic colors) */
  --arm1: #d97706;        /* amber — inherent LLM reasoning */
  --arm1-soft: #fffbeb;
  --arm2: #64748b;        /* slate — current rules */
  --arm2-soft: #f1f5f9;
  --arm3: #047857;        /* emerald — BODHI-integrated */
  --arm3-soft: #ecfdf5;
  --judge: #7c3aed;       /* violet — LLM judge */
  --judge-soft: #f5f3ff;

  /* Severity */
  --crit: #dc2626;
  --warn: #ea580c;
  --info: #2563eb;

  /* Shape */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06);

  /* Type */
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }

.container { max-width: 1260px; margin: 0 auto; padding: 0 32px; }
@media (max-width: 700px) { .container { padding: 0 16px; } }

/* ── Header ──────────────────────────────────────────────────────── */
.site-header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #4338ca 0%, #047857 100%);
  color: white; font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; flex-shrink: 0;
}
.brand-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 2px; }
.tab {
  padding: 8px 14px; font-size: 13px; color: var(--text-muted);
  text-decoration: none; border-radius: var(--r-sm);
  transition: color 0.12s, background-color 0.12s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(15,23,42,0.04); }
.tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

/* ── Main ────────────────────────────────────────────────────────── */
main { padding: 40px 0 80px; min-height: 70vh; }

/* ── Hero ────────────────────────────────────────────────────────── */
.hero { margin-bottom: 40px; }
.hero h1 {
  font-size: 36px; line-height: 1.15; font-weight: 600; letter-spacing: -0.03em;
  margin: 0 0 14px; max-width: 900px;
}
.hero p { font-size: 16px; color: var(--text-soft); max-width: 820px; margin: 0; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; flex-wrap: wrap; }

/* ── Section ─────────────────────────────────────────────────────── */
.section { margin-bottom: 40px; }
.section-header { margin-bottom: 16px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); font-weight: 600; margin: 0;
}
.section-h {
  font-size: 20px; font-weight: 600; letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.section-sub { color: var(--text-muted); font-size: 13px; margin: 0; }

/* ── Panel (the primary content container) ─────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 20px; }
.panel-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); font-weight: 600; margin: 0 0 4px;
}
.panel-h { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 4px; }
.panel-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }

/* ── Grid ────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Metric / Stat card ────────────────────────────────────────── */
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.stat-label-tag {
  font-size: 9px; padding: 2px 6px; border-radius: 3px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.stat-value {
  font-size: 32px; font-weight: 600; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat-value.small { font-size: 22px; }
.stat-value.xs { font-size: 16px; font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat.arm1 { border-left: 3px solid var(--arm1); }
.stat.arm1 .stat-value { color: var(--arm1); }
.stat.arm2 { border-left: 3px solid var(--arm2); }
.stat.arm2 .stat-value { color: var(--arm2); }
.stat.arm3 { border-left: 3px solid var(--arm3); }
.stat.arm3 .stat-value { color: var(--arm3); }
.stat.judge { border-left: 3px solid var(--judge); }
.stat.judge .stat-value { color: var(--judge); }
.stat.delta { background: linear-gradient(180deg, var(--arm3-soft) 0%, transparent 60%); border-color: var(--arm3); }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
table {
  width: 100%; border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead { background: #f8fafc; }
th {
  padding: 12px 14px; text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
  cursor: default;
}
th[title] { cursor: help; }
td {
  padding: 13px 14px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; transition: background-color 0.1s; }
tr.clickable:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; }
td.mono { font-family: var(--mono); font-size: 12px; }

/* ── Bars ────────────────────────────────────────────────────────── */
.bar-cell { display: inline-flex; align-items: center; gap: 10px; min-width: 160px; }
.bar {
  height: 8px; border-radius: 4px; flex: 1;
  background: #f1f5f9; position: relative; overflow: hidden;
  min-width: 90px;
}
.bar-fill { height: 100%; position: absolute; top: 0; left: 0; border-radius: 4px; transition: width 0.4s ease; }
.bar-fill.arm1 { background: var(--arm1); }
.bar-fill.arm2 { background: var(--arm2); }
.bar-fill.arm3 { background: var(--arm3); }
.bar-fill.judge { background: var(--judge); }
.bar-pct { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-soft); min-width: 44px; text-align: right; font-family: var(--mono); }

/* ── Chips ───────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 500;
  background: #f1f5f9; color: var(--text-soft);
}
.chip.warn { background: #fff7ed; color: var(--warn); }
.chip.crit { background: #fef2f2; color: var(--crit); }
.chip.info { background: #eff6ff; color: var(--info); }
.chip.rules { background: var(--arm2-soft); color: var(--arm2); }
.chip.bodhi { background: var(--arm3-soft); color: var(--arm3); }
.chip.judge { background: var(--judge-soft); color: var(--judge); }
.chip.cat { background: var(--accent-soft); color: var(--accent); }

.tag {
  font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px; background: #f1f5f9; color: var(--text-soft);
  display: inline-block;
}

/* ── Delta pills ─────────────────────────────────────────────────── */
.delta {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.delta.pos { background: var(--arm3-soft); color: var(--arm3); }
.delta.neg { background: #fef2f2; color: var(--crit); }
.delta.zero { background: #f1f5f9; color: var(--text-muted); }

/* ── Controls ────────────────────────────────────────────────────── */
.controls { display: flex; gap: 12px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; padding: 12px 20px 12px 24px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.controls label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
select, input[type="text"] {
  padding: 7px 11px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: white;
  font-size: 13px; color: var(--text); font-family: inherit;
}
select:focus, input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ── Transcript / code blocks ───────────────────────────────────── */
.transcript {
  font-family: var(--mono); font-size: 12px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 14px 16px; white-space: pre-wrap; line-height: 1.6;
  max-height: 520px; overflow-y: auto;
}
.muted { color: var(--text-muted); font-size: 13px; }

/* ── Alert list ──────────────────────────────────────────────────── */
.alerts-list { display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  display: grid; grid-template-columns: 70px 80px 140px 1fr; gap: 10px;
  align-items: center; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; background: white;
}
.alert-item .alert-msg { color: var(--text); }

.dangers-list { display: flex; flex-direction: column; gap: 6px; }
.danger-item {
  padding: 8px 12px; border-radius: var(--r-sm);
  font-size: 13px; display: flex; gap: 10px; align-items: center;
  background: #fff7ed; border: 1px solid #fed7aa;
}
.danger-item .danger-cat { font-weight: 500; min-width: 140px; color: var(--warn); }

/* ── Judge card ──────────────────────────────────────────────────── */
.judge-note {
  background: var(--judge-soft);
  border: 1px solid #e9d5ff;
  border-left: 3px solid var(--judge);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-soft);
  font-style: italic;
  margin-top: 8px;
}

/* ── Raw output viewer ──────────────────────────────────────────── */
.raw-tabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.raw-tab {
  padding: 9px 16px; font-size: 13px; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  user-select: none; font-weight: 500;
}
.raw-tab:hover { color: var(--text); }
.raw-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.raw-content { display: none; }
.raw-content.active { display: block; }
.raw-pre {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: #0f172a; color: #e2e8f0;
  border-radius: var(--r-sm); padding: 16px 18px;
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 520px; overflow-y: auto;
}
.raw-pre.note { background: #fafafa; color: var(--text); border: 1px solid var(--border); }
.raw-meta {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-size: 11px; color: var(--text-muted); margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}
.raw-meta .chip { background: var(--accent-soft); color: var(--accent); }

/* ── Model picker for encounter detail ───────────────────────────── */
.model-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.model-picker button {
  padding: 7px 13px; font-size: 12.5px; font-family: inherit;
  border: 1px solid var(--border-strong); background: white;
  border-radius: var(--r-sm); cursor: pointer;
  color: var(--text); transition: all 0.1s;
  font-weight: 500;
  white-space: nowrap;
}
.model-picker button:hover { background: #f1f5f9; border-color: var(--text-muted); }
.model-picker button.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Bar list (compact horizontal bars for a series) ─────────────── */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 60px; gap: 12px; align-items: center; font-size: 13px; }
.bar-row-label { color: var(--text-soft); font-weight: 500; }
.bar-row-track { height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.bar-row-fill { height: 100%; border-radius: 5px; transition: width 0.4s; }
.bar-row-num { font-family: var(--mono); font-size: 12px; color: var(--text); text-align: right; }

/* ── 4-stat SOAP grid ────────────────────────────────────────────── */
.soap-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.soap-cell { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.soap-cell .soap-letter { font-size: 24px; font-weight: 600; color: var(--text); line-height: 1; margin-bottom: 2px; }
.soap-cell .soap-name { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.soap-cell .soap-pct { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.soap-cell.strong { background: var(--arm3-soft); border-color: #a7f3d0; }
.soap-cell.strong .soap-pct { color: var(--arm3); }
.soap-cell.partial { background: #fffbeb; border-color: #fde68a; }
.soap-cell.partial .soap-pct { color: var(--arm1); }
.soap-cell.weak { background: #fef2f2; border-color: #fecaca; }
.soap-cell.weak .soap-pct { color: var(--crit); }
@media (max-width: 700px) { .soap-grid { grid-template-columns: 1fr 1fr; } }

/* ── Metric pairs (compact inline display) ───────────────────────── */
.metric-pair {
  display: flex; align-items: baseline; gap: 8px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.metric-pair:last-child { border: none; }
.metric-pair .label {
  color: var(--text-muted); font-size: 13px; font-weight: 500; flex: 1;
}
.metric-pair .value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Footer ──────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--text-muted); font-size: 12px; margin-top: 60px; background: var(--panel); }
.site-footer #meta-line { margin-bottom: 6px; font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

/* ── Loading / empty states ──────────────────────────────────────── */
.loading, .empty {
  padding: 64px 24px; text-align: center; color: var(--text-muted); font-size: 14px;
  background: var(--panel); border: 1px dashed var(--border-strong); border-radius: var(--r-md);
}

/* ── Utility ─────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-6 { gap: 6px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Info callout */
.callout {
  padding: 14px 16px; border-radius: var(--r-sm);
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  font-size: 13px; color: var(--text-soft);
}
.callout strong { color: var(--text); }

/* Scoring legend — compact and clear */
.scoring-legend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.scoring-legend-item { padding: 12px; border-radius: var(--r-sm); background: #f8fafc; border: 1px solid var(--border); }
.scoring-legend-item .type-tag {
  display: inline-block; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 2px 8px; border-radius: 3px; margin-bottom: 6px;
}
.scoring-legend-item.deterministic .type-tag { background: var(--arm2-soft); color: var(--arm2); }
.scoring-legend-item.judge .type-tag { background: var(--judge-soft); color: var(--judge); }
.scoring-legend-item h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.scoring-legend-item p { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
