﻿:root {
  --blue: #1a6dff;
  --blue-dark: #0f52c9;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #e4eaf2;
  --text: #1c2430;
  --muted: #7b8797;
  --ok: #14a06a;
  --warn: #e0721c;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(20, 40, 80, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
.screen { display: none; min-height: 100vh; }
.screen.is-active { display: block; }

/* ---------- 登录 ---------- */
#login { padding: 56px 24px 32px; }
.login-head { text-align: center; margin-bottom: 32px; }
.brand-mark {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(145deg, #2d7dff, #0f52c9); color: #fff;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
  box-shadow: 0 10px 24px rgba(26, 109, 255, .28);
}
.login-head h1 { font-size: 21px; margin: 0 0 4px; }
.login-head p { margin: 0; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 14px; }
.login-form label, .issue-form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); font-size: 16px; color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 109, 255, .12); }
.btn {
  height: 50px; border: 0; border-radius: 12px; background: var(--surface); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600;
}
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 8px 18px rgba(26, 109, 255, .3); }
.btn.primary:active { background: var(--blue-dark); }
.logout { background: #fff; border: 1px solid var(--line); color: var(--muted); }
.login-foot { margin-top: 24px; text-align: center; color: var(--muted); font-size: 12px; }
.err { color: #d63b3b; font-size: 13px; margin: 0; }

/* ---------- 主界面 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar b { font-size: 17px; }
.role { margin-left: 8px; font-size: 12px; color: var(--blue); background: rgba(26, 109, 255, .1); padding: 2px 8px; border-radius: 20px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 8px; cursor: pointer; }

.scan-block { padding: 20px 18px 8px; }
.scan-btn {
  width: 100%; border: 0; border-radius: 18px; padding: 26px 18px;
  background: linear-gradient(150deg, #2d7dff, #0f52c9); color: #fff;
  display: grid; justify-items: center; gap: 4px; cursor: pointer;
  box-shadow: 0 14px 30px rgba(26, 109, 255, .32);
}
.scan-btn:active { transform: scale(.99); }
.scan-ico { font-size: 34px; line-height: 1; }
.scan-btn > span:nth-child(2) { font-size: 20px; font-weight: 700; }
.scan-btn small { opacity: .82; font-size: 12px; }

.search-block { padding: 14px 18px 6px; }
.list { padding: 8px 18px 40px; display: grid; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 6px; box-shadow: var(--shadow);
}
.card.is-zero { opacity: .62; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-code { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.card-qty { font-size: 20px; font-weight: 700; color: var(--blue); }
.card-qty small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.card-name { font-size: 17px; font-weight: 600; }
.card-spec { color: var(--muted); font-size: 13px; }
.card-meta { display: flex; gap: 12px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* ---------- 出库表单 ---------- */
.sheet-wrap { position: fixed; inset: 0; display: none; z-index: 30; background: rgba(16, 26, 44, .45); }
.sheet-wrap.is-open { display: block; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head b { font-size: 18px; }
.mat-info { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; display: grid; gap: 4px; }
.mat-info .mi-name { font-size: 17px; font-weight: 600; }
.mat-info .mi-meta { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.issue-form { display: grid; gap: 12px; }
.qty-row { display: grid; grid-template-columns: 56px 1fr 56px; gap: 10px; align-items: center; }
.qty-row input { text-align: center; font-size: 20px; font-weight: 700; height: 52px; }
.step { height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 22px; cursor: pointer; }
.step:active { background: #e9eff8; }

/* ---------- 相机 ---------- */
.camera-wrap { position: fixed; inset: 0; display: none; z-index: 40; background: #000; }
.camera-wrap.is-open { display: block; }
#video { width: 100%; height: 100%; object-fit: cover; }
.camera-mask { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.camera-frame { width: 62vw; height: 62vw; max-width: 300px; max-height: 300px; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 2000px rgba(0,0,0,.45); }
.camera-bar { position: absolute; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; padding: 0 22px; }
.camera-bar .icon-btn { color: #fff; background: rgba(255,255,255,.16); border-radius: 20px; padding: 10px 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(22, 32, 48, .92); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; max-width: 88vw; text-align: center; z-index: 60;
}
.toast.ok { background: rgba(16, 130, 88, .95); }
.toast.err { background: rgba(190, 46, 46, .95); }

/* ---------- 批量出库清单 ---------- */
.scan-btn { position: relative; }
.scan-badge { position: absolute; top: 12px; right: 14px; min-width: 24px; height: 24px; border-radius: 12px; background: #fff; color: var(--blue); font-size: 13px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.cart-bar { margin: 10px 18px 0; background: #eef4ff; border: 1px solid #d5e2ff; border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: #1a4fae; }
.cart-bar b { font-size: 16px; }
.btn.small { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: #eef3fb; color: #2b5591; height: 44px; }
.card-add { margin-top: 4px; font-size: 12px; color: var(--blue); }
.cart-list { display: grid; gap: 8px; }
.cart-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.cr-main { display: grid; gap: 2px; min-width: 0; }
.cr-main b { font-size: 15px; }
.cr-main span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-qty { display: grid; grid-template-columns: 38px 64px 38px; align-items: center; gap: 4px; }
.cr-qty .step { height: 38px; font-size: 18px; border-radius: 9px; }
.cr-qty input { height: 38px; padding: 0 6px; text-align: center; font-size: 15px; font-weight: 600; }
.cr-del { border: 0; background: transparent; color: #c04a4a; font-size: 22px; line-height: 1; padding: 0 4px; cursor: pointer; }
.cart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; margin: 0; }
.shared { display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.cart-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.cart-foot span { color: var(--muted); font-size: 13px; }
.cart-foot .btn { flex: 1; max-width: 180px; }
/* 站点切换 */
.site-switch { display: inline-flex; gap: 2px; background: #eef3fa; border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.site-switch button { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 5px 10px; border-radius: 8px; }
.site-switch button.is-active { background: var(--blue); color: #fff; font-weight: 600; }
.site-switch.login-site { display: flex; width: fit-content; margin: 20px auto 8px; }
.topbar .site-switch { margin-right: 4px; }
.login-legal { margin: 8px 0 0; font-size: 11px; color: #8a94a6; text-align: center; }
.login-legal a { color: #8a94a6; text-decoration: none; }
