:root {
  --primary: #2f6fed;
  --primary-dark: #1f57c7;
  --red: #e5484d;
  --green: #30a46c;
  --orange: #f5a623;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #8a919c;
  --line: #e6e9ee;
  --radius: 12px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }

.view { min-height: 100vh; }

/* ---------------- 登录页 ---------------- */
#view-auth {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px 160px;
  background: linear-gradient(180deg, #e8f0ff 0%, var(--bg) 260px);
}

.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 18px;
  padding: 28px 22px;
  box-shadow: 0 6px 24px rgba(31, 87, 199, 0.08);
}

.logo { font-size: 44px; text-align: center; }
.auth-title { text-align: center; font-size: 22px; margin-top: 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 20px; }

.auth-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 10px 0;
  border-radius: 8px; font-size: 15px; color: var(--muted); cursor: pointer;
}
.auth-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.auth-form label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.auth-form input {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fafbfc;
}
.auth-form input:focus { outline: none; border-color: var(--primary); background: #fff; }
.auth-hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }

/* ---------------- 通用 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--primary); color: #fff;
}
.top-title { font-size: 17px; font-weight: 700; }
.top-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.btn.ghost { background: rgba(255,255,255,0.15); border: none; color: #fff; border-radius: 8px; padding: 7px 12px; }

.content { padding: 12px 12px 150px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05); margin-bottom: 10px;
}
.card-title { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.price { color: var(--red); font-weight: 700; }
.green { color: var(--green); }
.orange { color: var(--orange); }
.red { color: var(--red); }

.btn {
  border: none; border-radius: 10px; padding: 10px 14px; font-size: 14px;
  cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--primary); color: #fff; width: 100%; }
.btn.primary:active { background: var(--primary-dark); }
.btn.big { padding: 13px; font-size: 16px; margin-top: 16px; }
.btn.success { background: var(--green); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.plain { background: var(--bg); color: var(--text); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; background: #eef2f8; color: #5b6472; margin-right: 6px;
}
.tag.blue { background: #e7f0ff; color: var(--primary); }
.tag.red { background: #fdebec; color: var(--red); }
.tag.green { background: #e8f6ef; color: var(--green); }
.tag.orange { background: #fdf1df; color: #b7791f; }
.tag.gray { background: #f0f1f3; color: #6b7280; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; background: #fafbfc; font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); background: #fff; }
label.field { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }

.empty {
  text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px;
}
.empty .icon { font-size: 44px; display: block; margin-bottom: 12px; }

/* ---------------- 底部固定（导航 + 订货须知） ---------------- */
.bottom-fixed {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  max-width: 560px; margin: 0 auto;
}
.bottom-nav {
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; text-align: center; padding: 6px 0; background: none; border: none;
  font-size: 11px; color: var(--muted); cursor: pointer; font-family: inherit;
}
.nav-item .ico { font-size: 20px; display: block; margin-bottom: 2px; }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px;
  background: var(--red); color: #fff; border-radius: 9px; font-size: 10px;
  padding: 0 4px; margin-left: 2px; vertical-align: top;
}
.terms-bar {
  background: #fff7e8; color: #9a6b13; font-size: 10.5px; line-height: 1.5;
  padding: 5px 12px calc(5px + env(safe-area-inset-bottom));
  border-top: 1px solid #f5e6c4;
}

/* ---------------- 商品 ---------------- */
.prod-card { display: flex; gap: 12px; }
.prod-info { flex: 1; min-width: 0; }
.prod-name { font-size: 15px; font-weight: 600; }
.prod-meta { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.prod-tiers { font-size: 12px; color: #667085; margin-top: 6px; line-height: 1.5; }
.prod-price { font-size: 17px; }
.prod-right { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 8px; }
.stepper {
  display: inline-flex; align-items: center; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.stepper button { border: none; background: #f7f8fa; width: 30px; height: 30px; font-size: 16px; cursor: pointer; }
.stepper input { width: 42px; height: 30px; border: none; text-align: center; font-size: 14px; }
.stepper button:active { background: #e9ecf1; }

.notice {
  background: #fdf1df; color: #9a6b13; border-radius: 10px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 10px; line-height: 1.5;
}

.activity-banner {
  background: linear-gradient(120deg, #fef3d8, #ffe9c7);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
}
.activity-banner .name { font-weight: 700; font-size: 15px; color: #9a5b00; }
.activity-banner .time { font-size: 12px; color: #a56f1e; margin-top: 4px; }

/* ---------------- 购物车 ---------------- */
.cart-line { display: flex; align-items: center; gap: 10px; }
.cart-line .name { flex: 1; min-width: 0; font-size: 14px; }
.cart-summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; font-size: 15px;
}
.order-note { margin-top: 10px; }

/* ---------------- 订单 ---------------- */
.status-chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-待备货 { background: #e7f0ff; color: var(--primary); }
.status-待配送 { background: #fdf1df; color: #b7791f; }
.status-已完成 { background: #e8f6ef; color: var(--green); }
.status-作废 { background: #f0f1f3; color: #6b7280; }

.order-items { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.order-item { display: flex; justify-content: space-between; font-size: 13px; color: #3c4250; padding: 3px 0; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar .select { flex: 1; min-width: 110px; }

/* ---------------- 商家 ---------------- */
.admin-cards { display: flex; gap: 8px; margin-bottom: 12px; }
.admin-stat { flex: 1; background: #fff; border-radius: 10px; padding: 10px; text-align: center; }
.admin-stat .num { font-size: 20px; font-weight: 700; color: var(--primary); }
.admin-stat .label { font-size: 11px; color: var(--muted); margin-top: 2px; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }

.btn-group { display: flex; gap: 8px; }
.btn-group .btn { flex: 1; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 18px 18px 0 0; padding: 20px 18px 28px;
  animation: slideUp 0.18s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal .close { position: absolute; top: 14px; right: 14px; }

.tier-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.tier-row .input { flex: 1; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(17, 24, 39, 0.88); color: #fff; padding: 12px 18px;
  border-radius: 12px; font-size: 14px; z-index: 300; max-width: 80vw;
  text-align: center; line-height: 1.5; display: none;
}
#toast.show { display: block; animation: fadeIn 0.15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
