:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #17212b;
  --ink-2: #5b6b7b;
  --ink-3: #93a1b0;
  --brand: #1f5ce0;
  --brand-soft: #eaf0fd;
  --green: #0f9d58;
  --green-soft: #e7f6ee;
  --amber: #b46a00;
  --amber-soft: #fdf3e3;
  --red: #d23f31;
  --red-soft: #fdecea;
  --shadow-card: 0 1px 2px rgba(23, 33, 43, 0.05), 0 4px 16px rgba(23, 33, 43, 0.06);
  --shadow-pop: 0 2px 6px rgba(23, 33, 43, 0.08), 0 12px 32px rgba(23, 33, 43, 0.14);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.num { font-variant-numeric: tabular-nums; }

/* ---------- 顶栏 ---------- */
header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(242, 244, 247, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 14px 16px 10px;
}
header h1 { font-size: 17px; font-weight: 650; letter-spacing: 0.01em; text-wrap: balance; }
header .sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
header .badge {
  float: right; margin-top: 2px;
  font-size: 11px; font-weight: 600; color: var(--brand);
  background: var(--brand-soft); border-radius: 999px; padding: 4px 10px;
}

/* ---------- 页面容器 ---------- */
main { padding: 4px 14px 130px; }
.page { display: none; }
.page.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 { font-size: 14px; font-weight: 650; margin-bottom: 8px; text-wrap: balance; }
.muted { color: var(--ink-2); font-size: 13px; }
.tiny { color: var(--ink-3); font-size: 11.5px; }

/* ---------- 聊天 ---------- */
#chat-log { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.msg { display: flex; gap: 8px; opacity: 0; transform: translateY(6px); animation: rise 0.32s cubic-bezier(0.2, 0, 0, 1) forwards; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px;
  background: linear-gradient(135deg, #1f5ce0, #4f8bff); color: #fff;
  box-shadow: 0 2px 6px rgba(31, 92, 224, 0.35);
}
.msg.user .avatar { background: #dfe5ec; color: var(--ink-2); box-shadow: none; }
.bubble {
  max-width: 86%;
  background: var(--card); border-radius: 16px; border-top-left-radius: 6px;
  box-shadow: var(--shadow-card);
  padding: 10px 12px; font-size: 14px;
}
.msg.user .bubble {
  background: var(--brand); color: #fff;
  border-radius: 16px; border-top-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(31, 92, 224, 0.30);
}
.bubble .b-title { font-weight: 650; font-size: 13.5px; margin-bottom: 6px; }

/* AI 结果卡内的行 */
.hit {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  background: #f7f9fb; margin-top: 6px;
}
.hit .ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 19px;
  background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.hit .info { flex: 1; min-width: 0; }
.hit .l1 { font-size: 13.5px; font-weight: 600; }
.hit .l2 { font-size: 11.5px; color: var(--ink-3); }
.hit .qty { font-size: 15px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.hit .qty small { font-size: 11px; font-weight: 500; color: var(--ink-3); }

.tag { display: inline-block; font-size: 10.5px; font-weight: 600; border-radius: 6px; padding: 1.5px 6px; margin-left: 5px; vertical-align: 1px; }
.tag.vw   { background: var(--brand-soft); color: var(--brand); }
.tag.vac  { background: var(--green-soft); color: var(--green); }
.tag.wh   { background: #eef1f5; color: var(--ink-2); }
.tag.rent { background: var(--amber-soft); color: var(--amber); }
.tag.hi   { background: var(--red-soft); color: var(--red); }

/* 意图确认卡 / 差异表 */
.intent { border-radius: var(--r-md); background: #f7f9fb; padding: 10px 12px; margin-top: 8px; font-size: 13px; }
.intent .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.intent .row .k { color: var(--ink-3); flex: 0 0 auto; }
.intent .row .v { text-align: right; font-weight: 600; }
.fee { color: var(--brand); font-weight: 700; }

.ai-note {
  margin-top: 8px; padding: 9px 11px; border-radius: var(--r-md);
  background: var(--amber-soft); color: var(--amber); font-size: 12.5px;
}
.ai-note.ok { background: var(--green-soft); color: var(--green); }

.diff-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #f0f2f5; font-size: 13.5px; }
.diff-row:last-child { border-bottom: none; }
.diff-delta { font-weight: 700; }
.diff-delta.minus { color: var(--red); }
.diff-delta.plus { color: var(--green); }
.diff-delta.zero { color: var(--ink-3); font-weight: 500; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: none; border-radius: var(--r-md);
  background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition-property: transform, opacity, background-color;
  transition-duration: 0.15s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.btn:active { transform: scale(0.96); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.small { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* 快捷指令条 */
#chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 40px; display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border-radius: 999px; padding: 0 14px;
  font-size: 13px; font-weight: 550; color: var(--ink);
  box-shadow: var(--shadow-card); border: none; font-family: inherit; cursor: pointer;
  transition-property: transform; transition-duration: 0.15s;
}
.chip:active { transform: scale(0.96); }

/* 输入区 */
#composer {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; padding: 8px 14px 10px;
  background: linear-gradient(to top, var(--bg) 75%, transparent);
  display: flex; gap: 8px; z-index: 25;
}
#composer input {
  flex: 1; min-height: 44px; border: none; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-card);
  padding: 0 16px; font-size: 14px; font-family: inherit; color: var(--ink);
  outline: none;
}
#composer input::placeholder { color: var(--ink-3); }
#composer .btn { border-radius: 999px; min-width: 64px; }
#cam-btn {
  min-width: 44px; width: 44px; padding: 0; border-radius: 999px;
  background: var(--card); color: var(--ink-2); box-shadow: var(--shadow-card);
  font-size: 18px;
}

/* ---------- 底部导航 ---------- */
nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 30;
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 -1px 0 rgba(23, 33, 43, 0.07);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1; min-height: 56px; border: none; background: none; font-family: inherit;
  font-size: 10.5px; font-weight: 600; color: var(--ink-3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition-property: color, transform; transition-duration: 0.15s;
}
nav button:active { transform: scale(0.96); }
nav button .ni { font-size: 20px; line-height: 1; }
nav button.on { color: var(--brand); }

/* ---------- 台账 ---------- */
.bsel { display: flex; gap: 7px; overflow-x: auto; padding: 8px 0 12px; scrollbar-width: none; }
.bsel::-webkit-scrollbar { display: none; }
.bsel button {
  flex: 0 0 auto; min-height: 40px; padding: 0 15px; border: none; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-card);
  font-size: 13px; font-weight: 600; color: var(--ink-2); font-family: inherit; cursor: pointer;
}
.bsel button.on { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(31, 92, 224, 0.3); }

.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room-card {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  padding: 12px; cursor: pointer;
  transition-property: transform; transition-duration: 0.15s;
}
.room-card:active { transform: scale(0.97); }
.room-card .rid { font-size: 15px; font-weight: 700; }
.room-card .rmeta { font-size: 11.5px; color: var(--ink-3); margin: 2px 0 8px; }
.room-card .rcnt { font-size: 12.5px; color: var(--ink-2); }
.room-card .rcnt b { color: var(--brand); font-size: 15px; }

.inv-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0f2f5; }
.inv-row:last-child { border-bottom: none; }
.inv-row .ico { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: #f7f9fb; }
.inv-row .info { flex: 1; }
.inv-row .l1 { font-size: 13.5px; font-weight: 600; }
.inv-row .l2 { font-size: 11.5px; color: var(--ink-3); }
.inv-row .qty { font-size: 16px; font-weight: 700; }

.flow-row { padding: 8px 0; border-bottom: 1px solid #f0f2f5; font-size: 12.5px; }
.flow-row:last-child { border-bottom: none; }
.flow-row .f1 { display: flex; justify-content: space-between; font-weight: 600; }
.flow-row .f1 .via { font-weight: 500; color: var(--brand); font-size: 11px; }
.flow-row .f2 { color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }

.back-btn { background: none; border: none; color: var(--brand); font-size: 14px; font-weight: 600; font-family: inherit; padding: 6px 0 10px; cursor: pointer; min-height: 40px; }

/* ---------- 搬运单 ---------- */
.move-card { position: relative; }
.move-card .mid { font-size: 14px; font-weight: 700; }
.move-card .mst { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.mst.pending { background: var(--amber-soft); color: var(--amber); }
.mst.done { background: var(--green-soft); color: var(--green); }
.mst.approved { background: var(--brand-soft); color: var(--brand); }
.move-card .mroute { font-size: 13px; color: var(--ink-2); margin: 3px 0 7px; }
.move-card .mitems { font-size: 12.5px; color: var(--ink-2); background: #f7f9fb; border-radius: var(--r-md); padding: 8px 10px; }
.move-card .mfee { margin-top: 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; }

/* ---------- 看板 ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 13px 14px;
}
.stat .sv { font-size: 21px; font-weight: 750; letter-spacing: -0.01em; }
.stat .sv small { font-size: 12px; font-weight: 550; color: var(--ink-3); margin-left: 2px; }
.stat .sk { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.stat.good .sv { color: var(--green); }
.stat.warn .sv { color: var(--amber); }

.bars { display: flex; align-items: flex-end; gap: 9px; height: 110px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar-col .bv { font-size: 9.5px; color: var(--ink-3); }
.bar-col .bar { width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; background: #c9d7f5; }
.bar-col.hot .bar { background: var(--brand); }
.bar-col .bl { font-size: 10.5px; color: var(--ink-2); font-weight: 550; }

.idle-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.idle-row:last-child { border-bottom: none; }
.idle-row .ico { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; background: #f7f9fb; }
.idle-row .n { flex: 1; font-weight: 600; }
.idle-row .v { color: var(--ink-2); }

/* 盘点照片占位 */
.photo-ph {
  border-radius: var(--r-md); overflow: hidden; margin-top: 8px;
  outline: 1px solid rgba(0, 0, 0, 0.1); outline-offset: -1px;
}
.photo-ph img, .photo-ph canvas { display: block; width: 100%; height: auto; }

.scan {
  margin-top: 8px; display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--ink-2);
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--brand-soft); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footnote { text-align: center; padding: 18px 20px 6px; }
