/* =============================================================
   库存管理模块 · 内测版样式
   基础样式全部沿用主系统 styles.css，这里只补库存模块与内测标记
   ============================================================= */

/* ---------- 内测版标识 ---------- */
.beta-tag {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 99px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.7;
}
.beta-sub {
  font-size: 10px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .55);
  margin-top: 4px;
  font-weight: 400;
}
.mobile-topbar .beta-tag { background: #f59e0b; }


/* ---------- 登录页内测横幅 ---------- */
.login-beta-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 3px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 18px;
  font-size: 12px;
  line-height: 1.55;
  color: #92400e;
  text-align: left;
}
.login-beta-banner .lbb-title {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.login-beta-banner .lbb-title b { color: #78350f; font-size: 12px; }
.login-beta-banner .lbb-title span { color: #a16207; }
.login-beta-banner .lbb-desc { color: #a16207; font-size: 11.5px; line-height: 1.6; }
.login-card h1 { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px; }

/* ---------- 侧边栏分组 ---------- */
.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, .1);
  margin: 10px 12px 6px;
}
.nav-section-title {
  padding: 6px 14px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: rgba(255, 255, 255, .45);
}
#nav-inv-tech .nav-section-title { padding-top: 12px; }
#nav-inv-tech { border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 8px; }

/* ---------- 页面内通用 ---------- */
/* 工单记录页的类型页签（维修工单 / 发货工单 / 其他） */
.rec-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.rec-tab {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.rec-tab:hover { border-color: var(--primary); color: var(--primary); }
.rec-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}
.rec-tab.active:hover { color: #fff; }

/* 工单记录操作列：按钮文字不要被挤成竖排；状态徽章也别被压成两行 */
#records-body .btn { white-space: nowrap; }
#records-body .badge { white-space: nowrap; }

.inv-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px;
}
.inv-toolbar .spacer { flex: 1; }
.inv-toolbar select, .inv-toolbar input { width: auto; min-width: 140px; }
.inv-search { min-width: 240px !important; }

.inv-hint { font-size: 12px; color: var(--text-light); margin-top: 6px; line-height: 1.6; }
.inv-hint b { color: var(--text-secondary); }

.inv-note {
  font-size: 12px; color: var(--text-secondary); background: #f8fafc;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: 12px; line-height: 1.7;
}
.inv-note b { color: var(--text); }

/* 等宽字体（SKU / SN / 库位） */
.sn-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; font-size: 12px; letter-spacing: .2px; }
.sku-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-secondary); }

/* 库位标签 */
.loc-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: #eef6ff; color: var(--primary-dark);
  font-size: 12px; font-weight: 600;
  font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap;
}
.loc-tag.empty { background: #f1f5f9; color: var(--text-light); font-weight: 400; }

/* 类别徽章 */
.tag-cat {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tag-new-machine    { background: #dbeafe; color: #1d4ed8; }
.tag-new-part       { background: #f1f5f9; color: #475569; }
.tag-refurb-machine { background: #ffedd5; color: #c2410c; }
.tag-refurb-part    { background: #fef3c7; color: #b45309; }

.low-num { color: var(--danger); font-weight: 700; }

/* 统计卡 */
.stat-sub { font-size: 12px; color: var(--text-light); margin-top: 6px; line-height: 1.5; }
.stat-card.accent-blue   { border-top: 3px solid var(--primary); }
.stat-card.accent-orange { border-top: 3px solid var(--warning); }
.stat-card.accent-green  { border-top: 3px solid var(--success); }
.stat-card.accent-purple { border-top: 3px solid #8b5cf6; }

/* 预警行 */
.alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm); margin-bottom: 10px; background: #fffdf8;
}
.alert-row .ar-name { font-weight: 600; }
.alert-row .ar-meta { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.alert-row .ar-stock { color: var(--danger); font-weight: 700; font-size: 15px; white-space: nowrap; }
.inv-case-row { border-left-color: var(--primary); background: #f8fbff; }

/* 行内按钮 */
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.row-actions .btn { padding: 5px 10px; font-size: 12px; }

/* SN 勾选 */
.sn-pick-box {
  max-height: 200px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; background: #fcfdfe;
}
.sn-pick-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  font-size: 13px; cursor: pointer; border-bottom: 1px dashed #eef2f7;
}
.sn-pick-item:last-child { border-bottom: none; }
.sn-pick-item input { width: auto; margin: 0; }
.sn-pick-item .sp-loc { margin-left: auto; font-size: 11px; color: var(--text-light); }

/* 表单小节 */
.form-sub-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin: 18px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}

/* 库存页里的备注框别占太高（主系统 textarea 默认很高，出入库页显得很空） */
#view-inv-stockin textarea,
#view-inv-stockout textarea,
#view-inv-items textarea {
  min-height: 68px;
  height: 68px;
  resize: vertical;
}

/* 库存三列表单（库位）在窄屏自动堆叠 */
#view-inv-stockin .form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 700px) {
  #view-inv-stockin .form-grid-3 { grid-template-columns: 1fr; }
}

/* 费用预览条 */
.fee-bar {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: #eff6ff; border: 1px solid #bfdbfe;
  font-size: 13px; color: #1e40af; line-height: 1.7;
}
.fee-bar b { color: #1e3a8a; }

/* 关联工单 chip */
.case-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: #f0f9ff; border: 1px solid #bae6fd; font-size: 13px;
}

/* 空态 */
.inv-empty { text-align: center; padding: 44px 16px; color: var(--text-light); }
.inv-empty .ie-icon { font-size: 40px; margin-bottom: 10px; }

/* =============================================================
   库存模块自带弹窗（不复用主系统的确认弹窗，避免互相干扰）
   ============================================================= */
.inv-modal-overlay {
  position: fixed; inset: 0; z-index: 2147483400;
  background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center;
  padding: 24px; backdrop-filter: blur(2px);
}
.inv-modal-overlay.show { display: flex; }
.inv-modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-width: 780px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .28);
  animation: invModalIn .16s ease-out;
}
@keyframes invModalIn {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to   { opacity: 1; transform: none; }
}
.inv-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.inv-modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }
.inv-modal-x {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--text-light); padding: 4px 8px; border-radius: 6px; line-height: 1;
}
.inv-modal-x:hover { background: #f1f5f9; color: var(--text); }
.inv-modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.inv-modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}

/* =============================================================
   发货工单：模糊搜索下拉 + 已选标签
   ============================================================= */
.dm-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.dm-line .pick { position: relative; flex: 1 1 240px; min-width: 190px; }
.pick-input { width: 100%; }
.pick-drop {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .14);
  max-height: 230px; overflow-y: auto; display: none;
}
.pick-drop.show { display: block; }
.pick-opt { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.pick-opt:last-child { border-bottom: 0; }
.pick-opt:hover { background: #eff6ff; }
.po-main { font-size: 13px; font-weight: 600; color: var(--text); }
.po-meta { font-size: 11.5px; color: var(--text-light); margin-top: 2px; }
.pick-none { padding: 10px; font-size: 12px; color: var(--text-light); }
.dm-chip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  flex: 1 1 auto; padding: 6px 10px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
}
.dm-chip-name { font-size: 13px; font-weight: 600; }
.dm-chip-qty { font-size: 12px; color: var(--text-light); }
.dm-qty { width: 92px; }
.dm-over { font-size: 12px; color: #b91c1c; font-weight: 600; }
.dm-more { font-size: 11.5px; color: var(--text-light); }
.dm-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ---------- 运单附件上传（必填） ---------- */
.dm-wf-group { margin-top: 14px; }
.dm-wf-label-note { font-weight: 400; font-size: 12px; color: var(--text-light); margin-left: 8px; }
/* 真 input 藏起来但保留可点（display:none 在个别浏览器里点不弹窗） */
.dm-wf-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  opacity: 0; overflow: hidden; border: 0;
}
.dm-wf {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px dashed #cbd5e1; border-radius: 10px;
  background: #fbfdff; cursor: pointer; transition: border-color .15s, background .15s;
}
.dm-wf:hover { border-color: var(--primary); background: #f0f7ff; }
.dm-wf-on { border-style: solid; border-color: #bfdbfe; background: #eff6ff; cursor: default; }
.dm-wf-on:hover { border-color: #bfdbfe; background: #eff6ff; }
.dm-wf-icon { font-size: 18px; line-height: 1; }
.dm-wf-txt { flex: 1 1 220px; min-width: 0; }
.dm-wf-main { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-all; }
.dm-wf-sub { font-size: 11.5px; color: var(--text-light); margin-top: 2px; }
.dm-wf-pick {
  font-size: 12px; font-weight: 600; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 8px; padding: 4px 12px; white-space: nowrap;
}
.dm-att-ico { font-size: 12px; }
.dm-att-miss { font-size: 12px; opacity: .28; }

/* ---------- 没选品牌时锁住明细区 ---------- */
.dm-lock {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px; border: 1px dashed #cbd5e1; border-radius: 10px;
  background: #f8fafc; color: var(--text-light);
}
.dm-lock-icon { font-size: 18px; line-height: 1.2; opacity: .7; }
.dm-lock-main { font-size: 13px; font-weight: 600; color: var(--text); }
.dm-lock-sub { font-size: 12px; color: var(--text-light); margin-top: 3px; }

/* 列表里的 SN / SKU 相邻时留点缝，不然会粘成一串 */
#view-inv-demands td .sn-code, #view-inv-demands td .sku-code { margin-right: 6px; }
.badge-urgent { background: #fee2e2; color: #b91c1c; }
/* 立即处理：比加急更醒目（实心红） */
.badge-asap { background: #dc2626; color: #fff; }
.tag-type {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tag-type.tag-machine { background: #e0f2fe; color: #0369a1; }
.tag-type.tag-part { background: #f1f5f9; color: #475569; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .inv-toolbar select, .inv-toolbar input { min-width: 0; flex: 1 1 140px; }
  .inv-search { min-width: 0 !important; flex: 1 1 100%; }
  .alert-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .inv-modal-overlay { padding: 10px; }
  .inv-modal-box { max-height: 94vh; }
  .inv-modal-body { padding: 14px; }
  .inv-modal-foot { padding: 12px 14px; }
  .inv-modal-foot .btn { flex: 1; }
}

/* 手机上表格转卡片后，「在库」这类多内容单元格允许折行，避免挤成一团 */
@media (max-width: 768px) {
  #view-inv-inventory td,
  #view-inv-items td,
  #view-inv-stockin td,
  #view-inv-stockout td,
  #view-inv-fees td { flex-wrap: wrap; }
  #view-inv-inventory td .inv-hint,
  #view-inv-items td .inv-hint {
    flex: 1 0 100%;
    text-align: right;
    margin-top: 2px;
  }
  /* 手机上一行 SN 明细的缩进去掉，避免左边空白 */
  #view-inv-inventory td[style*="padding-left"] { padding-left: 2px !important; }
  /* 明细行不重复显示字段名（SN / 批次 本身就是内容） */
  #view-inv-inventory tr td::before { font-size: 10px; }
}

/* ---------- 打印（费用账单） ---------- */
@media print {
  .sidebar, .mobile-topbar, .inv-toolbar, .btn-group, .inv-modal-overlay { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd; }
}
