/* ==========================================================================
   验货照片采集工具
   ========================================================================== */
:root {
  --brand: #2563eb;
  --brand-600: #1d4ed8;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --line: #e3e8f0;
  --bg: #f4f6fa;
  --card: #fff;
  --ok: #059669;
  --bad: #dc2626;
  --r: 14px;
  --sh: 0 1px 2px rgba(15,23,42,.05), 0 10px 28px -18px rgba(15,23,42,.28);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 92px;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
h2, p { margin: 0; }

.wrap { max-width: 980px; margin: 0 auto; padding: 18px 16px 24px; }

/* ---------- 顶部 ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, #3b82f6, #1d4ed8 65%);
  color: #fff; font-size: 16px; font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 8px 20px -10px rgba(37,99,235,.9);
}
.brand-txt b { display: block; font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand-txt small { display: block; font-size: 11.5px; color: var(--ink-4); margin-top: 1px; }
.counter {
  display: flex; align-items: baseline; gap: 2px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 5px 12px;
}
.counter b { font-size: 17px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.counter span { font-size: 11.5px; color: var(--ink-4); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--r); border: 1px solid rgba(15,23,42,.05);
  box-shadow: var(--sh); padding: 16px; margin-bottom: 16px;
}
.head-card { display: flex; gap: 18px; align-items: center; }
.fields { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr; gap: 12px; }
.fld { display: block; }
.fld span { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 5px; letter-spacing: .2px; }
.fld input {
  width: 100%; height: 42px; padding: 0 13px; border-radius: 10px;
  border: 1px solid var(--line); background: #fbfcfe; outline: none; font-size: 15px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.fld input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.fld input::placeholder { color: #b6c1d4; font-size: 14px; }

.prod { flex: none; width: 180px; }
.prod-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 5px; }
.prod-slot { width: 180px; height: 152px; }

/* ---------- 照片格 ---------- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 14.5px; font-weight: 700; }
.card-head p { font-size: 11.5px; color: var(--ink-4); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.slot {
  position: relative; display: flex; flex-direction: column;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: #fff; padding: 0; text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.slot:active { transform: scale(.995); }
.slot:hover { border-color: #c3d3ee; }

.slot .cap {
  flex: none; padding: 7px 10px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  background: #f7f9fd; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot .cap .no {
  font-size: 9.5px; font-weight: 700; color: var(--ink-4);
  background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
  flex: none;
}

.slot .box {
  position: relative; flex: 1; min-height: 118px; background: #fafbfe;
  display: flex; align-items: center; justify-content: center;
}
.slot .box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .ph { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #b6c1d4; }
.slot .ph svg { width: 24px; height: 24px; }
.slot .ph em { font-style: normal; font-size: 11px; }

.slot.filled { border-color: #d6e2f5; }
.slot.filled .box { background: #eef1f6; }
.slot .tag {
  position: absolute; right: 8px; bottom: 8px; display: none;
  font-size: 10px; font-weight: 600; color: #fff;
  background: rgba(15,23,42,.62); padding: 2px 8px; border-radius: 6px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.slot.filled .tag { display: block; }
.slot .del {
  position: absolute; top: 7px; right: 7px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15,23,42,.62); color: #fff; font-size: 14px; line-height: 1;
  display: none; place-items: center; z-index: 3;
}
.slot.filled .del { display: grid; }

/* 产品图大格 */
.prod-slot .box { min-height: 106px; }

/* ---------- 底部操作条 ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.94); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.dock-info { margin-right: auto; font-size: 12px; color: var(--ink-3); }
.dock-info b { color: var(--ink); font-weight: 700; }
.dock button { height: 44px; border-radius: 11px; padding: 0 18px; font-size: 14px; font-weight: 600; }
.ghost { background: #f1f4f9; color: var(--ink-2); }
.ghost:hover { background: #e8edf6; }
.primary {
  background: linear-gradient(180deg, #2f6bf0, #1d4ed8); color: #fff;
  box-shadow: 0 8px 18px -8px rgba(37,99,235,.8);
}
.primary:active { transform: scale(.99); }
.primary[disabled] { background: #cbd5e1; box-shadow: none; }

/* ---------- Toast / 遮罩 ---------- */
.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: 110px; z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(15,23,42,.92); color: #fff; font-size: 13px;
  padding: 9px 17px; border-radius: 10px; max-width: 80vw;
  animation: tin .2s ease;
}
.toast.err { background: rgba(185,28,28,.95); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.busy {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(15,23,42,.42); color: #fff; font-size: 13.5px; font-weight: 500;
}
.busy[hidden] { display: none; }
.busy i {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
@media (min-width: 760px) {
  .fields { grid-template-columns: 1fr 1fr 1fr; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .slot .box { min-height: 150px; }
}
@media (max-width: 759px) {
  .head-card { flex-direction: column; align-items: stretch; }
  .fields { width: 100%; }
  .prod, .prod-slot { width: 100%; }
  .prod-slot { height: 190px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .slot .box { min-height: 140px; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .wrap { padding: 14px 12px 20px; }
}

/* ==========================================================================
   多视图：编辑 / 列表 / 详情
   ========================================================================== */
.view[hidden] { display: none; }

.top-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: var(--ink-2);
  background: #fff; border: 1px solid var(--line);
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: #f7f9fd; border-color: #cbd8ee; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- 列表 ---------- */
.list-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid rgba(15,23,42,.05); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px; text-align: left; box-shadow: var(--sh);
  transition: transform .12s, border-color .15s;
}
.list-item:active { transform: scale(.995); }
.list-item:hover { border-color: #cddbf1; }
.li-main { flex: 1; min-width: 0; }
.li-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.li-top b { font-size: 15px; font-weight: 600; }
.li-count {
  flex: none; font-size: 11px; font-weight: 600; color: var(--brand);
  background: var(--brand-50); padding: 2px 8px; border-radius: 6px;
}
.li-sub {
  font-size: 12.5px; color: var(--ink-3); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.li-time { font-size: 11px; color: var(--ink-4); margin-top: 3px; }
.li-arrow { flex: none; font-size: 20px; color: #c7d0e0; }

.empty-box { text-align: center; padding: 56px 20px; color: var(--ink-4); }
.empty-box svg { width: 44px; height: 44px; opacity: .55; margin-bottom: 12px; }
.empty-box b { display: block; font-size: 14px; color: var(--ink-3); font-weight: 600; }
.empty-box span { display: block; font-size: 12px; line-height: 1.7; margin-top: 6px; }

/* ---------- 详情 ---------- */
.detail-head .dh-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.detail-head .dh-row:last-child { border-bottom: 0; }
.dh-row span { flex: none; font-size: 12.5px; color: var(--ink-3); }
.dh-row b { font-size: 13.5px; font-weight: 600; text-align: right; word-break: break-all; }

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.d-item {
  margin: 0; background: #fff; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(15,23,42,.06); box-shadow: var(--sh);
}
.d-item img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; cursor: zoom-in;
}
.d-ph {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1; color: #c2cee2; font-size: 12px; background: #fafbfe;
}
.d-item figcaption {
  padding: 7px 10px; font-size: 11.5px; color: var(--ink-2);
  border-top: 1px solid var(--line); background: #f7f9fd;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.d-item.is-empty { opacity: .72; }

/* ---------- 看大图 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; padding: 16px;
  background: rgba(8,13,23,.93);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (min-width: 760px) {
  .detail-grid { grid-template-columns: repeat(4, 1fr); }
}
