/* PDA扫码发料 —— 移动端优先样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 15px; background: #f2f4f7; color: #1f2329; padding-bottom: env(safe-area-inset-bottom);
}
input, button { font-size: 16px; font-family: inherit; }

/* 顶栏 */
.topbar {
  background: #1d4ed8; color: #fff; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-back {
  width: 34px; height: 34px; border: none; border-radius: 8px; background: rgba(255,255,255,.18);
  color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.topbar-title { font-size: 19px; font-weight: 700; }
/* 仅 PDA 版：顶部设备号（小号灰字，窄屏单行省略） */
.device-line {
  padding: 3px 14px 0; font-size: 12px; line-height: 16px; color: #8a8f99;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.topbar-user-tag {
  display: inline-block;
  min-width: 80px;
  max-width: 160px;
  padding: 4px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f3f4f6;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

/* 视图容器（首页 / 库存查询 / 批量发料） */
.view { display: none; }
.view.active { display: block; }
#view-home { position: relative; }

.panel { display: none; padding: 12px; }
.panel.active { display: block; }

/* 首页：设备码卡片 */
.device-card {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6); color: #fff;
  border-radius: 12px; padding: 18px 16px; margin: 14px 12px 10px;
  box-shadow: 0 2px 8px rgba(29,78,216,.25);
}
.device-label { font-size: 13px; opacity: .85; margin-bottom: 6px; }
.device-code { font-size: 22px; font-weight: 700; letter-spacing: 1px; word-break: break-all; }
.device-code.device-nosn { font-size: 17px; font-weight: 600; opacity: .9; }

/* 首页：企业微信扫码登录卡片 */
.login-card {
  background: #fff; border-radius: 12px; padding: 12px 16px; margin: 0 12px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.login-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.login-label { font-size: 13px; color: #6b7280; }
.login-user { font-size: 15px; font-weight: 600; color: #111827; }
.login-card .btn-primary, .login-card .btn-ghost { width: 100%; margin-top: 4px; }

/* 首页：设备绑定二维码（未绑定操作员时展示，轮询绑定结果） */
.bind-qr {
  background: #fff; border-radius: 12px; padding: 14px 16px 16px; margin: 0 12px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08); text-align: center;
}
.bind-qr-title { font-size: 14px; font-weight: 700; color: #b45309; margin-bottom: 10px; }
.bind-qr-img {
  display: block; width: 180px; height: 180px; margin: 0 auto;
  border: 1px solid #e5e6eb; border-radius: 8px; background: #fafafa;
}
.bind-qr-tip { font-size: 14px; color: #1f2329; margin-top: 10px; }
.bind-qr-sub { font-size: 12px; color: #86909c; margin-top: 4px; }

/* 首页：功能菜单 */
.menu { padding: 6px 12px 16px; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  background: #fff; border: none; border-radius: 12px; padding: 16px 14px; margin-top: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); cursor: pointer; font-family: inherit;
}
.menu-item:active { background: #f0f4ff; }
.menu-icon {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
}
.icon-stock { background: linear-gradient(135deg, #00b42a, #23c343); }
.icon-issue { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.icon-tb { background: linear-gradient(135deg, #b45309, #f59e0b); }
.menu-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.menu-text b { font-size: 17px; color: #1f2329; }
.menu-text small { font-size: 13px; color: #86909c; }
.menu-arrow { font-size: 22px; color: #c9cdd4; }

/* 批量发料页签（嵌入视图内） */
.tabbar { display: flex; background: #fff; border-bottom: 1px solid #e5e6eb; position: sticky; top: 54px; z-index: 19; }
.tab {
  flex: 1; padding: 12px 0; border: none; background: none; color: #4e5969;
  font-size: 16px; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent;
}
.tab.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }

/* 视图内间距 */
#view-stock { padding: 12px; }

/* 扫码框 */
.scan-box { background: #fff; border-radius: 10px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.scan-box label { display: block; font-size: 13px; color: #86909c; margin-bottom: 8px; }
.scan-box input {
  width: 100%; padding: 12px; border: 1.5px solid #c9cdd4; border-radius: 8px;
  letter-spacing: 1px; margin-bottom: 10px;
}
.scan-box input:focus { outline: none; border-color: #1d4ed8; }
.scan-actions { display: flex; gap: 8px; align-items: stretch; }
.scan-actions .btn-primary { flex: 1; }
.scan-actions .btn-ghost { flex: 0 0 auto; padding: 12px 18px; font-size: 15px; }

/* 按钮 */
.btn-primary {
  width: 100%; padding: 12px; background: #1d4ed8; color: #fff; border: none;
  border-radius: 8px; font-size: 17px; font-weight: 600; cursor: pointer;
}
.btn-primary:disabled { background: #b8c4f0; }
.btn-ghost {
  padding: 10px 22px; background: #fff; color: #4e5969; border: 1.5px solid #c9cdd4;
  border-radius: 8px; font-size: 16px; cursor: pointer;
}
.btn-small {
  padding: 8px 16px; border-radius: 7px; border: none; font-size: 15px; font-weight: 600;
  background: #1d4ed8; color: #fff; cursor: pointer; min-width: 76px;
}
.btn-small:disabled { background: #d3d9e8; color: #8a93a5; }

/* 抬头卡片 */
.header-card {
  background: #fff; border-radius: 10px; padding: 12px 14px; margin-top: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.header-card .h-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.header-card .h-key { color: #86909c; }
.header-card .h-val { font-weight: 600; word-break: break-all; text-align: right; max-width: 62%; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-0 { background: #e8f3ff; color: #165dff; }
.badge-1 { background: #fff7e8; color: #ff7d00; }
.badge-2 { background: #e8ffea; color: #00b42a; }

/* 物料卡片 */
.mx-card {
  background: #fff; border-radius: 10px; padding: 12px 14px; margin-top: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.mx-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mx-btns { display: flex; gap: 8px; }
.btn-print { background: #e8f3ff; color: #165dff; }
.mx-matnr { font-size: 15px; font-weight: 700; color: #1d4ed8; white-space: nowrap; }
.mx-maktx { font-size: 14px; margin: 4px 0 8px; color: #4e5969; line-height: 1.45; }
.mx-meta { display: flex; gap: 14px; font-size: 13px; color: #4e5969; margin-bottom: 8px; }
.mx-meta b { color: #1f2329; }
.progress { height: 8px; background: #e5e6eb; border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.progress > i { display: block; height: 100%; background: #00b42a; border-radius: 4px; }
.mx-foot { display: flex; justify-content: space-between; align-items: center; }

/* 筛选条 */
.filter-bar { display: flex; gap: 8px; background: #fff; border-radius: 10px; padding: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.filter-bar input, .filter-bar select { flex: 1; padding: 9px; border: 1.5px solid #c9cdd4; border-radius: 8px; background: #fff; color: #1d2129; }
.filter-bar .btn-primary { width: auto; padding: 9px 20px; font-size: 15px; }

/* 记录列表 */
.rec-item {
  background: #fff; border-radius: 10px; padding: 12px 14px; margin-top: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); cursor: pointer;
}
.rec-item .r1 { display: flex; justify-content: space-between; margin-bottom: 6px; }
.rec-guid { font-size: 13px; color: #4e5969; word-break: break-all; }
/* 记录行副信息（订单/完成数/操作员）：按窗体宽度自动折行 */
.rec-sub {
  font-size: 13px; color: #4e5969; margin-top: 6px;
  display: flex; flex-wrap: wrap; gap: 2px 10px;
  white-space: normal; word-break: break-all; overflow-wrap: anywhere;
}

/* 记录查询：子表（物料汇总）/ 孙表（发料明细）内联展开 */
.rec-wrap { margin-top: 10px; }
.rec-wrap .rec-item { margin-top: 0; }
.rec-detail {
  background: #f7f8fa; border: 1px solid #e5e6eb; border-top: none;
  border-radius: 0 0 10px 10px; padding: 10px; margin: -6px 2px 0;
}
.rec-detail-head { font-weight: 700; font-size: 13px; color: #4e5969; margin-bottom: 6px; }
.mx-row { cursor: pointer; }
.mx-row:hover td { background: #f2f3f5; }
.gc-cell { background: #fff; }
.gc-table { font-size: 12px; }

/* 弹窗 */
.modal-mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 520px; border-radius: 14px 14px 0 0;
  padding: 16px; max-height: 82vh; overflow-y: auto; display: flex; flex-direction: column;
}
.modal-wide { border-radius: 14px; max-height: 88vh; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.modal-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.modal-foot button + button { margin-left: 10px; }

/* 库位选项 */
.sec-title { font-size: 13px; color: #4e5969; font-weight: 600; margin: 10px 0 6px; }
.sec-title.collapseable { user-select: none; }
.cc-arrow { display: inline-block; margin-right: 4px; font-size: 12px; }

/* 可发明细条目列表 */
.line-list {
  border: 1px solid #e5e6eb; border-radius: 8px; max-height: 30vh; overflow-y: auto; margin-bottom: 6px;
}
.line-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid #f2f3f5; font-size: 13px;
}
.line-item:last-child { border-bottom: none; }
.line-l { display: flex; flex-direction: column; gap: 2px; color: #4e5969; }
.line-r { white-space: nowrap; }
.can { color: #1d4ed8; }

.stock-list { max-height: 35vh; overflow-y: auto; }
.stock-item {
  display: flex; gap: 10px; padding: 11px; border: 1.5px solid #e5e6eb; border-radius: 9px;
  margin-bottom: 8px; align-items: center; cursor: pointer;
}
.stock-item:has(input:checked) { border-color: #1d4ed8; background: #f0f4ff; }
.stock-item.checked { border-color: #1d4ed8; background: #f0f4ff; }
.stock-item.disabled { opacity: .5; }
/* 行内发货数输入框（库位/批次右侧） */
.stock-item .row-qty {
  width: 86px; flex-shrink: 0; margin-left: auto; padding: 7px 6px;
  border: 1.5px solid #c9cdd4; border-radius: 7px; font-size: 15px; text-align: center;
}
.stock-item .row-qty:focus { outline: none; border-color: #1d4ed8; }
.stock-item .row-qty:disabled { background: #f2f3f5; color: #a0aab4; }
.stock-noissue { margin-left: auto; font-size: 12px; color: #a0aab4; font-weight: 400; }
/* SAP 过账按钮（批量发料页，暂存记录统一提交） */
.btn-sap { display: block; width: 100%; margin: 0 0 10px; }
/* SAP 过账预览（ITAB 接口数据表） */
.itab-wrap { max-height: 55vh; overflow: auto; }
.itab { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.itab th, .itab td { border: 1px solid #e5e6eb; padding: 5px 7px; text-align: left; }
.itab thead th { position: sticky; top: 0; background: #f2f3f5; }
.itab-maktx td { color: #86909c; font-size: 11px; border-top: none; }
.stock-main { flex: 1; }
.stock-line { display: flex; justify-content: space-between; font-size: 15px; font-weight: 600; }
.stock-sub { font-size: 13px; color: #86909c; margin-top: 3px; line-height: 1.4; }
.stock-avail { color: #00b42a; font-weight: 600; }

/* 库存查询结果卡片 */
.stock-card {
  background: #fff; border-radius: 10px; padding: 12px 14px; margin-top: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.stock-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sc-slot { font-size: 16px; font-weight: 700; color: #1d4ed8; }
.sc-avail { font-size: 16px; font-weight: 700; color: #00b42a; }
.sc-zero { color: #d54941; }
.stock-card-sub { font-size: 13px; color: #86909c; line-height: 1.5; }

.qty-quick { display: flex; margin: 8px 0 6px; }
.qty-quick button + button { margin-left: 8px; }
.qty-quick .btn-ghost { flex: 1; padding: 8px; font-size: 14px; }

.qty-row { display: flex; align-items: center; margin-top: 4px; }
.qty-row label { margin-right: 10px; }
.qty-row label { font-size: 14px; color: #4e5969; white-space: nowrap; }
.qty-row input {
  flex: 1; padding: 10px; border: 1.5px solid #c9cdd4; border-radius: 8px; font-size: 17px; text-align: center;
}
.qty-row input:focus { outline: none; border-color: #1d4ed8; }

.empty { text-align: center; color: #86909c; padding: 40px 0; font-size: 14px; }

/* 版本切换（PC版 / PDA版 / 手机企微版） */
.ver-switch { position: relative; display: flex; gap: 8px; padding: 4px 12px 18px; align-items: center; }
.ver-switch .ver-no { position: absolute; right: 12px; bottom: 4px; font-size: 12px; color: #a0aab4; user-select: none; }
.ver-switch a {
  flex: 1; text-align: center; padding: 8px 0; border-radius: 8px; font-size: 14px;
  border: 1.5px solid #c9cdd4; color: #4e5969; background: #fff; text-decoration: none;
}
.ver-switch a.on { border-color: #1d4ed8; color: #1d4ed8; background: #f0f4ff; font-weight: 600; }

/* ========== PC 版（app-pc）：居中布局 ========== */
.app-pc main { max-width: 980px; margin: 0 auto; }
.app-pc .menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.app-pc .menu-item { margin-top: 0; }
.app-pc #view-issue .panel { padding: 14px 12px 16px; }
.app-pc .mx-top { align-items: center; }

/* PC 版库存表格 */
.pc-table-wrap { background: #fff; border-radius: 10px; margin-top: 12px; overflow-x: auto; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.pc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pc-table th, .pc-table td { border: 1px solid #e5e6eb; padding: 8px 10px; text-align: left; white-space: nowrap; }
.pc-table th { background: #f7f8fa; color: #4e5969; position: sticky; top: 0; }
.pc-table tr:nth-child(even) td { background: #fafbfc; }
.pc-ok { color: #00b42a; }
.pc-zero { color: #d54941; }

/* 明细表 */
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table th, .detail-table td { border: 1px solid #e5e6eb; padding: 6px; text-align: left; }
.detail-table th { background: #f7f8fa; white-space: nowrap; }

/* 加载与提示 */
.loading {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.25); z-index: 80;
  display: flex; align-items: center; justify-content: center;
}
.loading-text {
  background: #fff; padding: 14px 28px; border-radius: 10px; font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 99; display: none; max-width: 84vw; text-align: center;
}
#toast.error { background: #d54941; }
#toast.show { display: block; animation: fade 2.4s forwards; }
@keyframes fade { 0% {opacity: 0;} 8% {opacity: 1;} 85% {opacity: 1;} 100% {opacity: 0;} }
.hidden { display: none !important; }
