/* FormPilot 工作台共享样式：tokens、壳层与组件。
   变量名取自 FormPilot-VI/02-Tokens/tokens.css；字体不走网络，本机有 IBM Plex / Noto 则用，否则回落系统字体。 */
:root {
  --navy-950: #071427; --navy-900: #0b1f3a; --navy-700: #1b3a66; --navy-500: #3a5a86;
  --surface-100: #f5f6f8; --surface-200: #fff; --surface-300: #ebeef2;
  --line: #d3d9e1; --line-soft: #e6eaf0; --grid-line: #dde3eb;
  --ink: #0b1f3a; --ink-muted: #4a5a70;
  --ai: #2468d6; --ai-text: #174da8; --ai-tint: #e6effc;
  --human: #f26b1d; --human-text: #b84a0c; --human-tint: #fdebdf;
  --pass: #1d7a55; --pass-tint: #e3f3ec;
  --fail: #b42318; --fail-tint: #fbeae8;
  --focus: #2468d6;
  --font-sans: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: 160ms ease-out;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--surface-100);
  font: 14px/1.6 var(--font-sans); font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.3; font-weight: 700; }
h2 { font-size: 16px; line-height: 1.4; font-weight: 600; }
a { color: var(--ai-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
.hidden, [hidden] { display: none !important; }
.muted, .subtle { color: var(--ink-muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.small { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wrap-any { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.kicker { font: 500 11px/16px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* ---------- 按钮 ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 2px; background: var(--surface-200); color: var(--ink);
  font-weight: 600; white-space: nowrap; text-decoration: none; transition: background var(--ease), border-color var(--ease);
}
.button:hover { border-color: var(--navy-500); text-decoration: none; }
.button.primary { color: #fff; background: var(--navy-900); border-color: var(--navy-900); }
.button.primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
.button.ai { color: #fff; background: var(--ai); border-color: var(--ai); }
.button.danger { color: var(--fail); }
.button.ghost { border-color: transparent; background: transparent; color: var(--ai-text); }
.button.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }
.button:disabled, .button[aria-disabled="true"] { color: var(--ink-muted); background: var(--surface-300); border-color: var(--line); cursor: not-allowed; }
.icon-button {
  display: inline-grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border: 1px solid transparent; border-radius: 2px;
  color: var(--ink-muted); background: transparent;
}
.icon-button:hover { color: var(--ai-text); border-color: var(--line); }
.ico { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }

/* ---------- 表单 ---------- */
label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 0 10px; color: var(--ink); background: var(--surface-200);
  border: 1px solid #b9c3d0; border-radius: 2px; max-width: 100%;
}
textarea { min-height: 80px; padding: 9px 10px; resize: vertical; }
input::placeholder { color: #7b8aa0; }
input:focus, select:focus, textarea:focus { border-color: var(--ai); box-shadow: 0 0 0 2px var(--ai-tint); }
input:disabled, select:disabled { color: var(--ink-muted); background: var(--surface-300); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 16px; min-height: 0; height: 16px; accent-color: var(--navy-900); }
.field { margin-bottom: 16px; }
.hint { margin-top: 6px; color: var(--ink-muted); font-size: 12px; }

/* ---------- 壳层 ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; padding: 20px 12px 16px; color: #fff; background: var(--navy-900); position: sticky; top: 0; height: 100vh; }
.brand { display: block; padding: 4px 8px 22px; margin-bottom: 8px; border-bottom: 1px solid var(--navy-700); }
.brand img { display: block; width: 168px; height: auto; }
.brand-sub { margin-top: 10px; color: #9fb2cb; font-size: 12px; }
.nav-label { padding: 0 10px 8px; color: #8aa0bd; }
.nav { display: grid; gap: 2px; }
.nav button, .nav a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-left: 2px solid transparent;
  color: #c4d1e3; background: transparent; text-align: left; text-decoration: none; border-radius: 0; transition: background var(--ease), color var(--ease);
}
.nav button:hover, .nav a:hover { color: #fff; background: var(--navy-700); text-decoration: none; }
.nav button.active, .nav a.active, .nav [aria-current="page"] { color: #fff; background: var(--navy-700); border-left-color: var(--human); }
.nav .tag { margin-left: auto; font: 500 10px/1 var(--font-mono); letter-spacing: .08em; color: #ffb48a; }
.sidebar :focus-visible { outline-color: #8fb6f5; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--navy-700); color: #9fb2cb; font-size: 12px; line-height: 1.6; }
.sidebar-foot strong { display: block; color: #fff; font-weight: 600; overflow-wrap: anywhere; }
.sidebar-foot a { color: #c4d1e3; }
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 32px;
  border-bottom: 1px solid var(--line); background: var(--surface-200);
}
.crumb { color: var(--ink-muted); font-size: 13px; min-width: 0; }
.crumb strong { color: var(--ink); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: grid; flex: 0 0 auto; width: 28px; height: 28px; place-items: center; color: #fff; background: var(--navy-700); font-size: 12px; font-weight: 700; }
.user-name { font-weight: 600; line-height: 1.3; }
.user-org { color: var(--ink-muted); font-size: 11px; line-height: 1.3; }
.user > div { min-width: 0; }
.content { max-width: 1360px; margin: 0 auto; padding: 28px 32px 56px; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.view-head .kicker { margin-bottom: 4px; }
.subline { margin-top: 4px; color: var(--ink-muted); }
.view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; padding: 0; border: 0; color: var(--ink-muted); background: transparent; font-size: 12px; }
.back-link:hover { color: var(--ai-text); }

/* ---------- 面板、指标 ---------- */
.panel { border: 1px solid var(--line); background: var(--surface-200); border-radius: 2px; min-width: 0; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.panel-head .kicker { white-space: nowrap; }
.panel-body { padding: 20px; }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--line); }
.metric { padding: 14px 18px; background: var(--surface-200); border-top: 2px solid transparent; }
.metric.ai { border-top-color: var(--ai); }
.metric.pass { border-top-color: var(--pass); }
.metric.human { border-top-color: var(--human); }
.metric-label { color: var(--ink-muted); font-size: 12px; }
.metric-value { margin-top: 2px; font: 600 26px/1.2 var(--font-sans); }
.metric-note { margin-top: 2px; color: var(--ink-muted); font-size: 11px; }
.notice { display: flex; gap: 10px; padding: 12px 14px; color: var(--ink); background: var(--surface-300); border: 1px solid var(--line); border-left: 3px solid var(--navy-500); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.notice.human { background: var(--human-tint); border-color: #f4c9ac; border-left-color: var(--human); }
.notice.has-entry { flex-direction: column; margin: 0 0 16px !important; }
.triage-entry-row { display: flex; flex-wrap: wrap; gap: 8px; }
.notice.err, .notice.error { color: var(--fail); background: var(--fail-tint); border-color: #efc4bf; border-left-color: var(--fail); }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-muted); }
.empty.err { color: var(--fail); }

/* ---------- 状态 ---------- */
.status, .badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--ink-muted); background: var(--surface-300);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.processing { color: var(--ai-text); background: var(--ai-tint); }
.status.done, .badge.active, .badge.online { color: var(--pass); background: var(--pass-tint); }
.status.warn, .badge.pending { color: var(--human-text); background: var(--human-tint); }
.status.fail { color: var(--fail); background: var(--fail-tint); }
.badge.disabled { color: var(--ink-muted); background: var(--surface-300); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status .dot { margin: 0; }

/* ---------- 数据表 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.search { width: 280px; }
#taskPager { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; color: var(--ink-muted); font-size: 13px; }
#queuePager { padding: 0 12px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; color: var(--ink-muted); font-size: 13px; }
#taskPager.hidden { display: none; }
#queuePager.hidden { display: none; }
#taskPager .pager-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
#queuePager .pager-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
#taskPager .pager-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#queuePager .pager-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#taskPager .pager-size select { width: auto; min-height: 28px; }
#queuePager .pager-size select { width: auto; min-height: 28px; }
#taskPager .button:disabled { opacity: .5; cursor: not-allowed; }
#queuePager .button:disabled { opacity: .5; cursor: not-allowed; }
#taskPager .pager-note { color: var(--ink-muted); }
#queuePager .pager-note { color: var(--ink-muted); }
#taskRows.stale, #queueRows.stale { opacity: .55; }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: var(--surface-200); border-radius: 2px; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 16px; color: var(--ink-muted); background: var(--surface-100); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
td { padding: 12px 16px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
td small { display: block; color: var(--ink-muted); font-size: 12px; overflow-wrap: anywhere; }
td strong { overflow-wrap: anywhere; }
tr.task-row { cursor: pointer; }
tr.task-row:hover { background: #f8fafc; }
tr.task-row:focus-visible { outline-offset: -2px; }
.num { text-align: right; }
.cell-file { min-width: 220px; max-width: 360px; }
.task-id { color: var(--ink-muted); font: 12px/1.4 var(--font-mono); overflow-wrap: anywhere; }
.file-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.file-name > span:last-child { overflow-wrap: anywhere; }
.file-ext { display: inline-grid; flex: 0 0 auto; min-width: 34px; height: 22px; padding: 0 5px; place-items: center; color: var(--ai-text); background: var(--ai-tint); border-radius: 2px; font: 500 10px/1 var(--font-mono); letter-spacing: .06em; }
.task-progress { width: 170px; margin-top: 6px; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-muted); font-size: 12px; }
.progress-track { --n: 1; position: relative; height: 6px; margin-top: 6px; overflow: hidden; background: var(--surface-300); }
.progress-fill { height: 100%; background: var(--ai); transition: width 240ms linear; }
.progress-fill.done { background: var(--pass); }
.progress-fill.warn { background: var(--human); }
/* 按阶段数画分隔线：5 阶段与 13 阶段都能数出进度 */
.progress-track::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100% / var(--n) - 1px), var(--surface-200) calc(100% / var(--n) - 1px), var(--surface-200) calc(100% / var(--n)));
}

/* ---------- 提交 ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 16px; align-items: stretch; }
.form-grid > .panel + .panel { margin-top: 0; }
.span-all { grid-column: 1 / -1; }
.step-no { color: var(--ai-text); font: 500 11px/1 var(--font-mono); letter-spacing: .1em; }
.upload-zone { display: grid; min-height: 168px; place-items: center; padding: 24px; border: 1px dashed #8d9bb0; background: var(--surface-100); text-align: center; transition: background var(--ease), border-color var(--ease); }
.upload-zone.drag { border-color: var(--ai); background: var(--ai-tint); }
.upload-icon { display: grid; width: 40px; height: 40px; place-items: center; margin: 0 auto 10px; color: var(--ai-text); background: var(--ai-tint); }
.upload-icon .ico { width: 20px; height: 20px; }
.upload-file { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); background: var(--pass-tint); }
.upload-file > div:first-child { min-width: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; min-width: 0; }
.check-list { display: grid; gap: 10px; margin-top: 16px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-muted); font-size: 12px; }
.check-item .ico { color: var(--pass); margin-top: 2px; }
.service-options { display: grid; gap: 8px; }
.service-panel { display: flex; flex-direction: column; }
.service-panel > .panel-body { flex: 1; display: flex; flex-direction: column; }
.service-panel .service-options { flex: 1; grid-auto-rows: 1fr; gap: 12px; }
.service-panel .service-option { margin: 0; }
.service-option { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr) 18px; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 2px; cursor: pointer; transition: border-color var(--ease), background var(--ease); }
.service-option:hover { border-color: var(--navy-500); }
.service-option.selected { border-color: var(--ai); background: var(--ai-tint); box-shadow: inset 3px 0 0 var(--ai); }
.service-option:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.service-icon { display: grid; width: 32px; height: 32px; place-items: center; color: var(--ai-text); background: var(--surface-100); }
.service-option.selected .service-icon { background: var(--surface-200); }
.service-option strong { display: block; }
.service-option small { display: block; margin-top: 2px; color: var(--ink-muted); font-size: 12px; line-height: 1.5; }
.service-check { width: 16px; height: 16px; border: 1.5px solid #8d9bb0; border-radius: 50%; background: var(--surface-200); }
.service-option.selected .service-check { border-color: var(--ai); box-shadow: inset 0 0 0 3px var(--surface-200); background: var(--ai); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* ---------- 工序与方向图 ---------- */
.ops-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.op-row { padding: 12px 0 12px 12px; border-top: 1px solid var(--line-soft); border-left: 3px solid var(--op-color); }
.op-row.hl { background: var(--surface-100); }
.op-head { display: grid; grid-template-columns: 46px minmax(0, 1fr) minmax(0, 1fr) 32px; gap: 8px; align-items: center; }
.op-name { font: 600 12px/1.4 var(--font-mono); }
.op-inherit { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 500; white-space: nowrap; }
.op-rot { display: grid; grid-template-columns: 46px repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; margin-top: 8px; }
.op-rot-label { padding-bottom: 10px; color: var(--ink-muted); font-size: 11px; }
.op-rot label { display: grid; gap: 4px; margin: 0; color: var(--ink-muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.op-row select, .op-row input:not([type="checkbox"]) { min-height: 34px; }
.op-note { margin-top: 8px; }
.op-meta { margin: 8px 0 0 54px; color: var(--ink-muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.op-meta strong { color: var(--ink); }
.op-meta .warn { color: var(--ink); font-weight: 600; }
.ops-table td, .ops-table th { padding: 10px 12px; }
.ops-table .vec { font: 12px/1.4 var(--font-mono); overflow-wrap: anywhere; }
.view-switch { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.view-switch button { min-height: 28px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface-200); border-radius: 2px; font-size: 12px; }
.view-switch button.on { color: #fff; border-color: var(--navy-900); background: var(--navy-900); }
.forming-field { padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.forming-switch { margin-bottom: 0; }
.forming-switch button { min-height: 36px; min-width: 96px; padding: 0 18px; font-size: 13px; font-weight: 600; }
.forming-field .req { margin-left: 6px; color: var(--human-text); font-weight: 400; }
.forming-field.missing .forming-switch button { border-color: var(--human); }
.dir-figure { display: block; width: 100%; max-width: 360px; margin: 0 auto; background: var(--surface-100); border: 1px solid var(--line); }
.fig-axis { fill: #7b8aa0; font-size: 11px; }
.fig-label { font-size: 11px; font-weight: 700; }
.dir-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--ink-muted); font-size: 12px; }
.dir-legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; }

/* ---------- 详情 ---------- */
.detail-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.detail-top > div:first-child { min-width: 0; }
.detail-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-title h1 { overflow-wrap: anywhere; }
.detail-id { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--ink-muted); font: 12px/1.5 var(--font-mono); flex-wrap: wrap; }
.detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.detail-main { min-width: 0; }
.detail-side { position: sticky; top: 72px; }
.progress-overview { margin-bottom: 20px; padding: 14px 16px; background: var(--surface-100); border: 1px solid var(--line-soft); }
.progress-overview .progress-meta { color: var(--ink); font-size: 13px; }
.progress-overview .progress-track { height: 8px; margin-top: 8px; }
.current-activity { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 10px; margin-top: 12px; }
.activity-mark { width: 8px; height: 8px; margin-top: 7px; background: var(--ai); border-radius: 50%; }
.activity-title { font-size: 13px; font-weight: 600; line-height: 1.6; }
.activity-detail { margin-top: 2px; color: var(--ink-muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
/* 阶段梯：行高随内容增长，13 阶段也不会挤在一起 */
.steps { position: relative; display: grid; }
.steps::before { content: ""; position: absolute; top: 16px; bottom: 16px; left: 15px; width: 1px; background: var(--line); }
.step { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; min-height: 44px; padding-bottom: 10px; }
.step:last-child { padding-bottom: 0; }
.step-mark { position: relative; z-index: 1; display: grid; width: 30px; height: 30px; place-items: center; color: var(--ink-muted); background: var(--surface-200); border: 1px solid var(--line); border-radius: 50%; }
.step-mark .ico { width: 14px; height: 14px; stroke-width: 2; }
.step.succeeded .step-mark { color: #fff; background: var(--pass); border-color: var(--pass); }
.step.running .step-mark { color: #fff; background: var(--ai); border-color: var(--ai); box-shadow: 0 0 0 4px var(--ai-tint); }
.step.failed .step-mark { color: #fff; background: var(--fail); border-color: var(--fail); }
.step-title { display: flex; align-items: baseline; gap: 8px; padding-top: 4px; font-weight: 600; overflow-wrap: anywhere; }
.step-title .no { color: var(--ink-muted); font: 500 11px/1 var(--font-mono); }
.step.pending .step-title { color: var(--ink-muted); font-weight: 500; }
.step-desc { margin-top: 2px; color: var(--ink-muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.step-time { padding-top: 6px; color: var(--ink-muted); font-size: 11px; text-align: right; }
.q-chip { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; color: var(--ink-muted); background: var(--surface-300); overflow-wrap: anywhere; }
.q-chip.passed { color: var(--pass); background: var(--pass-tint); }
.q-chip.conditional_pass { color: var(--ink); background: var(--surface-300); box-shadow: inset 0 0 0 1px var(--navy-500); }
.q-chip.failed { color: var(--fail); background: var(--fail-tint); }
.event-list { display: grid; }
.event-item { display: grid; grid-template-columns: 140px 10px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.event-item:first-child { padding-top: 0; }
.event-item:last-child { padding-bottom: 0; border-bottom: 0; }
.event-time { color: var(--ink-muted); font-size: 11px; line-height: 1.8; }
.event-dot { width: 7px; height: 7px; margin-top: 8px; background: #8d9bb0; border-radius: 50%; }
.event-item.running .event-dot { background: var(--ai); }
.event-item.succeeded .event-dot { background: var(--pass); }
.event-item.failed .event-dot { background: var(--fail); }
.event-item.needs_attention .event-dot { background: var(--human); }
.event-message { font-size: 13px; overflow-wrap: anywhere; }
.info-list { display: grid; }
.info-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.info-row:first-child { padding-top: 0; }
.info-row:last-child { padding-bottom: 0; border-bottom: 0; }
.info-label { flex: 0 0 auto; color: var(--ink-muted); font-size: 12px; }
.info-value { min-width: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.info-value.mono { font-weight: 500; word-break: break-all; }
.file-section + .file-section { margin-top: 20px; }
.file-section-title { margin-bottom: 8px; color: var(--ink-muted); font: 500 11px/1.4 var(--font-mono); letter-spacing: .08em; }
.result-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); margin-bottom: 6px; background: var(--surface-200); }
.result-item.final { border-color: var(--pass); background: var(--pass-tint); }
.result-item .file-name { align-items: flex-start; }
.result-item .file-ext { margin-top: 1px; }
.process-group { margin-bottom: 6px; border: 1px solid var(--line); background: var(--surface-200); }
.process-group summary { display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; font-size: 13px; font-weight: 600; list-style: none; }
.process-group summary::-webkit-details-marker { display: none; }
.process-group summary::after { margin-left: 4px; color: var(--ink-muted); font-weight: 400; font-size: 12px; content: "展开"; }
.process-group[open] summary::after { content: "收起"; }
.process-group summary > span:first-child { margin-right: auto; overflow-wrap: anywhere; }
.process-files { padding: 0 10px 10px; }
.process-files .result-item:last-child { margin-bottom: 0; }

/* ---------- 执行队列 ---------- */
.token-out { margin-bottom: 16px; padding: 12px 14px; background: var(--navy-950); color: #e8edf4; border-left: 3px solid var(--human); }
.token-out pre { margin: 8px 0 0; font: 12px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-all; }
.token-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: #ffb48a; }
.token-out .button { color: #fff; background: transparent; border-color: #5d7396; }
.worker-head, .worker-row { display: grid; grid-template-columns: minmax(200px, 1.5fr) minmax(90px, 120px) minmax(180px, 1.2fr) minmax(100px, 130px) 200px; gap: 16px; align-items: center; padding: 8px 20px; }
.worker-head { padding-top: 10px; color: var(--ink-muted); background: var(--surface-100); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.worker-head > div:last-child { text-align: right; }
.worker-row > * { min-width: 0; }
.worker-item { border-top: 1px solid var(--line-soft); }
.worker-head + .worker-item { border-top: 0; }
.worker-name { display: flex; align-items: center; gap: 8px; font: 600 12px/1.4 var(--font-mono); }
.worker-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker-status { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip.muted-chip { color: var(--ink-muted); background: var(--surface-100); font-weight: 500; }
.worker-beat-raw { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.worker-actions .button { flex: 0 0 auto; width: auto; white-space: nowrap; }
.worker-detail { padding: 8px 20px 12px 36px; border-top: 1px dashed var(--line-soft); background: var(--surface-100); overflow-wrap: anywhere; }
.worker-detail.hidden { display: none; }
.worker-detail-err { color: var(--human-text); }
.worker-detail-foot { margin-top: 6px; }
.pulse { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #8d9bb0; }
.pulse.on { background: var(--pass); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip { padding: 1px 7px; color: var(--ai-text); background: var(--ai-tint); font-size: 12px; font-weight: 600; border-radius: 2px; }
.tag-chip.warn { color: var(--human-text); background: var(--human-tint); }
.queue-head, .queue-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 150px; gap: 16px; padding: 10px 20px; }
.queue-head { color: var(--ink-muted); background: var(--surface-100); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.queue-row { align-items: center; padding: 12px 20px; border-top: 1px solid var(--line-soft); }
.queue-row:first-child { border-top: 0; }
.queue-row:hover { background: #f8fafc; }
.queue-row > div { min-width: 0; overflow-wrap: anywhere; }
.queue-row select { min-height: 30px; margin-top: 6px; font-size: 12px; }
.task-link { color: var(--ai-text); cursor: pointer; }
.task-link:hover { text-decoration: underline; }
.check-option { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--line); font-size: 13px; font-weight: 500; cursor: pointer; }
.check-option:has(input:checked) { border-color: var(--ai); background: var(--ai-tint); }
.check-option .mono { margin-left: auto; color: var(--ink-muted); }

/* ---------- 弹窗、提示 ---------- */
dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink); border: 1px solid var(--navy-900); border-radius: 2px; background: var(--surface-200); box-shadow: 0 8px 28px rgba(7, 20, 39, .25); }
dialog::backdrop { background: rgba(7, 20, 39, .55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; color: #fff; background: var(--navy-900); }
.dialog-head .icon-button { color: #c4d1e3; }
.dialog-head .icon-button:hover { color: #fff; border-color: var(--navy-500); }
.dialog-body { padding: 20px; }
.dialog-body .field:last-of-type { margin-bottom: 0; }
.dialog-actions, .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.message { padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere; }
.message.error { color: var(--fail); background: var(--fail-tint); border-left: 3px solid var(--fail); }
.toast, #toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); padding: 12px 14px; color: #fff; background: var(--navy-900);
  border-left: 3px solid var(--pass); box-shadow: 0 6px 20px rgba(7, 20, 39, .25); overflow-wrap: anywhere;
}
/* 两种显示协议：客户端 div.toast 靠 .show 显隐；后台 #toast（无 .toast 类）靠 hidden 属性，由全局 [hidden] 隐藏。 */
.toast { opacity: 0; visibility: hidden; transform: translateX(12px); pointer-events: none; transition: opacity var(--ease), transform var(--ease), visibility var(--ease); }
.toast.show { opacity: 1; visibility: visible; transform: none; }
.toast.err { border-left-color: #ff7a6e; background: #5a1a14; }

/* 登录、后台登录与 register 提示页的专用样式在 login.css；.form/.message 供弹窗等共用，留在这里。 */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; margin: 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .detail-layout, .form-grid, .ops-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-side { position: static; order: -1; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 8px 12px; overflow-x: auto; }
  .brand { flex: 0 0 auto; margin: 0; padding: 0 12px 0 0; border: 0; border-right: 1px solid var(--navy-700); }
  .brand img { width: 120px; }
  .brand-sub, .nav-label, .sidebar-foot { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav button, .nav a { width: auto; flex: 0 0 auto; padding: 8px 12px; border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .nav button.active, .nav a.active { border-bottom-color: var(--human); }
  .topbar { padding: 8px 16px; position: static; }
  .content { padding: 20px 16px 40px; }
}
@media (min-width: 901px) { .mobile-only { display: none; } }
@media (min-width: 769px) and (max-width: 1199px) {
  .worker-head { display: none; }
  .worker-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name name actions" "svc status beat"; row-gap: 6px; }
  .worker-row > .worker-name { grid-area: name; }
  .worker-row > .worker-actions { grid-area: actions; }
  .worker-row > .tags { grid-area: svc; }
  .worker-row > .worker-status { grid-area: status; }
  .worker-row > .worker-beat { grid-area: beat; text-align: right; }
}
@media (max-width: 768px) {
  .view-head, .detail-top { flex-direction: column; align-items: stretch; }
  .search, .filters select, .filters input { width: 100%; }
  .filters { width: 100%; }
  .toolbar > .button { width: 100%; }
  #taskPager, #taskPager .pager-ctl { width: 100%; }
  #queuePager, #queuePager .pager-ctl { width: 100%; }
  #taskPager .pager-ctl .button { flex: 1 1 0; }
  #queuePager .pager-ctl .button { flex: 1 1 0; }
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table tr { padding: 10px 14px; border-top: 1px solid var(--line); }
  .stack-table tbody tr:first-child { border-top: 0; }
  /* 标签放在左侧 88px 的绝对定位列，单元格内任意多个子元素都在右侧内容列里正常排列 */
  .stack-table td { position: relative; min-width: 0; padding: 5px 0 5px 96px; border: 0; }
  .stack-table td::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 88px; color: var(--ink-muted); font-size: 12px; line-height: 1.6; }
  .stack-table td:not([data-label]) { display: none; }
  .stack-table td.num { text-align: left; }
  .stack-table .cell-file { max-width: none; min-width: 0; }
  .task-progress { width: 100%; }
  .queue-head { display: none; }
  .queue-row { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 12px 14px; }
  .queue-row > div[data-label] { position: relative; padding-left: 96px; }
  .queue-row > div[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 0; width: 88px; color: var(--ink-muted); font-size: 12px; }
  .worker-head { display: none; }
  .worker-row { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 14px; }
  .worker-row > div[data-label] { position: relative; padding-left: 80px; min-height: 20px; }
  .worker-row > div[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 0; width: 72px; color: var(--ink-muted); font-size: 12px; }
  .worker-actions { justify-content: flex-start; }
  .worker-detail { padding: 8px 14px 12px; }
  .event-item { grid-template-columns: 10px minmax(0, 1fr); }
  .event-time { grid-column: 2; grid-row: 1; }
  .event-dot { grid-row: 1 / span 2; }
  .event-message { grid-column: 2; }
  .step { grid-template-columns: 32px minmax(0, 1fr); }
  .step-time { grid-column: 2; padding-top: 0; text-align: left; }
  .panel-head { padding: 12px 14px; flex-wrap: wrap; }
  .panel-body { padding: 14px; }
}
@media (max-width: 560px) {
  .op-head { display: flex; flex-wrap: wrap; }
  .op-head select, .op-head .op-inherit { flex: 1 1 110px; }
  .op-rot { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .op-rot-label { grid-column: 1 / -1; padding: 0; }
  .op-meta { margin-left: 0; }
  .user-name { display: none; }
  h1 { font-size: 20px; }
  .toast, #toast { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- 加载反馈（web/loading.js 配套）：旋转标识、骨架、慢提示；不显示虚构进度 ---- */
.fp-spin { display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: var(--ai); border-radius: 50%; animation: fp-spin 0.8s linear infinite; }
@keyframes fp-spin { to { transform: rotate(360deg); } }
.skel { display: block; height: 16px; border-radius: 4px; background: var(--surface-300); animation: fp-pulse 1.4s ease-in-out infinite; }
.skel-row td, .skel-block { padding: 18px 16px; }
@keyframes fp-pulse { 50% { opacity: 0.5; } }
.metric-value.pending { color: var(--ink-muted); }
.load-status { padding: 24px 16px; text-align: center; color: var(--ink-muted); }
.load-status .button { margin-left: 12px; }
.load-status.err { color: var(--fail); }
.inline-status { color: var(--ink-muted); font-size: 12px; margin-right: 10px; }
table[aria-busy="true"] tbody { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) {
  .fp-spin { animation: none; border-top-color: var(--line); border-right-color: var(--ai); }
  .skel { animation: none; }
}
