/* h5-stock 移动端样式：大按钮、大输入框，车间单手操作友好 */
:root {
  --primary: #1f6feb;
  --primary-dark: #1a5fd0;
  --danger: #d93025;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a9099;
  --line: #e5e7eb;
  --up: #d93025;    /* 增加/涨 → 红（国内习惯） */
  --down: #188038;  /* 减少/跌 → 绿 */
  --entry: #1f6feb;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: 64px;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  padding: 14px 12px;
}

/* 视图容器 */
#views { max-width: 640px; margin: 0 auto; padding: 12px; }
.view { display: none; }
.view.active { display: block; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; color: var(--text); }

/* 表单 */
.field { display: block; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  font-size: 16px; /* 防 iOS 自动放大 */
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

/* 按钮 */
.btn-primary, .btn-ghost {
  display: inline-block;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 18px;
  min-height: 48px;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { background: #a9c3f5; cursor: not-allowed; }
.btn-danger { background: var(--danger); }
.btn-ghost {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 14px;
  font-size: 15px;
}
.btn-block { display: block; width: 100%; }
.btn-submit { margin-bottom: 16px; }
.row-btns { display: flex; gap: 10px; margin-top: 12px; }
.row-btns .btn-primary { flex: 1; }

/* 拍照盒 */
.photo-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px dashed #c4ccd9;
  border-radius: 10px;
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 12px;
}
.photo-box.small { aspect-ratio: 16 / 10; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-hint { color: var(--muted); font-size: 15px; text-align: center; line-height: 1.6; }
.photo-hint small { font-size: 12px; }

/* 录入行 */
.entry-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fafbfc;
}
.entry-row-line { display: flex; gap: 8px; align-items: center; }
.entry-row-line .in-color { flex: 2; }
.entry-row-line .in-qty { flex: 1; }
.entry-row-line input {
  font-size: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  background: #fff;
}
.row-del {
  border: none;
  background: #fee;
  color: var(--danger);
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
/* 下拉选择器（尺码 / 颜色共用） */
.size-picker, .color-picker { position: relative; margin-top: 8px; }
.size-picker-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.size-picker-arrow { color: var(--muted); font-size: 12px; }
.size-menu {
  display: none;
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  padding: 8px;
}
.size-menu.open { display: block; }
.size-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.size-opt {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.size-opt.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.size-custom {
  width: 100%;
  margin-top: 8px;
  border: 1px dashed var(--line);
  background: #fafbfc;
  border-radius: 8px;
  padding: 9px 0;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
}
.entry-row .in-size {
  width: 100%;
  font-size: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 8px;
}

/* 款式卡片 */
.style-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}
.style-card:active { background: #eef3fb; }
.style-card.static { cursor: default; box-shadow: none; border: 1px solid var(--line); }
.style-card img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #eef0f3; }
.style-card-body { flex: 1; min-width: 0; }
.style-card-name { font-size: 16px; font-weight: 600; }
.style-card-zone { font-size: 13px; color: var(--muted); margin-top: 2px; }
.style-card-go { font-size: 24px; color: #c4ccd9; }

/* 颜色尺码选择 */
.combo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.combo {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  min-height: 48px;
}
.combo b { display: block; font-size: 15px; }
.combo span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.combo.on { border-color: var(--primary); background: #eef3fb; }
.combo.on b { color: var(--primary); }

.stock-hint {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  background: #f3f5f8;
  border-radius: 8px;
  padding: 10px;
}

/* 区域 */
.zone-card {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.zone-l1 { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.zone-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef0f3;
  flex-shrink: 0;
}
.zone-thumb.no-img { visibility: hidden; }
.zone-children { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.zone-child {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  font-size: 15px;
  cursor: pointer;
  background: #fafbfc;
}
.zone-child:active { background: #eef3fb; }
.zone-child .zone-thumb { width: 40px; height: 40px; }
.zone-nokid { font-size: 13px; color: var(--muted); }
.zone-item {
  display: flex;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.zone-item img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #eef0f3; }
.combo-text { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; }

/* 流水 */
.log-row {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.log-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-action { font-size: 12px; color: #fff; border-radius: 4px; padding: 2px 6px; flex-shrink: 0; }
.log-action.log-entry { background: var(--entry); }
.log-action.log-up { background: var(--up); }
.log-action.log-down { background: var(--down); }
.log-style { font-size: 15px; font-weight: 600; }
.log-zone { font-size: 12px; color: var(--muted); }
.log-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.log-time { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.log-time b { font-size: 15px; }
.log-time b.log-up { color: var(--up); }
.log-time b.log-down { color: var(--down); }
.log-time b.log-entry { color: var(--entry); }

/* 空状态 */
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 32px 16px; line-height: 1.8; }

/* 底部 Tab */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  padding: 12px 0 calc(10px + env(safe-area-inset-bottom));
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--primary); font-weight: 700; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 35, 41, 0.92);
  color: #fff;
  font-size: 15px;
  border-radius: 10px;
  padding: 10px 18px;
  max-width: 82vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(217, 48, 37, 0.95); }

/* ---------- 通用弹层（遮罩 + 居中卡片 + 右上角 ×，点遮罩可关闭） ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 28, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.18s;
}
.modal-overlay.open { opacity: 1; }
.modal-card {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.18s;
}
.modal-overlay.open .modal-card { transform: none; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
}
.modal-title { font-size: 17px; font-weight: 700; min-width: 0; }
.modal-close {
  border: none;
  background: #f3f5f8;
  color: var(--muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:active { background: #e8ebef; }
.modal-body {
  padding: 4px 16px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
.modal-foot .btn-primary { flex: 1; }
.modal-foot-inner { display: flex; gap: 10px; width: 100%; }
.modal-foot-inner .btn-primary { flex: 1; }
.modal-input {
  width: 100%;
  font-size: 16px; /* 防 iOS 自动放大 */
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  margin-top: 8px;
}
.modal-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.modal-desc { font-size: 13px; color: var(--muted); padding: 2px 0 10px; }
.size-menu-empty { font-size: 13px; color: var(--muted); padding: 10px 4px; line-height: 1.6; }

/* ---------- 查询区（流水 / 增加 / 减少 页共用） ---------- */
.query-name {
  width: 100%;
  font-size: 16px; /* 防 iOS 自动放大 */
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  margin-bottom: 10px;
}
.query-name:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.quick-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.quick-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 13px;
  min-height: 44px;
  cursor: pointer;
  color: var(--text);
}
.quick-btn.on { border-color: var(--primary); background: #eef3fb; color: var(--primary); font-weight: 600; }
.date-range { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.date-input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* 防 iOS 自动放大 */
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.date-sep { color: var(--muted); font-size: 13px; flex-shrink: 0; }
.query-btns { display: flex; gap: 10px; }
.query-btns .btn-primary { flex: 1; }

/* ---------- 录入：颜色管理 ---------- */
.color-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.color-empty { font-size: 13px; color: var(--muted); padding: 4px 0 10px; line-height: 1.7; }
.color-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef3fb;
  color: var(--primary);
  border: 1px solid #cfe0f8;
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
  font-size: 15px;
  font-weight: 600;
}
.color-tag-del {
  border: none;
  background: rgba(31, 111, 235, 0.15);
  color: var(--primary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.color-tag-del:active { background: rgba(31, 111, 235, 0.3); }
/* 录入行内的颜色下拉占满左侧，删除按钮靠右 */
.entry-row-line .color-picker { flex: 1; min-width: 0; margin-top: 0; }

/* ---------- 录入：尺码复选 + 每尺码数量 ---------- */
.size-check-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.size-check {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 0;
  font-size: 14px;
  min-height: 40px;
  cursor: pointer;
  color: var(--text);
}
.size-check.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.size-qty-list { margin-top: 10px; }
.size-qty-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.size-qty-row:last-child { margin-bottom: 0; }
.size-qty-label { width: 52px; font-size: 15px; font-weight: 600; flex-shrink: 0; }
.size-qty-row input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* 防 iOS 自动放大 */
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.size-qty-del {
  border: none;
  background: #fee;
  color: var(--danger);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- 区域：改名按钮 / 换区域选择 ---------- */
.zone-rename {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  border-radius: 8px;
  padding: 7px 12px;
  min-height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}
.zone-rename:active { background: #eef3fb; }
.zone-child .zone-rename { padding: 5px 10px; font-size: 12px; min-height: 32px; }
.zone-group { margin-bottom: 14px; }
.zone-group:last-child { margin-bottom: 0; }
.zone-group-title { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.zone-opt {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  min-height: 48px;
  cursor: pointer;
  margin-bottom: 6px;
  color: var(--text);
}
.zone-opt:last-child { margin-bottom: 0; }
.zone-opt.on { border-color: var(--primary); background: #eef3fb; color: var(--primary); font-weight: 600; }
.zone-opt.cur { border-style: dashed; }
.zone-opt.cur::after { content: '（当前）'; font-size: 12px; color: var(--muted); margin-left: 8px; font-weight: 400; }

/* ---------- 弹层内流水行补充 ---------- */
.log-sub-inline { font-size: 14px; }
