:root {
  --bg: #f3f5f9; --card: #fff; --text: #1d2433; --muted: #6b7486; --line: #e4e8ef;
  --primary: #1f6feb; --primary-soft: #e8f0fe; --ok: #1a9a5b; --ok-soft: #e6f6ee;
  --warn: #b7791f; --warn-soft: #fdf4e3; --danger: #d64545; --danger-soft: #fdecec;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar { background: var(--primary); color: #fff; padding: 14px 16px 12px; position: sticky; top: 0; z-index: 5; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.sub { font-size: 12px; opacity: .85; }

main { max-width: 720px; margin: 0 auto; padding: 12px; }
.page { display: none; }
.page.active { display: block; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .05); }
.card-title { font-weight: 700; margin-bottom: 10px; }
.card-title.row { display: flex; justify-content: space-between; align-items: center; }

/* 语音 */
.voice-card { text-align: center; }
.mic { width: 104px; height: 104px; border-radius: 50%; border: 0; margin: 8px auto 6px; display: grid; place-items: center;
  background: var(--primary); color: #fff; box-shadow: 0 8px 24px rgba(31, 111, 235, .35); cursor: pointer; transition: transform .15s; }
.mic:active { transform: scale(.95); }
.mic.listening { background: var(--danger); animation: pulse 1.2s infinite; box-shadow: 0 0 0 0 rgba(214, 69, 69, .5); }
.mic.disabled { background: #b8c2d3; box-shadow: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(214, 69, 69, .5); } 70% { box-shadow: 0 0 0 22px rgba(214, 69, 69, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 69, 69, 0); } }
.mic-label { font-weight: 600; }
.interim { min-height: 24px; color: var(--muted); margin: 4px 0 10px; font-size: 16px; word-break: break-all; }
.interim.heard { color: var(--text); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.chip { font-size: 12px; background: var(--primary-soft); color: var(--primary); padding: 4px 10px; border-radius: 99px; cursor: pointer; }

.input-row { display: flex; gap: 8px; }
input[type=text], input[type=search], input[type=number], input[type=password], textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; background: #fff; color: var(--text); }
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.ghost { background: #eef1f6; color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { flex: 1; padding: 14px; font-size: 17px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }

/* 确认卡 */
.confirm-card { border: 2px solid var(--primary); }
.fields { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.fields label { font-size: 12px; color: var(--muted); }
.fields input { margin-top: 4px; font-size: 20px; font-weight: 700; padding: 8px; text-align: center; }
.msgs div { margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.msg-err { background: var(--danger-soft); color: var(--danger); }
.msg-warn { background: var(--warn-soft); color: var(--warn); }
.raw { font-size: 12px; color: var(--muted); margin-top: 8px; }
.answer-card { border-left: 4px solid var(--ok); font-size: 16px; }
.answer-card .sub-list { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* 列表 */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .main { flex: 1; min-width: 0; }
.list .t { font-weight: 600; }
.list .s { font-size: 12px; color: var(--muted); }
.list .void .t { text-decoration: line-through; color: var(--muted); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #eef1f6; color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.empty { text-align: center; color: var(--muted); padding: 18px 0; }
.list li.clickable { cursor: pointer; }
.switch { font-size: 13px; font-weight: 400; color: var(--muted); display: flex; align-items: center; gap: 4px; }

/* 库存 */
.seg { display: flex; background: #eef1f6; border-radius: 10px; padding: 3px; margin: 12px 0 10px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.loc { font-weight: 700; color: var(--primary); }

.zone { margin-bottom: 12px; }
.zone-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cell { border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; text-align: center; background: #fafbfd; cursor: pointer; min-height: 58px; }
.cell .c { font-weight: 700; font-size: 14px; }
.cell .q { font-size: 12px; color: var(--muted); }
.cell.full { background: var(--primary-soft); border-color: #b9d0fb; }
.cell.full .q { color: var(--primary); font-weight: 600; }
.cell.hl { outline: 2px solid var(--warn); }

/* 拣配 */
.steps { display: grid; gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; }
.step b { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 13px; flex: none; }
.step a, .file-btn { color: var(--primary); font-weight: 600; text-decoration: none; cursor: pointer; }
.file-btn input { display: none; }
.manual { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.manual summary { color: var(--muted); font-size: 14px; cursor: pointer; }
.manual textarea { margin: 8px 0; }
.pick-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pick-code { font-weight: 700; font-size: 16px; }
.alert { background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.pick-line { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.pick-line .seq { width: 22px; color: var(--muted); font-size: 13px; text-align: center; flex: none; }
.pick-line .loc-big { font-size: 22px; font-weight: 800; color: var(--primary); width: 52px; flex: none; }
.pick-line .info { flex: 1; min-width: 0; }
.pick-line .info .s { font-size: 12px; color: var(--muted); }
.pick-line .act { display: flex; align-items: center; gap: 6px; flex: none; }
.pick-line .act input { width: 56px; padding: 6px; text-align: center; font-weight: 700; }
.pick-line.done { opacity: .55; }
.pick-line.done .loc-big { color: var(--ok); }
.fifo-badge { white-space: nowrap; display: inline-block; font-size: 11px; background: var(--ok-soft); color: var(--ok); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }

.kv { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.kv li { padding: 4px 0; }
.tips { padding-left: 18px; margin: 0; font-size: 14px; }

/* 底部导航 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabbar button { flex: 1; border: 0; background: transparent; padding: 7px 0 8px; font: inherit; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.tabbar button span { font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--primary); font-weight: 600; }
.tabbar button.on span { filter: none; opacity: 1; }

.toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); background: rgba(29, 36, 51, .92); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 30; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: rgba(26, 154, 91, .95); }
.toast.err { background: rgba(214, 69, 69, .95); }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { background: #fff; width: 100%; max-width: 720px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 70vh; overflow: auto; }

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(10, 1fr); }
}

/* 登录 */
body.logged-out main, body.logged-out .tabbar, body.logged-out .topbar { visibility: hidden; }
.login { position: fixed; inset: 0; z-index: 40; background: linear-gradient(160deg, #1f6feb 0%, #3b82f6 45%, var(--bg) 45%); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; overflow: auto; }
.login-box { width: 100%; max-width: 360px; background: #fff; border-radius: 18px; padding: 28px 20px 22px; box-shadow: 0 12px 40px rgba(20, 40, 90, .18); display: grid; gap: 12px; text-align: center; }
.login-box h1 { margin: 0; font-size: 22px; }
.login-box p { margin: -6px 0 6px; }
.login-logo { width: 64px; height: 64px; margin: -60px auto 0; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(31, 111, 235, .35); border: 4px solid #fff; }
.login-err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* 管理 */
.admin-only { display: none; }
body.is-admin #usersCard, body.is-admin #locCard, body.is-admin #demoCard { display: block; }
body.is-platform #platformCard { display: block; }
.small-text { font-size: 13px; margin: 0 0 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.list .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.form-grid { display: grid; gap: 10px; }
.form-grid label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.form-grid select { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; background: #fff; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 18px; background: var(--bg); padding: 10px; border-radius: 10px; text-align: center; user-select: all; word-break: break-all; }
.mic.busy { background: var(--warn); box-shadow: none; }

/* 期初库存导入 */
.sum-kv { list-style: none; padding: 0; margin: 0 0 10px; }
.sum-kv li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sum-kv li span { color: var(--muted); }
.sum-kv li b { font-weight: 600; text-align: right; word-break: break-all; }
.warn-text { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.check-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 8px 0; padding: 8px 10px; border: 1px solid var(--warn); border-radius: 10px; }
.check-row input { margin-top: 2px; flex: none; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 12px; }
.mini-table th, .mini-table td { padding: 6px 4px; }
.err-list li { color: var(--danger); font-size: 13px; padding: 7px 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
