/* 排人表页面 —— 样式对齐车间日报 */

.report .table-wrap { max-height: none; }

#staffGrid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

#staffGrid th,
#staffGrid td {
  border: 1px solid #cfd6df;
  padding: 0;
  font-size: 15px;
  line-height: 1.45;
  vertical-align: middle;
}

#staffGrid thead th {
  background: #eef2f7;
  font-weight: 600;
  color: #1f2937;
  padding: 9px 8px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

#staffGrid tbody td.cell {
  padding: 7px 9px;
  outline: none;
  cursor: text;
  word-break: break-all;
}

#staffGrid tbody td.cell:focus {
  background: #eff6ff;
  box-shadow: inset 0 0 0 2px #3b82f6;
}

#staffGrid td.idx { text-align: center; color: #6b7280; }
#staffGrid td.name { text-align: center; font-weight: 600; }
#staffGrid td.shift { text-align: center; color: #374151; }
#staffGrid td.qty { text-align: right; font-variant-numeric: tabular-nums; }
#staffGrid td.plan { font-size: 15px; letter-spacing: .3px; }

#staffGrid tbody tr:nth-child(even) { background: #fbfcfe; }
#staffGrid tbody tr.rest td { color: #9ca3af; }
#staffGrid tbody tr.over { background: #fff5f5; }
#staffGrid tbody tr.over td.qty { color: #dc2626; font-weight: 600; }

#staffGrid tfoot td {
  background: #f6f8fb;
  font-weight: 600;
  padding: 9px 10px;
  border: 1px solid #cfd6df;
}
#staffGrid tfoot td.qty { text-align: right; }

/* 图例 */
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #6b7280;
  padding: 10px 4px 0;
}
.legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}
.legend .lg-new { background: #fef3c7; border: 1px solid #fbbf24; }
.legend .lg-over { background: #fee2e2; border: 1px solid #f87171; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal.on { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 640px;
  max-width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal-box.wide { width: 1180px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.icon-btn {
  border: 0; background: none; font-size: 17px; cursor: pointer;
  color: #6b7280; padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: #f3f4f6; }
.modal-body { padding: 14px 18px; overflow: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid #e5e7eb;
}
.hint { color: #6b7280; font-size: 13px; line-height: 1.7; margin: 0 0 12px; }
.hint code {
  background: #f3f4f6; padding: 1px 5px; border-radius: 4px;
  font-size: 12px; color: #b91c1c;
}

.ocr-wrap { max-height: 56vh; overflow: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
#ocrTable { border-collapse: collapse; width: 100%; font-size: 13px; }
#ocrTable th, #ocrTable td { border: 1px solid #e5e7eb; padding: 2px 4px; }
#ocrTable th { background: #f3f4f6; position: sticky; top: 0; }
#ocrTable input {
  width: 100%; border: 0; background: transparent;
  font-size: 13px; padding: 4px 3px; outline: none;
}
#ocrTable input:focus { background: #eff6ff; }

@media (max-width: 720px) {
  .top-actions .btn { padding: 7px 10px; font-size: 13px; }
  #staffGrid th, #staffGrid td { font-size: 13px; }
  #staffGrid tbody td.cell { padding: 5px 6px; }
}

/* 识别弹窗里的起始日期 */
.ocr-date {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 13.5px;
  color: #374151;
}
.ocr-date input {
  border: 1px solid #d1d5db;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 13.5px;
}

/* ---------- 分享弹窗 ---------- */
.share-box { width: 1040px; max-width: calc(100vw - 32px); }
.share-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 16px 18px 6px;
}
.share-preview { flex: 1 1 auto; min-width: 0; }
.share-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.share-tip {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: #9ca3af;
  text-align: center;
}
.share-side {
  flex: 0 0 236px;
  width: 236px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-qr {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.share-qr #shareQr { width: 100%; max-width: 176px; margin: 0 auto; }
.share-qr svg { display: block; width: 100%; height: auto; }
.qr-cap { margin: 6px 0 0; font-size: 12px; color: #6b7280; }
.share-lab { font-size: 12.5px; color: #6b7280; margin-top: 2px; }
.share-link { display: flex; gap: 6px; }
.share-link input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12.5px;
  color: #374151;
  background: #f9fafb;
}
.share-link .btn { padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.share-meta { margin: 4px 0 0; font-size: 12.5px; color: #6b7280; }
@media (max-width: 860px) {
  .share-body { flex-direction: column; gap: 12px; }
  .share-side { flex: 1 1 auto; width: 100%; }
  .share-preview img { max-height: 46vh; }
  .share-qr { display: none; }
}

/* ---------- 周切换 ---------- */
.weekbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}
.weekbar-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: #64748b;
  letter-spacing: .04em;
  font-weight: 600;
}
.weekbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.weekbar::-webkit-scrollbar { height: 5px; }
.weekbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.wk-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1.25;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.wk-chip:hover { border-color: #c7d2fe; background: #f8fafc; }
.wk-chip .wk-d {
  font-size: 13.5px;
  font-weight: 650;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.wk-chip .wk-s {
  font-size: 11.5px;
  color: #94a3b8;
  white-space: nowrap;
}
.wk-badge {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: #1d4ed8;
  background: #e0e7ff;
  border-radius: 4px;
  padding: 1px 4px;
  margin-right: 5px;
}
.wk-chip.on {
  background: #1d4ed8;
  border-color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(29, 78, 216, .25);
}
.wk-chip.on .wk-d { color: #fff; }
.wk-chip.on .wk-s { color: #c7d2fe; }
.wk-chip.on .wk-badge { background: rgba(255,255,255,.22); color: #fff; }
@media (max-width: 640px) {
  .weekbar-row { gap: 6px; }
  .weekbar-label { display: none; }
  .wk-chip { padding: 6px 10px; }
}

/* 数量格子输入非法内容时的提示样式（不改数据，只标红） */
#staffGrid tbody td.cell.invalid {
  background: #fef2f2;
  box-shadow: inset 0 0 0 2px #f87171;
  color: #dc2626;
}

/* ---------- 人员名单：表格编辑 ---------- */
.roster-box { width: 1000px; }
.roster-stat {
  color: #6b7280; font-size: 12.5px; font-weight: 400;
  margin-left: 10px; font-variant-numeric: tabular-nums;
}
.roster-wrap {
  max-height: 54vh;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
#rosterTable { border-collapse: collapse; width: 100%; font-size: 13.5px; }
#rosterTable th, #rosterTable td { border: 1px solid #e5e7eb; padding: 0 4px; }
#rosterTable th {
  background: #f3f4f6; position: sticky; top: 0; z-index: 1;
  font-weight: 600; color: #374151; text-align: left;
  white-space: nowrap; padding: 7px 6px; font-size: 13px;
}
#rosterTable td.rn {
  text-align: center; color: #9ca3af; font-size: 12px;
  font-variant-numeric: tabular-nums; background: #fafafa;
}
#rosterTable input {
  width: 100%; border: 0; background: transparent;
  font-family: inherit; font-size: 13.5px;
  padding: 7px 3px; outline: none; color: #111827;
}
#rosterTable input:focus { background: #eff6ff; }
#rosterTable input::placeholder { color: #c7cbd3; }
#rosterTable input.num { text-align: right; font-variant-numeric: tabular-nums; }
#rosterTable .rdel { font-size: 13px; color: #b9bec7; padding: 4px 2px; }
#rosterTable .rdel:hover { color: #dc2626; background: #fef2f2; }
.roster-add { margin-top: 10px; }
.roster-warn { flex: 1; color: #b45309; font-size: 12.5px; line-height: 1.5; align-self: center; }

@media (max-width: 720px) {
  .roster-box { width: 100%; }
  #rosterTable { min-width: 660px; }
  .roster-wrap { max-height: 50vh; }
  .roster-warn { display: none; }
}

/* ================= 手机端：一人一行的表铺满屏，不用横着拖 ================= */
@media (max-width: 720px) {
  .sheet.report {
    margin-left: -10px;
    margin-right: -10px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .sheet.report .sheet-head { padding: 10px 12px; }

  /* 关键：去掉全局 table 的 780px 最小宽度 */
  #staffGrid { min-width: 0; }

  #staffGrid thead th { padding: 8px 2px; font-size: 11.5px; height: 34px; }
  #staffGrid thead th:nth-child(1) { width: 30px !important; }
  #staffGrid thead th:nth-child(2) { width: 72px !important; }
  #staffGrid thead th:nth-child(3) { width: 78px !important; }
  #staffGrid thead th:nth-child(5) { width: 88px !important; }

  /* 16px：iOS 上聚焦编辑时不会自动放大整页 */
  #staffGrid tbody td.cell { padding: 9px 4px; font-size: 16px; line-height: 1.35; }
  #staffGrid td.idx { font-size: 11px; }
  #staffGrid td.shift { font-size: 12.5px; letter-spacing: -.3px; white-space: nowrap; }
  #staffGrid td.qty { font-size: 15px; padding-right: 5px; }
  #staffGrid tfoot td { padding: 9px 6px; font-size: 13px; }
  #staffGrid tfoot td[colspan] { text-align: right; }
}

@media (max-width: 380px) {
  #staffGrid thead th:nth-child(1) { width: 28px !important; }
  #staffGrid thead th:nth-child(2) { width: 68px !important; }
  #staffGrid thead th:nth-child(3) { width: 84px !important; }
  #staffGrid thead th:nth-child(5) { width: 78px !important; }
  #staffGrid td.shift { font-size: 11.5px; }
  #staffGrid tbody td.cell { font-size: 15.5px; padding: 9px 3px; }
}

@media (max-width: 860px) and (min-width: 721px) {
  /* 平板竖屏：去掉 780px 最小宽度，避免多出 34px 横滑 */
  #staffGrid { min-width: 0; }
}

/* ================= 手机端弹窗 ================= */
@media (max-width: 720px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    width: 100%; max-width: 100%; max-height: 94vh;
    border-radius: 16px 16px 0 0;
  }
  .modal-head { padding: 12px 14px; }
  .modal-head h3 { font-size: 15px; }
  .modal-body { padding: 12px; }
  .modal-foot { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .modal-foot .btn { flex: 1 1 0; height: 44px; font-size: 14px; }
  .modal .icon-btn { width: 40px; height: 40px; font-size: 20px; }
  .roster-box { width: 100%; }
  .roster-wrap { max-height: 56vh; }
  .ocr-wrap { max-height: 58vh; }
  #rosterTable input, #ocrTable input, .ocr-date input { font-size: 16px; }
  #rosterTable { min-width: 600px; }
}
