/* 仓库库位管理系统 - 移动端优先 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --primary: #2563eb;
  --danger: #ef4444;
  --free: #22c55e;
  --occupied: #ef4444;
  --disabled: #94a3b8;
  --text: #1e293b;
  --sub: #64748b;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 24px;
}

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  /* 刘海屏/全面屏：内容避让状态栏（viewport-fit=cover 时生效，非刘海屏为 0） */
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #fff;
}

/* H5 防页面误缩放：
   1) iOS Safari 聚焦字号 <16px 的输入框会自动放大整页（放大后页面就不满屏了）——
      手机端统一输入类元素字号 ≥16px
   2) 配合 viewport 的 user-scalable=no，双击/双指不再缩放整页（图纸缩放是内部实现，不受影响） */
@media (max-width: 640px) {
  input:not([type="range"]):not([type="color"]):not([type="checkbox"]):not([type="radio"]),
  select, textarea, .search-box input { font-size: 16px !important; }
}
.topbar h1 { flex: 1; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.15); color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 10px; font-size: 18px;
  cursor: pointer; flex-shrink: 0;
}

main { padding: 16px; max-width: 720px; margin: 0 auto; }

/* 页脚：技术支持与备案信息 */
.site-footer {
  text-align: center;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
  color: var(--sub);
  font-size: 12px;
  line-height: 1.9;
  border-top: 1px solid #e2e8f0;
  margin-top: 8px;
}
.site-footer a { color: var(--sub); text-decoration: none; }

/* 登录页 */
.login-wrap {
  position: fixed; inset: 0; z-index: 900;
  background: linear-gradient(135deg, #1e293b, #334155);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 340px;
  background: var(--card); border-radius: 16px; padding: 22px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.login-box h2 { font-size: 19px; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--sub); margin-bottom: 14px; }
.login-box .field { margin-bottom: 12px; }
.login-box .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.login-err { min-height: 20px; color: var(--danger); font-size: 13px; margin-top: 8px; }
.login-tip { font-size: 12px; color: var(--sub); line-height: 1.7; margin-top: 10px; }

/* 仓库切换与管理 */
.wh-chips {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px;
}
.wh-chip {
  border: 1px solid #e2e8f0; border-radius: 999px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; background: var(--card);
  color: var(--text); cursor: pointer; white-space: nowrap;
}
.wh-chip:active { transform: scale(.96); }
.wh-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.wh-chip.manage { color: var(--primary); border-style: dashed; }
.wh-title {
  font-size: 13px; font-weight: 700; color: var(--sub);
  margin: 16px 0 8px;
}
.floor-row select.fr-wh {
  flex: 0 1 auto; min-width: 0; max-width: 96px;
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px 4px;
  font-size: 12px; background: #fff; color: var(--text);
}
/* 楼层卡片 */
.floor-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: transform .1s;
}
.floor-card:active { transform: scale(.98); }
.floor-card .fc-head { display: flex; justify-content: space-between; align-items: center; }
.floor-card .fc-name { font-size: 17px; font-weight: 600; }
.floor-card .fc-arrow { color: var(--sub); }
.floor-card .fc-stats { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--sub); }
.fc-stats b { font-size: 15px; }
.fc-stats .ok b { color: var(--free); }
.fc-stats .no b { color: var(--occupied); }

/* 楼层预览小格子 */
.fc-preview { display: flex; gap: 2px; margin-top: 10px; flex-wrap: wrap; }
.fc-preview span { width: 10px; height: 10px; border-radius: 2px; }

/* 统计条 */
.stats-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.stat {
  flex: 1; background: var(--card); border-radius: var(--radius);
  padding: 10px 6px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--sub); }
.stat.free b { color: var(--free); }
.stat.occ b { color: var(--occupied); }
.stat.rate b { color: var(--primary); font-size: 16px; }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .btn { flex-shrink: 0; }
.search-box { flex: 1 1 140px; position: relative; min-width: 120px; }
.search-box input {
  width: 100%; padding: 10px 12px 10px 34px;
  border: 1px solid #e2e8f0; border-radius: 10px; font-size: 14px; background: var(--card);
}
.search-box::before { content: '🔍'; position: absolute; left: 10px; top: 9px; font-size: 14px; }

/* 按钮样式 */
.btn {
  display: inline-block; padding: 10px 16px;
  border: none; border-radius: 10px; font-size: 14px;
  background: var(--primary); color: #fff; cursor: pointer;
}
.btn:disabled { opacity: .5; }
.btn.outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.gray { background: #e2e8f0; color: var(--text); }
.btn.red { background: var(--danger); }
.btn.green { background: var(--free); }
.btn.wide { width: 100%; }

/* 库位网格 */
.floor-wrap { position: relative; }
.plan-img {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  opacity: var(--plan-op, .25);
  pointer-events: none; z-index: 0;
  filter: grayscale(.4);
}
.loc-grid {
  position: relative; z-index: 1;
  display: grid; gap: 6px;
}

/* 图纸预览 */
.plan-preview {
  background: #f8fafc; border-radius: 10px;
  padding: 8px; text-align: center; margin-bottom: 12px;
  max-height: 220px; overflow: hidden;
}
.plan-preview img { max-width: 100%; max-height: 200px; object-fit: contain; }
.loc {
  position: relative;
  aspect-ratio: 1/1;
  border: none; border-radius: 0;
  color: #fff; font-size: 11px; font-weight: 600;
  cursor: pointer; padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
  transition: transform .1s;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.loc:active { transform: scale(.92); }
.loc .code { font-size: 1em; letter-spacing: -.3px; }
.loc .cargo {
  font-size: .78em; font-weight: 400; opacity: .9;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 库位大小：手动尺寸时可横向滚动 */
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
/* 自定义尺寸：正方形，小尺寸收紧字距 */
.loc-grid.custom-size .loc { border-radius: 0; }
.loc-grid.custom-size .loc .code { letter-spacing: 0; }
.floor-tools { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.floor-tools .btn { flex: 1 1 calc(50% - 5px); padding: 10px 8px; }

/* 工具栏按钮 */
.toolbar .btn { flex-shrink: 0; white-space: nowrap; }
.search-count { font-size: 12px; color: var(--sub); white-space: nowrap; align-self: center; }
.search-count.hit {
  background: #fef3c7; color: #92400e; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid #fde68a;
}
.search-count.hit:active { background: #fde68a; }

/* 搜索匹配：库存闪烁高亮 + 其余库位淡出，增强识别度 */
.loc.matching {
  animation: locMatchPulse .9s ease-in-out infinite;
  z-index: 5;
}
@keyframes locMatchPulse {
  0%, 100% {
    outline: 3px solid rgba(250, 204, 21, .95);
    outline-offset: 1px;
    box-shadow: 0 0 0 0 rgba(250, 204, 21, .45), 0 2px 6px rgba(0, 0, 0, .28);
  }
  50% {
    outline: 3px solid rgba(253, 224, 71, 1);
    outline-offset: 4px;
    box-shadow: 0 0 14px 6px rgba(250, 204, 21, .85), 0 2px 6px rgba(0, 0, 0, .28);
  }
}
.plan-stage.searching .loc:not(.matching) { opacity: .25; }
.plan-stage.searching .loc.matching { opacity: 1; }
/* 定位到匹配库位时的一次性强调闪烁 */
.loc.match-flash {
  animation: locMatchFlash .9s ease-out 1;
}
@keyframes locMatchFlash {
  0% {
    outline: 4px solid #22d3ee;
    outline-offset: 7px;
    box-shadow: 0 0 22px 9px rgba(34, 211, 238, .9);
  }
  100% {
    outline: 3px solid rgba(250, 204, 21, .95);
    outline-offset: 1px;
    box-shadow: 0 0 0 0 rgba(250, 204, 21, .45), 0 2px 6px rgba(0, 0, 0, .28);
  }
}
/* 定位标记：放大 + 青色光环，保证几像素的小库位也能看清 */
.loc.abs.match-locate {
  transform: translate(-50%, -50%) scale(2.4);
  z-index: 9;
  outline: 3px solid #22d3ee;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .35), 0 0 20px 8px rgba(34, 211, 238, .85);
}
.loc.match-locate:not(.abs) {
  z-index: 9;
  outline: 3px solid #22d3ee;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .35), 0 0 20px 8px rgba(34, 211, 238, .85);
}
/* 搜索匹配导航条：紧跟在「匹配 N 个」按钮后面 */
.match-bar {
  display: flex; align-items: center; gap: 6px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 999px; padding: 3px 8px;
  flex-shrink: 0; align-self: center;
}
.match-bar .mini-btn { padding: 3px 8px; font-size: 13px; line-height: 1.2; border-radius: 999px; }
.match-info {
  font-size: 12px; color: #1d4ed8; font-weight: 600;
  white-space: nowrap; text-align: center;
}

/* 图纸原图查看 */
.fullimg-overlay {
  position: fixed; inset: 0; z-index: 600;
  background: #0b1220; display: flex; flex-direction: column;
}
.fullimg-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; color: #fff; font-size: 14px;
  background: rgba(255,255,255,.08);
}
.fullimg-bar .fi-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fullimg-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.fullimg-scroll.fit { overflow: hidden; }
.fi-stage { position: relative; display: inline-block; line-height: 0; transform-origin: 0 0; }
.fullimg { display: block; max-width: none; width: auto; height: auto; }
.fi-locs { position: absolute; inset: 0; }
.fi-loc {
  position: absolute; transform: translate(-50%, -50%);
  box-sizing: border-box; border: 1px solid rgba(255,255,255,.9);
}
.fi-loc.free { background: rgba(34,197,94,.8); }
.fi-loc.occupied { background: rgba(239,68,68,.8); }
.fi-loc.disabled { background: rgba(148,163,184,.8); }
.fi-loc { pointer-events: auto; cursor: pointer; }
/* 原图查看时，面板/提示浮在原图之上 */
body.plan-full-open .sheet-mask,
body.plan-full-open .modal-mask { z-index: 700; }
body.plan-full-open .sheet,
body.plan-full-open .modal { z-index: 701; }
body.plan-full-open .toast { z-index: 800; }
.size-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.size-presets .mini-btn { flex: 1; text-align: center; padding: 8px 6px; }

/* 弹窗内模式切换（统一入库 / 随机分配） */
.seg { display: flex; gap: 8px; margin: 12px 0; }
.seg-btn {
  flex: 1; padding: 9px 10px; font-size: 14px; font-family: inherit;
  border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
  color: var(--text); cursor: pointer;
}
.seg-btn.active { border-color: var(--primary); background: #eff6ff; color: var(--primary); font-weight: 600; }

/* 弹窗内清单（批量出库预览） */
.list-box {
  max-height: 210px; overflow: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px;
  font-size: 13px; line-height: 1.8; color: var(--text); background: #f8fafc;
  margin-bottom: 12px;
}

/* 一键对齐整理 */
.align-opts { display: flex; flex-direction: column; gap: 10px; }
.align-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  width: 100%; padding: 12px 14px; text-align: left;
  border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
  cursor: pointer; font-family: inherit;
}
.align-opt b { font-size: 15px; }
.align-opt span { font-size: 12px; color: var(--sub); }
.align-opt:active { border-color: var(--primary); background: #f8fafc; }
.align-opt.active { border-color: var(--primary); background: #eff6ff; }
.align-opt.active b { color: var(--primary); }

/* 对齐弹窗内的「返回原状态」 */
.align-undo { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.align-undo .btn { width: 100%; padding: 11px; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.loc.free { background: var(--free); }
.loc.occupied { background: var(--occupied); }
.loc.disabled { background: var(--disabled); }
.loc.matching { outline: 3px solid #facc15; outline-offset: 1px; z-index: 1; }
.loc.selected { outline: 3px solid #2563eb; outline-offset: 1px; z-index: 1; filter: brightness(.85); }
.loc .check {
  position: absolute; top: 2px; right: 3px;
  width: 14px; height: 14px; line-height: 14px;
  background: #fff; color: var(--primary);
  border-radius: 50%; font-size: 10px; font-weight: 700;
}

/* 拖动调整位置 */
.loc.dragging { opacity: .3; }
.loc.drop-hover { outline: 3px dashed var(--primary); outline-offset: 1px; z-index: 2; }
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 500;
  pointer-events: none; opacity: .92;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
  margin: 0;
}
/* 自由布局：库位绝对定位在图纸上，支持双指缩放 */
.plan-viewport {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y;            /* 未放大：单指走浏览器原生滚动（平滑不闪）；双指缩放由 touch 事件接管 */
}
.plan-viewport.zoomed { touch-action: none; }   /* 放大后：单指平移由脚本接管 */
/* 放大后库位/区域不允许浏览器接管手势（manipulation 会让按在库位上的拖动被 pointercancel 掐断） */
.plan-viewport.zoomed .loc,
.plan-viewport.zoomed .zone { touch-action: none; }
.plan-stage { transform-origin: 0 0; }
/* 仅放大后（频繁 transform/平移）才提升合成层；未放大常驻合成层会导致页面滚动时闪烁 */
.plan-viewport.zoomed .plan-stage { will-change: transform; }

/* 未上传图纸时的空白画布 */
.plan-viewport.no-plan { background: #f8fafc; }
.plan-viewport.no-plan .plan-stage {
  width: 100%; aspect-ratio: 4 / 3;
  background-image:
    linear-gradient(rgba(148,163,184,.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.25) 1px, transparent 1px);
  background-size: 32px 32px;
}
.plan-bg { display: block; width: 100%; height: auto; pointer-events: none; }

/* 区域划分：报废区等背景色块（画在库位下方，不拦截点击） */
.zone {
  position: absolute;
  /* 不设 z-index：区域背景色块按 DOM 顺序画在库位下层；标题通过自身 z-index 浮在库位上 */
  border: 2px dashed #ef4444;
  border-radius: 10px;
  pointer-events: none;
  /* 标题超出区域框也要完整显示（区域框小/标题拖到边缘时不被裁剪） */
  overflow: visible;
}
.zone-tag {
  position: absolute; left: 2%; top: 2%;
  z-index: 5;             /* 标题浮在库位之上（居中在区域中间时不会被密集库位遮挡） */
  font-size: 12px; font-weight: 600; line-height: 1.4;
  background: rgba(255, 255, 255, .82);
  padding: 2px 7px; border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;   /* 默认不拦截库位/图纸交互 */
}
.zone-tag.zone-tag-move {
  pointer-events: auto;   /* 管理员可按住拖动调位置 */
  cursor: move;
  user-select: none;
  touch-action: none;
}
.zone-tag.zone-tag-move:active { opacity: .85; }
/* 竖排标题：中文直立从上到下 */
.zone-tag.vertical {
  writing-mode: vertical-rl;
  text-orientation: upright;
  line-height: 1.2;
  padding: 7px 2px;
}
.zone-font-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }
.zone-font-input { width: 58px; padding: 4px 6px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; }
.zone-font-input:focus { outline: none; border-color: var(--primary); }
.zone.draft {
  border-style: solid;
  border-color: #2563eb;
  background: rgba(37, 99, 235, .16);
}
/* 区域绘制提示条 */
.zone-tip {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
  border-radius: 10px; padding: 9px 12px; margin-bottom: 10px;
  font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
/* 区域名称 / 颜色编辑 */
.zone-name-input {
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px 8px;
  font-size: 14px; font-weight: 600; color: var(--text); width: 100%; max-width: 220px;
  background: #f8fafc;
}
.zone-name-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.zone-color-input { width: 44px; height: 30px; padding: 2px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }
/* 常用区域色块 */
.color-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-chip {
  border: 1px solid; border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; background: #fff;
}
.color-chip:active { transform: scale(.96); }
.loc.abs {
  position: absolute;
  transform: translate(-50%, -50%);
  margin: 0;
  touch-action: pan-y;            /* 跟随图纸区域：手机上按住库位滑动也可滚动页面 */
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,.28);
  font-size: 11px;
}
.loc.abs:active { transform: translate(-50%, -50%) scale(.96); }
.loc.abs.matching { z-index: 5; }

/* 小库位也容易按住：向外扩 3px 热区（不改变视觉大小） */
.loc.abs::before {
  content: '';
  position: absolute;
  inset: -3px;
}
/* 电脑端管理员允许拖动时，鼠标显示为“可拖动” */
body.can-drag .loc.abs { cursor: grab; }
body.can-drag .loc.abs:active { cursor: grabbing; }
.loc.abs.dragging { opacity: .85; }

/* 小尺寸格子：去掉内边距，保证严格正方形 */
.loc.tiny { padding: 0; min-width: 0; min-height: 0; }
.loc.tiny .check { display: none; }

/* 多选操作条 */
.select-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 150;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); box-shadow: 0 -2px 10px rgba(0,0,0,.1);
}
.select-bar .sel-count { flex: 0 0 auto; text-align: center; font-size: 13px; color: var(--sub); }
.select-bar .sel-hint { flex: 1 1 auto; text-align: left; font-size: 12px; color: var(--sub); }
.select-bar .mini-btn { padding: 10px 12px; font-size: 14px; flex: 1 1 28%; }

/* 框选矩形 */
.select-box {
  position: fixed; z-index: 400; pointer-events: none;
  border: 2px dashed var(--primary);
  background: rgba(37,99,235,.12);
  border-radius: 4px;
}

/* 多选模式下为底部固定操作条留出空间 */
body.in-select #view { padding-bottom: calc(var(--selbar-h, 150px) + 18px); }
.select-bar .mini-btn:disabled { opacity: .4; }

/* 顶部两行：第一行 图例 + 搜索框，第二行 按钮 */
.top-bar {
  position: sticky;          /* 滚动时工具栏与匹配导航始终可见 */
  top: 60px;
  z-index: 99;
  background: var(--bg);
  padding: 8px 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 14px;
}
.top-bar .legend { grid-column: 1; grid-row: 1; margin: 0; }
.top-bar .search-box { grid-column: 2; grid-row: 1; width: 100%; }
.top-bar .toolbar {
  grid-column: 1 / -1; grid-row: 2;
  margin-bottom: 0; justify-content: flex-start; align-items: center;
}
.top-bar .toolbar .btn { padding: 9px 12px; }

/* 图例（页面顶部，位于按钮左侧） */
.legend {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin: 0 0 12px; padding: 7px 10px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  font-size: 12px; color: var(--sub);
}
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* 底部抽屉 */
.sheet-mask, .modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
  background: var(--card); border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h3 { font-size: 16px; margin-bottom: 4px; }
.sheet .sub { font-size: 13px; color: var(--sub); margin-bottom: 14px; }

/* 弹窗 */
.modal {
  position: fixed; z-index: 201;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 420px); max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; padding: 20px;
  animation: pop .15s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.modal h3 { font-size: 16px; margin-bottom: 14px; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid #e2e8f0; border-radius: 10px; font-size: 14px;
  background: #f8fafc;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
.row2 { display: flex; gap: 10px; }
.row2 .field { flex: 1; }
.sheet .actions, .modal .actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.sheet .actions .btn, .modal .actions .btn { flex: 1 1 45%; padding: 12px; font-size: 15px; }

/* 库位信息展示 */
.loc-info { background: #f8fafc; border-radius: 10px; padding: 12px; margin-bottom: 14px; font-size: 14px; line-height: 1.9; }
.loc-info .li { display: flex; justify-content: space-between; }
.loc-info .li span:first-child { color: var(--sub); }

/* 日志 */
/* 日志弹窗：记录/统计 tab */
.logs-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.logs-tab {
  flex: 1; padding: 9px; border-radius: 8px; border: 1px solid #e2e8f0;
  background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--sub);
}
.logs-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 出入库统计 */
.stat-ranges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-range {
  padding: 5px 12px; border-radius: 999px; border: 1px solid #e2e8f0;
  background: #fff; font-size: 12px; cursor: pointer; color: var(--text);
}
.stat-range.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.stat-cards { display: flex; gap: 10px; margin-bottom: 12px; }
.stat-card {
  flex: 1; background: #f8fafc; border-radius: 10px;
  padding: 10px 8px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-card span { font-size: 12px; color: var(--sub); }
.stat-card b { font-size: 22px; line-height: 1.2; }
.stat-card b.ok { color: var(--occupied); }
.stat-card b.occ { color: var(--free); }
.stat-card i { font-style: normal; font-size: 11px; color: var(--sub); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th, .stat-table td { border-bottom: 1px solid #e2e8f0; padding: 7px 4px; text-align: left; }
.stat-table th { color: var(--sub); font-weight: 600; font-size: 12px; white-space: nowrap; }
.stat-table td.num { font-weight: 700; }
.stat-table td.num.ok { color: var(--occupied); }
.stat-table td.num.occ { color: var(--free); }
.stat-table .cnt { font-weight: 400; font-size: 11px; color: var(--sub); font-style: normal; }
.stat-sub { margin: 14px 0 6px; font-size: 13px; color: var(--sub); }
.stat-detail { max-height: 280px; overflow-y: auto; }

.log-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px;
}
.log-tag { padding: 2px 8px; border-radius: 6px; color: #fff; font-size: 12px; flex-shrink: 0; }
.log-tag.入库 { background: var(--occupied); }
.log-tag.入库时间 { background: #6366f1; }
.log-tag.出库 { background: var(--free); }
.log-tag.停用, .log-tag.启用 { background: var(--disabled); }
.log-main { flex: 1; }
.log-time { color: var(--sub); font-size: 12px; }
.empty { text-align: center; color: var(--sub); padding: 40px 0; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; z-index: 300; bottom: 90px; left: 50%;
  transform: translateX(-50%);
  background: rgba(30,41,59,.92); color: #fff;
  padding: 10px 18px; border-radius: 24px; font-size: 14px;
  animation: pop .2s ease; max-width: 80vw;
}

/* 楼层管理行 */
.floor-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}

/* 放置模式提示 */
.place-tip {
  display: flex; align-items: center; gap: 10px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px;
}
.place-tip .mini-btn { flex-shrink: 0; margin-left: auto; }
.undo-tip { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.move-sub { font-size: 13px; color: var(--sub); margin-top: 14px; }
.floor-row .fr-name { flex: 1; font-size: 15px; font-weight: 500; }
.floor-row .fr-count { color: var(--sub); font-size: 13px; }
.mini-btn {
  border: 1px solid #e2e8f0; background: #fff; border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer; color: var(--text);
}
.mini-btn.danger { color: var(--danger); border-color: #fecaca; }

/* 扫码弹窗 */
.scanner-mask {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(15, 23, 42, .68);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.scanner-box {
  width: min(520px, 100%); max-height: 92vh; overflow: auto;
  background: var(--card); border-radius: 16px; padding: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.scanner-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scanner-head h3 { margin: 0; font-size: 17px; }
.scanner-ctx {
  margin-top: 8px; padding: 8px 10px; border-radius: 10px;
  font-size: 12px; line-height: 1.6; word-break: break-all;
}
.scanner-ctx.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; }
.scanner-ctx.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #c2410c; }
.scanner-view {
  position: relative; margin: 12px 0;
  background: #0f172a; border-radius: 12px; overflow: hidden;
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
}
.scanner-view video { width: 100%; height: 100%; object-fit: cover; }
.scanner-view.no-cam video { display: none; }
.scanner-frame {
  position: absolute; inset: 20% 14%;
  border: 2px dashed rgba(255, 255, 255, .8); border-radius: 12px; pointer-events: none;
}
.scanner-tip {
  position: absolute; left: 0; right: 0; bottom: 8px;
  text-align: center; color: #e2e8f0; font-size: 12px; padding: 0 12px;
}
.scanner-actions { display: flex; gap: 10px; margin-bottom: 12px; }
.scanner-actions .btn { flex: 1 1 45%; padding: 12px; font-size: 15px; }
.scanner-manual label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
.scanner-manual textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px;
  font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; resize: vertical;
}
.scanner-manual textarea:focus { outline: none; border-color: var(--primary); }
.scanner-manual .btn { width: 100%; margin-top: 8px; padding: 10px; font-size: 14px; }
.hidden-file { display: none; }
/* 表单里的扫码按钮 */
.scan-row { display: flex; gap: 8px; align-items: center; }
.scan-row input { flex: 1 1 auto; min-width: 0; }
.scan-btn {
  flex: 0 0 auto; border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8;
  border-radius: 8px; padding: 8px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.scan-btn:active { background: #dbeafe; }

/* 先入先出提醒 */
.fifo-warn {
  background: #fff7ed; border: 1px solid #fed7aa; color: #c2410c;
  border-radius: 10px; padding: 9px 12px; margin: 10px 0; font-size: 13px; line-height: 1.7;
}
/* 总览页底部操作按钮 */
.ov-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.ov-actions .btn { width: 100%; }

/* 物料档案 */
.mat-list {
  max-height: 260px; overflow: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px;
  background: #f8fafc; margin-bottom: 12px;
}
.mat-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
}
.mat-row:last-child { margin-bottom: 0; }
.mat-row.editing { border-color: var(--primary); background: #eff6ff; }
.mr-main { min-width: 0; }
.mr-code { font-size: 14px; font-weight: 600; color: var(--text); word-break: break-all; }
.mr-name { font-size: 13px; color: var(--text); margin-top: 3px; }
.mr-extra { font-size: 12px; color: var(--sub); margin-top: 3px; }
.mr-ops { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.mat-form { border-top: 1px dashed #e2e8f0; padding-top: 12px; }

.hidden { display: none !important; }
