:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e6e9ef;
  --line-strong: #d5dae3;
  --text: #1b1f27;
  --sub: #6b7280;
  --faint: #9aa1ad;
  --primary: #2563eb;
  --primary-weak: #eaf1ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

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

button { cursor: pointer; border: none; background: none; }

.hidden { display: none !important; }

/* ---------- login ---------- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 40px;
  background:
    radial-gradient(1000px 420px at 50% -12%, #e8efff 0%, rgba(232, 239, 255, 0) 62%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 30px 22px 24px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  background: linear-gradient(140deg, #3b7bfa, #1e4fd0);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
  box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .7);
}

.login-card h1 { font-size: 21px; margin: 16px 0 4px; letter-spacing: .3px; }
.login-card .sub { color: var(--sub); font-size: 13px; margin: 0 0 22px; }

.field { margin-bottom: 12px; position: relative; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.textarea { min-height: 70px; resize: vertical; }

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}

.row-2 { display: flex; gap: 10px; }
.row-2 > * { flex: 1; min-width: 0; }

.btn {
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: #fff;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:active { background: #f2f4f8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:active { background: #1d4fd0; }
.btn.block { width: 100%; display: block; }
.btn.ghost { background: #f7f8fa; }
.btn.danger { color: var(--danger); border-color: #f3c9c9; background: #fff7f7; }
.btn:disabled { opacity: .55; }

.btn-code {
  position: absolute;
  right: 4px;
  top: 25px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  background: transparent;
}
.btn-code:disabled { color: var(--faint); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 12px;
  margin: 18px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.login-foot {
  margin-top: 18px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}

/* ---------- app shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(140deg, #3b7bfa, #1e4fd0);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.topbar .title { font-weight: 600; font-size: 15px; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 160px;
}
.avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.user-chip .name {
  font-size: 12px;
  color: var(--sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subbar {
  position: sticky;
  top: 49px;
  z-index: 29;
  background: rgba(244, 246, 249, .95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.subbar-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.proj-select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  max-width: 320px;
}
.icon-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}
.icon-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }

.tabs {
  position: sticky;
  top: 94px;
  z-index: 28;
  background: rgba(244, 246, 249, .96);
  backdrop-filter: blur(10px);
  padding: 2px 16px 10px;
}
.tabs-inner {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  background: #eaedf2;
  padding: 3px;
  border-radius: 11px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--sub);
  transition: background .15s, color .15s;
}
.tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

main {
  max-width: 940px;
  margin: 0 auto;
  padding: 4px 16px 90px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 14px 2px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
}
.section-title .count { font-weight: 400; color: var(--faint); font-size: 12px; }

/* ---------- summary ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.stat .num { font-size: 19px; font-weight: 650; letter-spacing: -.3px; }
.stat .lbl { font-size: 11px; color: var(--faint); margin-top: 2px; }
.stat.alert .num { color: var(--danger); }

.progress-line {
  height: 6px;
  border-radius: 999px;
  background: #e9edf3;
  overflow: hidden;
  margin-top: 8px;
}
.progress-line > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #16a34a);
}

/* ---------- board ---------- */
.board {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.board-col {
  flex: 0 0 258px;
  scroll-snap-align: start;
  background: #eef1f5;
  border-radius: 14px;
  padding: 8px;
  min-height: 120px;
}
.board-col > header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.board-col .n { margin-left: auto; color: var(--faint); font-weight: 400; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 11px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transition: transform .12s, box-shadow .12s;
}
.card:active { transform: scale(.99); }
.card .c-top { display: flex; align-items: flex-start; gap: 6px; }
.card .c-title {
  font-size: 13px;
  font-weight: 550;
  line-height: 1.45;
  flex: 1;
  word-break: break-word;
}
.card .c-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--faint);
}
.card .overdue { color: var(--danger); }
.card .c-parent {
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.6;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill.p-high { color: #b91c1c; background: #fef2f2; border-color: #fbdcdc; }
.pill.p-medium { color: #b45309; background: #fffbeb; border-color: #fae6bf; }
.pill.p-low { color: #4b5563; background: #f3f4f6; border-color: #e5e7eb; }
.pill.mile { color: #7c3aed; background: #f5f3ff; border-color: #e6e0fb; }

/* ---------- tree ---------- */
.tree-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
}
.tree-row .caret {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 11px;
  flex: none;
  transition: transform .15s;
}
.tree-row .caret.open { transform: rotate(90deg); }
.tree-row .t-main { flex: 1; min-width: 0; }
.tree-row .t-title {
  font-size: 13.5px;
  font-weight: 550;
  word-break: break-word;
}
.tree-row .t-sub {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tree-children { border-top: 1px solid var(--line); background: #fbfcfe; }
.tree-child { padding: 9px 12px 9px 34px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid #f1f4f8; }
.tree-child:last-child { border-bottom: none; }
.tree-child .t-main { flex: 1; min-width: 0; }
.tree-child .t-title { font-size: 13px; }
.done-text { text-decoration: line-through; color: var(--faint); }

.chk {
  width: 18px; height: 18px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  font-size: 11px;
  color: transparent;
}
.chk.on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- gantt ---------- */
.gantt-scroll {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
.gantt-head, .gantt-row {
  display: flex;
  align-items: stretch;
  white-space: nowrap;
}
.gantt-head { border-bottom: 1px solid var(--line); position: relative; }
.gantt-label {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: none;
  width: 138px;
  padding: 8px 10px;
  background: #fff;
  border-right: 1px solid var(--line);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-head .gantt-label {
  background: #fafbfd;
  color: var(--sub);
  font-weight: 600;
  display: flex;
  align-items: center;
}
.gantt-track { position: relative; flex: none; }
.gantt-day {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px solid #f2f4f8;
}
.gantt-day.weekend { background: #fbfcfe; }
.gantt-day-num {
  position: absolute;
  top: 4px;
  font-size: 10px;
  color: var(--faint);
  text-align: center;
}
.gantt-row { border-bottom: 1px solid #f2f4f8; }
.gantt-row:last-child { border-bottom: none; }
.gantt-row .gantt-label { font-size: 12px; display: flex; flex-direction: column; justify-content: center; }
.gantt-row .gantt-label .g-sub { font-size: 10.5px; color: var(--faint); }
.gantt-track-row { position: relative; height: 40px; }
.gantt-bar {
  position: absolute;
  top: 11px;
  height: 18px;
  border-radius: 6px;
  background: #93b4f7;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
  overflow: hidden;
  display: flex;
  align-items: center;
}
.gantt-bar > i {
  display: block;
  height: 100%;
  background: rgba(37, 99, 235, .55);
}
.gantt-bar > span {
  position: absolute;
  left: 6px;
  font-size: 10px;
  color: #10306e;
  font-weight: 600;
  white-space: nowrap;
}
.gantt-bar.done { background: #bbe6c9; }
.gantt-bar.done > i { background: rgba(22, 163, 74, .5); }
.gantt-milestone {
  position: absolute;
  top: 13px;
  width: 14px;
  height: 14px;
  background: #7c3aed;
  transform: rotate(45deg) translateX(-50%);
  border-radius: 3px;
}
.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ef4444;
  z-index: 2;
}
.gantt-today::after {
  content: "";
  position: absolute;
  top: 0;
  left: -3px;
  width: 7px; height: 7px;
  background: #ef4444;
  border-radius: 50%;
}

/* ---------- report ---------- */
.report-head {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.report-head .range { flex: 1; font-size: 13px; font-weight: 600; }
.report-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.report-block h3 {
  font-size: 13px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.report-block ul { margin: 0; padding-left: 18px; }
.report-block li { font-size: 13px; margin: 5px 0; line-height: 1.5; word-break: break-word; }
.report-block li .muted { color: var(--faint); font-size: 11.5px; margin-left: 6px; }
.report-block .empty-tip { color: var(--faint); font-size: 12.5px; }

/* ---------- empty ---------- */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--sub);
}
.empty .big {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: #e9effb;
  color: #5b7fd4;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
}
.empty h2 { font-size: 15px; margin: 0 0 6px; color: var(--text); font-weight: 600; }
.empty p { font-size: 13px; margin: 0 0 18px; line-height: 1.6; }

/* ---------- sheet / modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .38);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(18px) } to { transform: translateY(0) } }

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: rise .18s ease-out;
  box-shadow: 0 -8px 40px -10px rgba(16, 24, 40, .3);
}
@media (min-width: 620px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; margin: 0 20px; animation: none; }
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.sheet-head h2 { font-size: 15px; margin: 0; flex: 1; }
.sheet-close { color: var(--faint); font-size: 20px; line-height: 1; padding: 2px 4px; }
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.sheet-actions .btn { flex: 1; }

.status-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.status-opt {
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 12.5px;
  color: var(--sub);
}
.status-opt.on {
  border-color: var(--primary);
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 600;
}

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.range-row .val { width: 42px; text-align: right; font-size: 13px; color: var(--sub); }

.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); }
.check-line input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(25, 30, 40, .92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 90;
  max-width: 84vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- badges / tags ---------- */
.cd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.cd-ok { color: #4b5563; background: #f3f4f6; border-color: #e5e7eb; }
.cd-warn { color: #b45309; background: #fffbeb; border-color: #fae6bf; }
.cd-today { color: #c2410c; background: #fff7ed; border-color: #fed7aa; }
.cd-over { color: #b91c1c; background: #fef2f2; border-color: #fbdcdc; }
.cd-done { color: #15803d; background: #f0fdf4; border-color: #cdeed8; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 10.5px;
  background: #f1f4f9;
  color: #55607a;
  border: 1px solid #e5eaf3;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- ledger table ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
table.ledger {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1180px;
  width: 100%;
  font-size: 12.5px;
}
table.ledger th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f9fc;
  color: var(--sub);
  font-weight: 600;
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.ledger td {
  padding: 9px 10px;
  border-bottom: 1px solid #f1f4f8;
  color: #2b3240;
  vertical-align: middle;
  white-space: nowrap;
}
table.ledger tbody tr { cursor: pointer; }
table.ledger tbody tr:active { background: #f7f9fc; }
table.ledger tbody tr:last-child td { border-bottom: none; }
table.ledger td.desc {
  white-space: normal;
  min-width: 180px;
  max-width: 260px;
  font-weight: 500;
}
table.ledger .num { color: var(--faint); font-size: 11.5px; }
table.ledger .bar-mini {
  width: 90px;
  height: 5px;
  border-radius: 999px;
  background: #e9edf3;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
table.ledger .bar-mini > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #16a34a);
}

/* ---------- 6 页签适配 ---------- */
.tabs-inner { gap: 2px; }
.tab { font-size: 12.5px; padding: 7px 2px; }

/* ---------- 统计 5 格 ---------- */
.stat-grid.five { grid-template-columns: repeat(5, 1fr); }
.stat-grid.five .num { font-size: 17px; }
.stat-grid.five .lbl { font-size: 10.5px; }

/* ---------- 提示条 ---------- */
.banner {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.banner.warn { background: #fffbeb; border-color: #fae6bf; color: #92400e; }
.banner.danger { background: #fef2f2; border-color: #fbdcdc; color: #991b1b; }
.banner.ok { background: #f0fdf4; border-color: #cdeed8; color: #166534; }

/* ---------- 分区标题 ---------- */
.sec-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 20px 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: #7c8698;
  letter-spacing: .4px;
}
.sec-label .dot2 { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex: none; }
.sec-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 只读展示块 ---------- */
.ro {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  font-size: 13px;
  color: #3b4453;
}
.hint { font-size: 11.5px; color: var(--faint); margin-top: 6px; }

/* ---------- 卡片流程行 ---------- */
.card .c-flow { margin-top: 5px; color: #6b7c93; }
.pill.st { font-weight: 600; }

/* ---------- 耗时徽标 ---------- */
.dur {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #cfe8fb;
  white-space: nowrap;
}

/* ---------- 流程按钮 ---------- */
.flow-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.flow-bar .btn { flex: 1; min-width: 118px; font-size: 13px; padding: 10px 12px; }

/* ---------- 流程时间轴 ---------- */
.timeline {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px 0 2px;
  -webkit-overflow-scrolling: touch;
}
.tl-step {
  flex: 1 0 auto;
  min-width: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  position: relative;
  padding-top: 12px;
}
.tl-step::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  right: 50%;
  height: 2px;
  background: #e6e9ef;
}
.tl-step:first-child::before { display: none; }
.tl-step.on::before { background: #a9c6ff; }
.tl-dot {
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dfe4ec;
}
.tl-step.on .tl-dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.tl-label { font-size: 11px; color: var(--faint); }
.tl-step.on .tl-label { color: #2b3240; font-weight: 600; }
.tl-at { font-size: 9.5px; color: #b3bac6; line-height: 1.2; }

/* ---------- 照片 ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #eef1f5;
  border: 1px solid var(--line);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item .del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(17, 24, 39, .58);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-item .up {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--primary);
  background: rgba(255, 255, 255, .72);
}
.photo-add {
  aspect-ratio: 1;
  border: 1.5px dashed var(--line-strong);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--faint);
  font-size: 11px;
  background: #fbfcfe;
}
.photo-add .plus { font-size: 19px; line-height: 1; }
.photo-add:active { background: #f1f4f9; }

.thumbs { display: flex; gap: 6px; overflow-x: auto; margin-top: 7px; padding-bottom: 2px; }
.thumbs img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: none;
  background: #eef1f5;
  cursor: pointer;
}

/* ---------- 大图预览 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(9, 12, 18, .93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox .lb-close { position: absolute; top: 12px; right: 16px; color: #fff; font-size: 28px; line-height: 1; }

/* ---------- 成品库卡片 ---------- */
.stock-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  cursor: pointer;
}
.stock-card .sc-top { display: flex; align-items: flex-start; gap: 8px; }
.stock-card .sc-title { flex: 1; font-size: 13.5px; font-weight: 600; line-height: 1.45; word-break: break-word; }
.stock-card .sc-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--faint);
}
.stock-card .sc-act { margin-top: 9px; display: flex; justify-content: flex-end; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; width: auto; }

.empty-tip { color: var(--faint); font-size: 12.5px; }

table.ledger.wide { min-width: 3200px; }
.run-dot { font-style: normal; color: #f59e0b; font-size: 10.5px; margin-left: 3px; }
.section-title .mini-btn { margin-left: auto; align-self: center; }

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat .num { font-size: 17px; }
  .board-col { flex-basis: 244px; }
  .tab { font-size: 12px; }
  .stat-grid.five { grid-template-columns: repeat(5, 1fr); }
  .stat-grid.five .num { font-size: 15px; }
  .stat-grid.five .lbl { font-size: 10px; }
}


/* ================= 环节分页（任务详情） ================= */
.stage-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 10px;
  position: sticky;
  top: -16px;
  background: #fff;
  z-index: 3;
}
.stage-tab {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 52px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--sub);
  font-size: 11.5px;
}
.stage-tab .st-no {
  width: 20px; height: 20px; border-radius: 50%;
  background: #f1f4f8; color: #7c8698;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.stage-tab.done .st-no { background: #dcfce7; color: #15803d; }
.stage-tab.on { border-color: var(--primary); background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.stage-tab.on .st-no { background: var(--primary); color: #fff; }
.stage-pane { display: none; }
.stage-pane.on { display: block; }
.stage-lead {
  display: flex; flex-direction: column; gap: 3px;
  background: #f7f9fc; border: 1px solid var(--line); border-left: 3px solid var(--primary);
  border-radius: 10px; padding: 9px 11px; margin-bottom: 12px;
  font-size: 12px; color: var(--sub);
}
.stage-lead b { color: #2b3240; font-size: 12.5px; }
.detail-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.mini-btn {
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #fff;
  font-size: 11.5px; color: var(--sub);
}
.mini-btn.danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.req { color: #dc2626; }
.hint-inline { font-size: 11px; color: var(--faint); margin-left: 4px; font-weight: 400; }

/* ================= 人员多选 ================= */
.person-box { border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px; background: #fff; }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-weak); color: var(--primary);
  border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 600;
}
.pchip b { cursor: pointer; opacity: .55; font-weight: 400; }
.person-add { display: flex; gap: 6px; margin-top: 6px; }
.person-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12.5px; background: #fff;
}

/* ================= 选人弹层 ================= */
.picker-root { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.picker-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .42); }
.picker-panel {
  position: relative; width: 100%; max-width: 520px; max-height: 80vh;
  background: #fff; border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px -12px rgba(15, 23, 42, .4);
}
@media (min-width: 620px) {
  .picker-root { align-items: center; }
  .picker-panel { border-radius: 16px; margin: 0 20px; }
}
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.picker-head h3 { margin: 0; font-size: 15px; }
.picker-search { display: flex; gap: 8px; }
.picker-search .input { flex: 1; }
.picker-tip { font-size: 11.5px; color: var(--faint); margin: 8px 0; line-height: 1.45; }
.picker-list { flex: 1; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-height: 140px; }
.pick-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border-radius: 9px; text-align: left; }
.pick-item.on { background: var(--primary-weak); }
.pick-av {
  width: 28px; height: 28px; border-radius: 50%; background: #eef2f7;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #4b5563; flex: none;
}
.pick-name { flex: 1; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pick-tag { font-style: normal; font-size: 10px; background: #e0f2fe; color: #0369a1; border-radius: 4px; padding: 1px 4px; }
.pick-check { color: var(--primary); font-weight: 700; }
.picker-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.picker-foot .btn { width: auto; }
.picker-count { flex: 1; font-size: 12px; color: var(--sub); }

/* ================= 图纸 ================= */
.draw-grid { display: flex; flex-direction: column; gap: 8px; }
.draw-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.draw-thumb { width: 44px; height: 44px; border-radius: 8px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.draw-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pdf-ic { font-size: 10px; font-weight: 700; color: #dc2626; }
.draw-meta { flex: 1; min-width: 0; }
.draw-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draw-sub { font-size: 11px; color: var(--faint); }
.draw-act { display: flex; gap: 4px; flex: none; }
.draw-add { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 10px; color: var(--sub); font-size: 12.5px; background: #fbfcfe; }
.draw-add span { font-weight: 700; margin-right: 4px; }
.draw-item.uploading { opacity: .7; }

/* ================= 图纸查看器 ================= */
.doc-viewer { position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .94); display: flex; flex-direction: column; }
.dv-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #111827; color: #e5e7eb; }
.dv-title { flex: 1; font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-wm { font-size: 10px; background: #1e40af; color: #dbeafe; border-radius: 4px; padding: 1px 6px; flex: none; }
.dv-tools { display: flex; gap: 6px; flex: none; }
.dv-body { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.dv-page img { max-width: 100%; background: #fff; box-shadow: 0 4px 20px rgba(0, 0, 0, .35); }
.dv-loading { color: #cbd5e1; font-size: 13px; padding: 40px 0; text-align: center; }

/* ================= 打印 ================= */
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block !important; }
  body.printing { background: #fff !important; }
  .print-page { page-break-after: always; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0; }
  .print-page:last-child { page-break-after: auto; }
  .print-page img { max-width: 100%; max-height: 100vh; object-fit: contain; }
  .print-page.wo-page { display: block; }
  @page { size: A4; margin: 8mm; }
}

/* ================= 工单（打印 / 导出） ================= */
.wo-page { background: #fff; }
.wo-sheet {
  position: relative; width: 100%; max-width: 194mm; min-height: 270mm;
  padding: 2mm; box-sizing: border-box; background: #fff;
  font-size: 12px; color: #1f2937; overflow: hidden;
}
.wo-watermark {
  position: absolute; inset: 0; pointer-events: none;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
  place-items: center; overflow: hidden; z-index: 0;
}
.wo-watermark span {
  transform: rotate(-28deg);
  font-size: 17px; font-weight: 600; letter-spacing: 2px;
  color: rgba(71, 85, 105, .13);
  white-space: nowrap;
}
.wo-head, .wo-table, .wo-h2, .wo-tl, .wo-draw, .wo-note, .wo-foot { position: relative; z-index: 1; }
.wo-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid #0f4c9c; padding-bottom: 6px; }
.wo-logo { font-size: 20px; font-weight: 700; color: #0f4c9c; letter-spacing: 2px; }
.wo-sub { font-size: 10px; color: #6b7280; letter-spacing: 1px; }
.wo-title { text-align: right; }
.wo-title h1 { font-size: 19px; margin: 0; letter-spacing: 4px; }
.wo-no { font-size: 11.5px; color: #374151; margin-top: 3px; }
.wo-table, .wo-tl, .wo-draw { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 11.5px; }
.wo-table th, .wo-table td, .wo-tl th, .wo-tl td, .wo-draw th, .wo-draw td {
  border: 1px solid #cbd5e1; padding: 5px 7px; text-align: left;
}
.wo-table th, .wo-tl th, .wo-draw th { background: #f1f5f9; color: #334155; font-weight: 600; }
.wo-table th { width: 15%; }
.wo-tl th, .wo-tl td { text-align: center; }
.wo-h2 { font-size: 12.5px; margin: 14px 0 4px; color: #0f4c9c; }
.wo-note { border: 1px solid #cbd5e1; padding: 7px; font-size: 11.5px; min-height: 34px; white-space: pre-wrap; }
.wo-foot { margin-top: 18px; border-top: 1px dashed #cbd5e1; padding-top: 7px; font-size: 11px; color: #475569; display: flex; gap: 16px; flex-wrap: wrap; }
.wo-sign { width: 100%; margin-top: 8px; }

/* ================= 图纸页水印层 ================= */
.doc-page { position: relative; display: inline-block; max-width: 100%; }
.doc-page img { display: block; max-width: 100%; height: auto; background: #fff; }
.doc-page--view img { box-shadow: 0 4px 20px rgba(0, 0, 0, .35); }
.wm-layer {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
  place-items: center;
}
.wm-layer span {
  transform: rotate(-28deg);
  font-size: 13px; font-weight: 600; letter-spacing: 2px;
  color: rgba(71, 85, 105, .22);
  white-space: nowrap;
}
@media print {
  .print-page .doc-page { display: block; width: 100%; text-align: center; }
  .print-page .doc-page img { max-height: 100vh; object-fit: contain; margin: 0 auto; }
  .print-page .wm-layer { height: 100vh; }
}

/* ================= 生产环节准入锁定 ================= */
.person-field.locked .person-box { background: #f7f8fa; border-color: var(--line); }
.person-field.locked .person-input,
.person-field.locked .btn.mini { background: #f1f3f6; color: #9aa3b2; cursor: not-allowed; }
.person-field.locked .pchip { opacity: .75; }
.lock-hint { font-size: 11px; color: #b45309; margin-top: 6px; }
.range-row input[type="range"]:disabled { opacity: .45; }
.range-row input[type="range"]:disabled::-webkit-slider-thumb { background: #b6c0cd; }
