:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2f6fed;
  --brand-dark: #1d4ed8;
  --brand-soft: #eaf1fe;
  --ok: #15a06a;
  --ok-soft: #e6f6ef;
  --warn: #c2740a;
  --warn-soft: #fdf3e3;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

/* ---------------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #14213d;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 18px 18px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand small { display: block; font-weight: 400; color: #94a3b8; font-size: 12px; margin-top: 2px; }
.sidebar nav { padding: 10px 8px 24px; }
.sidebar .group { margin-top: 10px; }
.sidebar .group-title {
  font-size: 11px;
  letter-spacing: .12em;
  color: #93a5c0;
  padding: 8px 10px 4px;
}
.sidebar a.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
}
.sidebar a.item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar a.item.active { background: var(--brand); color: #fff; }
.sidebar .count {
  background: rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 12px;
  line-height: 18px;
}

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .who { color: var(--muted); font-size: 13px; }
.content { padding: 20px 24px 48px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- 组件 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card > header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card > header h3 { font-size: 15px; }
.card > header .hint { font-size: 12px; color: var(--muted); }
.card .body { padding: 16px 18px; }
.card .body.tight { padding: 0; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.5px; }
.stat .value.small { font-size: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  background: #eef2f7;
  color: #475569;
  white-space: nowrap;
}
.badge.blue { background: var(--brand-soft); color: var(--brand-dark); }
.badge.green { background: var(--ok-soft); color: #0f7a51; }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: #b13333; }
.badge.grey { background: #eef2f7; color: #475569; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
table.tbl tr:hover td { background: #fbfcfe; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono, table.tbl th.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
table.tbl td.wrapcell { max-width: 240px; white-space: normal; word-break: break-all; line-height: 1.5; }
table.tbl .actions { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); font-size: 14px; }

.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.one { grid-template-columns: minmax(0, 1fr); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .form-row, .form-row.three { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; color: #374151; }
.field .tip { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 111, 237, .25); border-color: var(--brand); }
textarea { min-height: 76px; resize: vertical; }
input[type="file"] { font-size: 13px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: #0f7a51; border: 1px solid #bfe6d5; }
.flash.err { background: var(--danger-soft); color: #a83333; border: 1px solid #f2c9c9; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: #475569;
  background: #eef2f7;
}
.tabs a:hover { text-decoration: none; background: #e4eaf2; }
.tabs a.active { background: var(--brand); color: #fff; }
.tabs a .n { opacity: .75; font-size: 12px; margin-left: 4px; }

.kv { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 104px minmax(0, 1fr); } }

.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: #f1f5f9; display: block; }
.thumb.lg { width: 160px; height: 160px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-grid a { display: block; }
.photo-grid img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.items-editor { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.items-editor .row { display: grid; grid-template-columns: minmax(0, 2fr) 100px 1.4fr 44px; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); align-items: center; }
.items-editor .row:last-child { border-bottom: 0; }
.items-editor .row.head { background: var(--surface-2); font-size: 12px; color: var(--muted); }
.items-editor.pkg .row { grid-template-columns: minmax(0, 1fr) 110px 72px; }
@media (max-width: 720px) {
  .items-editor .row { grid-template-columns: minmax(0, 1fr) 84px; grid-auto-rows: auto; }
  .items-editor .row.head { display: none; }
}

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, #eef2f9 0%, #e3eaf6 100%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(15, 23, 42, .10); padding: 30px 28px; }
.login-card h1 { font-size: 20px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }

/* ---------------------------------------------------------------- 仓库手机端 */
body.w {
  background: #eef1f6;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
.w-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #14213d;
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}
.w-top .back { color: #cbd5e1; font-size: 22px; line-height: 1; text-decoration: none; padding: 4px 6px; }
.w-top .t { font-size: 16px; font-weight: 600; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-top .who { font-size: 12px; color: #94a3b8; }
.w-body { padding: 12px 12px 24px; }
.w-cards { display: grid; gap: 10px; }

.w-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
  border: 1px solid #e6ebf2;
}
a.w-card:hover { text-decoration: none; }
.w-card .line1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.w-card .no { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.w-card .meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.w-card .skus { margin-top: 8px; font-size: 13px; color: #334155; word-break: break-all; }

.w-tile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.w-tile a {
  background: #fff;
  border-radius: 12px;
  padding: 18px 14px;
  border: 1px solid #e6ebf2;
  box-shadow: var(--shadow);
  color: inherit;
  display: block;
}
.w-tile a:hover { text-decoration: none; }
.w-tile .n { font-size: 30px; font-weight: 600; letter-spacing: -.5px; display: flex; align-items: center; gap: 6px; }
.w-tile .n .ico-svg { width: 22px; height: 22px; margin: 0; }
.w-tile a.accent .n { font-size: 21px; display: flex; align-items: center; gap: 6px; }
.w-tile a.accent .n .ico-svg { width: 24px; height: 24px; margin: 0; }
.w-tile .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.w-tile .wide { grid-column: span 2; }
.w-tile a.accent { background: var(--brand); border-color: var(--brand); color: #fff; }
.w-tile a.accent .l { color: rgba(255, 255, 255, .85); }

.w-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.w-nav a { padding: 8px 4px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.w-nav a:hover { text-decoration: none; }
.w-nav a.active { color: var(--brand); font-weight: 600; }
.w-nav .ico-svg { display: block; width: 22px; height: 22px; margin: 0 auto 2px; }

.w-form { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.w-form .field { margin-bottom: 14px; }
.w-form label { font-size: 14px; color: #374151; }
.w-form input, .w-form select, .w-form textarea { font-size: 16px; padding: 10px 12px; }
.btn.big { padding: 13px 16px; font-size: 16px; border-radius: 10px; }

.w-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.w-line:last-child { border-bottom: 0; }
.w-line .l { font-size: 13px; color: var(--muted); }

.w-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.w-item:last-child { border-bottom: 0; }
.w-item .t { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.w-item .t .code { font-size: 16px; font-weight: 600; }
.w-item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.w-item .line { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.w-item .line .l { font-size: 14px; color: #374151; white-space: nowrap; }
.w-item input[type="text"] { margin-top: 8px; }

.w-thumb {
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f1f5f9;
  display: block;
}
.w-thumb.empty { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.w-sku-row { display: flex; gap: 12px; align-items: flex-start; }
.w-sku-row .info { flex: 1 1 auto; min-width: 0; }
.w-sku-row .qty { font-size: 24px; font-weight: 700; color: var(--brand); line-height: 1.2; }
.w-sku-row .name { font-size: 15px; margin-top: 2px; word-break: break-all; }
.w-sku-row .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.w-list-thumb { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: #f1f5f9; }

/* 仓库端：发货详情 */
.w-section { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 8px; }
.w-section .t { font-size: 14px; font-weight: 600; color: #334155; }
.w-section .n { font-size: 13px; color: var(--muted); }

.w-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin-top: 12px; }
.w-summary .cell { background: #f8fafc; border-radius: 8px; padding: 8px 10px; }
.w-summary .cell .l { font-size: 12px; color: var(--muted); }
.w-summary .cell .v { font-size: 15px; font-weight: 600; margin-top: 2px; word-break: break-all; }

.w-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
  border-radius: 10px;
  margin-bottom: 10px;
}
.w-pick:last-child { border-bottom: 0; margin-bottom: 0; }
.w-pick-img {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f1f5f9;
}
.w-pick-img.empty { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.w-pick-main { flex: 1 1 auto; min-width: 0; }
.w-pick-label { font-size: 11px; color: #94a3b8; letter-spacing: .08em; }
.w-pick-name { font-size: 19px; font-weight: 700; line-height: 1.3; word-break: break-all; color: #0f172a; }
.w-pick-sku { margin-top: 6px; font-size: 14px; color: #334155; }
.w-pick-sku .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }
.w-pick-spec { margin-top: 2px; font-size: 13px; color: var(--muted); word-break: break-all; }
.w-pick-qty {
  flex: 0 0 auto;
  text-align: center;
  color: var(--brand);
  line-height: 1;
  padding-left: 6px;
}
.w-pick-qty .x { font-size: 16px; font-weight: 600; }
.w-pick-qty .n { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.w-pick-qty .u { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }

.pdf-box { border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; padding: 8px; min-height: 90px; }
.pdf-box [data-pdf-pages] { display: grid; gap: 8px; }
.pdf-canvas { display: block; border-radius: 6px; box-shadow: 0 1px 4px rgba(15, 23, 42, .12); background: #fff; }
.pdf-status { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 8px; }
.pdf-status.err { color: var(--danger); }

.file-pick {
  display: block;
  position: relative;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.file-pick input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.file-pick .icon { font-size: 26px; display: block; margin-bottom: 4px; color: #64748b; }
.file-pick .icon .ico-svg { width: 26px; height: 26px; margin: 0 auto; }
.file-pick.picked .icon { color: var(--brand-dark); }
.file-pick.picked { border-style: solid; border-color: #bcd3fb; background: var(--brand-soft); color: var(--brand-dark); }

/* 拍照和从相册选择，两个入口并排 */
.pick-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pick-group .file-pick { padding: 16px 10px; font-size: 13px; }
.pick-group .icon { font-size: 22px; margin-bottom: 2px; }
.pick-group .icon .ico-svg { width: 24px; height: 24px; }
.w-qty { width: 84px; text-align: center; font-size: 16px; padding: 8px; }

#scanner { width: 100%; border-radius: 12px; background: #000; display: block; }
.scan-frame { position: relative; }
.scan-frame .hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .sidebar .group { display: contents; }
  .sidebar .group-title { display: none; }
  .sidebar a.item { padding: 6px 10px; font-size: 13px; }
  .content { padding: 14px 14px 40px; }
  .topbar { padding: 10px 14px; }
}
