/* styles.css —— 移动端优先、高对比度、适合超市环境 */
:root {
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #5b6472;
  --line: #d9dfe8;
  --primary: #0b3d91;
  --primary-dark: #082c69;
  --accent: #047857;
  --danger: #b42318;
  --shadow: 0 2px 10px rgba(16, 24, 40, .08);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.page { max-width: 640px; margin: 0 auto; padding: 12px 12px 128px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff;
  font-weight: 900; letter-spacing: -2px; font-size: 18px;
}
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--primary);
  border-radius: 10px; padding: 8px 14px; font-weight: 700;
}

.segmented {
  display: flex; gap: 6px; padding: 5px; margin-bottom: 12px;
  background: #e4e9f2; border-radius: 14px;
}
.seg {
  flex: 1; border: 0; border-radius: 10px; padding: 12px 6px;
  background: transparent; color: var(--muted); font-weight: 700;
}
.seg.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 800; color: var(--primary); margin-bottom: 10px; }
.title-row { display: flex; align-items: center; justify-content: space-between; }
.badge { font-size: 13px; font-weight: 700; color: var(--muted); background: #eef2f8; padding: 2px 10px; border-radius: 999px; }

.btn {
  border: 1px solid transparent; border-radius: 12px; padding: 11px 16px;
  font-weight: 800; min-height: 46px; transition: filter .12s ease;
}
.btn:active { filter: brightness(.92); }
.btn-lg { width: 100%; font-size: 19px; min-height: 58px; }
.btn-block { width: 100%; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.secondary { background: #edf2fa; color: var(--primary); border-color: #cfd9ea; }
.btn.danger-ghost { background: #fff; color: var(--danger); border-color: #f0c9c4; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

input, select {
  width: 100%; min-height: 46px; padding: 10px 12px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 11px; outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 61, 145, .12); }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 10px 0 5px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.manual-row { display: flex; gap: 8px; margin-top: 10px; }
.manual-row input { flex: 1; min-width: 0; }
.manual-row .btn { flex: 0 0 auto; white-space: nowrap; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.error-text { color: var(--danger); font-size: 13px; font-weight: 700; margin: 8px 0 0; }
.empty { color: var(--muted); text-align: center; padding: 18px 6px; margin: 0; font-size: 14px; }

.scanner-box { margin-top: 12px; }
#reader { width: 100%; background: #000; border-radius: 12px; overflow: hidden; }
#reader video { width: 100% !important; height: auto !important; display: block; }
#reader__dashboard_section_csr, #reader__header_message { display: none !important; }

.sync-status-row { margin-top: 12px; padding: 10px 12px; background: #f4f7fc; border-radius: 10px; font-size: 14px; }
.sync-status-row strong { color: var(--accent); }
.sync-status-row strong.error { color: var(--danger); }

/* 清单项 */
.cart-item { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-item:last-child { border-bottom: 0; }
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cart-controls { display: flex; align-items: center; gap: 5px; }
.qty-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #f4f7fc; color: var(--primary); font-weight: 800; font-size: 18px; line-height: 1;
}
.qty-input { width: 52px; min-height: 36px; padding: 4px; text-align: center; font-weight: 800; border-radius: 9px; }
.cart-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.cart-subtotal { font-weight: 800; white-space: nowrap; color: var(--accent); }
.del-btn { border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; padding: 2px 0; }

/* 紧凑列表（搜索结果 / 建档记录 / 价格表） */
.compact-list { margin-top: 8px; }
.compact-item {
  display: flex; align-items: center; gap: 8px; padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.compact-item:last-child { border-bottom: 0; }
.compact-item .grow { flex: 1; min-width: 0; }
.compact-item .line1 { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-item .line2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.compact-item .mini-btn {
  border: 1px solid #cfd9ea; background: #edf2fa; color: var(--primary);
  border-radius: 9px; padding: 7px 10px; font-size: 13px; font-weight: 700;
}
.compact-item .mini-btn.danger { color: var(--danger); border-color: #f0c9c4; background: #fff; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 640px; margin: 0 auto; padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(16, 24, 40, .1);
}
.total-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 15px; }
.total-row strong { font-size: 28px; color: var(--danger); font-variant-numeric: tabular-nums; }
.footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }

/* 弹窗 */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 16, 32, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  background: #fff; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom));
}
.modal h2 { margin: 0 0 8px; font-size: 19px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.instructions { padding-left: 20px; margin: 0; }
.instructions li { margin-bottom: 7px; }

.toast {
  position: fixed; left: 50%; bottom: calc(148px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 60; max-width: 88vw; background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow);
  text-align: center;
}

@media (min-width: 641px) {
  .page { padding-top: 20px; }
  .overlay { align-items: center; }
  .modal { border-radius: 18px; }
}
