:root {
  --primary: #1F4E78;
  --primary-2: #2563EB;
  --ok: #15803D;
  --ok-bg: #DCFCE7;
  --warn: #B45309;
  --warn-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --bg: #F3F5F9;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --line: #E5E7EB;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.45; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); min-height: 20px; margin-top: 8px; font-size: 13px; }
.warn-text { color: var(--warn); }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; }
.grow { flex: 1; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 17px; }
h3 { font-size: 16px; }

/* ---------- 登录 ---------- */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border-radius: 20px; padding: 32px 24px; width: 100%; max-width: 360px;
  box-shadow: 0 10px 40px rgba(31, 78, 120, .15); text-align: center; }
.login-card .logo { font-size: 44px; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; color: var(--primary); }
.login-card input { width: 100%; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 16px; }
.block { width: 100%; margin-top: 12px; }

/* ---------- 顶栏 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.store-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 12px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; text-align: left; flex: 1; min-width: 0; }
.store-icon { font-size: 22px; }
.store-text { display: flex; flex-direction: column; min-width: 0; }
.store-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-hint { font-size: 11px; opacity: .8; }
.icon-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 12px; width: 42px; height: 42px; font-size: 22px; }

main { padding: 12px 12px calc(84px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); margin-bottom: 12px; }

/* ---------- 拍摄区 ---------- */
.btn-shutter-big { width: 100%; margin: 12px 0 10px; border: 0; border-radius: 16px; padding: 16px;
  background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; display: flex; align-items: center; gap: 14px; text-align: left;
  box-shadow: 0 8px 22px rgba(37, 99, 235, .3); }
.btn-shutter-big:active { transform: scale(.985); }
.big-icon { font-size: 34px; }
.big-text { display: flex; flex-direction: column; }
.big-text b { font-size: 19px; }
.big-text small { opacity: .9; font-size: 12px; }
.btn-secondary { display: inline-flex; justify-content: center; align-items: center; padding: 11px; border-radius: 12px;
  border: 1px solid var(--line); background: #F9FAFB; color: var(--text); font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: #F8FAFC; border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; color: var(--primary); }
.stat span { font-size: 11px; color: var(--muted); }
.stat.ok b { color: var(--ok); }
.stat.warn b { color: var(--danger); }
.size-line { margin-top: 10px; font-size: 12px; }
.thumb-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.thumb-strip:empty { display: none; }
.thumb { position: relative; flex: 0 0 auto; width: 74px; height: 74px; border-radius: 10px; overflow: hidden; background: #E5E7EB; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; padding: 2px 0; color: #fff; background: rgba(17,24,39,.75); }
.thumb.pending .badge { background: rgba(107,114,128,.85); }
.thumb.uploading .badge { background: rgba(37,99,235,.9); }
.thumb.failed .badge { background: rgba(185,28,28,.9); }
.thumb.done .badge { background: rgba(21,128,61,.9); }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 6px; background: #E9EDF3; padding: 4px; border-radius: 12px; margin-bottom: 10px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #E5E7EB; font-size: 12px; margin-left: 4px; }
.tab.active .count { background: var(--primary); color: #fff; }

.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.chips { display: flex; gap: 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

.list { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; background: var(--card); border-radius: var(--radius); }
.empty .ico { font-size: 34px; }

/* ---------- 商品卡片 ---------- */
.item { display: flex; gap: 10px; background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); border-left: 4px solid transparent; }
.item.review { border-left-color: #F59E0B; }
.item.reviewed { border-left-color: var(--ok); }
.item .pic { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #E5E7EB; flex: 0 0 auto; }
.item .body { flex: 1; min-width: 0; }
.item .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.item .name { font-weight: 700; font-size: 15px; word-break: break-all; }
.item .price { font-weight: 800; color: var(--danger); white-space: nowrap; font-size: 17px; }
.item .price small { font-size: 12px; font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #F1F5F9; color: #334155; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.soft { background: #EEF2FF; color: #3730A3; }
.pill.promo { background: #FCE7F3; color: #9D174D; }
.item { cursor: pointer; }
.item:active { background: #F8FAFC; }
.item .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 11px; color: var(--muted); gap: 8px; flex-wrap: wrap; }
.item .actions { display: flex; gap: 8px; margin-left: auto; }
.link { color: var(--primary-2); font-weight: 600; background: none; border: 0; padding: 0; font-size: 13px; }
/* 手机上可点的操作一律做成 ≥40px 高的大按钮 */
.btn-sm { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid #C7D7F5; background: #EFF6FF; color: var(--primary-2); font-weight: 700; font-size: 14px; }
.btn-sm.ok { background: var(--ok-bg); color: var(--ok); border-color: #A7E3BE; }
.btn-sm.danger { background: var(--danger-bg); color: var(--danger); border-color: #F5B5B5; }
.btn-sm:active { transform: scale(.97); }
.item .pic { width: 84px; height: 84px; }
.btn-link { width: 100%; margin-top: 10px; padding: 12px; background: transparent; border: 1px dashed #CBD5E1; border-radius: 12px; color: var(--primary-2); font-weight: 600; }

/* ---------- 照片行 ---------- */
.photo { display: flex; gap: 10px; background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); align-items: center; }
.photo .pic { width: 70px; height: 70px; border-radius: 10px; object-fit: cover; background: #E5E7EB; flex: 0 0 auto; }
.photo .body { flex: 1; min-width: 0; font-size: 13px; }
.photo .fn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo .errmsg { color: var(--danger); font-size: 12px; margin-top: 4px; word-break: break-all; }

/* ---------- 底栏 ---------- */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + var(--safe-bottom)); display: flex; justify-content: space-between; align-items: center; gap: 10px; z-index: 20; }
.foot-stats { font-size: 13px; color: var(--muted); }
.foot-stats b { color: var(--text); font-size: 16px; }
.btn-primary { background: var(--primary-2); color: #fff; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; }
.btn-primary:disabled { opacity: .5; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; }

/* ---------- 相机 ---------- */
.camera { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(rgba(0,0,0,.55), transparent); }
.cam-badge { background: rgba(255,255,255,.18); color: #fff; padding: 6px 10px; border-radius: 20px; font-size: 13px; font-weight: 600; backdrop-filter: blur(6px); }
.cam-badge.soft { opacity: .9; font-weight: 500; }
.cam-badge:empty { display: none; }
.cam-done { margin-left: auto; background: #fff; color: #000; border: 0; border-radius: 20px; padding: 8px 16px; font-weight: 700; }
.cam-hint { position: absolute; bottom: 150px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.85); font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 24px calc(28px + var(--safe-bottom)); display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.35); }
.shutter:active { background: #fff; transform: scale(.94); }
.cam-last { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: rgba(255,255,255,.15); border: 2px solid rgba(255,255,255,.5); }
.cam-last img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-small { width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: #fff; font-size: 12px; line-height: 1.2; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .12s; }
.flash.on { opacity: .85; }

/* ---------- 底部弹层 ---------- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + var(--safe-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.close { border: 0; background: #F1F5F9; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; }
.store-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.store-row { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #F9FAFB; }
.store-row.active { border-color: var(--primary-2); background: #EFF6FF; }
.store-row .sname { font-weight: 700; flex: 1; }
.store-row .smeta { font-size: 12px; color: var(--muted); }
.sheet input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; margin-top: 4px; font-size: 16px; }
.sheet input:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.sheet label small { display: block; margin-top: 3px; }
.sheet-actions { margin-top: 6px; }
.edit-photo { position: relative; margin-bottom: 10px; border-radius: 12px; overflow: hidden; background: #111; }
.edit-crop { position: relative; width: 100%; height: 34vh; min-height: 180px; max-height: 320px; overflow: hidden; cursor: zoom-in; touch-action: manipulation; }
.edit-crop img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.edit-crop.fit img { position: static; width: 100%; height: 100%; object-fit: contain; }
.tag-box { position: absolute; border: 3px solid #FACC15; border-radius: 4px; box-shadow: 0 0 0 2px rgba(0,0,0,.45), 0 0 18px rgba(250,204,21,.7); pointer-events: none; }
.edit-photo .zoom-hint { position: absolute; right: 8px; bottom: 8px; font-size: 11px; color: #fff; background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 10px; pointer-events: none; }

/* 原图查看器 */
.viewer { position: fixed; inset: 0; z-index: 55; background: #000; display: flex; flex-direction: column; color: #fff; }  /* 在弹层(40)/相机(50)之上、toast(60)之下 */
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; background: rgba(0,0,0,.6); z-index: 2; }
.viewer-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.viewer-btn { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.viewer-btn.strong { background: #fff; color: #111; }
.viewer-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.viewer-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.viewer-canvas img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.viewer-canvas .tag-box { display: flex; align-items: flex-end; }
.viewer-canvas .tag-box span { transform: translateY(100%); background: #FACC15; color: #111; font-weight: 700; padding: 1px 4px; border-radius: 0 0 4px 4px; white-space: nowrap; max-width: 180%; overflow: hidden; text-overflow: ellipsis; }
#editPhotoActions .btn-sm { white-space: nowrap; padding: 10px 6px; }
.viewer-hint { position: absolute; left: 50%; bottom: calc(14px + var(--safe-bottom)); transform: translateX(-50%); font-size: 12px; color: rgba(255,255,255,.85); background: rgba(0,0,0,.5); padding: 5px 10px; border-radius: 10px; pointer-events: none; white-space: nowrap; }
details { margin: 4px 0 10px; }
details summary { color: var(--primary-2); font-size: 13px; cursor: pointer; }
pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: #F8FAFC; padding: 10px; border-radius: 10px; color: #334155; }
.menu-item { width: 100%; text-align: left; padding: 14px; border: 0; background: #F9FAFB; border-radius: 12px; margin-bottom: 8px; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%); background: rgba(17,24,39,.92); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; max-width: 90vw; text-align: center; }

@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
}
