/* 业务流程图（#/process）与项目总览顶部的缩略条。
 * 中性色（底、线、字）一律用工作台的 :root 变量，谁以后给外壳做深色，这张图跟着走；
 * 只有泳道色是这里自己定的：每条泳道一个色，主线深青绿，分支暖橙 / 钢蓝 / 橄榄（多出来的再补两色）。
 * 泳道色只用在描边、色条和很淡的底色上，字一律 var(--ink)，所以深浅两套泳道色都要在白底上过 3:1。
 * 不用任何动画和过渡：这是一张要静下心看的图。 */

:root {
  --pm-l0: #0f6e66;   /* 主线：深青绿 */
  --pm-l1: #b85418;   /* 分支：暖橙 */
  --pm-l2: #3a6794;   /* 分支：钢蓝 */
  --pm-l3: #5f6f1c;   /* 分支：橄榄 */
  --pm-l4: #87507c;   /* 第五条：梅紫 */
  --pm-l5: #7a5733;   /* 第六条：赭石 */
  --pm-back: #b3352f; /* 计算顺序：倒推 */
  --pm-fwd: #2159d1;  /* 计算顺序：正排（与工作台主色同） */
}
/* 深色：系统是深色且没被钉成浅色，或外壳显式切到深色。提亮版在深底上够亮，在白底上也仍过 3:1 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pm-l0: #1a9383; --pm-l1: #d0692a; --pm-l2: #4f86c0; --pm-l3: #7f9530; --pm-l4: #a8649a; --pm-l5: #a07a4c;
    --pm-back: #d24a44; --pm-fwd: #4a7fe0;
  }
}
:root[data-theme="dark"] {
  --pm-l0: #1a9383; --pm-l1: #d0692a; --pm-l2: #4f86c0; --pm-l3: #7f9530; --pm-l4: #a8649a; --pm-l5: #a07a4c;
  --pm-back: #d24a44; --pm-fwd: #4a7fe0;
}

.pm-c0 { --pm-lane: var(--pm-l0); }
.pm-c1 { --pm-lane: var(--pm-l1); }
.pm-c2 { --pm-lane: var(--pm-l2); }
.pm-c3 { --pm-lane: var(--pm-l3); }
.pm-c4 { --pm-lane: var(--pm-l4); }
.pm-c5 { --pm-lane: var(--pm-l5); }
.pm-neutral { --pm-lane: var(--muted); }
.pm-calc-back { --pm-lane: var(--pm-back); }
.pm-calc-fwd { --pm-lane: var(--pm-fwd); }

/* ---------------- 整页 ---------------- */
.pm-root { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pm-eyebrow { font: 11px var(--mono); color: var(--faint); letter-spacing: .04em; }
.pm-head h2.pm-headline { margin: 4px 0 6px; font-size: 20px; line-height: 1.4; color: var(--ink); }
.pm-meta { margin: 0; font-size: 12px; color: var(--faint); }
.pm-guard { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pm-guard-ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.pm-guard-warn::before { content: "! "; color: var(--warn); font-weight: 700; }
.pm-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; }
.pm-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; background: var(--panel); }
.pm-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--pm-lane); display: inline-block; }
.pm-chip-note { border-style: solid; color: var(--faint); }
.pm-chip-dash { border-style: dashed; color: var(--faint); }
.pm-muted { color: var(--faint); }
.pm-small { font-size: 12px; color: var(--faint); margin: 6px 0 0; line-height: 1.7; }
.pm-action-link { font-size: 12.5px; text-decoration: none; padding: 5px 4px; }

/* 生成状态 */
.pm-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 13px;
  border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; background: var(--panel); }
.pm-status.pm-failed { border-left-color: var(--warn); }
.pm-status details { flex-basis: 100%; font-size: 12px; }
.pm-status pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; margin: 6px 0 0; }

/* 空状态 */
.pm-empty { border: 1px solid var(--line); border-left: 4px solid var(--pm-l0); border-radius: 10px; padding: 18px 20px;
  background: var(--panel); max-width: 780px; }
.pm-empty h2 { margin: 4px 0 8px; font-size: 19px; }
.pm-empty p { margin: 0 0 8px; font-size: 13px; line-height: 1.8; color: var(--muted); }
.pm-empty .pm-status { margin: 8px 0; }
.pm-empty-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.pm-skip { font-size: 12.5px; }

/* ---------------- 主图：左边泳道名不动，右边横向滚动 ---------------- */
.pm-chart { display: flex; align-items: flex-start; min-width: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); overflow: hidden; }
.pm-lanecol { flex: 0 0 112px; border-right: 1px solid var(--line); background: var(--panel2); }
.pm-lanecell { box-sizing: border-box; padding: 10px 10px 0 12px; border-bottom: 1px solid var(--line2);
  border-left: 4px solid var(--pm-lane, transparent); display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.pm-lanecell:last-child { border-bottom: 0; }
.pm-axiscell { padding-top: 8px; font: 11px var(--mono); color: var(--faint); border-left-color: transparent; }
.pm-calccell { font-size: 12px; font-weight: 600; color: var(--muted); border-left-color: transparent; padding-top: 16px; }
.pm-lanekind { font-size: 11px; color: var(--pm-lane); font-weight: 600; }
.pm-lanename { font-size: 13px; line-height: 1.45; color: var(--ink); overflow-wrap: anywhere; }
.pm-scroll { flex: 1 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; }
.pm-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pm-svg { display: block; font-family: inherit; }
.pm-scrollhint { margin: -6px 0 0; font-size: 11.5px; color: var(--faint); }

/* SVG 里的东西 */
.pm-laneband { fill: var(--pm-lane); fill-opacity: .025; }
.pm-laneband.pm-odd { fill-opacity: .045; }
.pm-lanesep { stroke: var(--line2); stroke-width: 1; }
.pm-grid { stroke: var(--line2); stroke-width: 1; }
.pm-axis { stroke: var(--line); stroke-width: 1; }
.pm-tick { fill: var(--faint); font-size: 11px; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.pm-box { fill: var(--pm-lane); fill-opacity: .13; stroke: var(--pm-lane); stroke-width: 1.5; }
.pm-bar { fill: var(--pm-lane); }
.pm-blk { cursor: pointer; }
.pm-blk:hover .pm-box, .pm-blk:focus .pm-box { fill-opacity: .24; }
.pm-blk:focus { outline: none; }
.pm-blk:focus-visible .pm-box, .pm-blk.pm-hl .pm-box { stroke-width: 3; fill-opacity: .28; }
.pm-nominal .pm-box { stroke-dasharray: 5 4; fill-opacity: .05; }
.pm-nominal .pm-bar { fill-opacity: .45; }
.pm-name { fill: var(--ink); font-size: 13px; font-weight: 600; }
.pm-name.pm-out { font-size: 12px; }
.pm-modelnamed .pm-name { font-style: italic; }
.pm-sub { fill: var(--muted); font-size: 11px; }
.pm-below { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.pm-unknown { fill: var(--pm-lane); font-weight: 600; }

/* 字压在线上时描一圈底色，线从字后面穿过去也读得清 */
.pm-gaptext, .pm-edgetext, .pm-calctext, .pm-name.pm-out {
  paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; }
.pm-gapline { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 4 4; }
.pm-gaptext { fill: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pm-link { fill: none; stroke: var(--pm-lane); stroke-width: 1.8; }
.pm-wait { fill: none; stroke: var(--pm-lane); stroke-width: 1.2; stroke-opacity: .6; }
.pm-wait.pm-implied { stroke-dasharray: 3 4; }
.pm-axisnote { font-family: inherit; }
/* 顺序轴（资料里大多数工序没有时长）：图上方一句说明；刻度是「第 N 步」，竖线画在格与格之间 */
.pm-ordernote { margin: 0 0 -6px; font-size: 12.5px; color: var(--muted); line-height: 1.6;
  border-left: 3px solid var(--line); padding: 2px 0 2px 10px; }
.pm-steptick { font-family: inherit; }
.pm-stepsep { stroke-dasharray: 2 4; }
.pm-edgetext { fill: var(--pm-lane); font-size: 11px; font-weight: 600; }
.pm-arrowhead { fill: var(--pm-lane); }
.pm-calcline { stroke: var(--pm-lane); stroke-width: 2.5; }
.pm-calcdot { fill: var(--pm-lane); }
.pm-guide { stroke: var(--pm-lane); stroke-opacity: .35; stroke-width: 1; stroke-dasharray: 1 3; }
.pm-calctext { fill: var(--pm-lane); font-size: 12px; font-weight: 600; }

/* ---------------- 总览（默认看法）：整图宽度 = 容器宽度，实色块白字，块高按时长分四档 ----------------
 * 块的填充色是固定值（不随深浅主题换）：每个都在白字下过 4.5:1，深底上照样看得清。 */
.pm-viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 -6px; }
.pm-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.pm-segbtn { min-height: 0; margin: 0; border: 0; border-radius: 0; background: none; padding: 4px 12px; font-size: 12.5px;
  color: var(--muted); cursor: pointer; box-shadow: none; }
.pm-segbtn + .pm-segbtn { border-left: 1px solid var(--line); }
.pm-segbtn:hover { background: var(--accent-soft); color: var(--ink); }
.pm-segbtn.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.pm-segbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pm-viewnote { font-size: 12px; color: var(--muted); line-height: 1.6; }
.pm-caption { margin: -6px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted); }

.pm-ov .pm-lanecol { flex-basis: 128px; }
.pm-ov .pm-lanecell { padding: 12px 10px 0 12px; }
.pm-ov .pm-lanename { font-size: 13px; line-height: 1.4; }
.pm-ov .pm-blk { --pm-on: #fff; --pm-fill: #0f6e66; }
.pm-ov .pm-c1 { --pm-fill: #b85418; }
.pm-ov .pm-c2 { --pm-fill: #3a6794; }
.pm-ov .pm-c3 { --pm-fill: #5f6f1c; }
.pm-ov .pm-c4 { --pm-fill: #87507c; }
.pm-ov .pm-c5 { --pm-fill: #7a5733; }
.pm-ov .pm-p0 { --pm-fill: #0f6e66; }
.pm-ov .pm-p1 { --pm-fill: #2f5f98; }
.pm-ov .pm-p2 { --pm-fill: #8a4a1c; }
.pm-ov .pm-p3 { --pm-fill: #6a4f8e; }
.pm-ov .pm-p4 { --pm-fill: #56691a; }
.pm-ov .pm-p5 { --pm-fill: #a03a4a; }
.pm-ov .pm-p6 { --pm-fill: #35627a; }
.pm-ov .pm-prep { --pm-fill: #cbd9d0; --pm-on: #1d3029; }
.pm-ov .pm-nominal { --pm-on: var(--ink); }
.pm-ov .pm-box { fill: var(--pm-fill); fill-opacity: 1; stroke: none; }
.pm-ov .pm-blk:hover .pm-box, .pm-ov .pm-blk:focus .pm-box { fill-opacity: 1; stroke: var(--ink); stroke-width: 1.5; }
.pm-ov .pm-blk:focus-visible .pm-box, .pm-ov .pm-blk.pm-hl .pm-box { fill-opacity: 1; stroke: var(--ink); stroke-width: 3; }
.pm-ov .pm-nominal .pm-box { fill-opacity: .14; stroke: var(--pm-fill); stroke-width: 1.5; stroke-dasharray: 5 4; }
.pm-ov .pm-nominal:hover .pm-box, .pm-ov .pm-nominal:focus .pm-box { fill-opacity: .24; }
.pm-ov .pm-name { fill: var(--pm-on); }
.pm-ov .pm-name12 { font-size: 12px; }
.pm-ov .pm-sub { fill: var(--pm-on); }
.pm-ov .pm-name.pm-out { fill: var(--ink); }
.pm-ov .pm-below { paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; }
.pm-ov .pm-cap { fill: var(--faint); }
.pm-gap11 { font-size: 11px; }
.pm-tickmark { stroke: var(--muted); stroke-width: 1; }

/* 文字版 */
.pm-textlist { border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; background: var(--panel); font-size: 13px; }
.pm-textlist summary { cursor: pointer; color: var(--muted); }
.pm-tl-lane { margin: 10px 0 4px; padding-left: 10px; border-left: 3px solid var(--pm-lane); }
.pm-tl-lane ol { margin: 4px 0 0 18px; padding: 0; line-height: 1.8; color: var(--muted); }

/* ---------------- 机制卡与待确认 ---------------- */
.pm-sec h3 { margin: 6px 0 2px; font-size: 15px; }
.pm-subline { margin: 0 0 10px; font-size: 12px; color: var(--faint); }
.pm-mech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pm-mech { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--panel);
  display: flex; flex-direction: column; gap: 6px; }
.pm-mech h4 { margin: 0; font-size: 14px; line-height: 1.5; }
.pm-mech p { margin: 0; font-size: 13px; line-height: 1.75; color: var(--muted); }
.pm-stagelink { align-self: flex-start; min-height: 0; padding: 1px 10px; font-size: 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--pm-lane); color: var(--ink); }
.pm-src { font-size: 12px; color: var(--faint); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 4px; margin-top: auto; }
.pm-refs { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 4px; }
.pm-ref { min-height: 0; padding: 0 2px; border: 0; background: none; color: var(--accent); font-size: 12px;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer; white-space: normal; text-align: left; }
.pm-ref:hover { background: var(--accent-soft); }
.pm-dot { color: var(--faint); }
.pm-unklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.pm-unklist li { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel);
  display: flex; flex-direction: column; gap: 2px; }
.pm-unklist b { font-size: 13.5px; }
.pm-why { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.pm-warns { font-size: 12px; color: var(--faint); }
.pm-warns summary { cursor: pointer; }
.pm-warns ul { margin: 6px 0 0 18px; padding: 0; line-height: 1.8; }

/* 抽屉里的工序详情 */
.pm-drawer-sub { margin: 0 0 10px; color: var(--muted); }
.pm-kv { display: grid; grid-template-columns: 7em 1fr; gap: 6px 10px; margin: 0 0 12px; font-size: 13px; }
.pm-kv dt { color: var(--faint); }
.pm-kv dd { margin: 0; overflow-wrap: anywhere; }
.pm-drawer-res { margin: 0; padding-left: 16px; }

/* ---------------- 项目总览顶部的缩略条 ---------------- */
.pm-mini { border: 1px solid var(--line); border-left: 4px solid var(--pm-l0); border-radius: 10px; padding: 12px 16px;
  margin: 8px 0 14px; background: var(--panel); min-width: 0; }
.pm-mini-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pm-mini-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pm-mini-headline { font-size: 15px; line-height: 1.45; }
.pm-mini-go { font-weight: 600; font-size: 13px; white-space: nowrap; text-decoration: none; }
.pm-mini-go:hover { text-decoration: underline; }
.pm-mini-strip { display: flex; align-items: stretch; gap: 3px; margin: 10px 0 4px; overflow-x: auto; text-decoration: none;
  color: var(--ink); padding-bottom: 2px; }
.pm-mini-blk { min-width: 52px; display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 5px 8px;
  border: 1.5px solid var(--pm-lane); border-left-width: 4px; border-radius: 6px; overflow: hidden;
  background: color-mix(in srgb, var(--pm-lane) 13%, var(--panel)); }
.pm-mini-blk.pm-nominal { border-style: dashed; background: var(--panel); }
.pm-mini-blk b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-mini-blk small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-mini-gap { min-width: 34px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.pm-mini-gap::before { content: ""; position: absolute; left: 2px; right: 2px; top: 50%; border-top: 1.5px dashed var(--muted); }
.pm-mini-gap small { position: relative; background: var(--panel); padding: 0 4px; font-size: 10.5px; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pm-mini-note { margin: 4px 0 0; font-size: 12px; color: var(--faint); }

/* ---------------- 窄屏：泳道名那一列收窄，图照样横向滚 ---------------- */
@media (max-width: 700px) {
  .pm-lanecol { flex-basis: 76px; }
  .pm-ov .pm-lanecol { flex-basis: 96px; }
  .pm-lanecell { padding: 8px 6px 0 8px; }
  .pm-lanename { font-size: 12px; }
  .pm-head h2.pm-headline { font-size: 17px; }
  .pm-mech-grid { grid-template-columns: minmax(0, 1fr); }
  .pm-kv { grid-template-columns: 5.5em 1fr; }
  .pm-mini { padding: 10px 12px; }
}

/* 这一页本来就没有动画；以后谁加了过渡，也先尊重「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  .pm-root *, .pm-mini * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------------- 手工修改（编辑条、选中、连线圆点） ---------------- */
.pm-editbar { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.pm-editbar.on { border-color: var(--accent); }
.pm-editrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pm-editswitch { min-height: 0; margin: 0; padding: 4px 14px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); cursor: pointer; }
.pm-editswitch.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pm-editswitch:focus-visible, .pm-editbtn:focus-visible, .pm-chipx:focus-visible, .pm-lane-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pm-editcount { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.pm-editbtn { min-height: 0; margin: 0; padding: 3px 11px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; }
.pm-editbtn:hover:not(:disabled) { background: var(--accent-soft); }
.pm-editbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pm-editbtn:disabled { opacity: .45; cursor: not-allowed; }
.pm-editmsg { font-size: 12.5px; color: var(--ok); }
.pm-editmsg.err { color: var(--warn); }
.pm-editnote { font-size: 12px; color: var(--faint); }
.pm-editsel { font-size: 13px; color: var(--ink); max-width: 100%; overflow-wrap: anywhere; }
.pm-editlabel { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.pm-editinput { min-width: 220px; max-width: 100%; padding: 4px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.pm-editchip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 4px 1px 10px; background: var(--panel); color: var(--ink); }
.pm-editchip.pm-implied { border-style: dashed; color: var(--faint); padding-right: 10px; }
.pm-chipx { min-height: 0; margin: 0; width: 20px; height: 20px; padding: 0; line-height: 1; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.pm-chipx:hover:not(:disabled) { background: var(--accent-soft); color: var(--ink); }
.pm-lane-edit { display: block; margin: 4px 0 0; min-height: 0; padding: 1px 8px; font-size: 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); cursor: pointer; }
.pm-blk.pm-editable { cursor: pointer; }
.pm-blk.pm-sel .pm-box, .pm-ov .pm-blk.pm-sel .pm-box { stroke: var(--accent); stroke-width: 3; stroke-dasharray: none; fill-opacity: 1; }
.pm-blk.pm-edited .pm-box { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 3; }
.pm-handle { fill: var(--accent); stroke: var(--panel); stroke-width: 2; cursor: crosshair; touch-action: none; }
.pm-dragline { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 5 4; pointer-events: none; }
.pm-edgehit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.pm-edges g.pm-edge-sel path:not(.pm-edgehit) { stroke: var(--accent); stroke-width: 3.5; }
.pm-edges g.pm-editable:hover path:not(.pm-edgehit) { stroke-width: 3; }
