/*
 * 全站外观（#95，ADR-0050）：Profita 官网的 token 与字体，只有深色（不跟随系统的浅色）。
 * 下面的 @font-face 与 :root 两段在 console/static/app.css 与 review/static/app.css 里逐字相同（web-theme.test.ts 守着）；
 * 字体由服务以同源提供（钉哈希资产的 web-fonts 组），url 相对样式表：网站下即 /fonts/…，审片页随令牌或挂载点。
 * 品牌绿只用在"完成 / 通过"；选中与键盘焦点用白色描边；回路色留给 Agent Map。
 * 对比度：#8a8a8a 与错误红作小字在卡片（#282828）上不够 4.5:1——卡片上的次级文字用 --text-2，错误红只作边框、符号与底色。
 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/InterVariable.woff2) format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/JetBrainsMono-Regular.woff2) format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(fonts/JetBrainsMono-Bold.woff2) format('woff2');
}

:root {
  color-scheme: dark;
  --bg: #191414;
  --panel: #1E1E1E;
  --card: #282828;
  --hi: #333333;
  --text: #FFFFFF;
  --text-2: #B3B3B3;
  --muted: #8a8a8a;
  --line: #404040;
  --line-2: #333333;
  --brand: #1DB954;
  --pass: #1DB954;
  --warn: #F5A623;
  --bad: #E54B4B;
  --loop: #509BF5;
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family: var(--sans);
  line-height: 1.5;
}

/* 以下是网站自己的（Web·T3，#74 起）：与审片页的基础件同一套写法。 */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--text);
  text-decoration-color: var(--text-2);
}

/* 键盘焦点：白色描边、向外让出 2px；鼠标点不出这一圈。当前步与选中另有底色与贴边的白条，不用 outline。 */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* 编号、金额、读数用等宽字（夹着的中文落到系统字体）；表头不换。 */
code, pre, tbody .num, .step-id, #spend dd {
  font-family: var(--mono);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  padding: 4px 12px;
  background: var(--hi);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--text-2);
}

input:not([type="checkbox"], [type="radio"]), select, textarea {
  box-sizing: border-box;
  max-width: 100%;
  padding: 4px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="checkbox"], input[type="radio"] {
  accent-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;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

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

/* 出错的说明：白字、红色左条（红字在深色卡片上不够清楚）。 */
.notice {
  color: var(--text);
  border-left: 3px solid var(--bad);
  padding-left: 8px;
}

.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-2);
  white-space: nowrap;
}

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

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

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

/* Run 的状态：文字始终在；完成用品牌绿，等待与部分完成用琥珀，失败与中止白字压红底（红字作小字不够清楚）。 */
.status-completed { color: var(--pass); }
.status-completed_partial, .status-awaiting_external, .status-awaiting_human { color: var(--warn); }
.status-failed, .status-aborted {
  color: var(--text);
  font-weight: 600;
  background: color-mix(in srgb, var(--bad) 22%, transparent);
}

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

.login h1 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.login input {
  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(--text-2);
}

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

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

.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(--card);
  border: 1px solid var(--line-2);
  border-top: 4px solid var(--line);
  border-radius: 4px;
  font-size: 0.85rem;
}

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

.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.node-succeeded { border-top-color: var(--pass); }
.step.node-running { border-top-color: var(--text); }
.step.node-failed {
  border-top-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, var(--card));
}
.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(--card));
}

/* 当前步：高亮底与白色的左、右、下边（顶边仍是状态色）；outline 只留给键盘焦点。 */
.step[aria-current="step"] {
  background: var(--hi);
  border-left-color: var(--text);
  border-right-color: var(--text);
  border-bottom-color: var(--text);
}

.node-degraded .step-status, .node-degraded .node-status { color: var(--warn); font-weight: 600; }
.node-failed .step-status, .node-failed .node-status { color: var(--text); 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(--text-2); }

.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-2);
  vertical-align: top;
}

.grid thead th {
  color: var(--text-2);
  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"] {
  background: var(--hi);
  box-shadow: inset 3px 0 0 var(--text);
}

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

.grid tr.node-failed {
  background: color-mix(in srgb, var(--bad) 12%, var(--panel));
}

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

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

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

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

.events .payload summary {
  cursor: pointer;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  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);
  border-radius: 6px;
}

.filters input[type="search"] {
  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(--text-2);
  border-style: dashed;
}

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

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

/* 排队告警（#223）：Run 列表顶部，提醒色的左条。 */
.queue-alert {
  border-left: 3px solid var(--warn);
  padding: 4px 0 4px 10px;
  margin: 12px 0;
}

.queue-alert h2 {
  font-size: 1rem;
  margin: 0 0 6px;
}

/* 客户对话的只读页（#223）：客户的靠右缩进、系统的次级色，确认卡与调用记录在消息里。 */
.messages {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}

.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
}

.message.role-customer {
  margin-left: 10%;
}

.message.role-system {
  color: var(--text-2);
}

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

.message-meta {
  margin: 0 0 4px;
  font-size: 0.85rem;
  color: var(--text-2);
}

.message-text {
  margin: 0 0 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.draft {
  border-top: 1px solid var(--line-2);
  padding-top: 6px;
}

.pairs {
  margin: 0;
  padding-left: 18px;
  overflow-wrap: anywhere;
}

.transcripts {
  padding-left: 18px;
}

.transcript p {
  overflow-wrap: anywhere;
}

/* 客户账户页（#276）：一次性显示的口令。 */
.secret {
  padding: 8px 12px;
  margin: 12px 0;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--warn);
}

.secret code {
  font-size: 1rem;
  user-select: all;
}
