/* ==========================================================================
   Evaluation Harness — UI, sharing the design language of the RAG app:
     deep violet #2F004F · plum #722268 · coral #E85F5C · amber #F5AB00
     off-white #F7F7F9 · ink #221331
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --violet-950: #22003b;
  --violet-900: #2f004f;
  --violet-800: #3d0f63;
  --violet-100: #efe6f7;
  --plum: #722268;
  --coral: #e85f5c;
  --coral-dark: #d14b48;
  --coral-soft: #fdeeed;
  --amber: #f5ab00;
  --amber-soft: #fdf3da;
  --teal: #0e7c86;
  --teal-soft: #e2f4f5;
  --bg: #f7f7f9;
  --surface: #ffffff;
  --ink: #221331;
  --muted: #6f677e;
  --border: #e7e3ee;
  --border-strong: #d8d2e2;
  --success: #1e9e6a;
  --success-soft: #e4f5ee;
  --danger: #c43d3b;
  --danger-soft: #fbe9e9;
  --radius: 12px;
  --radius-sm: 8px;
  --rail-w: 244px;
  --topbar-h: 60px;
  --shadow-sm: 0 1px 2px rgba(34, 0, 59, 0.06), 0 1px 3px rgba(34, 0, 59, 0.08);
  --shadow-md: 0 4px 16px rgba(34, 0, 59, 0.10);
  --shadow-lg: 0 12px 40px rgba(34, 0, 59, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
code, pre, .mono { font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
code { background: var(--violet-100); color: var(--violet-900); padding: 0.1em 0.4em; border-radius: 5px; }
h1, h2, h3, h4 { margin: 0 0 0.5rem 0; font-weight: 700; color: var(--ink); }
p { margin: 0 0 0.5rem 0; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--plum); }
::selection { background: var(--coral); color: #fff; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.nav-rail {
  width: var(--rail-w);
  background: linear-gradient(180deg, var(--violet-900) 0%, var(--violet-950) 100%);
  color: #efe9f6; display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  transform: translateX(-100%); transition: transform 0.24s ease;
}
.nav-rail.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.nav-brand { display: flex; align-items: center; gap: 0.7rem; padding: 1.15rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 800; font-size: 1rem; color: #fff; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.68rem; color: #b9a8cd; font-weight: 500; }

.nav-menu { padding: 0.9rem 0.7rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item { display: flex; align-items: center; gap: 0.7rem; width: 100%; background: transparent; border: none;
  color: #cbbcdc; font-size: 0.9rem; font-weight: 600; padding: 0.68rem 0.85rem; border-radius: 9px;
  text-align: left; transition: background 0.15s ease, color 0.15s ease; position: relative; }
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.11); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -0.7rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--coral); }
.nav-foot { margin-top: auto; padding: 1rem 1.1rem 1.2rem; border-top: 1px solid rgba(255, 255, 255, 0.09); }
.nav-pipeline { font-size: 0.68rem; line-height: 1.6; color: #a893be; font-weight: 500; }

.backdrop { position: fixed; inset: 0; background: rgba(34, 0, 59, 0.45); z-index: 55; opacity: 0;
  pointer-events: none; transition: opacity 0.2s ease; }
.backdrop.show { opacity: 1; pointer-events: auto; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- topbar ---------- */
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 0.85rem; padding: 0 1.1rem;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40; }
.page-title { font-size: 1.08rem; font-weight: 800; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 0.75rem; font-weight: 600;
  padding: 0.32rem 0.7rem; border-radius: 999px; white-space: nowrap; }
.chip-model { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.status-dot.ok { background: var(--success); }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--ink);
  border-radius: var(--radius-sm); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.only-mobile { display: inline-flex; }

/* ---------- content ---------- */
.content { flex: 1; padding: 1.25rem 1.1rem 2rem; width: 100%; max-width: 1120px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.page-lede { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.card-title { font-size: 0.95rem; font-weight: 800; margin-bottom: 0.85rem; display: flex; align-items: center; gap: 0.5rem; }
.card-title svg { color: var(--plum); flex-shrink: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-2.tight { gap: 0.35rem 1.2rem; }
.span-2 { grid-column: 1 / -1; }
.section-label { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 1.6rem 0 0.7rem; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 0.8rem; min-width: 0; }
.field > span { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
.field .val { color: var(--plum); font-weight: 800; }
input[type="text"], input[type="number"], input[type="password"], textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink);
  border-radius: var(--radius-sm); padding: 0.58rem 0.75rem; font-size: 0.88rem; font-family: inherit;
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
input:focus, textarea:focus, select:focus { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(114, 34, 104, 0.13); }
textarea { resize: vertical; min-height: 2.4rem; line-height: 1.5; font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }
::placeholder { color: #b3abc1; }
input[type="range"] { width: 100%; accent-color: var(--coral); height: 24px; }
.hint { font-size: 0.76rem; color: var(--muted); line-height: 1.5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem;
  font-weight: 600; color: var(--ink); margin-bottom: 0.8rem; cursor: pointer; gap: 0.6rem; }
.switch-row input[type="checkbox"] { position: absolute; opacity: 0; }
.switch { width: 40px; height: 22px; border-radius: 999px; background: var(--border); border: 1px solid var(--border-strong);
  position: relative; flex-shrink: 0; transition: background 0.18s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.18s ease; }
.switch-row input:checked + .switch { background: var(--success); border-color: var(--success); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  padding: 0.62rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 700; min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease; }
.btn:hover { border-color: var(--plum); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn-secondary { background: var(--violet-100); border-color: var(--violet-100); color: var(--violet-900); }
.btn-secondary:hover { border-color: var(--plum); }
.btn-ghost { background: transparent; color: var(--plum); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--plum); background: var(--violet-100); }

/* ---------- toasts ---------- */
.toast-container { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 0.5rem; align-items: center; width: min(92vw, 430px); }
.toast { width: 100%; border-radius: var(--radius-sm); padding: 0.68rem 0.95rem; font-size: 0.83rem; font-weight: 600;
  box-shadow: var(--shadow-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  animation: toast-in 0.2s ease; }
.toast.success { border-color: var(--success); background: var(--success-soft); color: #0f6b46; }
.toast.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- config summary strip ---------- */
.config-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
.cfg-item { display: flex; align-items: center; gap: 0.6rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.7rem 0.85rem; box-shadow: var(--shadow-sm); }
.cfg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.cfg-dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.cfg-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.cfg-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.cfg-label { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.cfg-value { font-size: 0.82rem; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.3rem; }
.conn-result { font-size: 0.78rem; font-weight: 700; }
.conn-result.ok { color: var(--success); } .conn-result.err { color: var(--danger); } .conn-result.testing { color: var(--muted); }

/* ---------- stat cards (metrics) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-bottom: 1rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.95rem 1rem; box-shadow: var(--shadow-sm); position: relative; }
.stat-card.pass { border-color: var(--success); box-shadow: inset 0 0 0 1px var(--success), var(--shadow-sm); }
.stat-card.fail { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger), var(--shadow-sm); }
.stat-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; display: block; }
.stat-num { display: block; font-size: 1.7rem; font-weight: 800; color: var(--violet-900); line-height: 1.15; margin-top: 0.15rem; }
.stat-thresh { font-size: 0.68rem; color: var(--muted); margin-top: 0.1rem; }
.stat-bar { height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 0.5rem; }
.stat-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--amber)); transition: width 0.4s ease; }
.delta { font-size: 0.78rem; font-weight: 800; margin-left: 0.4rem; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); } .delta.flat { color: var(--muted); }
.tag { display: inline-block; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.04em; border-radius: 6px;
  padding: 0.12rem 0.45rem; text-transform: uppercase; margin-top: 0.5rem; }
.tag.pass { background: var(--success-soft); color: var(--success); }
.tag.fail { background: var(--danger-soft); color: var(--danger); }

/* verdict banner */
.verdict-banner { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 999px;
  font-weight: 800; font-size: 0.9rem; margin-bottom: 1rem; }
.verdict-banner.pass { background: var(--success-soft); color: #0f6b46; }
.verdict-banner.fail { background: var(--danger-soft); color: var(--danger); }

/* ---------- progress log ---------- */
.run-progress { background: var(--violet-950); color: #d8c9ea; border-radius: var(--radius); padding: 0.9rem 1rem;
  margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.run-progress .prog-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.run-progress .spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--coral); animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.prog-title { font-weight: 800; font-size: 0.9rem; color: #fff; }
.prog-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; margin-bottom: 0.6rem; }
.prog-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--coral), var(--amber)); transition: width 0.3s ease; }
.prog-log { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; line-height: 1.7; max-height: 180px;
  overflow-y: auto; color: #c3b2da; }
.prog-log .ok { color: #7ee0b0; } .prog-log .bad { color: #ff9d9a; } .prog-log .dim { color: #8a7aa4; }

/* ---------- question table ---------- */
.result-table-wrap { overflow-x: auto; padding: 0; }
table.qtable { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
table.qtable th, table.qtable td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.qtable th { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 800; position: sticky; top: 0; background: var(--surface); }
table.qtable tr.rowfail { background: var(--danger-soft); }
table.qtable td .q { font-weight: 700; color: var(--ink); }
table.qtable td .src { font-size: 0.72rem; color: var(--muted); }
.chip-sm { display: inline-block; font-size: 0.64rem; font-weight: 800; border-radius: 6px; padding: 0.12rem 0.45rem;
  text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.chip-sm.grounded, .chip-sm.correct, .chip-sm.hit { background: var(--success-soft); color: var(--success); }
.chip-sm.partial { background: var(--amber-soft); color: #8a6100; }
.chip-sm.ungrounded, .chip-sm.incorrect, .chip-sm.miss { background: var(--danger-soft); color: var(--danger); }
.chip-sm.na { background: var(--border); color: var(--muted); }

/* ---------- failure cards ---------- */
.fail-card { border: 1px solid var(--border); border-left: 3px solid var(--danger); border-radius: var(--radius-sm);
  background: var(--surface); padding: 0.8rem 0.95rem; margin-bottom: 0.7rem; box-shadow: var(--shadow-sm); }
.fail-q { font-weight: 800; margin-bottom: 0.35rem; }
.fail-meta { font-size: 0.76rem; color: var(--muted); margin-bottom: 0.35rem; }
.fail-reason { font-size: 0.78rem; color: var(--danger); font-weight: 600; margin: 0.15rem 0; }
.fail-ans { font-size: 0.78rem; color: var(--muted); white-space: pre-wrap; margin-top: 0.4rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.55rem 0.65rem; }
.fail-ans b { color: var(--ink); }

/* ---------- golden question list ---------- */
.golden-list { display: flex; flex-direction: column; gap: 0.55rem; }
.golden-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0.7rem 0.85rem; }
.golden-item .gq { font-weight: 700; font-size: 0.87rem; }
.golden-item .gmeta { font-size: 0.72rem; color: var(--muted); margin: 0.2rem 0; }
.golden-item .ga { font-size: 0.8rem; color: var(--ink); }
.golden-item .ga b { color: var(--plum); }

/* ---------- runs history ---------- */
.runs-table-wrap { overflow-x: auto; }
table.runs { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
table.runs th, table.runs td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.runs th { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 800; }
table.runs td .rlabel { font-weight: 700; color: var(--ink); }
table.runs a { font-weight: 700; text-decoration: none; }
table.runs a:hover { text-decoration: underline; }
.metric-mini { font-weight: 800; }
.metric-mini.good { color: var(--success); } .metric-mini.bad { color: var(--danger); }

.empty-hint { color: var(--muted); font-size: 0.88rem; padding: 0.8rem 0.2rem; }
.footer { text-align: center; font-size: 0.72rem; color: var(--muted); padding: 1.1rem 1rem 1.4rem; }

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  .only-mobile { display: none; }
  .nav-rail { transform: none; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
  .backdrop { display: none; }
  .content { padding: 1.6rem 2rem 2.4rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .config-summary { grid-template-columns: repeat(4, 1fr); }
  .params-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); display: grid; gap: 0.2rem 1.4rem; }
}
@media (max-width: 480px) {
  .chip-model { display: none; }
  .page-title { font-size: 0.98rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 1rem 0.85rem 1.6rem; }
}
