/* ============================================================
   代刷下单平台 · 移动端商城排版
   布局与图标尺寸对齐供货端风格（搜索栏 / 5 列分类 / 左图右文商品卡 / 底部导航）
   组件全部自研，无框架依赖
   ============================================================ */

:root {
  --primary: #007aff;          /* 主色，与 ios 蓝一致 */
  --price: #ff5555;            /* 价格红 */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #ededed;
  --text: #1a1a1a;
  --text-2: #666;
  --text-3: #999;
  --ok: #19be6b;
  --warn: #ff9900;
  --err: #ee0a24;
  --tab-h: 52px;
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

a { color: inherit; text-decoration: none; }
img { display: block; }

.page { max-width: 750px; margin: 0 auto; background: var(--bg); min-height: 100vh; }

/* ---------------- 顶部搜索栏 ---------------- */
.head {
  position: sticky; top: 0; z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.head-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
}
.shop-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; letter-spacing: -.2px;
}
.searchbox {
  flex: 1; min-width: 0; position: relative;
  display: flex; align-items: center;
  height: 34px; border-radius: 17px;
  background: #f2f3f5; padding: 0 12px 0 32px;
}
.searchbox svg { position: absolute; left: 11px; width: 15px; height: 15px; opacity: .45; }
.searchbox input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  font-size: 13.5px; color: var(--text); font-family: inherit; outline: none;
}
.searchbox input::placeholder { color: #b0b0b0; }
.searchbox .go {
  border: 0; background: var(--primary); color: #fff;
  height: 26px; padding: 0 12px; border-radius: 13px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}

/* 公告条 */
.notice-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px 9px; font-size: 12px; color: var(--text-2);
}
.notice-bar .tag {
  flex: 0 0 auto; color: var(--price); border: 1px solid rgba(255,85,85,.35);
  border-radius: 3px; padding: 0 4px; font-size: 10.5px; line-height: 15px;
}
.notice-bar .txt {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------------- 轮播 ---------------- */
.banner-wrap { background: #fff; padding: 0 0 4px; }
.banner {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 10px 12px; scrollbar-width: none;
}
.banner::-webkit-scrollbar { display: none; }
.banner-item {
  flex: 0 0 100%; scroll-snap-align: center;
  height: 120px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #007aff, #4da3ff);
  color: #fff; padding: 18px; display: flex; flex-direction: column; justify-content: center;
}
.banner-item .bt { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.banner-item .bs { font-size: 12.5px; opacity: .9; margin-top: 5px; }
.dots { display: flex; gap: 5px; justify-content: center; padding: 2px 0 8px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: #d8dbe0; transition: all .2s; }
.dots i.on { width: 14px; border-radius: 3px; background: var(--primary); }

/* ---------------- 分类网格（5 列 × 2 行 = 10 个/页，横向滑动翻页） ---------------- */
.cats-wrap {
  background: #fff; border-bottom: 1px solid var(--line);
  position: relative; padding-bottom: 6px;
}
.cats-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: 12px 0 2px;
}
.cats-track::-webkit-scrollbar { display: none; }
.cats-page {
  flex: 0 0 100%; width: 100%;
  display: grid; grid-template-columns: repeat(5, 1fr);
  row-gap: 4px; padding: 0 4px; scroll-snap-align: start;
}
.cat {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 2px; cursor: pointer; min-width: 0;
}
.cat:active { opacity: .6; }
.cat-icon {
  width: 45px; height: 45px; border-radius: 50%; overflow: hidden;
  background: #f2f3f5; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--primary); flex: 0 0 45px;
}
.cat-icon img { width: 100%; height: 100%; object-fit: cover; }
.cat-text {
  margin-top: 5px; font-size: 11.5px; color: var(--text);
  width: 100%; text-align: center; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat.on .cat-text { color: var(--price); font-weight: 600; }
.cat.on .cat-icon { box-shadow: 0 0 0 2px rgba(255,85,85,.45); }

.cats-dots { display: flex; gap: 5px; justify-content: center; padding: 4px 0 2px; }
.cats-dots i { width: 5px; height: 5px; border-radius: 50%; background: #dcdfe5; transition: all .2s; }
.cats-dots i.on { width: 14px; border-radius: 3px; background: var(--primary); }

/* ---------------- 二级分类横滑 ---------------- */
.subcats {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 4px;
  background: #fff; scrollbar-width: none;
}
.subcats::-webkit-scrollbar { display: none; }
.subcat {
  flex: 0 0 auto; padding: 5px 13px; border-radius: 14px;
  background: #f4f5f7; color: var(--text-2); font-size: 12.5px;
  cursor: pointer; white-space: nowrap;
}
.subcat.on { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------------- 商品列表（左图右文） ---------------- */
.goods { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 10px; }

.goods-item {
  display: flex; gap: 11px; padding: 11px;
  background: #fff; border-radius: 10px; cursor: pointer;
}
.goods-item:active { background: #fafafa; }
.goods-item.off { opacity: .55; }

.goods-img {
  flex: 0 0 92px; width: 92px; height: 92px; border-radius: 8px;
  overflow: hidden; background: #f2f3f5;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #c9ced6;
}
.goods-img img { width: 100%; height: 100%; object-fit: cover; }

.goods-detail {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
}
.goods-name {
  font-size: 14px; line-height: 1.45; color: #000; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 40px;
}
.goods-meta {
  display: flex; gap: 5px; flex-wrap: wrap; align-items: center;
  margin-top: 4px;
}
.goods-foot {
  display: flex; align-items: flex-end; gap: 8px; margin-top: auto; padding-top: 4px;
}
.goods-price {
  color: var(--price); font-size: 17.5px; font-weight: 700;
  letter-spacing: -.4px; line-height: 1;
}
.goods-price small { font-size: 11.5px; font-weight: 400; color: var(--text-3); margin-left: 2px; letter-spacing: 0; }
.goods-stock { font-size: 11.5px; color: var(--text-3); }
.goods-buy {
  margin-left: auto; flex: 0 0 auto;
  background: var(--price); color: #fff;
  font-size: 12.5px; font-weight: 600;
  height: 27px; padding: 0 13px; border-radius: 14px; border: 0;
  display: inline-flex; align-items: center; cursor: pointer;
  font-family: inherit;
}
.goods-buy.off { background: #c0c0c0; }

.mini {
  font-size: 10.5px; padding: 0 5px; line-height: 16px; border-radius: 3px;
  background: #f2f3f5; color: var(--text-2); white-space: nowrap;
}
.mini.ok { background: rgba(25,190,107,.1); color: var(--ok); }
.mini.warn { background: rgba(255,153,0,.12); color: var(--warn); }
.mini.err { background: rgba(238,10,36,.1); color: var(--err); }
.mini.brand { background: rgba(0,122,255,.1); color: var(--primary); }

/* 加载 / 空状态 */
.loading-tip { text-align: center; color: var(--text-3); font-size: 13px; padding: 22px 0; }
.empty { text-align: center; color: var(--text-3); padding: 60px 20px; }
.empty-ico { font-size: 40px; opacity: .3; margin-bottom: 10px; }
.more-btn {
  display: block; width: calc(100% - 24px); margin: 14px auto 0;
  height: 40px; border: 0; border-radius: 20px; background: #fff;
  color: var(--text-2); font-size: 13.5px; cursor: pointer; font-family: inherit;
}

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.97);
  backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
}
.tabbar-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-3); font-size: 10.5px; cursor: pointer;
}
.tabbar-item svg { width: 21px; height: 21px; }
.tabbar-item.on { color: var(--primary); }

/* ---------------- 表单 ---------------- */
.form-card { background: #fff; margin: 10px 12px; border-radius: 10px; padding: 14px; }
.field { display: block; margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field .lb { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.field .lb b { color: var(--price); font-weight: 400; margin-left: 2px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid #e3e5e8; border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fafbfc; outline: none; transition: border-color .15s, background .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--primary); background: #fff;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.field input::placeholder, .field textarea::placeholder { color: #b0b0b0; }
.tip { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px; padding: 0 20px; border: 0; border-radius: 21px;
  background: var(--primary); color: #fff;
  font-size: 14.5px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn:active { opacity: .85; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.btn.ghost { background: #f2f3f5; color: var(--text); }
.btn.sm { height: 30px; padding: 0 13px; font-size: 12.5px; border-radius: 15px; }
.btn.pay { background: var(--price); }

/* 底部结算条 */
.buybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.buybar .sum { flex: 1; }
.buybar .sum .k { font-size: 11.5px; color: var(--text-3); }
.buybar .sum .v { color: var(--price); font-size: 21px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; }
.buybar .btn { flex: 0 0 auto; min-width: 130px; height: 42px; }

/* ---------------- 卡片 / 详情 ---------------- */
.card { background: #fff; margin: 10px 12px; border-radius: 10px; padding: 14px; }
.card-hd { display: flex; align-items: center; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; line-height: 1.45; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 10px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-all; }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 11px;
}
.status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.pending_pay { color: var(--warn); background: rgba(255,153,0,.1); }
.status.paid, .status.executing { color: var(--primary); background: rgba(0,122,255,.1); }
.status.placed { color: #7a5af8; background: rgba(122,90,248,.1); }
.status.processing { color: #0ba5ec; background: rgba(11,165,236,.1); }
.status.completed { color: var(--ok); background: rgba(25,190,107,.1); }
.status.failed, .status.manual { color: var(--err); background: rgba(238,10,36,.08); }
.status.refunded { color: var(--text-3); background: #f2f3f5; }

.notice {
  margin: 10px 12px; padding: 11px 13px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.55;
  background: rgba(0,122,255,.06); color: #0055b3; border: 1px solid rgba(0,122,255,.15);
}
.notice.ok { background: rgba(25,190,107,.07); color: #0d7a45; border-color: rgba(25,190,107,.2); }
.notice.warn { background: rgba(255,153,0,.08); color: #a86600; border-color: rgba(255,153,0,.22); }
.notice.err { background: rgba(238,10,36,.06); color: #b3001b; border-color: rgba(238,10,36,.18); }

.section-title { font-size: 12.5px; color: var(--text-3); margin: 16px 14px 8px; }

.foot {
  text-align: center; color: var(--text-3); font-size: 11.5px;
  padding: 26px 20px calc(26px + var(--tab-h)); line-height: 1.7;
}

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.mask.hide { display: none; }
.sheet {
  width: 100%; max-width: 750px; background: #fff;
  border-radius: 16px 16px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow: auto;
}
.sheet h3 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px);
  transform: translate(-50%, 12px);
  background: rgba(0,0,0,.82); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 13.5px; z-index: 300;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 桌面端居中 ---------------- */
@media (min-width: 751px) {
  body { background: #e9ebef; }
  .page { box-shadow: 0 0 40px rgba(0,0,0,.08); }
  .tabbar, .buybar { max-width: 750px; margin: 0 auto; }
  .goods { display: grid; grid-template-columns: 1fr 1fr; }
}

.hide { display: none !important; }
.dim { color: var(--text-3); }
.center { text-align: center; }

/* ============================================================
   管理后台（沿用同一套设计 token）
   ============================================================ */
.admin-page { max-width: 1080px; margin: 0 auto; padding: 16px 14px 40px; }
.tabs { display: flex; gap: 2px; background: #fff; border-radius: 10px; padding: 4px; margin-bottom: 14px; overflow-x: auto; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 9px 15px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; border-radius: 8px; white-space: nowrap; }
.tab:hover { background: #f5f6f8; }
.tab.on { color: #fff; background: var(--primary); }

.panel { background: #fff; border-radius: 10px; padding: 16px; }
.panel + .panel { margin-top: 10px; }
.panel-pad { padding: 16px; }
.sec-title { font-size: 12.5px; color: var(--text-3); margin: 16px 2px 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #fff; border-radius: 10px; padding: 14px; }
.stat-k { font-size: 12px; color: var(--text-3); }
.stat-v { font-size: 21px; font-weight: 700; margin-top: 3px; letter-spacing: -.5px; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 10px 11px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.tbl th { font-size: 11.5px; font-weight: 600; color: var(--text-3); background: #fafbfc; white-space: nowrap; }
.tbl tr:hover td { background: #fafbfc; }

.log { max-height: 240px; overflow: auto; background: #f7f8fa; border-radius: 8px; padding: 11px; font-size: 11.5px; font-family: ui-monospace, Consolas, monospace; line-height: 1.7; color: var(--text-2); }
.inp { height: 36px; padding: 0 11px; border: 1px solid #e3e5e8; border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fafbfc; color: var(--text); }
.inp:focus { outline: none; border-color: var(--primary); background: #fff; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.sheet .kv { font-size: 13px; }
