/* 固定资产盘点小程序 —— 移动端样式（企业微信内置浏览器优先） */
:root {
  --brand: #2f6fed;
  --brand-dark: #1f56c9;
  --ok: #16a34a;
  --ok-bg: #e7f7ee;
  --bad: #dc2626;
  --bad-bg: #fdeaea;
  --warn: #d97706;
  --warn-bg: #fdf3e3;
  --line: #e6e8ee;
  --text: #1f2430;
  --sub: #6b7280;
  --bg: #f2f4f8;
  --card: #fff;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(64px + var(--safe-b));
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--brand), #4b8bf5);
  color: #fff; padding: 12px 16px 14px;
  box-shadow: 0 2px 10px rgba(47,111,237,.25);
}
.tb-title { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.tb-sub { font-size: 12px; opacity: .9; margin-top: 3px; }

main { padding: 12px 12px 8px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(20,30,60,.06);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { font-size: 12px; color: var(--sub); font-weight: 400; }

/* ---------------- 进度 ---------------- */
.progress-card { padding-bottom: 6px; }
.pc-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; font-weight: 600; }
.pc-count { font-size: 13px; color: var(--sub); font-weight: 500; }
.bar { height: 10px; background: #eef1f6; border-radius: 6px; overflow: hidden; margin: 10px 0 14px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #34d399, var(--ok)); border-radius: 6px; transition: width .35s ease; }
.pc-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  border: 0; border-radius: 10px; padding: 10px 4px; text-align: center;
  background: #f6f8fb; color: var(--text); font-family: inherit; cursor: pointer;
}
.stat b { display: block; font-size: 21px; line-height: 1.15; }
.stat span { font-size: 12px; color: var(--sub); }
.stat-ok b { color: var(--ok); }
.stat-bad b { color: var(--bad); }
.stat-pending b { color: var(--warn); }
.stat:active { transform: scale(.97); }
.pc-foot { font-size: 12px; color: var(--sub); margin-top: 10px; text-align: center; }

/* ---------------- 快捷按钮 ---------------- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.qbtn {
  border: 0; background: #fff; border-radius: var(--radius); padding: 12px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text); font-size: 12px; font-family: inherit; cursor: pointer;
  box-shadow: 0 1px 3px rgba(20,30,60,.06);
}
.qbtn:active { transform: scale(.96); }
.qbtn-primary { background: linear-gradient(135deg, var(--brand), #4b8bf5); color: #fff; box-shadow: 0 4px 12px rgba(47,111,237,.32); }

/* ---------------- 部门列表 ---------------- */
.dept-list { display: flex; flex-direction: column; gap: 2px; max-height: 42vh; overflow: auto; }
.dept-item { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.dept-item:last-child { border-bottom: 0; }
.dept-name { flex: 1 1 auto; font-size: 14px; }
.dept-num { font-size: 12px; color: var(--sub); white-space: nowrap; }
.dept-bar { width: 62px; height: 6px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.dept-bar > i { display: block; height: 100%; background: var(--ok); }
.dept-arrow { color: #c3c9d5; font-size: 15px; }

/* ---------------- 表单 ---------------- */
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.form-row label { flex: 0 0 68px; font-size: 14px; color: var(--sub); }
.form-row input, .input-row input, textarea, select {
  flex: 1 1 auto; width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; font-size: 15px; font-family: inherit;
  background: #fbfcfe; color: var(--text); outline: none;
}
.form-row input:focus, .input-row input:focus, textarea:focus { border-color: var(--brand); background: #fff; }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.input-row { display: flex; gap: 8px; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: 0; border-radius: 9px; padding: 11px 16px;
  font-size: 15px; font-family: inherit; cursor: pointer;
  background: #eef1f6; color: var(--text); white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(47,111,237,.3); }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn-lg { width: 100%; padding: 15px; font-size: 16px; font-weight: 600; }
.btn-mini { padding: 5px 10px; font-size: 12px; border-radius: 7px; background: #f0f2f7; }
.btn-danger { background: var(--bad-bg); color: var(--bad); }

/* ---------------- 扫码页 ---------------- */
.scan-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.scan-tip { font-size: 13px; color: var(--sub); margin-bottom: 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: #a6adbb; font-size: 12px; margin: 18px 0 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.recent-title { font-size: 13px; color: var(--sub); margin: 18px 0 8px; }
.recent { display: flex; flex-direction: column; }
.recent-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.recent-item:last-child { border-bottom: 0; }
.recent-main { flex: 1 1 auto; min-width: 0; }
.recent-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 12px; color: var(--sub); }
.recent-time { font-size: 11px; color: #9aa2b1; white-space: nowrap; }
.empty { text-align: center; color: #9aa2b1; font-size: 13px; padding: 22px 0; }

#camVideo { width: 100%; border-radius: 10px; background: #000; display: block; max-height: 62vh; object-fit: cover; }

/* ---------------- 资产详情 ---------------- */
.detail-hero {
  background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(20,30,60,.06);
}
.detail-name { font-size: 18px; font-weight: 600; line-height: 1.35; }
.detail-code { font-size: 13px; color: var(--brand); margin-top: 4px; font-weight: 600; letter-spacing: .5px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 20px; background: #f0f3f9; color: #4b5563; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-bad { background: var(--bad-bg); color: var(--bad); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-brand { background: #e8f0ff; color: var(--brand); }

.info-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.info-table td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.info-table tr:last-child td { border-bottom: 0; }
.info-table td:first-child { color: var(--sub); width: 84px; white-space: nowrap; }
.info-table td:last-child { word-break: break-all; }

.status-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 14px; }
.pick {
  border: 2px solid var(--line); border-radius: var(--radius); background: #fff;
  padding: 16px 8px; text-align: center; font-size: 16px; font-weight: 600;
  color: var(--sub); font-family: inherit; cursor: pointer; transition: all .12s;
}
.pick:active { transform: scale(.98); }
.pick small { display: block; font-size: 11px; font-weight: 400; color: #9aa2b1; margin-top: 3px; }
.pick-ok.on { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.pick-bad.on { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

.dup-warn { background: var(--warn-bg); color: #92400e; border-radius: 9px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.notfound { text-align: center; padding: 8px 0 4px; }

/* ---------------- 清单 ---------------- */
.sticky-filters { position: sticky; top: 0; z-index: 10; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 8px 0 2px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--sub);
  border-radius: 20px; padding: 5px 13px; font-size: 13px; white-space: nowrap;
  font-family: inherit; cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.list-meta { font-size: 12px; color: var(--sub); padding-top: 6px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.asset-item {
  background: #fff; border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(20,30,60,.06); cursor: pointer;
  border-left: 4px solid #dfe3ea;
}
.asset-item.s-在库 { border-left-color: var(--ok); }
.asset-item.s-报废 { border-left-color: var(--bad); }
.asset-item.s-盘亏 { border-left-color: var(--warn); }
.ai-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.ai-name { font-size: 15px; font-weight: 600; word-break: break-word; }
.ai-status { font-size: 12px; padding: 2px 9px; border-radius: 20px; white-space: nowrap; background: #f0f3f9; color: var(--sub); }
.ai-status.st-在库 { background: var(--ok-bg); color: var(--ok); }
.ai-status.st-报废 { background: var(--bad-bg); color: var(--bad); }
.ai-status.st-盘亏 { background: var(--warn-bg); color: var(--warn); }
.ai-sub { font-size: 12.5px; color: var(--sub); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.ai-sub b { font-weight: 500; color: #4b5563; }
.ai-note { font-size: 12.5px; color: var(--warn); margin-top: 5px; }
.load-more { text-align: center; padding: 14px; color: var(--brand); font-size: 14px; cursor: pointer; }

/* ---------------- 记录页 ---------------- */
.sum-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sum-table th, .sum-table td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.sum-table th:first-child, .sum-table td:first-child { text-align: left; }
.sum-table th { color: var(--sub); font-weight: 500; font-size: 13px; }
.sum-table tr:last-child td { border-bottom: 0; }
.export-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.operator-stats { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.op-row { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.op-row:last-child { border-bottom: 0; }
.about p { font-size: 13.5px; color: #4b5563; margin: 6px 0; }
.sync-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--sub); }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  box-shadow: 0 -2px 10px rgba(20,30,60,.05);
}
.tab {
  border: 0; background: none; font-family: inherit; cursor: pointer;
  padding: 7px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #98a1b0; font-size: 11px;
}
.tab.active { color: var(--brand); }

/* ---------------- 提示与弹窗 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(10px);
  background: rgba(28,34,48,.94); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 22px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 84vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: rgba(180,35,35,.96); }

.modal { position: fixed; inset: 0; background: rgba(18,22,30,.5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 14px; padding: 18px; width: 100%; max-width: 400px; max-height: 80vh; overflow: auto; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

@media (min-width: 720px) {
  main { max-width: 660px; margin: 0 auto; }
  .topbar .tb-title, .topbar .tb-sub { max-width: 660px; margin-left: auto; margin-right: auto; }
}
