/* ============================================================
 * 悦点订货商城 · 样式（所有单位共用同一套页面）
 * 移动优先：<=520px 单列；桌面居中 640px 卡片式。
 * 主色与进销存一致 #1677ff；红涨绿跌等业务色不在此页面出现。
 * ============================================================ */

:root {
  --brand: #1677ff;
  --brand-dark: #0e5fd8;
  --brand-soft: #e8f1ff;
  --red: #ff3141;
  --text: #1d2129;
  --text-2: #4e5969;
  --text-3: #86909c;
  --line: #e5e6eb;
  --bg: #f2f3f5;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input, button { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
b { font-weight: 600; }

/* ---------------- 视图切换 ---------------- */
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 44px 20px 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand { text-align: center; padding: 12px 0 26px; }

/* 品牌标用系统同一张 app-logo-plain.png（20261112c 起：透明底、无方块背景、无发光，只轻微浮动） */
.brand-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mlLogoBob 3.4s ease-in-out infinite;
}

.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; transform: none; }
@keyframes mlLogoBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
}

.brand-title { margin: 0 0 6px; font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.6; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}

.login-card { padding: 20px 16px 16px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  outline: none;
  transition: border-color .16s, background .16s;
}
.field input:focus { border-color: var(--brand); background: #fff; }
.field input::placeholder { color: #b8bcc4; }

.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }

.btn-send {
  flex: 0 0 auto;
  min-width: 106px;
  height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-send:disabled { background: #f2f3f5; color: var(--text-3); }

.btn-primary {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  transition: opacity .16s;
}
.btn-primary:active { opacity: .86; }
.btn-primary:disabled { opacity: .5; }

#btn-login { margin-top: 6px; letter-spacing: 6px; }

.login-tip {
  margin: 14px 2px 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.7;
}
.login-tip b { color: var(--text-2); font-weight: 600; }

.foot-note { margin-top: auto; text-align: center; color: #b8bcc4; font-size: 12px; padding-top: 26px; }
/* 2026-10-31：底部互链 → 进销存管理端 */
.foot-note a.foot-link { display: inline-block; margin-top: 6px; color: #1677ff; font-size: 12.5px; text-decoration: none; }
.foot-note a.foot-link:active { opacity: .7; }

/* ---------------- 商城头部 ---------------- */
.shop-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #4f9dff, var(--brand));
  color: #fff;
  box-shadow: 0 2px 10px rgba(22, 119, 255, .18);
}
.shop-head-main { flex: 1; min-width: 0; }
.shop-org {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shop-cus { font-size: 12px; opacity: .9; margin-top: 2px; }
.shop-head-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, .16);
}
.icon-btn svg { width: 19px; height: 19px; }
/* 2026-10-31：头部直达进销存管理端（a 标签复用 icon-btn） */
a.icon-btn { text-decoration: none; }
a.icon-btn:active { background: rgba(255, 255, 255, .28); }

.shop-body {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px calc(84px + var(--safe-bottom));
}

/* 2026-10-31：商城首页底部互链 → 进销存管理端，随内容流滚动不挡商品 */
.mall-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 26px;
  padding: 14px 0 2px;
  border-top: 1px solid #eef0f3;
  color: #b8bcc4;
  font-size: 12px;
}
.mall-foot a { color: #1677ff; font-size: 12.5px; text-decoration: none; }
.mall-foot a:active { opacity: .7; }

.search-row {
  position: relative;
  margin-bottom: 10px;
}
.search-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-3);
}
.search-row input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 0;
  border-radius: 20px;
  background: #fff;
  outline: none;
  font-size: 14px;
}

.cat-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }

.cat-chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 14px;
  border-radius: 15px;
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.cat-chip.on { background: var(--brand); color: #fff; font-weight: 600; }

/* ---------------- 商品网格 ---------------- */
.prod-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 560px) {
  .prod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.prod-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .04);
}

.prod-img {
  position: relative;
  width: 100%;
  padding-top: 100%;
  background: #f7f8fa;
  overflow: hidden;
}
.prod-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.prod-img .no-img {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c9cdd4;
  font-size: 26px;
}

.tag-cus {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 1px 7px;
  border-radius: 8px;
  background: rgba(255, 49, 65, .92);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.tag-out {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .68);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.prod-info { padding: 8px 10px 10px; display: flex; flex-direction: column; flex: 1; }
.prod-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}
.prod-spec { color: var(--text-3); font-size: 12px; margin-top: 3px; min-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.prod-foot {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
}
.price-wrap { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.price { color: var(--red); font-size: 17px; font-weight: 700; }
.price small { font-size: 11px; font-weight: 600; margin-right: 1px; }
.price-unit { color: var(--text-3); font-size: 11px; }
.stock { color: var(--text-3); font-size: 11px; }

.add-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(22, 119, 255, .32);
}
.add-btn.off { background: #e5e6eb; box-shadow: none; color: #fff; }
.add-btn:active { transform: scale(.94); }

.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-ico { font-size: 40px; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 14px; }

/* ---------------- 底部购物车条 ---------------- */
.cart-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + var(--safe-bottom));
  width: min(616px, calc(100% - 24px));
  height: 58px;
  border-radius: 29px;
  background: #1d2129;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 6px 0 16px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .26);
  z-index: 30;
}
.cart-bar[hidden] { display: none; }
.cart-bar-left { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.cart-badge-wrap { position: relative; color: #fff; }
.cart-badge-wrap svg { width: 26px; height: 26px; display: block; }
.cart-badge {
  position: absolute;
  top: -6px;
  right: -9px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.cart-sum { display: flex; flex-direction: column; line-height: 1.2; }
.cart-sum b { font-size: 17px; font-weight: 700; }
.cart-sum span { font-size: 11px; opacity: .72; }
.cart-sum i { font-style: normal; }

.btn-checkout {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 26px;
  border-radius: 23px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* ---------------- 子页（购物车 / 订单 / 详情） ---------------- */
.sub-view { padding-bottom: calc(20px + var(--safe-bottom)); }

.sub-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.sub-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; text-align: center; }
.sub-head-right { width: 40px; }
.back-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.back-btn svg { width: 22px; height: 22px; }

.sub-body { max-width: 640px; margin: 0 auto; padding: 12px; }

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  padding-left: 9px;
  position: relative;
}
.card-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--brand);
}

/* 购物车行 */
.cart-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f2f3f5;
}
.cart-row:last-child { border-bottom: 0; }
.cart-thumb {
  width: 58px;
  height: 58px;
  border-radius: 9px;
  background: #f7f8fa;
  overflow: hidden;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c9cdd4;
}
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cart-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-spec { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.cart-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.cart-price { color: var(--red); font-weight: 700; font-size: 15px; }

.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button {
  width: 28px;
  height: 26px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  background: #fafbfc;
}
.stepper button:disabled { color: #c9cdd4; }
.stepper input {
  width: 40px;
  height: 26px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  background: #fff;
  outline: none;
  font-size: 13px;
}

.cart-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px 0;
}
.cart-total-bar > div { font-size: 13px; color: var(--text-2); }
.cart-total-bar b { color: var(--red); font-size: 20px; font-weight: 700; margin-left: 4px; }
.btn-submit { width: auto; padding: 0 28px; height: 44px; letter-spacing: 1px; }

.safe-tip { color: var(--text-3); font-size: 12px; line-height: 1.6; margin: 10px 4px 0; }

/* 订单卡 */
.order-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .04);
}
.order-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-no { font-size: 13px; color: var(--text-2); font-weight: 600; }
.order-status { font-size: 12px; font-weight: 600; color: var(--brand); }
.order-status.done { color: #00b578; }
.order-status.cancel { color: var(--text-3); }
.order-mid { margin: 8px 0 10px; color: var(--text-3); font-size: 12px; }
.order-bot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.order-amount b { color: var(--red); font-size: 18px; font-weight: 700; }
.order-btns { display: flex; gap: 8px; }
.btn-ghost {
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px;
}
.btn-ghost.danger { border-color: #ffd6d9; color: var(--red); }
.btn-ghost.solid { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 订单详情 */
.detail-row { display: flex; gap: 12px; font-size: 13px; padding: 6px 0; }
.detail-row .k { color: var(--text-3); flex: 0 0 76px; }
.detail-row .v { color: var(--text); flex: 1; word-break: break-all; }
.detail-items { border-top: 1px solid #f2f3f5; margin-top: 6px; }

/* ---------------- toast / loading ---------------- */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 76vw;
  padding: 11px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .82);
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  z-index: 200;
  word-break: break-all;
}
.toast[hidden] { display: none; }

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .5);
  z-index: 190;
}
.loading[hidden] { display: none; }
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(22, 119, 255, .22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
