/* 贝乐盘存助手 网页版 — 移动优先样式 */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --danger: #d93025;
  --success: #188038;
  --warning: #b06000;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100vh; padding-bottom: 72px; }

/* ---------- 通用组件 ---------- */
button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
input, textarea { font: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #e0a3a0; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 10px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 6px; }
.hint-text { color: var(--text-secondary); font-size: 12px; margin-top: 4px; }
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e8f0fe;
  color: var(--primary);
  margin-left: 6px;
}
.tag.inspection { background: #fef3e0; color: var(--warning); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.topbar .title { font-size: 17px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; opacity: 0.9; white-space: nowrap; }
.topbar button { color: #fff; font-size: 14px; padding: 6px 8px; border-radius: 6px; }
.topbar button:active { background: rgba(255,255,255,0.2); }

/* ---------- Tab ---------- */
.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 50px; z-index: 15; }
.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 15px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 列表卡片 ---------- */
.list { padding: 6px 0 20px; }
.item-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 8px 10px;
  padding: 12px 14px;
}
.item-card .row-title { display: flex; align-items: center; font-size: 16px; font-weight: 600; }
.item-card .row-sub { color: var(--text-secondary); font-size: 13px; margin-top: 4px; line-height: 1.6; }
.item-card .row-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.item-card .row-meta .time { color: var(--text-secondary); font-size: 12px; }
.item-card .delete-btn { color: var(--danger); font-size: 13px; padding: 6px 10px; }
.item-card .row-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.row-qty { font-size: 14px; font-weight: 600; color: var(--primary); }

.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 14px;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  line-height: 56px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(26, 115, 232, 0.4);
  z-index: 30;
}
.fab:active { transform: scale(0.94); }

/* FAB 菜单 */
.fab-menu {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 31;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.fab-menu button {
  display: block;
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.fab-menu button:last-child { border-bottom: none; }

/* ---------- 弹层 / 弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.dialog {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.dialog-body { overflow-y: auto; flex: 1; min-height: 0; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 12px; padding-top: 12px; }

/* 底部浮层（扫码录入） */
.sheet {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.sheet-body { overflow-y: auto; padding: 16px; flex: 1; min-height: 0; }
.sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.sheet-handle { width: 40px; height: 4px; background: #ddd; border-radius: 2px; margin: 8px auto 0; }

/* 单选列表 */
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.radio-row:active { background: #f0f4fb; }
.radio-dot {
  width: 18px; height: 18px;
  border: 2px solid #c8ccd4;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.radio-row.selected .radio-dot { border-color: var(--primary); }
.radio-row.selected .radio-dot::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--primary);
}
.radio-row .label { font-size: 15px; }

/* 状态流布局（FlowRow 近似） */
.flow { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: #fff;
}
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 扫码页 ---------- */
.scan-page { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.scan-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: #fff;
  z-index: 60;
}
.scan-topbar button { color: #fff; font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.scan-topbar button:active { background: rgba(255,255,255,0.2); }
#reader { flex: 1; width: 100%; overflow: hidden; }
#reader video { width: 100%; height: 100%; object-fit: cover; }
.scan-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #000;
  color: #fff;
  z-index: 60;
}
.scan-bottom .count { font-size: 15px; }
.scan-bottom .btn { font-size: 13px; padding: 8px 12px; }
.scan-hint {
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  text-align: center;
  padding: 6px;
  background: rgba(255,255,255,0.08);
}

/* 拍照识别扫码页 */
.scan-photo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.photo-btn {
  background: #fff;
  border-radius: 20px;
  padding: 34px 28px;
  text-align: center;
  max-width: 280px;
  width: 100%;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  color: var(--text);
  display: block;
}
.photo-btn:active { transform: scale(0.97); }
.photo-icon { font-size: 54px; line-height: 1; margin-bottom: 14px; }
.photo-text { font-size: 19px; font-weight: 700; }
.photo-sub { color: var(--text-secondary); font-size: 13px; margin-top: 8px; line-height: 1.6; }

/* 扫码页顶栏手动输入按钮 */
.scan-topbar .manual-btn {
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.12);
}

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #e8f0fe 0%, var(--bg) 60%);
}
.auth-logo { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 24px; }
.auth-card { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 20px; }
.auth-tabs { display: flex; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 10px; text-align: center; color: var(--text-secondary); border-bottom: 2px solid transparent; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 行内编辑 ---------- */
.inline-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.inline-edit .input { flex: 1; }
.inline-edit span { font-size: 14px; color: var(--text-secondary); }

/* ---------- 搜索框 ---------- */
.search-bar { padding: 10px; background: #fff; border-bottom: 1px solid var(--border); }
.search-bar .input { border-radius: 20px; background: #f0f2f5; border: none; }

/* 弹窗内的门店搜索列表 */
.store-list { max-height: 40vh; overflow-y: auto; }
.store-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.store-item:last-child { border-bottom: none; }
.store-item .name { font-size: 15px; }
.store-item .group { font-size: 12px; color: var(--text-secondary); }
.store-warehouse { background: #fff8e6; border-radius: 8px; margin-bottom: 4px; }
.store-item.selected .radio-dot { border-color: var(--primary); }
.store-item.selected .radio-dot::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--primary);
}
.store-item .radio-dot { position: relative; }
.store-item:active { background: #f0f4fb; }

/* 已保存 Tab 多选（网页版简化：不实现多选，保持手机端一致体验） */
