/* 仓库入库计数 PWA —— 移动端优先样式 */
:root {
  --green-700: #166534;
  --green-600: #15803d;
  --green-100: #dcfce7;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --border: #e5e7eb;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(64px + var(--safe-bottom));
  overscroll-behavior-y: none;
}

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
}
.app-title { font-size: 18px; font-weight: 700; }
.app-sub { font-size: 12px; opacity: .85; }

/* ---------- 主区域 ---------- */
.app-main { padding: 12px; }

.tab { display: none; }
.tab.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: .3; } to { opacity: 1; } }

.banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h3 {
  font-size: 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  background: var(--green-100);
  color: var(--green-700);
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.field input, .field select {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 16px; /* 避免 iOS 聚焦自动放大 */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  appearance: auto;
}
.field input:focus, .field select:focus { outline: 2px solid var(--green-600); outline-offset: 0; border-color: transparent; }

.tip { font-size: 12px; color: var(--muted); margin: 6px 0; }
.tip-box {
  background: var(--green-100);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--green-700);
}
.tip-box p { margin: 4px 0; }

.row { display: flex; gap: 8px; margin-top: 4px; }
.grow { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  font-size: 15px;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform .06s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--green-600); color: #fff; }
.btn.ghost { background: #fff; color: var(--green-700); border: 1px solid var(--green-600); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.block { display: block; width: 100%; margin-bottom: 10px; }

.mini {
  font-size: 13px;
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  background: var(--green-600);
  color: #fff;
}
.mini.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- 出入库切换 ---------- */
.seg { display: flex; border: 1px solid var(--green-600); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.seg-btn {
  flex: 1; padding: 10px 0; border: none; background: #fff; color: var(--green-700);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--green-600); }
.seg-btn.active { background: var(--green-600); color: #fff; }
.seg-btn:active { transform: scale(.98); }

/* 记录业务类型徽章 */
.rec-kind { font-size: 11px; padding: 1px 6px; border-radius: 5px; font-weight: 600; }
.rec-kind.in { background: var(--green-100); color: var(--green-700); }
.rec-kind.out { background: #fff3cd; color: #8a6d1a; }

/* ---------- 今日汇总 ---------- */
.agg-row { border-bottom: 1px solid var(--border); padding: 8px 0; }
.agg-row:last-child { border-bottom: none; }
.agg-main { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.agg-name { font-weight: 600; flex: 1; }
.agg-total { color: var(--green-700); font-weight: 700; font-size: 15px; }
.agg-caret { color: var(--muted); font-size: 12px; }
.agg-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.agg-detail { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
.agg-detail-line { font-size: 13px; padding: 2px 0; color: #374151; }

/* ---------- 记录列表 ---------- */
.query-summary { font-size: 13px; color: var(--green-700); background: var(--green-100); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.rec { border-bottom: 1px solid var(--border); padding: 8px 0; }
.rec:last-child { border-bottom: none; }
.rec-main { display: flex; align-items: center; gap: 8px; }
.rec-name { font-weight: 600; }
.rec-sub { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.rec-ops { display: flex; align-items: center; gap: 8px; }
.rec-num { width: 90px; font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; }
.rec-num-static { font-size: 14px; font-weight: 600; color: #374151; }
.rec-lock { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 999px; }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0; }

/* ---------- 导出统计 ---------- */
.stat-line { font-size: 14px; padding: 4px 0; }
.stat-line b { color: var(--green-700); }

/* ---------- 档案 ---------- */
.search { width: 100%; font-size: 15px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.goods-item {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.goods-item:last-child { border-bottom: none; }
.goods-item b { font-size: 14px; }
.goods-meta { font-size: 12px; color: var(--muted); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
  z-index: 30;
}
.tabbar button {
  flex: 1;
  border: none;
  background: none;
  font-size: 13px;
  padding: 12px 0 10px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.tabbar button.active { color: var(--green-700); font-weight: 700; }
.tabbar button.active::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 6px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--green-600);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(17, 24, 39, .92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 24px;
}
.modal.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 340px;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-msg { font-size: 14px; color: #374151; white-space: pre-line; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions .btn { flex: 1; }
