/* 新版预分包系统 —— 共享样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f4f6f9; color: #333; font-size: 14px;
}
a { color: #2c7be5; text-decoration: none; }
button { cursor: pointer; }

/* 顶部导航 */
.nav {
  background: #1f2d3d; color: #fff; display: flex; align-items: center;
  padding: 0 16px; height: 52px; gap: 4px; position: sticky; top: 0; z-index: 100;
}
.nav .brand { font-size: 16px; font-weight: 700; margin-right: 18px; white-space: nowrap; }
.nav .tab {
  color: #cfd8e3; padding: 0 16px; height: 52px; line-height: 52px; cursor: pointer;
  font-size: 15px; white-space: nowrap;
}
.nav .tab:hover { color: #fff; }
.nav .tab.on { color: #fff; border-bottom: 3px solid #2c7be5; font-weight: 600; }
.nav .spacer { flex: 1; }
.nav .org { background: #2c7be5; color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 10px; margin-right: 12px; white-space: nowrap; }
.nav .user { color: #cfd8e3; margin-right: 12px; font-size: 13px; }
.nav .logout { color: #f0ad4e; cursor: pointer; font-size: 13px; }

/* 页面容器 */
.wrap { max-width: 1280px; margin: 16px auto; padding: 0 12px; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); overflow: hidden; }

/* 搜索条 */
.search-bar { display: flex; gap: 10px; padding: 14px 16px; align-items: center; flex-wrap: wrap; }
.search-bar input[type=text] {
  flex: 1; min-width: 160px; padding: 10px 12px; border: 1px solid #ddd;
  border-radius: 6px; font-size: 16px;
}

/* 表格 */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef0f2; }
table.grid th { background: #f0f2f5; font-weight: 600; color: #444; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.grid tr:hover td { background: #fafbfc; }
table.grid td.num, table.grid th.num { text-align: right; }

/* 表格横向滚动容器（手机看宽表用，可左右滑动） */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 订单列表：操作列固定在右侧，手机不用滑到底就能点「分拣/打包」 */
.sticky-op th:last-child, .sticky-op td:last-child {
  position: sticky; right: 0; z-index: 2;
  box-shadow: -3px 0 5px -3px rgba(0,0,0,.15);
}
.sticky-op th:last-child { background: #f0f2f5; z-index: 3; }
.sticky-op td:last-child { background: #fff; }
.sticky-op tr:hover td:last-child { background: #fafbfc; }

/* 板件卡片列表（分拣/打包页：像号位一样，每条一个纵向卡片，无需横向滚动） */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.board-card {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.12);
  padding: 12px 14px; border-left: 5px solid #aab; cursor: pointer; user-select: none;
}
.board-card.unpicked { background: #fff8ec; border-left-color: #f0ad4e; }
.board-card .bc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.board-card .bc-code { font-weight: 700; font-size: 15px; color: #1f2d3d; word-break: break-all; }
.board-card .bc-cnt { font-weight: 700; color: #2c7be5; white-space: nowrap; font-size: 14px; }
.board-card .bc-cnt.done { color: #4caf50; }
.board-card .bc-name { color: #333; font-size: 14px; margin-top: 4px; }
.board-card .bc-meta { color: #888; font-size: 12px; margin-top: 4px; line-height: 1.6; display: flex; flex-wrap: wrap; gap: 2px 8px; }
.board-card .bc-meta .bc-dim { color: #555; font-weight: 600; }
.board-card .bc-pos { color: #e67e22; font-size: 13px; font-weight: 600; margin-top: 6px; }
.board-card .bc-sub { color: #999; font-size: 12px; margin-top: 2px; }
.board-card .bc-actions { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }

/* 按钮 */
.btn { padding: 8px 16px; border: none; border-radius: 6px; font-size: 14px; background: #eef0f2; color: #333; }
.btn:hover { filter: brightness(.96); }
.btn.primary { background: #2c7be5; color: #fff; }
.btn.success { background: #2ecc71; color: #fff; }
.btn.danger { background: #e74c3c; color: #fff; }
.btn.warn { background: #f0ad4e; color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { background: #ccc !important; cursor: not-allowed; }

/* 状态徽标 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; color: #fff; white-space: nowrap; }
.badge.未分拣 { background: #aab; }
.badge.分拣中 { background: #f0ad4e; }
.badge.打包中 { background: #f0ad4e; }
.badge.可以打包 { background: #17a2b8; }
.badge.已满 { background: #4caf50; }
.badge.已打包 { background: #2c7be5; }

/* 提示 toast */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 12px 24px; border-radius: 8px;
  font-size: 16px; z-index: 9999; display: none; max-width: 90%; text-align: center;
}
.toast.err { background: rgba(200,40,40,.9); }

/* 加载遮罩 + 旋转动画（导入等耗时操作） */
.loading-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff; font-size: 16px; }
.spinner { width: 46px; height: 46px; border: 4px solid rgba(255,255,255,.28); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 弹窗遮罩 */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; }
.dialog { background: #fff; border-radius: 10px; min-width: 320px; max-width: 90%; max-height: 88vh; overflow: auto; }
.dialog .dlg-head { padding: 14px 18px; font-size: 16px; font-weight: 700; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.dialog .dlg-body { padding: 18px; }
.dialog .dlg-foot { padding: 12px 18px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 10px; }

/* 扫码窗口：全屏（手机扫条码，越大越好扫） */
.camera-dlg {
  width: 100vw; height: 100vh;
  max-width: 100vw; max-height: 100vh; min-width: 0;
  border-radius: 0; background: #000; overflow: hidden;
  display: flex; flex-direction: column;
}
.camera-dlg .dlg-head {
  flex: 0 0 auto; background: rgba(0,0,0,.62); color: #fff; border-bottom: none; font-size: 17px;
}
.camera-dlg .dlg-head span:last-child { font-size: 28px; line-height: 1; padding: 0 4px; }
.camera-dlg .dlg-body {
  flex: 1; padding: 0; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
#qr-reader { width: 100%; height: 100%; }
#qr-reader video { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }

/* 大号显示（扫码提示，屏幕中央放大动画） */
.bigshow {
  position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center;
  pointer-events: none; animation: fadeBig 2.2s forwards;
}
.bigshow .inner {
  text-align: center; padding: 40px 60px; border-radius: 16px; background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.bigshow .pos { font-size: 120px; font-weight: 900; color: #2c7be5; line-height: 1; }
.bigshow .name { font-size: 24px; color: #555; margin-top: 10px; }
.bigshow.err .pos { color: #e74c3c; font-size: 60px; }
.bigshow.stay { animation: none; opacity: 1; }
@keyframes fadeBig {
  0% { opacity: 0; transform: scale(.6); }
  15% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}

/* 响应式：手机 */
@media (max-width: 720px) {
  .nav .brand { display: none; }
  .nav .tab { padding: 0 12px; font-size: 15px; }
  .nav .user { display: none; }
  .nav .org { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .wrap { margin: 8px auto; padding: 0 8px; }
  /* 阻止 iOS 聚焦输入框时自动放大：手机端所有输入字号 >= 16px（扫码输入保持 18px） */
  input, textarea, select { font-size: 16px !important; }
  .scan-bar input { font-size: 18px !important; }
  table.grid th, table.grid td { padding: 8px 6px; font-size: 13px; }
  /* 触控目标做大，防误触 */
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
  .op-link, .voice { display: inline-block; padding: 8px 6px; font-size: 14px; }
  .search-bar { padding: 10px 12px; gap: 8px; }
  /* 扫码大字提示不超出屏幕 */
  .bigshow .inner { padding: 20px 26px; }
  .bigshow .pos { font-size: 72px; }
  .bigshow.err .pos { font-size: 44px; }
}
