:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --bd: #e3e6eb;
  --txt: #1c1f23;
  --sub: #6b7280;
  --pri: #2563eb;
  --pri-d: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --r: 10px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--pri); text-decoration: none; }

/* 顶栏 */
.top {
  background: #fff; border-bottom: 1px solid var(--bd);
  padding: 12px 16px; position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
}
.top h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; }
.top .who { font-size: 13px; color: var(--sub); }
.top a.out {
  font-size: 13px; color: var(--sub); border: 1px solid var(--bd);
  padding: 5px 11px; border-radius: 999px;
}

/* 容器 */
.wrap { max-width: 900px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 460px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--bd);
  border-radius: var(--r); padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.card h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 600; color: var(--sub); }

/* 表单 */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--bd);
  border-radius: 8px; font-size: 15px; font-family: inherit;
  background: #fff; color: var(--txt); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { min-height: 72px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* 按钮 */
button, .btn {
  display: inline-block; width: 100%; padding: 12px 16px; border: 0;
  border-radius: 8px; background: var(--pri); color: #fff; font-size: 15px;
  font-family: inherit; font-weight: 500; cursor: pointer; text-align: center;
}
button:hover, .btn:hover { background: var(--pri-d); }
.btn.ghost { background: #fff; color: var(--txt); border: 1px solid var(--bd); }
.btn.ghost:hover { background: #f6f7f9; }
.btn.ok { background: var(--ok); }
.btn.warn { background: var(--warn); }
.btn.err { background: var(--err); }
.btn.sm { padding: 7px 12px; font-size: 13px; width: auto; }
.btn.xs { padding: 5px 10px; font-size: 12px; width: auto; border-radius: 6px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row .btn.sm { flex: 0 0 auto; }

/* 提示 */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: #dcfce7; color: #166534; }
.flash.err { background: #fee2e2; color: #991b1b; }
.flash.warn { background: #fef3c7; color: #92400e; }
.hint { font-size: 12.5px; color: var(--sub); line-height: 1.7; }

/* 提示条 */
.notice {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px;
}
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* 商品卡 */
.goods { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.g {
  background: #fff; border: 1px solid var(--bd); border-radius: var(--r);
  overflow: hidden; display: flex; flex-direction: column;
}
.g .ph {
  aspect-ratio: 4/3; background: #eef1f5; display: flex; align-items: center;
  justify-content: center; color: #b6bdc7; font-size: 26px; overflow: hidden;
}
.g .ph img { width: 100%; height: 100%; object-fit: cover; }
.g .body { padding: 10px 11px 12px; flex: 1; display: flex; flex-direction: column; }
.g .nm { font-size: 14px; font-weight: 500; margin-bottom: 3px; line-height: 1.4; }
.g .sp { font-size: 12px; color: var(--sub); margin-bottom: 7px; }
.g .pr { font-size: 16px; color: #dc2626; font-weight: 600; margin-bottom: 9px; }
.g .pr small { font-size: 11.5px; color: var(--sub); font-weight: 400; }
.g .act { margin-top: auto; }
.g .tag {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: #f1f5f9; color: #64748b; margin-bottom: 5px;
}

/* 分类条 */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 6px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 0 0 auto; padding: 7px 15px; border-radius: 999px; font-size: 13.5px;
  background: #fff; border: 1px solid var(--bd); color: var(--sub);
}
.tabs a.on { background: var(--pri); border-color: var(--pri); color: #fff; }

/* 表格 */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; border: 1px solid var(--bd); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; min-width: 520px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid #eef0f3; white-space: nowrap; }
th { background: #f7f9fb; font-weight: 600; color: #475569; font-size: 12.5px; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* 购物车行 */
.ci { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eef0f3; }
.ci:last-child { border-bottom: 0; }
.ci .im { width: 52px; height: 52px; border-radius: 8px; background: #eef1f5; object-fit: cover; flex: 0 0 auto; display:flex; align-items:center; justify-content:center; color:#b6bdc7; }
.ci .info { flex: 1; min-width: 0; }
.ci .nm { font-size: 14px; font-weight: 500; }
.ci .sp { font-size: 12px; color: var(--sub); }
.ci .ctl { display: flex; align-items: center; gap: 8px; }
.ci .ctl button { width: 30px; height: 30px; padding: 0; border-radius: 6px; background: #f1f5f9; color: #334155; font-size: 16px; }
.ci .ctl button:hover { background: #e2e8f0; }
.ci .ctl input { width: 56px; text-align: center; padding: 6px 4px; }
.qtybox { display: inline-flex; align-items: center; gap: 6px; }
.qtybox button { width: 32px; height: 32px; padding: 0; border-radius: 6px; background: #f1f5f9; color: #334155; font-size: 17px; border:0; cursor:pointer; }
.qtybox button:hover { background: #e2e8f0; }
.qtybox input { width: 58px; text-align: center; padding: 5px 2px; }

/* 底部固定条 */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
  border-top: 1px solid var(--bd); padding: 11px 16px;
  display: flex; align-items: center; gap: 12px; z-index: 60;
  padding-bottom: calc(11px + env(safe-area-inset-bottom));
}
.bottom .info { flex: 1; }
.bottom .t { font-size: 12px; color: var(--sub); }
.bottom .v { font-size: 19px; font-weight: 600; color: #dc2626; }
.bottom .btn { width: auto; padding: 12px 30px; }
.pad { height: 76px; }

/* 标签 */
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 5px; font-weight: 500; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.wait { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.info { background: #e0e7ff; color: #3730a3; }

/* 统计块 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 11px; margin-bottom: 16px; }
.st { background: #fff; border: 1px solid var(--bd); border-radius: var(--r); padding: 13px 15px; }
.st .k { font-size: 12px; color: var(--sub); }
.st .v { font-size: 22px; font-weight: 600; margin-top: 3px; }
.st .v small { font-size: 12px; color: var(--sub); font-weight: 400; margin-left: 3px; }

/* 登录页 */
.login-box { max-width: 380px; margin: 8vh auto; padding: 0 18px; }
.login-box .lg { text-align: center; margin-bottom: 22px; }
.login-box .lg .t { font-size: 21px; font-weight: 600; }
.login-box .lg .s { font-size: 13px; color: var(--sub); margin-top: 5px; }
.pin { letter-spacing: 5px; font-size: 19px !important; text-align: center; font-family: ui-monospace, monospace; }

/* 底栏导航 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
  border-top: 1px solid var(--bd); display: flex; z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; text-align: center; padding: 9px 4px 10px; font-size: 11px; color: var(--sub);
}
.nav a .ic { display: block; font-size: 18px; line-height: 1.35; }
.nav a.on { color: var(--pri); }
.nav a .badge-n {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px;
  background: var(--err); color: #fff; border-radius: 9px; font-size: 10.5px;
  padding: 0 4px; vertical-align: top; margin-left: 2px;
}

/* 后台子导航 */
.subnav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 4px; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: 0 0 auto; padding: 6px 13px; border-radius: 7px; font-size: 13px;
  background: #fff; border: 1px solid var(--bd); color: var(--sub);
}
.subnav a.on { background: #1f2937; border-color: #1f2937; color: #fff; }
