/* 常驻网站（Web·T3，#74）：少量 CSS，跟随系统的浅色 / 深色，与审片页同一套颜色。 */
:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e2dd;
  --pass: #1f7a3f;
  --warn: #9a6400;
  --bad: #b3261e;
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --panel: #20201e;
    --text: #ececea;
    --muted: #9a9a94;
    --line: #34342f;
    --pass: #5cc07c;
    --warn: #e0a83a;
    --bad: #ef7b72;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

main, .top {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.top h1 {
  margin: 0;
  font-size: 1.4rem;
}

.top #operator {
  margin: 0 0 0 auto;
}

.muted {
  color: var(--muted);
}

.notice {
  color: var(--bad);
}

button {
  font: inherit;
  padding: 4px 12px;
  cursor: pointer;
}

.runs {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 0.9rem;
}

.runs th, .runs td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.runs thead th {
  color: var(--muted);
  font-weight: 600;
}

.runs .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.runs code {
  font-size: 0.8rem;
}

.status-completed { color: var(--pass); }
.status-completed_partial, .status-awaiting_external, .status-awaiting_human { color: var(--warn); }
.status-failed, .status-aborted { color: var(--bad); }

.login {
  max-width: 320px;
  margin: 12vh auto 0;
}

.login form {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login input {
  font: inherit;
  padding: 6px 8px;
}

@media (max-width: 800px) {
  main {
    overflow-x: auto;
  }
}

/* Run 详情（Web·T5，#76）：进度轴、明细表、事实列表与花费表。状态的区分不只靠颜色：每种另有符号与文字（labels.js）。 */
.runs a {
  color: inherit;
}

.crumbs {
  margin-bottom: 8px;
}

.detail h2 {
  font-size: 1.1rem;
  margin: 24px 0 8px;
}

.detail h3 {
  font-size: 0.95rem;
  margin: 16px 0 6px;
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts .processes {
  margin: 0;
  padding-left: 1.2em;
}

.caliber {
  font-size: 0.85rem;
}

.axis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 56px;
  padding: 4px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--line);
  border-radius: 4px;
  font-size: 0.85rem;
}

.step-id {
  font-weight: 600;
}

.step-status {
  font-size: 0.8rem;
}

.substeps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.substeps .step {
  min-width: 0;
  font-size: 0.75rem;
}

.step[aria-current="step"] {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.step.node-succeeded { border-top-color: var(--pass); }
.step.node-running { border-top-color: var(--text); }
.step.node-failed { border-top-color: var(--bad); }
.step.node-skipped { border-top-style: dashed; }

/* 降级：琥珀色的顶边、底色与加粗的状态字，与成功明显不同（PRD §23.2）。 */
.step.node-degraded {
  border-color: var(--warn);
  border-top-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
}

.node-degraded .step-status, .node-degraded .node-status { color: var(--warn); font-weight: 600; }
.node-failed .step-status, .node-failed .node-status { color: var(--bad); font-weight: 600; }
.node-succeeded .step-status, .node-succeeded .node-status { color: var(--pass); }
.node-skipped .step-status, .node-skipped .node-status, .node-pending .step-status, .node-pending .node-status { color: var(--muted); }

.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 0.9rem;
}

.grid th, .grid td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.grid thead th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.grid .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.grid th.child {
  padding-left: 24px;
}

.grid tr[aria-current="step"] {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

.grid tr.node-degraded {
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
}

.grid .reason {
  overflow-wrap: anywhere;
}

.grid tr.total th, .grid tr.total td {
  font-weight: 600;
  border-top: 2px solid var(--line);
}

/* 追查（#78）：Node 产出、事件流、修复 Run 与列表的筛选、分页、dry-run 标记。 */
button.link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
}

pre.output, .events pre {
  margin: 0;
  padding: 8px;
  max-height: 60vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.events .payload summary {
  cursor: pointer;
  overflow-wrap: anywhere;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

#events-panel > summary {
  cursor: pointer;
}

#events-panel > summary h2 {
  display: inline;
}

.repair-runs {
  padding-left: 20px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.filters fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--line);
}

.filters input[type="search"] {
  font: inherit;
  padding: 4px 8px;
  min-width: 16rem;
}

.pager {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.kind {
  font-size: 0.8rem;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.kind-dry-run {
  color: var(--muted);
  border-style: dashed;
}

.kind-production {
  font-weight: 600;
}

@media (max-width: 800px) {
  .facts {
    grid-template-columns: 1fr;
  }
}
