:root {
  --bg: #eef1f4;
  --paper: #ffffff;
  --ink: #18202a;
  --muted: #6b7480;
  --line: #dce1e6;
  --navy: #111a24;
  --navy-2: #1b2734;
  --teal: #16a394;
  --amber: #ec9f28;
  --red: #d95952;
  --green: #198754;
  --shadow: 0 12px 35px rgba(22, 31, 42, .09);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #f7f9fb; background: var(--navy); border-right: 1px solid #273544; }
.brand { height: 86px; display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid #273544; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #081014; background: var(--teal); border-radius: 10px; font-weight: 900; letter-spacing: -.04em; }
.brand strong, .sidebar-foot strong { display: block; font-size: 14px; }
.brand small, .sidebar-foot small { display: block; color: #8fa0b1; font-size: 11px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 15px 10px 20px; color: #8fa0b1; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 8px; color: inherit; background: transparent; font-size: 21px; line-height: 1; }
.icon-button:hover { background: rgba(255,255,255,.09); }
.dataset-list { flex: 1; overflow: auto; padding: 0 10px; }
.dataset-item { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; text-align: left; color: #c8d1db; background: transparent; border: 1px solid transparent; border-radius: 9px; padding: 11px 10px; margin-bottom: 4px; }
.dataset-item:hover { background: var(--navy-2); }
.dataset-item.active { color: #fff; background: #223242; border-color: #31475a; }
.dataset-item strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dataset-item span { color: #8fa0b1; font-size: 11px; }
.sidebar-empty { padding: 28px 12px; color: #708192; font-size: 12px; text-align: center; }
.sidebar-foot { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 16px 20px; border-top: 1px solid #273544; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #647383; box-shadow: 0 0 0 4px rgba(100,115,131,.14); }
.status-dot.ready { background: var(--teal); box-shadow: 0 0 0 4px rgba(22,163,148,.15); }
.main { min-width: 0; padding: 30px 34px 50px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 5px; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 27px; letter-spacing: -.035em; }
h2 { margin-bottom: 3px; font-size: 16px; letter-spacing: -.01em; }
.topbar p:last-child, .section-title p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.button { min-height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 700; }
.button.primary { color: white; background: var(--teal); }
.button.primary:hover { background: #138d81; }
.button.secondary { color: var(--ink); background: var(--paper); border-color: var(--line); }
.button.danger { color: #a33b36; background: #fff; border-color: #efc7c4; }
.button.danger:hover { background: #fff3f2; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.top-actions { display: flex; gap: 8px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 2px 10px rgba(20,31,43,.035); }
.readonly-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 10px 14px; color: #765113; background: #fff4d7; border: 1px solid #efd493; border-radius: 10px; font-size: 12px; }
.readonly-banner[hidden] { display: none; }
.readonly-banner strong { padding: 2px 7px; color: #fff; background: var(--amber); border-radius: 5px; font-size: 10px; }
.run-card { padding: 20px 22px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.section-title.compact { padding: 18px 20px 13px; margin: 0; }
.run-form { display: grid; grid-template-columns: 1fr 1.35fr .75fr .75fr auto; gap: 12px; align-items: end; }
label { display: grid; gap: 6px; color: #4f5964; font-size: 11px; font-weight: 750; }
input, select { width: 100%; min-height: 39px; padding: 0 11px; color: var(--ink); background: #fbfcfd; border: 1px solid var(--line); border-radius: 8px; outline: none; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,163,148,.1); }
input:disabled { color: #7e8892; background: #f1f3f5; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin: 14px 0; }
.metric { position: relative; padding: 18px 19px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.metric::after { content: ""; position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: #cbd3da; }
.metric:nth-child(1)::after { background: var(--teal); }
.metric:nth-child(2)::after { background: var(--amber); }
.metric span, .metric small { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin: 3px 0 0; font-size: 25px; letter-spacing: -.04em; }
.content-grid { display: grid; grid-template-columns: minmax(330px, .8fr) minmax(500px, 1.4fr); gap: 14px; }
.table-wrap { border-top: 1px solid var(--line); overflow: auto; }
.empty-box { min-height: 280px; display: grid; place-items: center; color: #929ba5; font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; color: #78828d; background: #f8f9fa; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid #edf0f2; font-size: 12px; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.active { background: #f3faf9; }
.mono { font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; color: #59636e; background: #eef1f3; font-size: 10px; font-weight: 750; white-space: nowrap; }
.badge.pass, .badge.completed { color: #136c47; background: #e4f5ed; }
.badge.fail, .badge.failed { color: #a33b36; background: #fdecea; }
.badge.running, .badge.queued { color: #946318; background: #fff3d8; }
.progress { width: 78px; height: 5px; overflow: hidden; background: #e5e9ec; border-radius: 999px; }
.progress i { display: block; height: 100%; background: var(--teal); }
dialog { width: min(480px, calc(100vw - 30px)); color: var(--ink); background: var(--paper); border: 0; border-radius: 14px; box-shadow: var(--shadow); padding: 0; }
dialog::backdrop { background: rgba(9,16,23,.5); backdrop-filter: blur(2px); }
.dialog-form, .wide-dialog { padding: 22px; }
.dialog-form { display: grid; gap: 17px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; }
.dialog-head h2 { font-size: 20px; }
.file-drop { padding: 16px; color: #59636e; background: #f8fafb; border: 1px dashed #bdc7cf; border-radius: 9px; }
.file-drop input { min-height: auto; padding: 0; border: 0; background: transparent; }
.file-drop span { font-weight: 500; }
.form-note { margin: 0; color: var(--muted); font-size: 11px; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; }
.wide-dialog { width: min(880px, calc(100vw - 30px)); }
.task-list { max-height: 68vh; overflow: auto; margin: 12px -22px -22px; border-top: 1px solid var(--line); }
.task-row { padding: 14px 22px; border-bottom: 1px solid var(--line); }
.task-row summary { cursor: pointer; font-weight: 750; }
.task-row pre, .json-block { max-width: 100%; overflow: auto; padding: 12px; color: #cad6e2; background: #15202b; border-radius: 8px; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.drawer { position: fixed; z-index: 30; top: 0; right: 0; width: min(720px, 94vw); height: 100vh; display: flex; flex-direction: column; background: var(--paper); box-shadow: -20px 0 50px rgba(10,18,27,.2); transform: translateX(105%); transition: transform .24s ease; }
.drawer.open { transform: translateX(0); }
.backdrop { position: fixed; z-index: 29; inset: 0; pointer-events: none; opacity: 0; background: rgba(10,17,24,.32); transition: opacity .2s; }
.backdrop.open { pointer-events: auto; opacity: 1; }
.drawer-head { display: flex; justify-content: space-between; align-items: start; padding: 21px 24px 16px; border-bottom: 1px solid var(--line); }
.drawer-content { flex: 1; overflow: auto; padding: 20px 24px 40px; }
.detail-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.mini-metric { padding: 11px; background: #f6f8f9; border-radius: 8px; }
.mini-metric span { display: block; color: var(--muted); font-size: 10px; }
.mini-metric strong { display: block; margin-top: 2px; font-size: 15px; }
.detail-section { margin-top: 23px; }
.detail-section h3 { margin: 0 0 10px; font-size: 13px; }
.failure-list { margin: 0; padding-left: 20px; color: var(--red); }
.trace { position: relative; padding-left: 23px; }
.trace::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 1px; background: #d6dde3; }
.trace-step { position: relative; margin-bottom: 14px; padding: 13px 14px; background: #f8fafb; border: 1px solid #e3e8eb; border-radius: 9px; }
.trace-step::before { content: ""; position: absolute; left: -21px; top: 17px; width: 9px; height: 9px; background: var(--teal); border: 3px solid var(--paper); border-radius: 50%; box-shadow: 0 0 0 1px #cdd5db; }
.trace-step.assistant::before { background: var(--amber); }
.trace-step.agent_error::before { background: var(--red); }
.trace-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.trace-head strong { font-size: 12px; }
.trace-head span { color: var(--muted); font-size: 10px; }
.trace-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trace-box { min-width: 0; padding: 9px; color: #42505c; background: #fff; border: 1px solid #e3e8eb; border-radius: 7px; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.trace-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.trace-meta span { padding: 3px 7px; color: #5b6570; background: #edf1f3; border-radius: 5px; font: 9px/1.4 ui-monospace, monospace; }
.trace-details { margin-top: 8px; background: #fff; border: 1px solid #e2e7ea; border-radius: 7px; }
.trace-details summary { padding: 8px 10px; color: #3f4d59; cursor: pointer; font-size: 10px; font-weight: 750; }
.trace-details pre { max-height: 360px; margin: 0; overflow: auto; padding: 10px; color: #cad6e2; background: #15202b; border-radius: 0 0 7px 7px; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.trace-error { padding: 10px; color: #a33b36; background: #fff0ef; border-radius: 7px; font: 10px/1.5 ui-monospace, monospace; word-break: break-word; }
.state-change { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.state-chip { padding: 3px 6px; color: #177267; background: #e6f5f2; border-radius: 5px; font: 9px/1.4 ui-monospace, monospace; }
.answer { padding: 12px 14px; color: #31404d; background: #f2f7f6; border-left: 3px solid var(--teal); border-radius: 0 7px 7px 0; white-space: pre-wrap; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 28px; padding: 10px 15px; color: white; background: #26323e; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a33b36; }
@media (max-width: 1000px) {
  .shell { grid-template-columns: 205px minmax(0, 1fr); }
  .main { padding: 25px 22px 40px; }
  .run-form { grid-template-columns: 1fr 1fr 1fr; }
  .run-form .button { grid-column: span 1; }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; }
  .brand { height: 68px; }
  .dataset-list { display: flex; gap: 5px; overflow: auto; padding-bottom: 10px; }
  .dataset-item { min-width: 190px; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 14px 35px; }
  .topbar { align-items: start; }
  .top-actions { flex-direction: column-reverse; }
  .run-form, .metric-grid { grid-template-columns: 1fr 1fr; }
  .run-form .button { grid-column: span 2; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
  .trace-grid { grid-template-columns: 1fr; }
}
