:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #111827;
  --panel-2: #172033;
  --line: #2a354b;
  --text: #e7edf7;
  --muted: #93a4bc;
  --accent: #69a7ff;
  --good: #4ade80;
  --warn: #fbbf24;
  --pending: #c084fc;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
}
button, input, select { font: inherit; }
header {
  min-height: 72px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
h1 { margin: 0; font-size: 18px; }
header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.dataset-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dataset-tab, button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.dataset-tab.active { background: var(--accent); border-color: var(--accent); color: #07111f; font-weight: 700; }
.layout { display: grid; grid-template-columns: 330px 1fr; height: calc(100vh - 72px); }
aside {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}
.control-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
select, input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1321;
  color: var(--text);
  padding: 8px 9px;
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav button { font-size: 12px; }
#counter { color: var(--muted); font-variant-numeric: tabular-nums; }
.run-meta {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1321;
  color: var(--muted);
  padding: 8px;
  font-size: 11px;
}
.run-meta-item { display: grid; gap: 2px; }
.run-meta-item + .run-meta-item { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.run-meta-item strong { color: var(--text); }
.run-meta-item span { overflow-wrap: anywhere; }
#docList {
  list-style: none;
  margin: 0 -12px -12px;
  padding: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
}
#docList li {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
#docList li:hover { background: var(--panel-2); }
#docList li.active { background: #203151; box-shadow: inset 3px 0 var(--accent); }
.doc-id { font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.doc-preview { color: var(--muted); font-size: 11px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count-pill, .badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  background: #26334a;
  color: var(--muted);
}
.count-pill { float: right; margin-left: 6px; }
.badge.good { color: var(--good); background: #123121; }
.badge.pending { color: var(--pending); background: #29183d; }
.badge.warn { color: var(--warn); background: #392d0d; }
main { overflow: auto; padding: 18px; }
.record-head {
  position: sticky;
  top: -18px;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 8px 0 12px;
  margin-bottom: 14px;
}
.record-head h2 { margin: 4px 0; font: 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.record-head .meta { color: var(--muted); font-size: 11px; }
.split {
  display: grid;
  grid-template-columns: minmax(300px, .8fr) repeat(2, minmax(380px, 1fr));
  gap: 16px;
  align-items: start;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}
.panel-title { padding: 10px 13px; border-bottom: 1px solid var(--line); font-weight: 700; background: var(--panel-2); }
.panel-body { padding: 13px; }
.source-body { max-height: calc(100vh - 190px); overflow: auto; }
.structure-body { max-height: calc(100vh - 190px); overflow: auto; }
.source-body table, .artifact table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12px; }
th, td { border: 1px solid var(--line); padding: 5px 7px; text-align: left; }
th { background: #202b3d; position: sticky; top: 0; }
.source-body h1, .source-body h2, .source-body h3 { margin-top: 1.2em; }
.source-body pre, .artifact pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #090e17;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pending-panel, .empty-panel {
  min-height: 280px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}
.pending-panel strong { color: var(--pending); font-size: 16px; }
.shape-group { border-bottom: 1px solid var(--line); }
.shape-group:last-child { border-bottom: 0; }
.shape-title { padding: 9px 12px; display: flex; justify-content: space-between; background: #131d2d; }
.artifact { padding: 12px; border-top: 1px solid var(--line); }
.artifact h4 { margin: 0 0 3px; font-size: 13px; overflow-wrap: anywhere; }
.artifact .description { color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.loading { color: var(--muted); padding: 60px; text-align: center; }
@media (max-width: 1400px) {
  .split { grid-template-columns: repeat(2, minmax(360px, 1fr)); }
  .split > .panel:first-child { grid-column: 1 / -1; }
  .source-body { max-height: 42vh; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 280px 1fr; }
  .split { grid-template-columns: 1fr; }
  .split > .panel:first-child { grid-column: auto; }
  .source-body, .structure-body { max-height: none; }
}
