/* 周计划排产页 —— 在 app.css 基础上的补充 */

.date-nav .lbl { font-size: 12.5px; color: var(--ink-3); }
.num-input {
  width: 64px; padding: 7px 8px; border: 1px solid var(--line-2);
  border-radius: 8px; background: #fff; font-size: 13px; text-align: center;
}
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.chk input { width: 14px; height: 14px; }

.dot.green { background: #059669; }

main { padding-bottom: 60px; }

/* 周计划表格 */
#weekGrid { table-layout: fixed; }
#weekGrid td { padding: 0; }
#weekGrid .wk-cell {
  width: 100%; border: 0; background: transparent; padding: 8px 8px;
  font-size: 13px; color: var(--ink); outline: none;
}
#weekGrid .wk-cell:focus { background: var(--blue-soft); box-shadow: inset 0 0 0 2px #bfdbfe; border-radius: 6px; }
#weekGrid .wk-cell.num { text-align: right; font-variant-numeric: tabular-nums; }
#weekGrid tr.odd td { background: #fbfcfe; }
#weekGrid tr:hover td { background: #f8fafc; }

.pri {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 11.5px; line-height: 1.6; white-space: nowrap; border: 1px solid transparent;
}
.pri-p0 { background: #fee2e2; color: #b91c1c; border-color: #fecaca; font-weight: 600; }
.pri-p1 { background: #ffedd5; color: #c2410c; border-color: #fed7aa; font-weight: 600; }
.pri-p2 { background: #fef9c3; color: #a16207; border-color: #fde68a; }
.pri-p3 { background: #eef2f7; color: #475569; border-color: #e2e8f0; }
.pri-p4 { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.pri-p5 { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.pri-cell { padding: 6px 4px !important; text-align: center; }

/* 六天 tabs */
.days-sheet { margin-top: 18px; }
.day-tabs {
  display: flex; gap: 8px; padding: 12px 14px 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); background: #fcfdff;
}
.day-tab {
  border: 1px solid var(--line); border-bottom: none; background: #f8fafc;
  border-radius: 10px 10px 0 0; padding: 8px 14px 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-width: 108px; transition: all .12s; position: relative; top: 1px;
}
.day-tab:hover { background: #f1f5f9; }
.day-tab.on {
  background: #fff; border-color: var(--line-2); box-shadow: 0 -2px 0 var(--blue) inset;
}
.day-tab .d1 { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.day-tab .d2 { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.day-tab.on .d1 { color: var(--blue); }

#dayGrid { table-layout: fixed; }
#dayGrid td { padding: 0; }
#dayGrid .wk-cell { padding: 8px; }
#dayGrid tr.odd td { background: #fbfcfe; }
#dayGrid .qty-cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
#dayGrid .qty-cell.changed { color: var(--blue); background: #f5f9ff; }

.empty-hint {
  padding: 40px 16px; text-align: center; color: var(--ink-3); font-size: 13.5px;
}

/* 打印：只留六天计划 */
@media print {
  .topbar, .datebar, .days-sheet .sheet-tools, .day-tabs, .sheet:first-of-type { display: none !important; }
  .days-sheet { margin: 0; box-shadow: none; border: 0; }
  #dayGrid .wk-cell { padding: 4px 6px; font-size: 11px; }
  body { background: #fff; }
}

@media (max-width: 760px) {
  .day-tab { min-width: 84px; padding: 7px 10px 8px; }
  .top-actions .btn { padding: 0 9px; height: 32px; font-size: 12.5px; }
}

/* ---------- 周切换 ---------- */
.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; }
}

/* ==================== 移动端优化 ==================== */

@media (max-width: 640px) {
  /* 六个日期标签一行放下，不再折成两排 */
  .day-tabs { gap: 4px; padding: 8px 8px 0; flex-wrap: nowrap; }
  .day-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 2px 7px;
    align-items: center;
    text-align: center;
  }
  .day-tab .d1 { font-size: 11px; white-space: nowrap; }
  .day-tab .d2 { font-size: 9.5px; white-space: nowrap; }
  /* 手机上「42 条 · 」省掉，只留数量，否则 6 个标签放不下 */
  .day-tab .d2n { display: none; }
}

@media (max-width: 860px) {
  /* 宽表格：冻住「产品编号」列，横滑时始终能看到是哪一行 */
  #weekGrid thead th:nth-child(3),
  #weekGrid tbody td:nth-child(3),
  #dayGrid thead th:nth-child(3),
  #dayGrid tbody td:nth-child(3),
  #grid thead th:nth-child(3),
  #grid tbody td:nth-child(3) {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 4px 0 6px -4px rgba(15, 23, 42, .22);
  }
  #weekGrid thead th:nth-child(3),
  #dayGrid thead th:nth-child(3),
  #grid thead th:nth-child(3) {
    z-index: 4;
    background: #f8fafc;
  }
  #dayGrid tr.odd td:nth-child(3) { background: #fbfcfe; }

  #weekGrid thead th:nth-child(3) { width: 118px !important; }
  #dayGrid thead th:nth-child(3) { width: 118px !important; }
  #grid thead th:nth-child(3) { width: 118px !important; }

  /* 16px：iOS 上点格子编辑不会把整页放大 */
  #weekGrid .wk-cell, #dayGrid .wk-cell, #grid .cell { font-size: 16px; }
  #weekGrid thead th, #dayGrid thead th { height: 34px; font-size: 11.5px; }
  #weekGrid tfoot td, #dayGrid tfoot td { font-size: 12.5px; }
}

@media (max-width: 860px) {
  .top-actions .btn { height: 40px; padding: 0 13px; font-size: 13px; }
}

@media (max-width: 860px) {
  /* 日期标签容器可以被压缩，否则会撑破页面 */
  .day-tabs { min-width: 0; max-width: 100%; }
  .day-tab { overflow: hidden; }
  .day-tab .d1, .day-tab .d2 { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .view-tab { height: 36px; }
}
