/* ============================================================================
   Origin WMS 移动端样式
   设计要点：
     - 移动优先，单手操作，主要按钮固定在拇指可达区域
     - 顶部栏 + 底部 4 个 Tab，中间内容区滚动
     - 卡片化信息层级，关键数字用大字号
     - 适配 iOS 安全区（刘海屏 / 底部横条）
   ========================================================================== */

:root {
  --pri: #2f6bff;
  --pri-dark: #1f4fd8;
  --pri-soft: #eaf0ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2333;
  --text-2: #5b6478;
  --muted: #98a1b3;
  --line: #e9edf4;
  --ok: #12b76a;
  --ok-soft: #e7f8ef;
  --warn: #f79009;
  --warn-soft: #fff5e6;
  --danger: #f04438;
  --danger-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(23, 38, 68, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: 14px; color: inherit; }
a { color: var(--pri); text-decoration: none; }

/* ---------------- 启动 / 空状态 ---------------- */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 14px; }
.boot-logo {
  width: 64px; height: 64px; border-radius: 18px; background: var(--pri); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; letter-spacing: 1px;
  box-shadow: 0 8px 22px rgba(47, 107, 255, .35);
}
.boot-text { color: var(--muted); font-size: 13px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-ico { font-size: 34px; margin-bottom: 8px; opacity: .55; }

/* ---------------- 布局骨架 ---------------- */
.app-shell { min-height: 100vh; padding-bottom: calc(62px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: none; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--text-2);
}
.view { padding: 14px 14px 22px; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.section-title a { font-size: 12px; }

/* ---------------- 卡片 ---------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card.tight { padding: 10px 12px; }
.card-row { display: flex; align-items: center; gap: 10px; }
.card-row + .card-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.card-title { font-weight: 600; font-size: 15px; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- 首页统计 ---------------- */
.hero {
  background: linear-gradient(135deg, #3d78ff 0%, #2f55d4 100%);
  border-radius: 18px; padding: 16px; color: #fff;
  box-shadow: 0 10px 24px rgba(47, 85, 212, .28);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; opacity: .9; }
.hero-main { display: flex; align-items: flex-end; gap: 18px; margin-top: 10px; }
.hero-num { font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.hero-label { font-size: 11px; opacity: .8; margin-top: 5px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat {
  background: #fff; border-radius: 12px; padding: 12px 10px; text-align: center; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 19px; }
.stat span { font-size: 11px; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick {
  background: #fff; border-radius: 14px; padding: 12px 6px; text-align: center;
  box-shadow: var(--shadow); border: none;
}
.quick .q-ico {
  width: 38px; height: 38px; margin: 0 auto 6px; border-radius: 12px;
  background: var(--pri-soft); color: var(--pri);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.quick span { font-size: 11.5px; color: var(--text-2); }
.quick:active { transform: scale(.97); }

/* ---------------- 列表 ---------------- */
.list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: flex; gap: 12px; padding: 12px 14px; align-items: center;
  border-bottom: 1px solid var(--line); background: #fff;
}
.item:last-child { border-bottom: none; }
.item:active { background: #f8faff; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-right { text-align: right; flex-shrink: 0; }
.item-right b { font-size: 15px; }
.item-right small { display: block; font-size: 11px; color: var(--muted); }
.thumb {
  width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--bg); flex-shrink: 0;
}
.thumb-ph {
  width: 46px; height: 46px; border-radius: 10px; background: var(--pri-soft); color: var(--pri);
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}

/* ---------------- 标签 ---------------- */
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px; line-height: 1.5;
  background: var(--pri-soft); color: var(--pri); margin-right: 6px;
}
.badge.gray { background: #f1f3f7; color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field .req::after { content: " *"; color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: #fbfcfe; border-radius: 10px;
  padding: 11px 12px; outline: none; transition: .15s;
}
.input:focus { border-color: var(--pri); background: #fff; box-shadow: 0 0 0 3px rgba(47, 107, 255, .1); }
textarea.input { min-height: 74px; resize: vertical; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.btn {
  border: none; border-radius: 11px; padding: 12px 16px; font-size: 15px; font-weight: 500;
  background: var(--pri); color: #fff; width: 100%; transition: .15s;
}
.btn:active { background: var(--pri-dark); transform: scale(.99); }
.btn[disabled] { opacity: .55; }
.btn.ghost { background: var(--pri-soft); color: var(--pri); }
.btn.gray { background: #eef1f6; color: var(--text-2); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 12px; font-size: 13px; width: auto; border-radius: 9px; }
.btn-row { display: flex; gap: 10px; }
.fixed-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(10px + var(--safe-b));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); z-index: 40;
}
.footer-space { height: 78px; }

/* 分段控件 */
.seg { display: flex; background: #eef1f6; border-radius: 11px; padding: 3px; gap: 3px; overflow-x: auto; }
.seg button {
  flex: 1; min-width: 64px; border: none; background: transparent; padding: 8px 6px;
  border-radius: 9px; font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.seg button.on { background: #fff; color: var(--pri); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* 搜索栏 */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar .input { background: #fff; }

/* ---------------- 图片 ---------------- */
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-cell { position: relative; width: 78px; height: 78px; border-radius: 10px; overflow: hidden; background: var(--bg); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .del {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none; font-size: 12px; line-height: 1;
}
.photo-add {
  width: 78px; height: 78px; border-radius: 10px; border: 1px dashed #c8d2e4; background: #fbfcff;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; gap: 2px;
}
.photo-add span:first-child { font-size: 20px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.gallery img { width: 130px; height: 130px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: var(--bg); }

/* ---------------- 底部 Tab ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: flex;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; border: none; background: none; padding: 8px 0 7px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px;
}
.tabbar button .t-ico { font-size: 19px; line-height: 1; }
.tabbar button.on { color: var(--pri); }

/* ---------------- 弹窗 / Toast ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 18px 18px 0 0;
  padding: 14px 14px calc(14px + var(--safe-b)); max-height: 82vh; overflow: auto;
  animation: up .2s ease;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h3 { margin: 0; font-size: 15.5px; }
.sheet-close { border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; color: var(--text-2); }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.95);
  background: rgba(28, 35, 51, .92); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13.5px; max-width: 78vw; text-align: center; z-index: 90;
  opacity: 0; pointer-events: none; transition: .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------------- 登录页 ---------------- */
.login-wrap { min-height: 100vh; padding: 0 22px; display: flex; flex-direction: column; justify-content: center; }
.login-logo {
  width: 62px; height: 62px; border-radius: 18px; background: var(--pri); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
  box-shadow: 0 10px 26px rgba(47,107,255,.3); margin-bottom: 18px;
}
.login-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
.login-card { background: #fff; border-radius: 18px; padding: 18px; box-shadow: 0 8px 30px rgba(23,38,68,.08); }
.login-tip { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 18px; line-height: 1.8; }

/* ---------------- 详情信息行 ---------------- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex-shrink: 0; }
.kv .v { text-align: right; word-break: break-all; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--pri); }

/* 明细行 */
.d-item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.d-item:last-child { border-bottom: none; }
.d-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.d-line.sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.qty-edit { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.qty-edit input { width: 74px; text-align: center; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.qty-edit .btn.small { padding: 7px 10px; }
