/* ═══════════════════════════════════════════════════════════════
   RUNS & TRACES — waterfall, feed, inspector
   ═══════════════════════════════════════════════════════════════ */

/* ── HISTOGRAM ───────────────────────────────────────────── */
.hist {
  padding: 18px 20px 14px;
  position: relative;
}
.hist-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 4px;
  height: 96px;
  align-items: end;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--b2);
}
.hist-col {
  position: relative;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  cursor: default;
}
.hist-col:hover .hist-bar { background: var(--t1); }
.hist-bar {
  width: 100%;
  background: color-mix(in srgb, var(--t1) 72%, transparent);
  border-radius: 2px 2px 0 0;
  position: relative;
  z-index: 1;
}
.hist-bar.err {
  position: absolute;
  bottom: 0;
  background: var(--fail);
  z-index: 2;
}
.hist-axis {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t3);
  letter-spacing: 0.1em;
}
.hist-axis span:nth-child(even) { text-align: center; }
.hist-axis span:last-child { text-align: right; }

/* ── FILTER BAR ─────────────────────────────────────────── */
.run-filterbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--b1);
  border-radius: var(--r);
  background: linear-gradient(180deg, var(--s2), var(--s1));
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filt-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filt-grow { flex: 1; min-width: 180px; }
.filt-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-right: 4px;
}
.filt-pill {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid var(--b2);
  border-radius: var(--r-chip);
  background: transparent;
  color: var(--t2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.filt-pill:hover { color: var(--t1); border-color: var(--b3); }
.filt-pill.on {
  background: var(--t1);
  color: var(--bg);
  border-color: var(--t1);
}
/* the count is set apart by weight; opacity .7 took it under the alpha floor */
.filt-pill .filt-count {
  font-size: 9px;
  font-weight: 500;
}
.filt-select {
  padding: 4px 8px;
  font-size: 11px;
}
.filt-input {
  flex: 1;
  padding: 5px 10px;
  width: 100%;
}

/* ── SPLIT LAYOUT ──────────────────────────────────────── */
.runs-split { align-items: stretch; }
.runs-split > .panel { display: flex; flex-direction: column; min-height: 540px; }

/* Stack feed + inspector on narrower content widths */
@media (max-width: 1280px) {
  .runs-split { grid-template-columns: 1fr; }
  .runs-split > .panel.span-7,
  .runs-split > .panel.span-5 { grid-column: 1 / -1; }
  .runs-split > .panel.trace-inspector { min-height: 720px; }
}

/* ── RUN FEED TABLE ────────────────────────────────────── */
.run-table-wrap {
  flex: 1;
  overflow-y: auto;
  max-height: 580px;
}
.run-table {
  font-size: 12px;
}
.run-table th { background: var(--bg); position: sticky; top: 0; z-index: 1; }
.run-table td { padding: 9px 12px; }
.run-table .run-row { cursor: pointer; }
.run-table .run-row:hover td { background: var(--s2); }
.run-table .run-row.selected td { background: var(--s2); }
/* selection: one white stripe on the row, not one on every cell */
.run-table .run-row.selected td:first-child { box-shadow: inset 3px 0 0 var(--t1); }
/* STATUS_PIP: a finished run is ok (--mint, no glow); .pip.run means live */
.runs-split .pip.ok { color: var(--mint); }
.run-task {
  color: var(--t1);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 2px;
}
.run-meta-line {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t2);
  letter-spacing: 0.04em;
  display: flex;
  gap: 6px;
  align-items: center;
}
/* factory is a category: --t1 and weight against the --t2 meta line */
.run-fac { color: var(--t1); font-weight: 700; }
.run-dot { color: var(--t3); }
.run-table .num { font-variant-numeric: tabular-nums; }
.run-table .mono { font-family: var(--mono); }

/* ── TRACE INSPECTOR ───────────────────────────────────── */
.trace-inspector { background: var(--bg); }
.trace-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--b2);
}
.trace-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--t3);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.trace-task {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--t1);
  margin-bottom: 10px;
}
.trace-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
/* v3 .chip, shrunk. The four tags are categories (factory, entry, model,
   trigger): edge and tone tell them apart, not colour */
.tag {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid var(--b3);
  border-radius: var(--r-chip);
  color: var(--t1);
  background: var(--bg);
}
.tag.blue { border-color: var(--b2); color: var(--t2); }
.tag.amber { border-color: var(--b3); border-style: dashed; color: var(--t2); }
.tag.ghost { border-color: var(--b2); border-style: dotted; color: var(--t3); }
.trace-error {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in oklch, var(--fail) 45%, transparent);
  border-radius: var(--r-c);
  background: var(--fail-wash);
  color: var(--fail);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}
/* the run note is a HITL hold ("approval pending") */
.trace-note {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in oklch, var(--hold) 45%, transparent);
  border-radius: var(--r-c);
  background: var(--hold-wash);
  color: var(--hold);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* trace stats row */
.trace-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--b2);
}
.ts-cell {
  padding: 12px 14px;
  border-right: 1px solid var(--b2);
}
.ts-cell:last-child { border-right: 0; }
.ts-lbl {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.ts-val {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}

/* ── WATERFALL ─────────────────────────────────────────── */
.waterfall-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  border-bottom: 1px dashed var(--b2);
}
.waterfall-head > span:first-child {
  font-size: 9px;
  letter-spacing: 0.2em;
}
.wf-axis {
  display: flex;
  gap: 0;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.05em;
  flex: 1;
  margin-left: 24px;
  justify-content: space-between;
  max-width: 60%;
}
.waterfall {
  padding: 8px 0;
  border-bottom: 1px solid var(--b2);
  max-height: 280px;
  overflow-y: auto;
  position: relative;
}
.waterfall::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  background-image: linear-gradient(to right, var(--b1) 1px, transparent 1px);
  background-size: 25% 100%;
  left: 220px; right: 60px;
  pointer-events: none;
}

.span-row {
  display: grid;
  grid-template-columns: 220px 1fr 60px;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.span-row:hover { background: var(--s2); }
.span-row.selected {
  background: var(--s2);
  border-left-color: var(--t1);
}
.span-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
/* layer badges are categories: a fill for L0, then a solid, dashed and
   dotted edge. The outline sits inside the box, so the badge keeps its size. */
.span-lyr {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 1px 5px;
  display: inline-block;
  width: fit-content;
  text-transform: uppercase;
  border-radius: var(--r-chip);
  outline-offset: -1px;
}
.span-lyr.lyr-0 { background: var(--t1); color: var(--bg); }
.span-lyr.lyr-1 { outline: 1px solid var(--b3); color: var(--t1); }
.span-lyr.lyr-2 { outline: 1px dashed var(--b3); color: var(--t1); }
.span-lyr.lyr-3 { outline: 1px dotted var(--t3); color: var(--t2); }

.span-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.span-op {
  font-size: 10px;
  letter-spacing: 0.05em;
}

.span-track {
  position: relative;
  height: 22px;
  background: transparent;
}
.span-bar {
  position: absolute;
  top: 4px; bottom: 4px;
  min-width: 3px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  overflow: hidden;
  border-radius: 2px;
}
/* layers are categories: white in steps, L3 hatched. States override them;
   an error no longer blinks, state colours carry no motion. */
.span-bar.lyr-0 { background: var(--t1); }
.span-bar.lyr-1 { background: color-mix(in srgb, var(--t1) 60%, transparent); }
.span-bar.lyr-2 { background: color-mix(in srgb, var(--t1) 82%, transparent); }
.span-bar.lyr-3 { background: repeating-linear-gradient(135deg, var(--t2) 0 2px, transparent 2px 5px); box-shadow: inset 0 0 0 1px var(--t3); }
.span-bar.st-warn { background: var(--hold); box-shadow: none; }
.span-bar.st-err  { background: var(--fail); box-shadow: none; }
.span-bar.st-hitl { background: var(--hold); box-shadow: none; border: 1px dashed var(--bg); }
.span-bar-lbl {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--bg);
  white-space: nowrap;
}

.span-dur {
  font-size: 11px;
  color: var(--t2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── SPAN DETAIL ───────────────────────────────────────── */
.span-detail {
  padding: 14px 16px;
  border-bottom: 1px solid var(--b2);
  background: var(--s2);
}
.sd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.sd-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 14px;
}
.sd-stats {
  display: flex;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t2);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.sd-io {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sd-io-block { display: flex; flex-direction: column; gap: 4px; }
.sd-io-lbl {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.2em;
}
.sd-pre {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--t1);
  background: var(--bg);
  border: 1px solid var(--b2);
  border-radius: var(--r-m);
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 140px;
  overflow-y: auto;
}
.sd-pre.err {
  color: var(--fail);
  border-color: color-mix(in oklch, var(--fail) 45%, transparent);
  background: var(--fail-wash);
}

.trace-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

/* ── COST BREAKDOWN ────────────────────────────────────── */
.cost-row {
  display: grid;
  grid-template-columns: 200px 1fr 70px 70px 60px 60px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--b1);
}
.cost-row:last-of-type { border-bottom: 0; }
.cost-name {
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cost-model {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t3);
  letter-spacing: 0.05em;
  font-weight: 400;
}
.cost-bar {
  height: 8px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.cost-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: color-mix(in srgb, var(--t1) 72%, transparent);
}
.cost-stat {
  font-size: 12px;
  text-align: right;
}
.cost-foot {
  display: grid;
  grid-template-columns: 200px 1fr 70px 70px 60px 60px;
  gap: 12px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--b2);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.cost-foot .num { text-align: right; }

/* ── REPLAY SANDBOX ────────────────────────────────────── */
/* the selected trace: one surface step up and a --b3 edge, like .panel.blue */
.replay-target {
  border: 1px solid var(--b3);
  border-radius: var(--r-c);
  padding: 10px 12px;
  background: var(--s3);
  margin-bottom: 14px;
}
.replay-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border: 1px solid var(--b2);
  border-radius: var(--r-c);
  font-size: 12px;
  background: var(--bg);
}
.toggle-row .mono { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.replay-note {
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: 0.05em;
  line-height: 1.5;
  padding-top: 10px;
  border-top: 1px dashed var(--b2);
}

/* ── DIM-LINE (matches existing) ───────────────────────── */
.dim-line {
  display: flex; align-items: center; gap: 14px;
  margin-top: 24px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.dim-line .dim-rule { flex: 1; height: 1px; background: var(--b2); }
.dim-line .dim-label { white-space: nowrap; }
