* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f2f4f7;
  color: #1f2937;
  font-size: 15px;
  padding-bottom: 40px;
}

.topbar {
  background: linear-gradient(135deg, #1a73e8, #0b57d0);
  color: #fff;
  padding: 18px 16px 14px;
}
.topbar h1 { font-size: 18px; font-weight: 600; line-height: 1.3; }
.topbar .sub { font-size: 12px; opacity: .85; }
.topbar .ver { display: block; margin-top: 4px; font-size: 11px; opacity: .72; }

main { padding: 12px; max-width: 640px; margin: 0 auto; }

.card {
  background: #fff; border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: #333; }
.card-title .hint { font-weight: 400; font-size: 12px; color: #9aa1ab; }

.type-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-btn {
  padding: 10px 0; border: 1px solid #e5e7eb; background: #f9fafb;
  border-radius: 8px; font-size: 13px; color: #4b5563;
}
.type-btn.active { background: #e8f0fe; border-color: #1a73e8; color: #1a73e8; font-weight: 600; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid label { font-size: 12px; color: #6b7280; display: flex; flex-direction: column; gap: 4px; }
.field-grid input, .field-grid select {
  height: 38px; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 0 10px; font-size: 14px; color: #1f2937; background: #fff;
}
.field-grid input:focus, .field-grid select:focus { outline: none; border-color: #1a73e8; }

.preview {
  width: 100%; height: 220px; border: 1px dashed #cbd5e1; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #fafafa; cursor: pointer;
}
.preview img { width: 100%; height: 100%; object-fit: contain; display: none; }
.preview .placeholder { color: #9aa1ab; font-size: 14px; }

.btn {
  display: block; width: 100%; border: none; border-radius: 10px;
  padding: 12px; font-size: 15px; cursor: pointer; margin-top: 10px;
}
.btn.primary { background: #1a73e8; color: #fff; font-weight: 600; }
.btn.primary:disabled { background: #b6c8e8; }
.btn.big { padding: 14px; font-size: 17px; margin-top: 4px; }
.btn.mini { width: auto; display: inline-block; padding: 6px 12px; font-size: 12px;
  background: #eef2f7; color: #1a73e8; margin: 0; border-radius: 8px; }

.gps-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.gps-text { font-size: 13px; color: #6b7280; word-break: break-all; }

.result { border-left: 4px solid #16a34a; }
.result-ok { font-size: 16px; font-weight: 700; color: #16a34a; margin-bottom: 8px; }
.rec-list { display: flex; flex-direction: column; gap: 6px; }
.rec-line { display: flex; justify-content: space-between; background: #f9fafb;
  padding: 10px; border-radius: 8px; }
.rec-text { font-size: 18px; font-weight: 600; letter-spacing: 1px; }
.rec-score { font-size: 12px; color: #9aa1ab; }
.rec-summary { margin-top: 10px; font-size: 14px; color: #374151; word-break: break-all; }
.meta { margin-top: 8px; font-size: 12px; color: #9aa1ab; }
.muted { color: #9aa1ab; }
.error-box, .warn-box { padding: 12px; border-radius: 8px; font-size: 14px; margin-top: 8px; }
.error-box { background: #fef2f2; color: #dc2626; }
.warn-box { background: #fffbeb; color: #d97706; }

.loading {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 999; color: #fff; gap: 12px;
}
.spinner {
  width: 36px; height: 36px; border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 4 张照片网格 ---------- */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-slot {
  position: relative; aspect-ratio: 3 / 4; border: 1px dashed #cbd5e1;
  border-radius: 10px; overflow: hidden; background: #fafafa;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.photo-slot.bill-slot { aspect-ratio: 4 / 3; }
.photo-slot.bill-slot img { object-fit: contain; }
.photo-slot img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none;
}
.photo-slot:not(.empty) img { display: block; }
.photo-slot .slot-plus { font-size: 42px; color: #cbd5e1; font-weight: 300; line-height: 1; }
.photo-slot:not(.empty) .slot-plus { display: none; }
.photo-slot .slot-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 0; z-index: 2;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; text-align: center;
}
.slot-del {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; z-index: 3;
  border: none; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer; display: none;
}
.photo-slot:not(.empty) .slot-del { display: block; }

.rec-info { flex: 1; }
.rec-info .slot-label {
  position: static; display: inline-block; margin: 0 0 6px 0; padding: 2px 6px;
  background: #e8f0fe; color: #1a73e8; border-radius: 4px; font-size: 12px;
}

/* ---------- 顶部切换 ---------- */
.tabbar { display: flex; background: #fff; border-radius: 10px; padding: 4px; margin-bottom: 12px; gap: 4px; }
.tab { flex: 1; padding: 10px 0; border: none; border-radius: 8px; background: transparent; font-size: 14px; color: #6b7280; cursor: pointer; }
.tab.active { background: #1a73e8; color: #fff; font-weight: 600; }

/* ---------- 我的记录 ---------- */
.mine-list { display: flex; flex-direction: column; gap: 10px; }
.mine-item {
  display: flex; gap: 10px; background: #f9fafb; border-radius: 10px;
  padding: 10px; align-items: flex-start;
}
.mine-thumb { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: #e5e7eb; flex-shrink: 0; }
.mine-item.no-img .mine-thumb { display: none; }
.mine-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mine-top { display: flex; justify-content: space-between; align-items: center; }
.type-tag { background: #e8f0fe; color: #1a73e8; border-radius: 4px; font-size: 12px; padding: 2px 6px; flex-shrink: 0; }
.mine-time { font-size: 11px; color: #9aa1ab; }
.mine-head { font-size: 14px; font-weight: 600; color: #1f2937; word-break: break-all; }
.mine-meta { font-size: 12px; color: #6b7280; }
.mine-rec { font-size: 12px; color: #374151; word-break: break-all; }
.mine-rec .pending { color: #d97706; }
.empty-hint { color: #9aa1ab; font-size: 13px; text-align: center; padding: 20px 0; }

.auto-reset-tip { margin-top: 10px; font-weight: 600; color: #1a73e8; }

/* ---------- 图片放大查看 ---------- */
.img-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.img-viewer img {
  max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: #000;
}
.img-viewer-close {
  position: absolute; top: 14px; right: 16px; width: 40px; height: 40px;
  border: none; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff;
  font-size: 28px; line-height: 1; cursor: pointer;
}

/* ---------- 登录 / 修改密码 ---------- */
.login-overlay {
  position: fixed; inset: 0; background: #f2f4f7; z-index: 2000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.login-box {
  width: 100%; max-width: 340px; background: #fff; border-radius: 14px;
  padding: 28px 22px; box-shadow: 0 8px 30px rgba(0,0,0,.08);
  margin: auto; /* 内容高时正常滚动，键盘弹出时输入框可滚动到可视区 */
}
.login-box h2 { font-size: 20px; text-align: center; margin-bottom: 4px; color: #1a73e8; }
.login-sub { text-align: center; color: #9aa1ab; font-size: 13px; margin-bottom: 14px; }
.login-tabs { display: flex; background: #f2f4f7; border-radius: 10px; padding: 3px; margin-bottom: 14px; gap: 3px; }
.login-tab { flex: 1; padding: 8px 0; border: none; border-radius: 8px; background: transparent; font-size: 14px; color: #6b7280; cursor: pointer; }
.login-tab.active { background: #1a73e8; color: #fff; font-weight: 600; }
.login-box input {
  width: 100%; height: 44px; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 0 12px; font-size: 15px; margin-bottom: 10px;
}
.login-box input:focus { outline: none; border-color: #1a73e8; }
.login-box .result-ok { text-align: center; margin-top: 6px; }

/* ---------- 当前用户 ---------- */
.user-bar { display: flex; align-items: center; justify-content: space-between; }
.user-info { min-width: 0; }
.user-no { font-size: 16px; font-weight: 700; color: #1f2937; }
.user-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn.ghost { background: #fff; border: 1px solid #e5e7eb; color: #6b7280; }

/* ---------- 我的记录（按组，四张一记录） ---------- */
.mine-group { background: #fff; border-radius: 10px; padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.mine-group-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.mine-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.mine-photo { background: #f9fafb; border-radius: 8px; overflow: hidden; }
.mine-photo .mine-thumb { width: 100%; height: 110px; object-fit: cover; display: block; background: #e5e7eb; cursor: pointer; }
.mine-thumb.no-img { display: none; }
.mine-photo-body { padding: 6px 8px; }
.mine-photo-label { font-size: 12px; color: #1a73e8; font-weight: 600; }

/* ---------- 角色视图 / 闭环选择 / 车号查询 ---------- */
#loopSelect, #viewSampling select, #queryVehicleNo {
  width: 100%; height: 38px; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 0 10px; font-size: 14px; background: #fff; color: #1f2937;
}
.query-row { display: flex; gap: 8px; align-items: center; }
.query-row input {
  flex: 1; height: 40px; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 0 10px; font-size: 15px;
}
.query-row .btn { width: auto; margin-top: 0; padding: 0 18px; height: 40px; border-radius: 8px; }

/* ---------- 我的记录：磅单独占一行 + 识别字段分行 ---------- */
.mine-bill {
  position: relative; margin-top: 10px; border-radius: 8px; overflow: hidden;
  background: #f0f2f5; display: block;
}
.mine-bill-img {
  width: 100%; height: 200px; object-fit: contain; display: block; background: #f0f2f5;
  cursor: pointer;
}
.mine-bill-img.no-img { display: none; }
.mine-bill-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; text-align: center;
}
.mine-fields {
  margin-top: 8px; background: #fafbfc; border: 1px solid #eef0f3; border-radius: 8px;
  padding: 4px 10px; display: flex; flex-direction: column;
}
.mine-field {
  display: flex; align-items: center; padding: 6px 0;
  border-bottom: 1px dashed #eef0f3; font-size: 13px;
}
.mine-field:last-child { border-bottom: none; }
.mine-field-k { flex-shrink: 0; width: 92px; color: #9aa1ab; }
.mine-field-v { flex: 1; color: #1f2937; word-break: break-all; text-align: right; font-weight: 500; }

/* ---------- 我的记录：关联卸车记录（进厂卸车前）展示 ---------- */
.mine-unload-group { margin-top: 14px; padding-top: 14px; border-top: 1px dashed #e5e7eb; }
.mine-unload-label { font-size: 13px; font-weight: 600; color: #16a34a; margin-bottom: 2px; }
.mine-unload-group .mine-photos { margin-top: 8px; }