/* =====================================================================
   E-QS · DFMEA 演示页 — 交互演示 v2
   对齐真实编辑器：4 个工作区 + 子导航 + 结构/功能/失效三列
   + 结构框图 / ADV&P / 特殊特性清单 / 结果文件化
   ===================================================================== */

.ys-sim { height: 748px; }
.ys-sim-main { display: none; }

/* --- 工作区页签 --- */
.ys-wsbar {
  display: flex; align-items: flex-end; gap: 2px; padding: 0 14px;
  border-bottom: 1px solid var(--line); background: #fff; flex: 0 0 auto;
}
.ys-ws-tab {
  position: relative; border: 0; background: transparent;
  padding: 9px 14px 8px; border-radius: 9px 9px 0 0;
  font-size: 11.5px; font-weight: 700; color: var(--faint);
  transition: color .18s, background .18s; text-align: left;
}
.ys-ws-tab b {
  display: block; font-size: 9px; font-weight: 600; color: #b3c1d4;
  letter-spacing: .01em; margin-top: 1px;
}
.ys-ws-tab:hover { color: var(--ink2); background: #f7fafd; }
.ys-ws-tab.is-on { color: var(--brand); background: var(--brand-soft); }
.ys-ws-tab.is-on b { color: #7f9fc9; }
.ys-ws-tab.is-on::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: var(--brand);
}
.ys-stepdots { margin-left: auto; display: flex; align-items: center; gap: 3px; padding-bottom: 9px; }
.ys-stepdot {
  width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 8.5px; font-weight: 800;
  background: #eef2f8; color: #aab8cb;
  transition: background .3s, color .3s, box-shadow .3s;
}
.ys-stepdot.done { background: #d9f6ea; color: #047857; }
.ys-stepdot.on { background: var(--brand); color: #fff; box-shadow: 0 0 0 3px rgba(15, 118, 110, .14); }

/* --- 子导航 --- */
.ys-subbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 14px; border-bottom: 1px solid var(--line);
  background: #f8fbff; flex: 0 0 auto;
}
.ys-subbtn {
  border: 1px solid transparent; background: transparent;
  border-radius: 7px; padding: 4px 10px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  transition: all .16s;
}
.ys-subbtn:hover { background: #fff; color: var(--ink2); }
.ys-subbtn.is-on {
  background: #fff; border-color: #99f6e4; color: var(--brand);
  box-shadow: 0 1px 2px rgba(15, 118, 110, .08);
}
.ys-subbtn i { font-size: 9px; margin-right: 4px; opacity: .8; }
.ys-subnote { margin-left: auto; font-size: 9.5px; color: var(--faint); }
.ys-subnote b { color: var(--brand); font-weight: 700; }

/* --- 视图容器 --- */
.ys-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.ys-view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.ys-view.is-on { display: flex; }

/* ============ 三列工作区 ============ */
.ys-work { flex: 1; min-height: 0; display: grid; grid-template-columns: 24% 27% minmax(0, 1fr); }
.ys-col {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: #fff;
}
.ys-col:last-child { border-right: 0; }
.ys-col-hd {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 700; color: var(--ink2); background: #fff;
}
.ys-col-hd .r { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.ys-col-hd .switch {
  font-size: 8.5px; color: var(--faint); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.ys-col-hd .switch em {
  width: 20px; height: 11px; border-radius: 999px; background: #cfe0f5;
  position: relative; display: inline-block;
}
.ys-col-hd .switch em::after {
  content: ''; position: absolute; right: 1.5px; top: 1.5px;
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
}
.ys-cbtn {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--faint); font-size: 9.5px;
  display: grid; place-items: center; transition: all .16s;
}
.ys-cbtn:hover { color: var(--brand); border-color: #99f6e4; background: var(--brand-soft); }
.ys-cbtn.is-ai {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  box-shadow: 0 3px 8px -3px rgba(15, 118, 110, .6);
}
.ys-cbtn.is-ai.is-busy { animation: ysWand 1.1s ease-in-out infinite; }
@keyframes ysWand {
  0%, 100% { box-shadow: 0 3px 8px -3px rgba(15, 118, 110, .6); }
  50% { box-shadow: 0 0 0 4px rgba(15, 118, 110, .16); }
}
.ys-col-body { flex: 1; overflow: auto; min-height: 0; }

/* 树：层级缩进 + 导引线 + 展开箭头，体现 BOM 父子关系 */
.ys-tree2 { padding: 8px 6px 10px; display: flex; flex-direction: column; gap: 0; }
.ys-tree2 .ys-tnode {
  position: relative;
  padding: 4px 6px 4px calc(6px + var(--lv, 0) * 16px);
  border-radius: 6px; font-size: 11px;
}
/* 每一级在父级所在的列上画一条竖向导引线 */
.ys-tnode[data-lv="1"]::before,
.ys-tnode[data-lv="2"]::before,
.ys-tnode[data-lv="3"]::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 1px;
  left: calc(6px + (var(--lv, 1) - 1) * 16px + 6px);
  background: #dbe6f3;
}
/* 拐角短横线，接上图标 */
.ys-tnode[data-lv="1"]::after,
.ys-tnode[data-lv="2"]::after,
.ys-tnode[data-lv="3"]::after {
  content: ''; position: absolute; top: 50%; height: 1px; width: 7px;
  left: calc(6px + (var(--lv, 1) - 1) * 16px + 6px);
  background: #dbe6f3;
}
/* 同级最后一个孩子：竖线止于中心，形成 └ 拐角 */
.ys-tnode.is-last::before { bottom: 50%; }

.ys-tree2 .ys-tnode[data-lv="0"] {
  font-size: 11.5px; font-weight: 700; color: #1e2d42;
  background: #f4f9ff; border: 1px solid #e3eefa; margin-bottom: 3px;
}
.ys-tree2 .ys-tnode[data-lv="1"] {
  font-weight: 700; color: #2b3c52;
}
.ys-tree2 .ys-tnode[data-lv="2"] {
  font-weight: 500; color: #4a5c73;
}
.ys-tree2 .ys-tnode[data-lv="2"] .nm { color: #4a5c73; }
.ys-tree2 .ys-tnode .tw {
  width: 12px; height: 12px; flex: 0 0 12px; border-radius: 3px;
  display: grid; place-items: center; font-size: 8px; color: #9db0c6;
}
.ys-tree2 .ys-tnode .tw.has { color: #6b8db3; background: #eef4fb; }
.ys-tree2 .ys-tnode .tw.has:hover { background: #e0edfa; color: var(--brand); }
.ys-tree2 .ys-tnode .badge {
  height: 15px; min-width: 16px; padding: 0 4px; font-size: 9px;
}
.ys-tree2 .ys-tnode .badge.has { background: var(--brand); color: #fff; }
.ys-tree2 .ys-tnode[data-lv="1"] > i.fa-solid { color: #8fb4d6 !important; }
.ys-tree2 .ys-tnode.is-collapsed .tw i { transform: rotate(-90deg); }
.ys-tree2 .ys-tnode.is-hidden { display: none; }
/* 4M 工作要素：常显、单行省略（悬停看全） */
.ys-tree2 .ys-tnode.ys-t4m {
  align-items: center;
  padding: 2px 6px 2px calc(6px + 16px);
  margin: 0 0 2px;
  background: #f8fbfb;
  border: 1px dashed #e2ecec;
  animation: ysRowIn .3s ease both;
}
.ys-tree2 .ys-tnode.ys-t4m > i { font-size: 7.5px; color: #8fb4b4; }
.ys-tree2 .ys-tnode.ys-t4m .nm {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 8.5px; line-height: 1.5; color: #7d9496; font-weight: 500;
}
.ys-tree2 .ys-tnode.ys-t4m .nm b {
  display: inline-block; margin-right: 4px; padding: 0 3px;
  font-size: 7.5px; font-weight: 800; color: #0f766e;
  background: #ecfdf5; border: 1px solid #99f6e4; border-radius: 3px;
}

.ys-empty-hint {
  padding: 22px 12px; text-align: center; color: #a9b8cc; font-size: 10.5px; line-height: 1.7;
}
.ys-empty-hint i { display: block; font-size: 17px; margin-bottom: 7px; color: #c8d6e8; }
.ys-empty-hint small { display: inline-block; margin-top: 4px; font-size: 9px; line-height: 1.6; color: #bccada; }
.ys-empty-hint b { color: var(--brand); font-weight: 700; }

/* 功能卡 */
.ys-fn2 {
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  margin-bottom: 7px; overflow: hidden;
  opacity: 0; transform: translateY(7px); animation: ysRowIn .44s ease forwards;
}
.ys-fn2.lvl2 { margin-left: 11px; }
.ys-fn2.lvl3 { margin-left: 22px; }
.ys-fn2 .hd {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: #f8fbff; border-bottom: 1px solid var(--line2);
  font-size: 9px; font-weight: 700; color: #7f93ac;
}
.ys-fn2 .hd .kind {
  padding: 0 6px; border-radius: 999px; background: #e8f1fd; color: var(--brand);
  font-size: 8.5px; letter-spacing: .02em;
}
.ys-fn2 .bd { padding: 7px 9px; font-size: 10.5px; line-height: 1.55; color: #334155; }
.ys-fn2 .ft { display: flex; align-items: center; gap: 5px; padding: 0 9px 7px; flex-wrap: wrap; }
.ys-fn2 .reqchip {
  font-size: 8.5px; font-weight: 700; color: #6d28d9;
  background: #f5f3ff; border: 1px solid #e4dcff; border-radius: 4px; padding: 0 5px;
}
.ys-fn2 .ai-mark { font-size: 8.5px; color: #14b8a6; font-weight: 700; margin-left: auto; }

/* 失效卡 */
.ys-fail {
  border: 1px solid var(--line); border-left: 3px solid #cbd5e1; border-radius: 9px;
  background: #fff; margin-bottom: 8px; overflow: hidden;
  opacity: 0; transform: translateY(7px); animation: ysRowIn .45s ease forwards;
}
.ys-fail.h { border-left-color: var(--danger); }
.ys-fail.m { border-left-color: var(--amber); }
.ys-fail .hd {
  display: flex; align-items: center; gap: 6px; padding: 7px 9px;
  border-bottom: 1px solid var(--line2); background: #fcfdff;
}
.ys-fail .hd .fm { font-size: 10.5px; font-weight: 700; color: var(--ink2); flex: 1; line-height: 1.4; }
.ys-fail .row {
  display: grid; grid-template-columns: 30px 1fr; gap: 5px;
  padding: 4px 9px; font-size: 10px; line-height: 1.5; color: #475569;
}
.ys-fail .row dt { color: #a0b0c5; font-weight: 700; font-size: 9px; padding-top: 1px; }
.ys-fail .sod {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 6px 9px; border-top: 1px dashed var(--line); background: #fbfdff;
  font-size: 9px; color: var(--faint);
}
.ys-sod-box {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 9px; font-weight: 700; color: var(--ink2);
}
.ys-sod-box span {
  width: 15px; height: 15px; border-radius: 4px; background: #f1f5fb;
  display: grid; place-items: center;
}
.ys-sod-box span.s { background: #fff1f4; color: #be123c; }
.ys-sod-box span.o { background: #fffbeb; color: #b45309; }
.ys-sod-box span.d { background: #ecfdf5; color: #047857; }
.ys-fail .act {
  padding: 6px 9px; border-top: 1px solid var(--line2);
  font-size: 9.5px; color: #64748b; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ys-fail .act b { color: var(--ink2); font-weight: 600; }
.ys-fail .act .who {
  margin-left: auto; background: #f1f5fb; border-radius: 999px; padding: 1px 7px;
  font-size: 8.5px; color: #475569; font-weight: 600;
}

/* ============ 策划视图 ============ */
.ys-plan { flex: 1; overflow: auto; padding: 14px 18px; background: #fff; }
.ys-plan-head {
  display: flex; align-items: center; gap: 10px; padding-bottom: 11px;
  border-bottom: 1px solid var(--line2); margin-bottom: 13px;
}
.ys-plan-head .ico {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-size: 13px;
}
.ys-plan-head h4 { font-size: 12.5px; font-weight: 700; }
.ys-plan-head p { font-size: 10px; color: var(--faint); margin-top: 2px; }
.ys-plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.ys-fld { font-size: 9.5px; font-weight: 700; color: #7f93ac; }
.ys-fld span.label { display: block; margin-bottom: 3px; }
.ys-fld span.label i { margin-right: 3px; opacity: .7; }
.ys-fld input, .ys-fld textarea, .ys-fld .val {
  width: 100%; border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 8px; font-size: 10.5px; color: var(--ink2); background: #fff;
  font-family: inherit; line-height: 1.45; resize: none;
}
.ys-fld .val { background: #fafcfe; }
.ys-fld .val.em { color: #b6c3d5; }
.ys-plan-grid .span2 { grid-column: span 2; }
.ys-plan-grid .span3 { grid-column: span 3; }
.ys-5t {
  font-size: 9px; font-weight: 700; color: #0f766e; background: #ecfdf8;
  border: 1px solid #b7ece2; border-radius: 5px; padding: 1px 6px;
}
.ys-5t.lead { color: #6d28d9; background: #f5f3ff; border-color: #e4dcff; }
.ys-team { display: flex; gap: 4px; flex-wrap: wrap; }
.ys-team span {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9.5px; color: #475569; background: #f4f8fd;
  border: 1px solid var(--line2); border-radius: 999px; padding: 2px 8px 2px 2px;
}
.ys-team span i {
  width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center;
  background: #ccfbf1; color: #0d6b64; font-size: 7.5px; font-weight: 800; font-style: normal;
}
.ys-langsel { display: flex; gap: 4px; }
.ys-langsel span {
  font-size: 9.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--muted); background: #fff;
}
.ys-langsel span.on { border-color: #99f6e4; background: var(--brand-soft); color: var(--brand); }

/* ============ 框图画布 ============ */
.ys-canvas-wrap { flex: 1; min-height: 0; padding: 10px 12px; background: #fff; display: flex; }
.ys-canvas {
  position: relative; flex: 1; border-radius: 10px;
  border: 1px solid var(--line); background:
    radial-gradient(circle at 1px 1px, #e6edf7 1px, transparent 0) 0 0 / 18px 18px,
    #fcfdff;
  overflow: hidden;
}
.ys-boundary {
  position: absolute; left: 6%; top: 4%; right: 6%; bottom: 10%;
  border: 1.5px dashed #a8c8ea; border-radius: 14px;
  background: rgba(15, 118, 110, .022);
}
.ys-boundary::after {
  content: '系统边界';
  position: absolute; left: 12px; top: -8px; padding: 0 6px;
  background: #fcfdff; font-size: 8.5px; font-weight: 800; color: #7b9cc4;
  letter-spacing: .06em;
}
/* 边界端口：接口的对外出入口 */
.ys-port {
  position: absolute; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  font-size: 8.5px; font-weight: 700; color: #7c3aed;
  background: #faf8ff; border: 1px dashed #c4b5fd;
  box-shadow: 0 0 0 3px #fcfdff;
}
.ys-port i { font-size: 7.5px; opacity: .8; }
.ys-port.left { left: 0; top: 49%; }
.ys-port.right { left: 100%; top: 49%; }
.ys-cnode {
  position: absolute; transform: translate(-50%, -50%);
  padding: 5px 9px; border-radius: 7px; background: #fff;
  border: 1px solid #d7e3f1; box-shadow: 0 3px 8px -5px rgba(15, 23, 42, .3);
  font-size: 9px; font-weight: 700; color: #24354b; text-align: center;
  white-space: nowrap; line-height: 1.3; letter-spacing: -.01em;
}
.ys-cnode small { display: block; font-size: 7px; font-weight: 600; color: #9aabc0; letter-spacing: 0; }
.ys-cnode.root {
  padding: 7px 13px; font-size: 10px; border-radius: 8px;
  background: linear-gradient(135deg, #04201f, #0f766e); color: #fff; border-color: transparent;
  box-shadow: 0 8px 18px -10px rgba(15, 42, 74, .8);
}
.ys-cnode.root small { color: rgba(255, 255, 255, .72); }
.ys-cnode.parent {
  background: #f5faff; border-color: #b9d5f0; color: #1e3a5f;
  border-bottom: 2px solid #8fbde6;
}
.ys-cnode.leaf { background: #fff; }
.ys-cnode.is-hit { box-shadow: 0 0 0 3px rgba(15, 118, 110, .16), 0 6px 14px -6px rgba(15, 23, 42, .3); }
.ys-canvas svg.links { position: absolute; inset: 0; width: 100%; height: 100%; }
/* 接口标签：贴在虚线中段 */
.ys-iface-lbl {
  position: absolute; transform: translate(-50%, -50%); z-index: 2;
  font-size: 7px; font-weight: 700; color: #7c3aed; background: #faf8ff;
  border: 1px solid #e4dcff; border-radius: 4px; padding: 0 3px; white-space: nowrap;
}
.ys-canvas .legend {
  position: absolute; left: 10px; bottom: 8px; display: flex; gap: 10px;
  font-size: 8px; color: #8fa1b8; background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px;
}
.ys-canvas .legend i {
  display: inline-block; width: 14px; height: 0; border-top: 2px solid #9fb6d1;
  vertical-align: middle; margin-right: 3px;
}
.ys-canvas .legend i.dash { border-top-style: dashed; border-color: #a78bfa; }
.ys-canvas-tools {
  position: absolute; right: 8px; top: 8px; display: flex; gap: 3px;
  background: rgba(255, 255, 255, .94); border: 1px solid var(--line);
  border-radius: 7px; padding: 3px; box-shadow: var(--shadow-sm);
}
.ys-canvas-tools span {
  width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center;
  font-size: 8px; color: #94a3b8;
}
.ys-canvas-tools span.on { background: var(--brand-soft); color: var(--brand); }

/* ============ 宽表格视图（ADV&P / 特殊特性） ============ */
.ys-wide { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; }
.ys-wide-hd {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.ys-wide-hd h4 { font-size: 11.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.ys-wide-hd h4 i { color: var(--brand); font-size: 11px; }
.ys-wide-hd .tools { margin-left: auto; display: flex; gap: 5px; }
.ys-toolbtn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9.5px; font-weight: 600; color: #475569;
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 8px;
}
.ys-toolbtn i { font-size: 8.5px; color: #94a3b8; }
.ys-toolbtn { cursor: pointer; }
.ys-toolbtn:hover { border-color: #99f6e4; background: #f6fdfb; color: #0f766e; }
.ys-toolbtn.is-primary:hover { background: #0f8a80; color: #fff; }
.ys-toolbtn.is-busy { opacity: .8; pointer-events: none; }
.ys-toolbtn.is-busy i { animation: ysSpin .9s linear infinite; }
@keyframes ysSpin { to { transform: rotate(360deg); } }
.ys-toolbtn.is-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.ys-toolbtn.is-primary i { color: rgba(255, 255, 255, .8); }
.ys-toolbtn.is-sync { background: var(--teal-soft); border-color: #b7ece2; color: #0f766e; }
.ys-toolbtn.is-sync i { color: #0f766e; }
.ys-scroll { flex: 1; overflow: auto; min-height: 0; }
.ys-tbl { width: 100%; border-collapse: collapse; font-size: 10px; }
.ys-tbl th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 700; color: #6b7d94; font-size: 9px;
  background: #f6f9fd; padding: 6px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.ys-tbl th small { display: block; font-size: 8px; font-weight: 500; color: #a3b2c6; }
.ys-tbl td {
  padding: 6px 8px; border-bottom: 1px solid var(--line2);
  color: #3b4a60; vertical-align: top; line-height: 1.5;
}
.ys-tbl tbody tr { opacity: 0; animation: ysRowIn .38s ease forwards; }
.ys-tbl tbody tr:hover td { background: #fbfdff; }
.ys-tbl .cat { display: inline-block; font-size: 8.5px; font-weight: 700; border-radius: 4px; padding: 0 5px; }
.ys-tbl .cat.detect { color: #0369a1; background: #e0f2fe; }
.ys-tbl .cat.optimize { color: #b45309; background: #fffbeb; }
.ys-tbl .st { font-size: 8.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.ys-tbl .st.open { color: #b91c1c; background: #fff1f4; }
.ys-tbl .st.doing { color: #b45309; background: #fffbeb; }
.ys-tbl .st.done { color: #047857; background: #ecfdf5; }
.ys-tbl .sc-tag {
  display: inline-block; font-size: 8.5px; font-weight: 800; letter-spacing: .04em;
  border-radius: 4px; padding: 0 5px; color: #fff;
}
.ys-tbl .sc-tag.sc { background: linear-gradient(135deg, #f59e0b, #f97316); }
.ys-tbl .sc-tag.cc { background: linear-gradient(135deg, #e11d48, #be123c); }
.ys-wide-foot {
  padding: 6px 14px; border-top: 1px solid var(--line); background: #fafcfe;
  font-size: 9px; color: #9aabc0; flex: 0 0 auto;
}

/* ============ 文件化视图 ============ */
.ys-doc { flex: 1; overflow: auto; padding: 14px 16px; background: #fff; }
.ys-doc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.ys-doc-stat { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fcfdff; }
.ys-doc-stat b {
  display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; color: var(--brand);
}
.ys-doc-stat b.h { color: var(--danger); }
.ys-doc-stat b.m { color: var(--amber); }
.ys-doc-stat b.n { color: #64748b; }
.ys-doc-stat span { display: block; font-size: 9px; color: #8fa1b8; font-weight: 600; margin-top: 1px; }
.ys-doc-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ys-doc-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff;
  display: flex; flex-direction: column; gap: 6px;
}
.ys-doc-card .ic {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-size: 13px; background: #ecfdf5; color: #059669;
}
.ys-doc-card .ic.json { background: #eef2ff; color: #4f46e5; }
.ys-doc-card h5 { font-size: 11.5px; font-weight: 700; }
.ys-doc-card p { font-size: 10px; color: #7c8ca3; line-height: 1.55; }
.ys-doc-card .btn-mock {
  margin-top: 2px; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; border-radius: 7px; padding: 5px 11px;
  background: var(--brand); color: #fff;
}
.ys-doc-card .btn-mock.sec { background: #fff; color: var(--ink2); border: 1px solid var(--line); }
.ys-excel-strip { margin-top: 11px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.ys-excel-hd {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px;
  background: #f6f9fd; border-bottom: 1px solid var(--line);
  font-size: 9px; font-weight: 700; color: #6b7d94;
}
.ys-excel-hd .ok { margin-left: auto; color: #047857; font-weight: 700; }
.ys-excel-hd .ok i { font-size: 8px; }
.ys-excel-grid {
  display: grid; grid-template-columns: 60px 1.02fr .9fr .96fr 36px 36px 36px 34px;
  font-size: 8px; color: #475569;
}
.ys-excel-grid div {
  padding: 3px 5px; border-bottom: 1px solid #eef3fa; border-right: 1px solid #eef3fa;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ys-excel-grid .h {
  background: #ecfdf5; color: #115e59; font-weight: 800; font-size: 7.5px;
  text-align: center; letter-spacing: .02em;
}
.ys-excel-grid .grp {
  background: #ccfbf1; color: #1e3a8a; font-weight: 800; text-align: center;
  font-size: 7.5px; letter-spacing: .03em; border-bottom-color: #c7ddf7;
}
.ys-excel-grid .apcell { font-weight: 800; text-align: center; }
.ys-excel-grid .apcell.h { color: #e11d48; }
.ys-excel-grid .apcell.m { color: #b45309; }

/* --- 响应式 --- */
@media (max-width: 1200px) {
  .ys-work { grid-template-columns: 190px 220px minmax(0, 1fr); }
}
@media (max-width: 1120px) {
  .ys-work { grid-template-columns: 180px 206px minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .ys-work { grid-template-columns: 172px 196px minmax(0, 1fr); }
  .ys-req-foot .ys-review-btns { gap: 4px; }
}
@media (max-width: 900px) {
  .ys-sim { height: 700px; }
  .ys-body { overflow-x: auto; }
  .ys-work { min-width: 880px; grid-template-columns: 172px 200px minmax(430px, 1fr); }
  .ys-wsbar { overflow-x: auto; }
  .ys-ws-tab { flex: 0 0 auto; }
  .ys-stepdots { display: none; }
  .ys-plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ys-doc-stats { grid-template-columns: repeat(2, 1fr); }
  .ys-canvas { min-width: 780px; }
  .ys-canvas-wrap { overflow-x: auto; }
}
@media (max-width: 640px) {
  .ys-sim { height: 660px; }
  .ys-plan-grid { grid-template-columns: 1fr; }
  .ys-plan-grid .span2, .ys-plan-grid .span3 { grid-column: span 1; }
  .ys-doc-cards { grid-template-columns: 1fr; }
  .ys-subbar { overflow-x: auto; flex-wrap: nowrap; }
  .ys-subbtn { flex: 0 0 auto; }
  .pf-kb-bar .chips { display: none; }
}

/* 顶部工具栏右侧按钮组 */
.ys-sim-top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* 需求列底部与整体贴合 */
.ys-col .ys-req-foot { border-top: 1px solid var(--line); }

/* 树节点被选中 */
.ys-tnode.is-sel { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px #cfe3fb; }

/* 抽屉关闭时不占横向滚动空间（否则 transform 会把 scrollWidth 撑宽） */
.ys-drawer { display: none; }
.ys-drawer.is-open { display: flex; transform: none; animation: ysDrawerIn .36s cubic-bezier(.3, .9, .3, 1); }
@keyframes ysDrawerIn { from { transform: translateX(100%); } to { transform: none; } }

/* 移动端抽屉占满 */
@media (max-width: 640px) {
  .ys-drawer { width: 100%; }
}

/* 桌面端：body 内不产生横向滚动（抽屉滑入不再撑宽） */
.ys-body { overflow: hidden; }
@media (max-width: 900px) { .ys-body { overflow-x: auto; overflow-y: hidden; } }

.ys-toolbtn { cursor: pointer; }
.ys-toolbtn:hover { background: var(--brand-soft); border-color: #99f6e4; color: var(--brand); }
.ys-toolbtn.is-primary:hover { background: #0d6b64; color: #fff; }
.ys-toolbtn.is-sync:hover { background: #d9f7f1; color: #0f766e; }
.ys-req-drop { cursor: pointer; }

/* 树顶层级图例 */
.ys-tree-legend {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  padding: 5px 8px 6px; margin: -8px -6px 4px;
  border-bottom: 1px dashed #e6eefa; background: #fafcff;
  font-size: 8.5px; font-weight: 700; color: #9db0c6; letter-spacing: .01em;
}
.ys-tree-legend span { white-space: nowrap; }
.ys-tree-legend i { font-style: normal; color: #cbd8e7; font-size: 8px; }

/* 展开箭头过渡 */
.ys-tree2 .ys-tnode .tw i { transition: transform .18s ease; }

/* 层级视觉：L1 有底色，L2 缩进带导引线 */
.ys-tree2 .ys-tnode[data-lv="1"] { border-radius: 6px; }
.ys-tree2 .ys-tnode[data-lv="1"]:hover,
.ys-tree2 .ys-tnode[data-lv="2"]:hover { background: #f2f8ff; }

/* 子系统之间留一点组间距，层级更清晰 */
.ys-tree2 .ys-tnode[data-lv="1"]:not(:first-of-type) { margin-top: 3px; }
.ys-tree2 .ys-tnode[data-lv="2"]:last-of-type { margin-bottom: 2px; }

/* ==========================================================================
   PFMEA 演示 · 失效分析（与真实分析页同构）
   影响(S) → 模式(S·O·D·AP 前后) → 原因(4M 来源) + 措施
   ========================================================================== */
.ys-col-hd .n {
  flex: 0 0 auto; width: 15px; height: 15px; border-radius: 4px;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 800; font-family: var(--mono);
  background: #eef4fb; color: #4b6b8f;
}
.ys-col-fail .ys-col-hd { border-bottom-color: #e2ecec; }
.ys-col-fail .ys-col-hd .n { background: #ecfdf5; color: #0f766e; }

.pf-fail-hint {
  flex: 0 0 auto; display: flex; align-items: flex-start; gap: 5px;
  padding: 5px 10px; background: #fbfefd; border-bottom: 1px dashed #e2ecec;
  font-size: 9px; line-height: 1.55; color: #7d9496;
}
.pf-fail-hint i { color: #14b8a6; font-size: 8.5px; margin-top: 2px; }
.pf-fail-hint code {
  font-family: var(--mono); font-size: 8.5px; color: #0f766e;
  background: #ecfdf5; border-radius: 3px; padding: 0 3px;
}
.pf-fail-hint b { color: #b45309; font-weight: 700; }
.pf-fail-hint strong { color: #0f766e; font-weight: 700; }

/* --- 失效节点卡 --- */
.ys-fi {
  border: 1px solid #e6eef6; border-radius: 7px; background: #fff;
  margin-bottom: 4px; overflow: hidden;
  opacity: 0; transform: translateY(5px); animation: ysRowIn .4s ease forwards;
}
.ys-fi.lv-effect { border-left: 3px solid #ef4444; background: linear-gradient(180deg, #fff, #fdfcfc); }
.ys-fi.lv-mode { border-left: 3px solid #14b8a6; }
.ys-fi.lv-cause { border-left: 3px solid #f59e0b; background: #fffdf8; }
.ys-fi-hd { display: flex; align-items: flex-start; gap: 4px; padding: 5px 7px; }
.ys-fi-tw {
  flex: 0 0 auto; width: 12px; height: 12px; margin-top: 2px;
  border: 0; background: transparent; color: #b6c6d8; padding: 0;
  display: grid; place-items: center; font-size: 7px;
}
.ys-fi-tw i { transition: transform .18s ease; }
.ys-fi-tw.is-off i { transform: rotate(-90deg); }
.ys-fi-badge {
  flex: 0 0 auto; margin-top: 1px; padding: 0 5px; border-radius: 3px;
  font-size: 8.5px; font-weight: 800; color: #fff; line-height: 14px; letter-spacing: .02em;
}
.ys-fi-badge.effect { background: linear-gradient(135deg, #ef4444, #dc2626); }
.ys-fi-badge.mode { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.ys-fi-badge.cause { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #3d2600; }
.ys-fi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ys-fi-desc { font-size: 10.5px; line-height: 1.5; color: #26384d; font-weight: 650; }
.lv-mode > .ys-fi-hd .ys-fi-desc { color: #0f766e; }
.lv-cause > .ys-fi-hd .ys-fi-desc { color: #475569; font-weight: 500; }
.ys-fi-sev {
  flex: 0 0 auto; font-family: var(--mono); font-size: 8.5px; font-weight: 800;
  color: #be123c; background: #fff1f4; border: 1px solid #fecdd3;
  border-radius: 3px; padding: 0 4px; line-height: 14px;
}
.ys-fi-kids { position: relative; padding: 0 0 2px 11px; }
.ys-fi-kids::before {
  content: ''; position: absolute; left: 5px; top: 0; bottom: 8px; width: 1px; background: #e3edf6;
}
.ys-fi.is-folded > .ys-fi-kids, .ys-fi.is-folded > .ys-fi-acts { display: none; }

/* 悬浮操作（与真实 tree-item-actions 对应） */
.ys-fi-tools { flex: 0 0 auto; display: flex; gap: 0; opacity: 0; transition: opacity .15s ease; }
.ys-fi:hover > .ys-fi-hd > .ys-fi-tools { opacity: 1; }
.ys-fi-tools button {
  width: 14px; height: 14px; border: 0; background: transparent; padding: 0;
  color: #9db0c6; font-size: 7.5px; display: grid; place-items: center; border-radius: 3px;
}
.ys-fi-tools button:hover { background: #eef4fb; color: #0f766e; }

/* 来源（4M 工作要素） */
.ys-src {
  display: inline-flex; align-items: center; gap: 3px; align-self: flex-start;
  font-size: 8px; color: #0f766e; background: #f0fdfa;
  border: 1px solid #ccfbf1; border-radius: 3px; padding: 0 4px; line-height: 14px;
}
.ys-src i { font-size: 7px; }

/* --- 前/后 S·O·D·AP --- */
.ys-risk { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; margin-top: 1px; }
.ys-risk-row { display: flex; align-items: center; gap: 2px; border-radius: 4px; padding: 1px 3px; }
.ys-risk-row.init { background: #f6fbfa; border: 1px solid #e2ecec; }
.ys-risk-row.rev { background: linear-gradient(135deg, #f7fee7, #ecfccb); border: 1px solid #86efac; }
.ys-risk-row .tg {
  flex: 0 0 11px; text-align: center; font-size: 8px; font-weight: 800; color: #5b7375; line-height: 1;
}
.ys-risk-row.rev .tg { color: #166534; }
.ys-sod {
  display: inline-flex; align-items: center; gap: 1px; font-family: var(--mono);
  font-size: 8px; font-weight: 700; color: #475569; background: #fff;
  border: 1px solid #e2ecf5; border-radius: 3px; padding: 0 3px; line-height: 13px;
}
.ys-sod b { color: #9db0c6; font-weight: 700; }
.ys-sod.rev { border-color: #86efac; color: #3f6212; }
.ys-sod.rev b { color: #65a30d; }
.ys-ap {
  font-size: 8px; font-weight: 800; border-radius: 3px; padding: 0 4px; line-height: 13px; color: #fff;
}
.ys-ap.h { background: #ef4444; }
.ys-ap.m { background: #f59e0b; color: #2b1d00; }
.ys-ap.l { background: #10b981; }
.ys-ap.empty { background: #eef7f6; color: #8ba1a2; border: 1px dashed #cfdede; }
.ys-ap.rev:not(.empty) { box-shadow: inset 0 0 0 1.5px #52c41a; }
.ys-risk-edit {
  width: 12px; height: 12px; border: 0; background: transparent; padding: 0;
  color: #65a30d; font-size: 7px; display: grid; place-items: center; border-radius: 2px;
}
.ys-risk-edit:hover { background: #d9f99d; }

/* --- 措施 --- */
.ys-fi-acts { padding: 0 6px 5px 6px; display: flex; flex-direction: column; gap: 3px; }
.ys-act {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  border: 1px dashed #e2ecf5; border-radius: 5px; padding: 3px 5px;
  background: #fbfdff; font-size: 9px; line-height: 1.45;
}
.ys-act.k-cp { background: #f8fdf3; border-color: #e2f0d0; }
.ys-act.k-cd { background: #f4fbfb; border-color: #d6eeeb; }
.ys-act.k-op { background: #fffdf3; border-color: #f1e6c2; }
.ys-act.k-od { background: #f5f9ff; border-color: #d8e7f8; }
.ys-act-dot {
  flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid #94a3b8; background: #fff; padding: 0;
}
.ys-act-dot.done { background: #10b981; border-color: #059669; }
.ys-act-dot.doing { background: #14b8a6; border-color: #0f766e; animation: ysPulse 1.8s infinite; }
.ys-act-dot.todo { background: #e9eef5; border-color: #94a3b8; }
@keyframes ysPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, .5); } 50% { box-shadow: 0 0 0 3px rgba(20, 184, 166, 0); } }
.ys-act-tag {
  flex: 0 0 auto; font-size: 7.5px; font-weight: 800; letter-spacing: .01em;
  border-radius: 3px; padding: 0 4px; line-height: 13px;
  background: #eef4fb; color: #4b6b8f;
}
.k-cp .ys-act-tag { background: #ecfccb; color: #4d7c0f; }
.k-cd .ys-act-tag { background: #ccfbf1; color: #0f766e; }
.k-op .ys-act-tag { background: #fef3c7; color: #92400e; }
.k-od .ys-act-tag { background: #dbeafe; color: #1d4ed8; }
.ys-act-tx { flex: 1 1 120px; min-width: 90px; color: #3d5163; }
.ys-act-meta { flex: 0 0 auto; font-size: 8px; color: #9db0c6; white-space: nowrap; }

/* ==========================================================================
   知识包横条（工作区顶部）
   ========================================================================== */
.pf-kb-strip {
  flex: 0 0 auto; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfefd, #f6fbfa);
}
.pf-kb-bar {
  display: flex; align-items: center; gap: 6px; padding: 5px 12px;
  font-size: 10px; font-weight: 700; color: #33504f; cursor: pointer;
}
.pf-kb-bar:hover { background: #f1faf8; }
.pf-kb-bar .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .15);
}
.pf-kb-bar .cnt { font-size: 9px; font-weight: 600; color: #8ba1a2; font-family: var(--mono); }
.pf-kb-bar .chips { display: flex; gap: 4px; overflow: hidden; flex: 1; min-width: 0; }
.pf-kb-bar .chips .pf-kb-chip { flex: 0 0 auto; height: 17px; font-size: 8.5px; }
.pf-kb-bar .hits { font-size: 8.5px; font-weight: 700; color: #0f766e; white-space: nowrap; }
.pf-kb-bar .cv { font-size: 8px; color: #9db0b1; transition: transform .2s ease; }
.pf-kb-strip.is-open .pf-kb-bar .cv { transform: rotate(180deg); }
.pf-kb-body {
  display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px;
  padding: 0 12px 9px;
}
.pf-kb-strip.is-open .pf-kb-body { display: grid; }
.pf-kb-strip .pf-kb-chunk {
  font-size: 9px; line-height: 1.55; padding: 5px 7px; border-left-width: 2px;
  animation: ysRowIn .4s ease both;
}
.pf-kb-strip .pf-kb-chunk b { font-size: 8px; margin-bottom: 2px; }
.pf-kb-strip .pf-kb-chunk mark { background: #ccfbf1; color: #0f766e; }
/* AI 生成来源标签（知识包命中） */
.ys-ai-src {
  display: inline-flex; align-items: center; gap: 3px; align-self: flex-start;
  font-size: 7.5px; font-weight: 700; color: #6d28d9;
  background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 3px;
  padding: 0 4px; line-height: 13px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ys-ai-src i { font-size: 6.5px; }
/* 功能选中态（决定右侧失效分析显示哪条链） */
.ys-fn2 { cursor: pointer; }
.ys-fn2.is-sel {
  border-color: #5eead4;
  box-shadow: 0 0 0 1px #ccfbf1, 0 10px 20px -18px rgba(15, 118, 110, .85);
  background: #fbfffe;
}
.ys-fn2.is-sel .hd { background: #ecfdf5; color: #0f766e; }
.ys-fn2.is-sel .hd .kind { color: #0f766e; }
/* ==========================================================================
   生成流水线：结构 → 功能 → 失效 → 风险，后一步依赖前一步
   ========================================================================== */
.ys-genline {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 5px 11px; background: #fcfdfe; border-bottom: 1px solid var(--line2);
  font-size: 9px;
}
.ys-genline .lbl {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; font-weight: 800; color: #33504f; white-space: nowrap;
  padding-right: 2px;
}
.ys-genline .lbl i { font-size: 8px; color: #14b8a6; }
.ys-genline .arw { font-size: 6.5px; color: #cbd8e6; }
.ys-genline .note {
  margin-left: auto; font-size: 8.5px; color: #a3b3c6; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.ys-gen-chip {
  display: inline-flex; align-items: center; gap: 3px;
  height: 19px; padding: 0 6px 0 4px; border-radius: 99px;
  border: 1px solid #e2ecf5; background: #fff;
  font-size: 8.5px; font-weight: 600; color: #90a3b8; white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s;
}
.ys-gen-chip .n {
  width: 13px; height: 13px; border-radius: 50%; display: grid; place-items: center;
  background: #eef4fb; color: #7f93ac;
  font-family: var(--mono); font-size: 7.5px; font-weight: 800;
}
.ys-gen-chip .mk { display: grid; place-items: center; font-size: 6.5px; color: #c3d0e0; }
.ys-gen-chip.is-done {
  background: #f0fdfa; border-color: #99f6e4; color: #0f766e;
}
.ys-gen-chip.is-done .n { background: #14b8a6; color: #fff; }
.ys-gen-chip.is-done .mk { color: #0f766e; }
.ys-gen-chip.is-active {
  background: #fff; border-color: #5eead4; color: #0f766e;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, .12);
}
.ys-gen-chip.is-active .n { background: #ccfbf1; color: #0f766e; }
.ys-gen-chip.is-active .mk { color: #14b8a6; animation: ysSpin 2.4s linear infinite; }
.ys-gen-chip.is-locked { background: #f8fafc; border-style: dashed; color: #b7c4d4; cursor: not-allowed; }
.ys-gen-chip.is-wait { background: #fff; border-style: dashed; color: #aebdd0; }
@keyframes ysSpin { to { transform: rotate(360deg); } }

/* 锁定 / 提示态按钮 */
.ys-cbtn.is-locked {
  color: #c2cfdd; cursor: not-allowed;
  background: #f7fafc; border-color: #e8eff6;
}
.ys-cbtn.is-locked:hover { background: #f7fafc; border-color: #e8eff6; color: #c2cfdd; }
.ys-cbtn.is-nudge { animation: ysNudge 1.4s ease; }
@keyframes ysNudge {
  0%, 100% { transform: none; box-shadow: none; }
  15% { transform: translateX(-2px); box-shadow: 0 0 0 3px rgba(251, 191, 36, .35); }
  30% { transform: translateX(2px); }
  45% { transform: translateX(-2px); }
  60% { transform: translateX(1px); box-shadow: 0 0 0 4px rgba(251, 191, 36, .18); }
}

@media (max-width: 900px) {
  .ys-genline { flex-wrap: nowrap; overflow-x: auto; }
  .ys-genline .note { display: none; }
}