/* ============================================================================
   工作台 / 材料拆解台 / 工作项详情抽屉 / 附件预览 —— 视图样式
   仅使用 css/app.css 的设计令牌与通用类，不修改 app.css
   ========================================================================== */

/* ------------------------------------------------------------------ 通用补充 */
.bar {
  height: 5px;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 6px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.35s;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.code-chip {
  font-size: 11px;
  letter-spacing: -0.01em;
  flex: none;
}
.owner-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12.5px;
}
/* 负责人可多选：多个人时每人一个「头像 + 姓名」单元 */
.owner-cell.multi {
  gap: 4px 10px;
  flex-wrap: wrap;
}
.owner-cell-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.owner-cell > span:last-child,
.owner-cell-item > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar.avatar-empty {
  background: var(--surface-3);
  color: var(--faint);
}
.dep-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.dep-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 5px;
  line-height: 1.5;
  white-space: nowrap;
}
.dep-badge.up {
  color: var(--st-doing);
  background: var(--doing-soft);
}
.dep-badge.down {
  color: var(--info);
  background: var(--info-soft);
}
.detail-loading {
  padding: 22px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.detail-error {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  margin: 8px 0;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line-2);
  border-radius: 10px;
  font-size: 13px;
}
.detail-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 0;
}
/* 解除下游依赖的确认框：把「会改动谁、不会删掉谁」讲清楚 */
.dep-unlink-confirm {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.dep-unlink-warn {
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--st-doing);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.65;
}
.dep-unlink-warn b { font-weight: 700; }
.dep-unlink-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.65;
}
.dep-unlink-list li { padding-left: 2px; }
.dep-unlink-list b { color: var(--ink); font-weight: 600; }
.dep-unlink-list .mono { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.detail-empty {
  padding: 16px;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}
.detail-footnote {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.6;
}
.warn-text {
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line-2);
  border-radius: 9px;
  padding: 9px 11px;
}
.ref-list {
  margin: 2px 0 4px;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-2);
  max-height: 180px;
  overflow: auto;
}

/* ============================================================================
   视图 1 · 我的工作台
   ========================================================================== */
.wb-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wb-head {
  margin-bottom: 0;
  align-items: flex-end;
}
.wb-head-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.wb-head-main h1 {
  font-size: clamp(21px, 3vw, 27px);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.wb-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.wb-stats {
  flex: none;
}
.wb-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wb-my-materials {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 2px 0;
}
.wb-my-materials .chip {
  cursor: pointer;
  transition: 0.15s;
}
.wb-my-materials .chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

/* 分组卡片 */
.wb-groups-card .card-h {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.wb-groups {
  display: flex;
  flex-direction: column;
}
.wb-group {
  border-top: 1px solid var(--line-soft);
}
.wb-group:first-child {
  border-top: 0;
}
.wb-group-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-fade) 100%);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.wb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.wb-group-t {
  letter-spacing: 0.01em;
}
.wb-task-list {
  display: flex;
  flex-direction: column;
}
.wb-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.12s;
  min-height: 46px;
}
.wb-task:hover {
  background: var(--surface-2);
}
.wb-task-main {
  flex: 1;
  min-width: 0;
}
.wb-task-title {
  font-size: 13.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wb-task-sub {
  display: flex;
  gap: 6px;
  margin-top: 1px;
  min-width: 0;
}
.wb-task-sub .ellipsis {
  max-width: 48ch;
}
.wb-due {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  flex: none;
  white-space: nowrap;
}
.wb-due.overdue {
  color: var(--danger);
  font-weight: 600;
}

/* 阻塞关系 */
.wb-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.wb-rel-card .card-h {
  flex-wrap: wrap;
  row-gap: 4px;
}
.wb-rel-list {
  display: flex;
  flex-direction: column;
}
.wb-rel {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  min-height: 44px;
}
.wb-rel:first-child {
  border-top: 0;
}
.wb-rel:hover {
  background: var(--surface-2);
}
.wb-rel.is-done {
  opacity: 0.68;
}
.wb-rel.is-missing {
  cursor: default;
  background: var(--surface-2);
}
.wb-rel-main {
  flex: 1;
  min-width: 0;
}
.wb-rel-title {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wb-rel-sub {
  line-height: 1.4;
}
.wb-dead {
  color: var(--faint) !important;
  text-decoration: line-through;
}

/* 负责人分布 */
.wb-dist-card .card-b {
  padding: 4px 0;
}
.wb-dist {
  display: flex;
  flex-direction: column;
}
.wb-dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-top: 1px solid var(--line-soft);
}
.wb-dist-row:first-child {
  border-top: 0;
}
.wb-dist-row .owner-cell {
  min-width: 76px;
  flex: none;
}
.wb-dist-bars {
  flex: 1;
  min-width: 0;
}
.wb-dist-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.4;
}

/* 最近改动 */
.audit-list {
  display: flex;
  flex-direction: column;
}
.audit-row {
  display: flex;
  gap: 12px;
  padding: 9px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.audit-row:first-child {
  border-top: 0;
}
.audit-row.click {
  cursor: pointer;
}
.audit-row.click:hover {
  background: var(--surface-2);
}
.audit-time {
  flex: none;
  width: 74px;
  color: var(--faint);
  font-size: 11.5px;
  padding-top: 1px;
  white-space: nowrap;
}
.audit-main {
  flex: 1;
  min-width: 0;
}
.audit-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.5;
}
.audit-actor {
  font-weight: 600;
  color: var(--ink-2);
}
.audit-item {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}
.audit-diff {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  flex-wrap: wrap;
  word-break: break-word;
}
.audit-diff .old {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-color: var(--faint-line);
}
.audit-diff .new {
  color: var(--ink-2);
  font-weight: 500;
}
.audit-diff .arrow {
  color: var(--faint);
  flex: none;
}

/* ============================================================================
   视图 2 · 材料拆解台
   ========================================================================== */
.mat-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mat-head {
  margin-bottom: 0;
}
.mat-head-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.mat-head-main h1 {
  font-size: clamp(21px, 3vw, 27px);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.mat-head-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* 面包屑 */
.crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  min-height: 24px;
  font-size: 12.5px;
}
.crumb {
  padding: 3px 8px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 42ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: 0.14s;
}
.crumb:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.crumb.current {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
  cursor: default;
}
.crumb-sep {
  color: var(--faint);
  font-size: 12px;
  flex: none;
  user-select: none;
}

/* 布局 */
.mat-stats {
  flex: none;
}
.mat-layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.mat-side {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mat-side-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.mat-side-toggle {
  display: none;
}
.mat-list {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - 110px);
  overflow-y: auto;
}
.mat-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px 13px;
  border: 0;
  border-top: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
  text-align: left;
  background: transparent;
  transition: 0.14s;
}
.mat-item:first-child {
  border-top: 0;
}
.mat-item:hover {
  background: var(--surface-2);
}
.mat-item.on {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.mat-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.mat-item-tpl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mat-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}
.mat-item.on .mat-item-title {
  color: var(--accent);
}
.mat-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
}
.mat-item .bar {
  margin-top: 2px;
}
.mat-item .bar > i {
  background: var(--accent);
  opacity: 0.75;
}

/* 右侧主区 */
.mat-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.mat-empty-card .card-b {
  padding: 10px 16px 24px;
}
.mat-detail-card {
  padding: 16px 18px 18px;
}
.mat-detail-h {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mat-code {
  font-size: 12px;
  padding: 3px 9px;
}
.mat-detail-title {
  font-size: clamp(17px, 2.4vw, 21px);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
  min-width: 0;
}
.mat-detail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}
.mat-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.mat-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.mat-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.mat-progress .bar {
  flex: 1;
  margin-top: 0;
  height: 6px;
}
.mat-desc {
  margin-top: 14px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-2);
  max-width: 92ch;
}
.mat-info {
  margin-top: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}
.mat-info-h {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}
.mat-info-b {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 子任务表 */
.mat-tasks-card {
  overflow: hidden;
}
.mat-tasks-h {
  flex-wrap: wrap;
  row-gap: 8px;
}
.mat-search {
  width: min(300px, 42vw);
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 8px;
}
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.mat-tbl {
  min-width: 980px;
}
.mat-tbl th {
  position: relative;
}
.mat-tbl th.sortable {
  cursor: pointer;
  user-select: none;
}
.mat-tbl th.sortable:hover {
  color: var(--ink);
  background: var(--surface-3);
}
.mat-tbl th.on {
  color: var(--accent);
}
.sort-ind {
  margin-left: 4px;
  font-size: 9.5px;
  letter-spacing: -0.04em;
}
.sort-ind.on {
  color: var(--accent);
}
.mat-row {
  cursor: pointer;
}
.mat-row:hover td {
  background: var(--accent-soft) !important;
}
.col-order {
  width: 52px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
}
/* 「星标」列：暗（☆ 灰）/ 亮（★ 金）两态，标记重要任务 */
.col-star {
  width: 40px;
  text-align: center;
}
.star-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  vertical-align: middle;
  transition: opacity 0.12s, color 0.12s, transform 0.12s;
}
.star-btn:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.18);
}
.star-btn:disabled {
  cursor: wait;
}
.star-btn.on {
  color: #e8a63c;
  opacity: 1;
}
.mat-tbl th.col-star {
  padding-left: 8px;
  padding-right: 8px;
}
/* 「调整」列：上下箭头，改同级位次（编号随位次联动） */
.col-move {
  width: 56px;
  text-align: center;
  white-space: nowrap;
}
.move-btns {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}
.move-btn {
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.move-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.move-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
.col-title {
  min-width: 260px;
}
.mat-title-cell {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}
.mat-title-sub {
  max-width: 46ch;
  margin-top: 1px;
}
.mat-dates {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
}
.dep-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
}
.dep-count.has-missing {
  color: var(--danger);
}
.col-actions {
  width: 116px;
  text-align: right;
  white-space: nowrap;
}
.row-actions {
  display: inline-flex;
  gap: 4px;
  justify-content: flex-end;
}
.mat-table-empty {
  padding: 12px 16px 22px;
}

/* ============================================================================
   工作项详情抽屉
   ========================================================================== */
.item-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}
.detail-head {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* 「← 返回上一项」：从依赖树切到别的工作项后，原项还能一键退回去 */
.detail-backrow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.detail-back {
  flex: none;
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.detail-back-title {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
  min-width: 0;
  word-break: break-word;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 6px 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
}
.detail-meta-item {
  white-space: nowrap;
}
.detail-crumbs {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
}
.crumb-link {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 5px;
}
.crumb-link:hover {
  background: var(--surface-2);
  color: var(--accent);
}
.crumb-current {
  color: var(--ink-2);
  padding: 1px 4px;
}
.detail-gone {
  padding: 20px;
  text-align: center;
  color: var(--muted);
}
.detail-tabs {
  position: sticky;
  top: -18px;
  z-index: 3;
  background: var(--bg);
  padding-top: 2px;
}
.detail-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* 页签内容「保温」：每个页签的内容常驻，切走只隐藏不销毁。
   这样用户正在输入的内容、滚动位置、展开状态都原样保留
   （旧实现每次切页签都重建整块 DOM，未保存的输入被静默丢弃）。 */
.detail-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.detail-pane[hidden] {
  display: none;
}
.form-body {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 14px;
}
.form-grid .span2 {
  grid-column: 1 / -1;
}
.form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}
.form-err {
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line-2);
  word-break: break-word;
}
.detail-banner-box:empty {
  display: none;
}
.detail-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.65;
  flex-wrap: wrap;
}
.detail-banner.conflict {
  background: var(--danger-soft);
  border: 1px solid var(--danger-line-soft);
  color: var(--danger);
}
.detail-banner.warn {
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--st-doing);
}
.banner-text {
  flex: 1;
  min-width: 220px;
}
.banner-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.detail-readonly {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.detail-readonly-h {
  padding: 9px 13px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.meta-row {
  display: flex;
  gap: 12px;
  padding: 7px 13px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  line-height: 1.55;
}
.meta-row:first-of-type {
  border-top: 0;
}
.meta-k {
  flex: none;
  width: 96px;
  color: var(--muted);
}
.meta-v {
  flex: 1;
  min-width: 0;
  color: var(--ink-2);
  word-break: break-word;
}
.static-code {
  padding: 7px 0;
}

/* 依赖页签 */
.deps-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.detail-sec-h {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-sec-t {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}
.dep-sec {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  overflow: hidden;
}
.dep-sec-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.dep-sec-t {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.dep-sec-up .dep-sec-t::before {
  content: '↑ ';
  color: var(--st-doing);
}
.dep-sec-down .dep-sec-t::before {
  content: '↓ ';
  color: var(--info);
}
.dep-list {
  padding: 2px 0;
}
.dep-tree {
  display: flex;
  flex-direction: column;
}
.dep-node {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  font-size: 12.5px;
  border-top: 1px solid var(--line-soft);
  min-height: 40px;
  min-width: 0;
}
.dep-node:first-child {
  border-top: 0;
}
.dep-node.dep-clickable {
  cursor: pointer;
}
.dep-node.dep-clickable:hover {
  background: var(--surface-2);
}
.dep-indent {
  flex: none;
}
.dep-branch {
  color: var(--faint);
  flex: none;
  width: 12px;
  text-align: center;
  font-size: 11px;
}
.dep-depth-2 {
  padding-left: 32px;
}
.dep-depth-3 {
  padding-left: 51px;
}
.dep-depth-4 {
  padding-left: 70px;
}
.dep-depth-2 .dep-indent,
.dep-depth-3 .dep-indent,
.dep-depth-4 .dep-indent {
  display: none;
}
.dep-depth-2 .dep-branch,
.dep-depth-3 .dep-branch,
.dep-depth-4 .dep-branch {
  color: var(--line);
}
.dep-title {
  font-size: 12.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
  flex: 0 1 auto;
  min-width: 0;
}
.dep-node.dep-missing {
  background: var(--surface-2);
  color: var(--faint);
}
.dep-missing .dep-dead {
  color: var(--faint);
  text-decoration: line-through;
}
.dep-dead-text {
  font-size: 12px;
  color: var(--faint);
}
.dep-picker {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.dep-picker-list {
  max-height: min(360px, 52vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.dep-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  font-size: 12.5px;
  min-width: 0;
}
.dep-pick-row:first-child {
  border-top: 0;
}
.dep-pick-row:hover {
  background: var(--surface-2);
}
.dep-pick-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
  flex: 0 1 auto;
  min-width: 0;
}

/* 选择器内顺手新建前置任务 */
.dep-create {
  border-top: 1px dashed var(--line);
  padding-top: 9px;
}
.dep-create-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.dep-create-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 11px;
  padding: 11px 12px;
}
.dep-create-form .form-grid { gap: 11px; }
/* 操作行粘在弹窗可视区底部：视口再矮，提交按钮也不会被推出屏幕 */
.dep-create-form .row {
  position: sticky;
  bottom: 0;
  margin: 0 -12px -11px;
  padding: 9px 12px;
  background: var(--accent-soft);
  border-top: 1px solid var(--accent-line);
  border-radius: 0 0 10px 10px;
}
@media (max-width: 620px) {
  .dep-create-form .form-grid { grid-template-columns: 1fr; }
  .dep-create-form .field.span2 { grid-column: auto; }
}

/* 备注页签 */
.notes-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.note-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px;
}
.note-composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13px;
  resize: vertical;
  min-height: 68px;
  outline: none;
  line-height: 1.6;
}
.note-composer textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.note-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.note-head {
  display: flex;
  align-items: center;
  gap: 7px;
}
.note-author {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.note-time {
  font-size: 11px;
}
.note-body {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 历史页签 */
.history-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  overflow: hidden;
}
.hist-row {
  display: flex;
  gap: 12px;
  padding: 9px 13px;
  border-top: 1px solid var(--line-soft);
}
.hist-row:first-child {
  border-top: 0;
}
.hist-time {
  flex: none;
  width: 70px;
  font-size: 11.5px;
  color: var(--faint);
  padding-top: 1px;
  white-space: nowrap;
}
.hist-body {
  flex: 1;
  min-width: 0;
}
.hist-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  line-height: 1.5;
}
.hist-actor {
  font-weight: 600;
  color: var(--ink-2);
}
.hist-field {
  color: var(--muted);
}
.hist-diff {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: 11.5px;
  word-break: break-word;
}
.hist-diff .old {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-color: var(--faint-line);
}
.hist-diff .new {
  color: var(--accent);
  font-weight: 500;
}
.hist-diff .arrow {
  color: var(--faint);
}
.hist-ip {
  margin-top: 2px;
}

/* 附件页签 */
.att-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.att-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.att-head-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.att-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}
.att-sensitive {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.wechat-hint {
  font-size: 12px;
  color: var(--st-doing);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: 9px;
  padding: 7px 10px;
  line-height: 1.6;
}
.wechat-inline {
  width: 100%;
  font-size: 11px;
  color: var(--st-doing);
}
.att-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.att-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
}
.att-row.is-sensitive {
  border-color: var(--danger-line);
  background: linear-gradient(90deg, var(--danger-soft), transparent 42%);
}
.att-ico {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.att-ico[data-ext='pdf'] {
  color: var(--danger);
  background: var(--danger-soft);
}
.att-ico[data-ext='docx'],
.att-ico[data-ext='doc'] {
  color: var(--info);
  background: var(--info-soft);
}
.att-ico[data-ext='xlsx'],
.att-ico[data-ext='xls'],
.att-ico[data-ext='csv'] {
  color: var(--accent);
  background: var(--accent-soft);
}
.att-ico[data-ext='pptx'],
.att-ico[data-ext='ppt'] {
  color: var(--st-doing);
  background: var(--doing-soft);
}
.att-ico[data-ext='jpg'],
.att-ico[data-ext='jpeg'],
.att-ico[data-ext='png'],
.att-ico[data-ext='gif'],
.att-ico[data-ext='webp'],
.att-ico[data-ext='svg'] {
  color: var(--plum);
  background: var(--plum-soft);
}
.att-main {
  flex: 1;
  min-width: 180px;
}
.att-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.att-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}
.att-meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.5;
}
.att-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* —— 附件分组（上级材料共享 / 本项自有） —— */
.att-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.att-head-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* [hidden] 的默认 display:none 会被上面的 display:flex 盖掉，这里显式兜住 */
.att-content[hidden],
.att-head-tools[hidden] {
  display: none;
}
.att-fold {
  flex: none;
}
.att-sec {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.att-sec-h {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.att-sec-inherit .att-sec-h {
  color: var(--accent);
}
.att-sec-mark {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}
.att-own-h {
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
}
.att-row.is-inherited {
  background: var(--surface-2);
}

/* —— 材料拆解台 · 顶级附件模块 —— */
.mat-att-card .card-b {
  padding: 14px 16px 16px;
}

/* ============================================================================
   预览器（js/preview/*）
   ========================================================================== */
.pv-body {
  margin: -18px;
  min-height: 240px;
  max-height: calc(100vh - 168px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.pv-body > .md-body,
.pv-body > .pv-docx,
.pv-body > .sheet-table,
.pv-body > .pptx-deck,
.pv-body > .pv-image-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.pv-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.pv-page-input {
  width: 58px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 12.5px;
  text-align: center;
  outline: none;
}
.pv-page-input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.pv-page-total {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.pv-zoom-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  min-width: 42px;
  text-align: center;
}
.pv-status {
  margin-left: auto;
}
.pv-canvas-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  background: var(--surface-3);
}
.pv-canvas {
  display: block;
  box-shadow: var(--shadow-md);
  background: #fff;
  border-radius: 2px;
}
.pv-image-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 18px;
  background: var(--surface-3);
}
.pv-image {
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow-md);
  border-radius: 4px;
  background: #fff;
}
.pv-image-meta {
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
  text-align: center;
}
.pv-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 20px;
  color: var(--muted);
  font-size: 13px;
}
.pv-spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pvspin 0.8s linear infinite;
}
@keyframes pvspin {
  to {
    transform: rotate(360deg);
  }
}
.pv-error {
  padding: 44px 20px 10px;
  text-align: center;
}
.pv-error-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--danger);
}
.pv-error-msg {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-word;
}
.pv-error-actions {
  display: flex;
  justify-content: center;
  padding: 4px 20px 30px;
}
.pv-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
}
.pv-footer {
  justify-content: flex-end;
}
.md-body {
  padding: 26px 30px 40px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
  max-width: 92ch;
  margin: 0 auto;
  width: 100%;
  word-break: break-word;
}
.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 1.3em 0 0.55em;
}
.md-body h1 {
  font-size: 1.62em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3em;
}
.md-body h2 {
  font-size: 1.32em;
}
.md-body h3 {
  font-size: 1.12em;
}
.md-body p {
  margin: 0.7em 0;
}
.md-body ul,
.md-body ol {
  margin: 0.7em 0;
  padding-left: 1.6em;
}
.md-body li {
  margin: 0.25em 0;
}
.md-body blockquote {
  margin: 0.9em 0;
  padding: 0.4em 1em;
  border-left: 3px solid var(--accent-line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 0 8px 8px 0;
}
.md-body code {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 0.1em 0.36em;
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--ink);
}
.md-body pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.9em 0;
}
.md-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.83em;
  line-height: 1.6;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.9em 0;
  font-size: 0.92em;
}
.md-body th,
.md-body td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.md-body th {
  background: var(--surface-2);
  font-weight: 600;
}
.md-body img {
  max-width: 100%;
  border-radius: 6px;
}
.md-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.md-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4em 0;
}
.pv-docx {
  padding: 16px 18px 40px;
  background: var(--surface-2);
}
.docx-wrap .docx-wrapper {
  background: transparent;
  padding: 0;
}
.docx-wrap .docx {
  box-shadow: var(--shadow-md);
  margin: 0 auto 16px;
  background: #fff;
}
.sheet-tabs {
  flex: none;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sheet-tab {
  padding: 4px 11px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid transparent;
}
.sheet-tab:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.sheet-tab.on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}
.sheet-meta {
  flex: none;
  padding: 6px 13px;
  border-bottom: 1px solid var(--line-soft);
}
.sheet-table {
  padding: 13px;
  overflow: auto;
}
.sheet-table table {
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}
.sheet-table td,
.sheet-table th {
  border: 1px solid var(--line);
  padding: 4px 8px;
  min-width: 42px;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}
.sheet-table th {
  background: var(--surface-2);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.pptx-hint {
  flex: none;
  margin: 12px 14px 0;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--st-doing);
  font-size: 12px;
  line-height: 1.6;
}
.pptx-deck {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-2);
}
.pptx-slide {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pptx-slide-h {
  padding: 7px 13px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.pptx-slide-b {
  padding: 12px 16px 16px;
}
.pptx-p {
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
  margin: 0.3em 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================================
   竖屏 / 窄屏适配
   ========================================================================== */
@media (max-width: 1080px) {
  .mat-layout {
    grid-template-columns: 250px minmax(0, 1fr);
  }
  .wb-task-sub .ellipsis {
    max-width: 34ch;
  }
}

@media (max-width: 860px) {
  /* 工作台 */
  .wb-head {
    align-items: flex-start;
  }
  .wb-head-right {
    margin-left: 0;
  }
  .wb-cols {
    grid-template-columns: 1fr;
  }
  .wb-task {
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 10px 13px;
  }
  .wb-task .spacer {
    display: none;
  }
  .wb-task-main {
    flex: 1 1 100%;
    order: 3;
    min-width: 0;
  }
  .wb-task-title {
    white-space: normal;
  }
  .wb-due {
    order: 2;
    margin-left: auto;
  }
  .wb-rel {
    flex-wrap: wrap;
    row-gap: 5px;
  }
  .wb-rel .spacer {
    display: none;
  }
  .wb-rel-main {
    flex: 1 1 100%;
    order: 3;
  }
  .audit-time {
    width: 58px;
  }

  /* 材料台：左侧材料清单折叠为横向滚动 */
  .mat-layout {
    grid-template-columns: 1fr;
  }
  .mat-side {
    position: static;
    top: auto;
  }
  .mat-side-toggle {
    display: inline-flex;
  }
  .mat-list {
    flex-direction: row;
    gap: 8px;
    padding: 9px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
  }
  .mat-side.closed .mat-list {
    display: none;
  }
  .mat-item {
    flex: none;
    width: 232px;
    border: 1px solid var(--line);
    border-radius: 12px;
    border-left-width: 3px;
    scroll-snap-align: start;
    background: var(--surface);
  }
  .mat-item.on {
    border-color: var(--accent-line);
  }
  .mat-detail-actions {
    margin-left: 0;
    width: 100%;
  }
  .mat-detail-card {
    padding: 14px;
  }
  .mat-tbl {
    min-width: 900px;
  }
  .mat-search {
    width: 100%;
    order: 3;
  }
  .mat-tasks-h .btn {
    margin-left: auto;
  }

  /* 详情抽屉 / 预览 */
  .form-grid {
    grid-template-columns: 1fr;
  }
  .detail-tabs {
    top: -14px;
  }
  .detail-title {
    font-size: 16px;
  }
  .detail-crumbs {
    display: none;
  }
  .detail-backrow {
    order: -1;
  }
  .detail-back-title {
    display: none;
  }

  /* 依赖树 / 依赖选择器：窄屏上标题独占一行，缩进收窄，避免横向溢出 */
  .dep-node,
  .dep-pick-row {
    flex-wrap: wrap;
    row-gap: 3px;
  }
  .dep-node .spacer {
    display: none;
  }
  .dep-title,
  .dep-pick-title {
    flex: 1 1 100%;
    max-width: none;
    white-space: normal;
    word-break: break-word;
  }
  .dep-depth-2 {
    padding-left: 18px;
  }
  .dep-depth-3 {
    padding-left: 30px;
  }
  .dep-depth-4 {
    padding-left: 42px;
  }
  .dep-picker-list {
    max-height: 42dvh;
  }
  .dep-picker-list {
    max-height: 42vh;
  }
  .pv-body {
    max-height: calc(100vh - 150px);
  }
  .att-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
  .md-body {
    padding: 18px 18px 34px;
  }
}

@media (max-width: 480px) {
  .crumbs {
    font-size: 12px;
  }
  .crumb {
    max-width: 26ch;
  }
  .wb-due {
    display: none;
  }
  .mat-item {
    width: 210px;
  }
  .audit-time {
    display: none;
  }
  .hist-time {
    width: 54px;
    font-size: 11px;
  }
  .meta-k {
    width: 78px;
  }
  .att-name {
    max-width: 30ch;
  }
}
