* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: #f5f7fa; color: #1f2937; font-size: 14px;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #eef2f7; padding: 24px;
}
.login-card {
  width: 430px; background: #fff; border: 1px solid #e5e9f0; border-radius: 16px;
  padding: 30px 32px 24px;
}
.brand { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.mark { width: 10px; height: 22px; border-radius: 3px; background: #2563eb; display: inline-block; }
.sub { color: #6b7280; font-size: 13px; margin: 8px 0 22px; }
.fld { display: block; margin-bottom: 13px; }
.fld > span { display: block; font-size: 12px; color: #6b7280; margin-bottom: 5px; }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #dbe3ee; border-radius: 9px;
  font-size: 14px; font-family: inherit; background: #fff; color: #1f2937; outline: none;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: #93b4f5; }
.btn {
  border: 1px solid #dbe3ee; background: #fff; color: #374151; border-radius: 9px;
  padding: 8px 13px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c3d0e4; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 10px; font-size: 14px; margin-top: 4px; }
.err { color: #dc2626; font-size: 12px; min-height: 16px; margin: 8px 0 0; }
.accounts { border-top: 1px dashed #e5e9f0; margin-top: 16px; padding-top: 14px; }
.acc-h { font-size: 11px; color: #9ca3af; margin-bottom: 8px; }
.acc-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.acc {
  border: 1px solid #eef1f6; background: #fafbfd; border-radius: 8px; padding: 7px 9px;
  text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.acc:hover { border-color: #c3d0e4; background: #f3f6fb; }
.acc b { font-size: 12px; color: #374151; font-weight: 500; }
.acc span { font-size: 11px; color: #9ca3af; }
.qr-link {
  display: block; text-align: center; margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed #e5e9f0; font-size: 12.5px; color: #2563eb; text-decoration: none;
}
.qr-link:hover { text-decoration: underline; }

/* ---------- 应用骨架 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.side {
  width: 222px; flex: 0 0 222px; background: #fff; border-right: 1px solid #e5e9f0;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.logo { font-size: 19px; font-weight: 600; padding: 0 10px 18px; letter-spacing: .5px; }
.logo span { color: #2563eb; font-size: 11px; font-weight: 500; margin-left: 3px; }
nav { display: flex; flex-direction: column; gap: 3px; }
nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0;
  background: transparent; padding: 10px 12px; border-radius: 9px;
  font-size: 13.5px; color: #4b5563; cursor: pointer; text-align: left;
}
nav button:hover { background: #f3f6fb; }
nav button.on { background: #eff6ff; color: #1d4ed8; font-weight: 500; }
.ico { width: 18px; text-align: center; opacity: .75; font-size: 15px; }
.side-foot { margin-top: auto; font-size: 11px; color: #9ca3af; padding: 12px 10px 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top {
  height: 56px; flex: 0 0 56px; background: #fff; border-bottom: 1px solid #e5e9f0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
}
.crumb { font-size: 15px; font-weight: 500; }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 12px; color: #6b7280; }
.live { display: inline-flex; align-items: center; gap: 6px; color: #16a34a; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; display: inline-block; }
.me { color: #374151; }
.view { flex: 1; overflow: auto; padding: 20px 22px 44px; }

/* ---------- 卡片 / KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; padding: 14px; }
.kpi-l { font-size: 12px; color: #6b7280; }
.kpi-v { font-size: 19px; font-weight: 600; margin-top: 6px; letter-spacing: -.2px; }
.kpi-s { font-size: 11px; color: #9ca3af; margin-top: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid #e5e9f0; border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-h h3 { font-size: 14px; font-weight: 600; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }

/* ---------- 表格 ---------- */
.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th {
  text-align: left; font-weight: 500; color: #6b7280; background: #f8fafc;
  padding: 9px 10px; border-bottom: 1px solid #e5e9f0; white-space: nowrap;
}
.t td { padding: 10px; border-bottom: 1px solid #f1f4f9; vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t.small th, .t.small td { padding: 6px 8px; font-size: 12px; }
.t tr.low td { background: #fff7ed; }
.bad { color: #dc2626; font-weight: 500; }
.muted { color: #9ca3af; }
.sub2 { color: #9ca3af; font-size: 12px; }
.hint { color: #9ca3af; font-size: 12px; margin: 8px 0 0; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.pill.ok { background: #ecfdf5; color: #047857; }
.pill.run { background: #eff6ff; color: #1d4ed8; }
.pill.wait { background: #f3f4f6; color: #6b7280; }
.pill.bad { background: #fef2f2; color: #b91c1c; }

/* ---------- 任务工序 ---------- */
.task { border: 1px solid #eef1f6; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.task:last-child { margin-bottom: 0; }
.task-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.task-h b { font-size: 14px; }
.task-meta { color: #6b7280; font-size: 12px; margin-top: 4px; }
.pipe { display: flex; gap: 8px; margin-top: 12px; }
.step {
  flex: 1; border: 1px solid #e5e9f0; background: #fff; border-radius: 10px;
  padding: 8px 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.step:hover { border-color: #bfdbfe; }
.step b { font-size: 13px; font-weight: 500; }
.step span { font-size: 12px; color: #6b7280; }
.step em { font-size: 11px; color: #9ca3af; font-style: normal; }
.step.done { background: #ecfdf5; border-color: #a7f3d0; }
.step.done span { color: #047857; }
.step.run { background: #eff6ff; border-color: #bfdbfe; }
.step.run span { color: #1d4ed8; }

/* ---------- 产品 / BOM ---------- */
.prod { border: 1px solid #eef1f6; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.prod:last-child { margin-bottom: 0; }
.prod-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.prod-h b { font-size: 14px; }
.mini-h { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.cost-line { margin-top: 8px; font-size: 12px; color: #6b7280; }

/* ---------- 动态 ---------- */
.logs { list-style: none; padding: 0; margin: 0; }
.logs li { padding: 8px 0; border-bottom: 1px dashed #eef1f6; display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.logs li:last-child { border-bottom: 0; }
.logs em { color: #9ca3af; font-style: normal; font-size: 12px; white-space: nowrap; }

/* ---------- 弹窗 ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .38); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { position: relative; width: 480px; max-width: 100%; max-height: 88vh; overflow: auto; background: #fff; border-radius: 14px; padding: 20px 22px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-h h3 { font-size: 15px; font-weight: 600; margin: 0; }
.x { border: 0; background: transparent; font-size: 20px; color: #9ca3af; cursor: pointer; line-height: 1; }
.modal-body { max-height: 62vh; overflow: auto; padding-right: 2px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #eef1f6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; opacity: 0; transition: opacity .18s; pointer-events: none; z-index: 80;
}
.toast.show { opacity: 1; }
.toast.bad { background: #b91c1c; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .pipe { flex-wrap: wrap; }
  .step { flex: 1 1 30%; }
}

/* ---------- 手机端（企业微信内置浏览器 / 手机浏览器） ---------- */
@media (max-width: 820px) {
  .app { flex-direction: column; height: 100vh; height: 100dvh; }

  /* 侧栏变顶部横向导航 */
  .side {
    width: 100%; flex: 0 0 auto; flex-direction: row; align-items: center;
    padding: 6px 8px; border-right: 0; border-bottom: 1px solid #e5e9f0;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .logo { display: none; }
  .side-foot { display: none; }
  nav { flex-direction: row; gap: 6px; }
  nav button {
    width: auto; flex: 0 0 auto; white-space: nowrap;
    padding: 9px 12px; font-size: 13px; border-radius: 8px;
  }
  nav button .ico { font-size: 14px; }

  .top { height: auto; flex: 0 0 auto; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .crumb { font-size: 14px; }
  .top-right { gap: 10px; font-size: 12px; }

  .view { padding: 12px 12px 40px; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; min-width: 0; }
  .kpi-l { font-size: 11.5px; }
  .kpi-v { font-size: 16px; line-height: 1.35; word-break: break-word; }
  .kpi-s { font-size: 10.5px; }

  .card { padding: 12px; border-radius: 12px; }
  .card-h { flex-wrap: wrap; gap: 8px; }

  /* 宽表格在卡片内横向滚动，不撑破页面 */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .t { min-width: 100%; font-size: 12.5px; }
  .t th, .t td { padding: 8px 9px; white-space: nowrap; }
  .t td .sub2 { white-space: normal; }

  .task-h, .prod-h { flex-wrap: wrap; }
  .pipe { gap: 6px; }
  .step { flex: 1 1 calc(50% - 6px); padding: 11px 12px; }
  /* 车间手机屏幕小、光线差，工序字放大一档（2026-10-28 按王织带反馈调整） */
  .step b { font-size: 15px; font-weight: 600; }
  .step span { font-size: 13.5px; }
  .step em { font-size: 12px; }

  .logs li { flex-direction: column; gap: 3px; }

  /* iOS / 企业微信 聚焦输入框会自动放大页面，故统一 16px */
  .fld input, .fld select, .fld textarea { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 9px 12px; }
  .btn.sm { padding: 7px 10px; font-size: 12.5px; }

  .login-wrap { padding: 14px; align-items: flex-start; padding-top: 34px; }
  .login-card { width: 100%; padding: 22px 18px 18px; border-radius: 14px; }
  .acc-list { grid-template-columns: 1fr; }

  .modal-mask { padding: 10px; }
  .modal { width: 100%; max-height: 90vh; padding: 16px; border-radius: 12px; }
  .modal-body { max-height: 66vh; }
  .toast { bottom: 20px; max-width: calc(100% - 32px); text-align: center; }
}

/* ---------- 问题反馈 ---------- */
.fb-item {
  border: 1px solid #e5e9f0; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; background: #fff;
}
.fb-item.is-done { background: #f8fafc; border-color: #e8edf4; }
.fb-item.is-done .fb-text { color: #94a3b8; }
.fb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; font-size: 12px; }
.fb-head b { font-size: 13px; font-weight: 600; }
.fb-text { font-size: 13px; line-height: 1.75; color: #334155; white-space: pre-wrap; }
.fb-reply { margin-top: 8px; font-size: 12px; color: #15803d; background: #f0fdf4; border: 1px solid #dcfce7; border-radius: 8px; padding: 7px 10px; }
