/* 基础样式：移动端优先，S7 阶段统一收敛 */

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  /* 底部要留够固定入口栏的高度，否则最后一张卡片会被挡住 */
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  background: #f4f6fa;
  color: #1f2733;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

.view[hidden] { display: none; }

.card {
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.title { font-size: 20px; margin: 0 0 4px; }
.subtitle { color: #6b7684; margin: 0 0 16px; font-size: 14px; }
.muted { color: #6b7684; font-size: 14px; margin: 0; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 14px; color: #6b7684; margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 16px; /* 小于 16px 时 iOS 会自动放大页面 */
  border: 1px solid #d3dae4;
  border-radius: 8px;
  background: #fff;
}

.btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 16px;
  cursor: pointer;
}
.btn:active { opacity: 0.85; }
.btn-primary { width: 100%; background: #2f6fed; color: #fff; }
.btn-ghost { background: #fff; border-color: #d3dae4; color: #1f2733; padding: 0 14px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.topbar span { font-weight: 600; }

.quota { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.quota strong { font-size: 22px; color: #2f6fed; }

.msg {
  margin: 8px 0 0;
  font-size: 14px;
  color: #d64545;
}
.msg-ok { color: #2e9e5b; }
.msg-info { color: #2f6fed; }

/* ===== 录入模块（S3） ===== */

.scan-input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  font-size: 16px; /* 小于 16px 时 iOS 会自动放大页面 */
  border: 2px solid #2f6fed;
  border-radius: 8px;
  background: #fff;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.code-count { font-size: 14px; color: #6b7684; }
.code-count.warning { color: #e8890c; font-weight: 600; }
.code-count.danger { color: #d64545; font-weight: 600; }

.code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f6;
}
.code-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.code-index { color: #9aa4b2; font-size: 13px; min-width: 20px; }
.code-value { font-family: "SFMono-Regular", Consolas, monospace; font-size: 15px; word-break: break-all; }
.code-reason { font-size: 12px; color: #e8890c; }

.tag {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eef1f6;
  color: #4a5568;
}
.tag-IMEI { background: #e8f0fe; color: #2f6fed; }
.tag-SN { background: #eaf6ee; color: #2e9e5b; }
.tag-warn, .tag-存疑 { background: #fdf2e2; color: #e8890c; }
.tag-bad { background: #fdecec; color: #d64545; }
.tag-ok { background: #eaf6ee; color: #2e9e5b; }

.btn-mini { min-height: 32px; height: 32px; padding: 0 10px; font-size: 14px; }
.btn-block { display: block; width: 100%; text-align: center; }
label.btn-block { min-height: 44px; line-height: 44px; }
button.btn-block { line-height: normal; padding: 0 12px; }

/* ===== 主界面两入口与移动端适配（S7） ===== */

/* 顶部留白：微信 web-view 的导航栏会占掉顶部一段 */
.topbar { padding-top: calc(6px + env(safe-area-inset-top)); }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.topbar span { min-width: 0; word-break: break-all; }

/* 底部固定入口，避开 iPhone 底部安全区 */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e3e8ef;
}
.tab {
  flex: 1;
  min-height: 48px;
  font-size: 16px;
  border: 1px solid #d3dae4;
  border-radius: 10px;
  background: #fff;
  color: #1f2733;
}
.tab:active { opacity: 0.85; }
.tab-active { background: #2f6fed; border-color: #2f6fed; color: #fff; }

/* ===== 管理员视图（S10） ===== */

.sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f2f6;
}
.sub-info { min-width: 0; flex: 1; }
.sub-name { font-size: 15px; }
.sub-actions { display: flex; gap: 6px; flex-shrink: 0; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.summary-cell {
  background: #f7f9fc;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.summary-cell strong { font-size: 18px; color: #1f2733; }

.log-row { padding: 8px 0; border-bottom: 1px solid #f0f2f6; font-size: 14px; }
.log-plus { color: #2e9e5b; font-weight: 600; }
.log-minus { color: #d64545; font-weight: 600; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f2f6;
}
.history-info { min-width: 0; }
.history-time { font-size: 15px; }

.ocr-status { margin-top: 8px; min-height: 18px; }

/* 拍照与选文件并排，各占一半 */
.upload-row { display: flex; gap: 8px; }
.upload-row .btn-block { flex: 1; min-width: 0; text-align: center; }

.candidate-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f6;
}
.candidate-row input { min-width: 22px; min-height: 22px; margin-top: 2px; }
#candidate-actions { margin-top: 12px; }

/* ===== 查询编排（S4） ===== */

.est-bar {
  background: #eef2f9;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: #33415c;
  margin-bottom: 12px;
}
.est-bar.warning { background: #fdf2e2; color: #a35c05; font-weight: 600; }

.service-box { margin-bottom: 12px; }
.service-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f6;
}
.service-item input { min-width: 22px; min-height: 22px; }

.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.action-row .btn-primary { flex: 1 1 120px; }

.blocked-bar {
  background: #fdecec;
  color: #b3261e;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}

.progress-track {
  height: 8px;
  background: #eef1f6;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar { height: 100%; width: 0; background: #2f6fed; transition: width 0.3s; }

.result-card {
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.result-card.failed { border-color: #f3c6c2; background: #fffafa; }
.result-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-body { margin-top: 6px; font-size: 14px; color: #33415c; line-height: 1.7; }

/* ===== 结果展示（S5）：等宽纯文本块 ===== */

.result-block {
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #1f2733;
  white-space: pre;
  overflow-x: auto;   /* 长内容横向滚动，不撑破布局 */
}
.raw-block { margin-top: 6px; color: #5a6577; }

.failure-reason {
  margin-top: 6px;
  background: #fdecec;
  color: #b3261e;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}

.raw-details { margin-top: 8px; }
.raw-details summary { font-size: 13px; color: #2f6fed; cursor: pointer; }

.result-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.result-summary { font-size: 14px; font-weight: 600; color: #33415c; }
.toggle-raw { font-size: 13px; color: #6b7684; display: flex; align-items: center; gap: 6px; }
.toggle-raw input { min-width: 20px; min-height: 20px; }
