/* 后台 WAP 手机版 UI 模板 */
:root {
  --wap-top-h: 48px;
  --wap-tab-h: 56px;
  --wap-safe-b: env(safe-area-inset-bottom, 0px);
  --wap-safe-t: env(safe-area-inset-top, 0px);
  --wap-primary: #2563eb;
  --wap-bg: #f3f4f6;
  --wap-card: #fff;
  --wap-border: #e5e7eb;
  --wap-text: #111827;
  --wap-muted: #6b7280;
}

html.wap-root,
body.wap {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body.wap {
  background: var(--wap-bg);
  padding-bottom: calc(var(--wap-tab-h) + var(--wap-safe-b));
}

/* 遮罩 */
.wap-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.wap-mask.show {
  opacity: 1;
  visibility: visible;
}

/* 侧滑菜单 */
.wap-drawer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(280px, 82vw);
  background: #fff;
  z-index: 210;
  transform: translateX(-105%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, .12);
  padding-top: var(--wap-safe-t);
}
.wap-drawer.open {
  transform: translateX(0);
}
.wap-drawer__hd {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--wap-border);
}
.wap-drawer__brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--wap-text);
}
.wap-drawer__user {
  margin-top: 4px;
  font-size: 12px;
  color: var(--wap-muted);
}
.wap-drawer__nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 16px;
  -webkit-overflow-scrolling: touch;
}
.wap-drawer__group + .wap-drawer__group {
  margin-top: 12px;
}
.wap-drawer__label {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.wap-drawer__nav a {
  display: block;
  padding: 11px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
}
.wap-drawer__nav a:hover,
.wap-drawer__nav a.active {
  background: #eff6ff;
  color: var(--wap-primary);
  text-decoration: none;
}
.wap-drawer__nav a.active {
  font-weight: 600;
}
.wap-drawer__logout {
  color: #dc2626 !important;
}
.wap-drawer__logout.active {
  background: #fef2f2 !important;
  color: #dc2626 !important;
}
.wap-drawer__ft {
  padding: 12px 16px calc(12px + var(--wap-safe-b));
  border-top: 1px solid var(--wap-border);
}

.wap-switch-pc {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--wap-muted);
  text-decoration: none;
}
.wap-switch-pc:hover {
  color: var(--wap-primary);
  text-decoration: none;
}

/* 主框架 */
.wap-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

/* 顶栏 */
.wap-top {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(var(--wap-top-h) + var(--wap-safe-t));
  padding: var(--wap-safe-t) 12px 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--wap-border);
}
.wap-top__btn,
.wap-top__avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #f3f4f6;
  color: #374151;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.wap-top__avatar span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--wap-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wap-top__title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--wap-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.wap-top__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* 用户弹出菜单 */
.wap-user-pop {
  position: fixed;
  top: calc(var(--wap-top-h) + var(--wap-safe-t) + 4px);
  right: 12px;
  min-width: 140px;
  background: #fff;
  border: 1px solid var(--wap-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  z-index: 120;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .2s, transform .2s, visibility .2s;
  overflow: hidden;
}
.wap-user-pop.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.wap-user-pop__name {
  padding: 12px 14px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--wap-text);
  border-bottom: 1px solid #f3f4f6;
}
.wap-user-pop a {
  display: block;
  padding: 11px 14px;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
}
.wap-user-pop a:hover {
  background: #f9fafb;
  text-decoration: none;
}
.wap-user-pop a.danger {
  color: #dc2626;
  border-top: 1px solid #f3f4f6;
}

/* 内容区 */
.wap-body {
  padding: 12px;
}

/* 底部 Tab */
.wap-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  height: calc(var(--wap-tab-h) + var(--wap-safe-b));
  padding-bottom: var(--wap-safe-b);
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--wap-border);
}
.wap-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--wap-muted);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 0 4px;
  font-family: inherit;
}
.wap-tabbar__item svg {
  opacity: .75;
}
.wap-tabbar__item.active,
.wap-tabbar__item.active svg {
  color: var(--wap-primary);
  opacity: 1;
}
.wap-tabbar__item.active span {
  font-weight: 600;
}

/* ========== WAP 组件库 ========== */

/* 统计卡片 */
.wap-body .stats {
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.wap-body .stat {
  padding: 14px;
  border-radius: 12px;
}
.wap-body .stat__num {
  font-size: 22px;
}

/* 卡片 */
.wap-body .card {
  border-radius: 12px;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.wap-body .card + .card {
  margin-top: 12px;
}
.wap-body .card-hd {
  padding: 14px 14px 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.wap-body .card-hd h2 {
  font-size: 15px;
}
.wap-body .card-bd {
  padding: 14px;
}

/* 搜索栏 */
.wap-body .form-inline {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.wap-body .form-inline input,
.wap-body .form-inline select {
  width: 100%;
  min-width: 0;
}
.wap-body .form-inline .btn {
  width: 100%;
}

/* 表单 */
.wap-body .form,
.wap-body .form-wide {
  max-width: none;
}
.wap-body .form-grid-2 {
  grid-template-columns: 1fr;
}
.wap-body .form-actions {
  flex-direction: column;
}
.wap-body .form-actions .btn {
  width: 100%;
}

/* 表格 → 横向滚动 */
.wap-body .table-wrap {
  margin: 0 -14px;
  padding: 0 14px;
}
.wap-body table.data {
  font-size: 12px;
}
.wap-body table.data th,
.wap-body table.data td {
  padding: 10px 8px;
  white-space: nowrap;
}

/* 分页 */
.wap-body ul.pagination a,
.wap-body ul.pagination span {
  min-width: 36px;
  height: 36px;
}

/* 配置 Tab 横向滚动 */
.wap-body .config-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 4px;
  margin: 0 -14px 16px;
  padding: 0 14px 0;
  scrollbar-width: none;
}
.wap-body .config-tabs::-webkit-scrollbar {
  display: none;
}
.wap-body .config-tab {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 8px 14px;
}

/* 图空间 */
.wap-body .imagespace-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.wap-body .imagespace-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.wap-body .imagespace-stat {
  min-width: 0;
}

/* 订单卡片 */
.wap-body .order-list-hd {
  display: none;
}
.wap-body .order-goods-row {
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 12px;
}
.wap-body .order-goods-row__price,
.wap-body .order-goods-row__qty,
.wap-body .order-goods-row__sub {
  text-align: left;
  font-size: 12px;
}
.wap-body .order-goods-row__price::before { content: '单价：'; color: #9ca3af; }
.wap-body .order-goods-row__qty::before { content: '数量：'; color: #9ca3af; }
.wap-body .order-goods-row__sub::before { content: '小计：'; color: #9ca3af; }
.wap-body .order-card__recv {
  max-width: 100%;
}
.wap-body .order-card__actions {
  width: 100%;
  justify-content: space-between;
}
.wap-body .order-card__hd {
  flex-direction: column;
  align-items: flex-start;
}

/* SKU / 商品表单 */
.wap-body .product-param-row {
  grid-template-columns: 1fr;
}
.wap-body .spec-value-add {
  padding-left: 0;
  flex-direction: column;
  align-items: stretch;
}
.wap-body .spec-value-add input {
  flex: 1;
  max-width: none;
}
.wap-body .sku-table-wrap {
  overflow-x: auto;
  margin: 0 -14px;
  padding: 0 14px;
}
.wap-body .sku-batch-panel__fields {
  flex-direction: column;
}
.wap-body .sku-batch-field {
  min-width: 0;
}

/* 通用列表卡片（可选组件） */
.m-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.m-list-item {
  display: block;
  padding: 14px;
  background: var(--wap-card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  text-decoration: none;
  color: inherit;
}
.m-list-item:active {
  background: #f9fafb;
}
.m-list-item__hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.m-list-item__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--wap-text);
}
.m-list-item__meta {
  font-size: 12px;
  color: var(--wap-muted);
  line-height: 1.6;
}
.m-list-item__ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}

/* 空状态 */
.m-empty {
  text-align: center;
  padding: 48px 20px;
  color: #9ca3af;
  font-size: 13px;
}
.m-empty svg {
  display: block;
  margin: 0 auto 12px;
  opacity: .35;
}

/* 浮动操作按钮 */
.wap-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--wap-tab-h) + var(--wap-safe-b) + 16px);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--wap-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  text-decoration: none;
}
.wap-fab:hover {
  color: #fff;
  text-decoration: none;
}

/* 登录页 */
.wap-login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 45%, #172554 100%);
}
.wap-login {
  width: 100%;
  max-width: 360px;
}
.wap-login__brand {
  text-align: center;
  margin-bottom: 28px;
}
.wap-login__logo {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}
.wap-login__sub {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, .55);
}
.wap-login__form {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
.wap-field {
  margin-bottom: 16px;
}
.wap-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}
.wap-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
  color: #111827;
  background: #fff;
  -webkit-appearance: none;
}
.wap-field input:focus {
  outline: none;
  border-color: var(--wap-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.wap-login__submit {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  border-radius: 10px;
  margin-top: 4px;
}
.wap-login__tip {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, .45);
}
.wap-login__switch {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: rgba(255, 255, 255, .55);
}

/* Toast 位置适配 */
body.wap .toast-wrap {
  top: calc(var(--wap-top-h) + var(--wap-safe-t) + 12px);
}

/* Modal 底部弹出风格 */
body.wap .modal-mask {
  align-items: flex-end;
}
body.wap .modal {
  width: 100%;
  max-width: none;
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + var(--wap-safe-b));
  animation: wapSheetUp .25s ease;
}
@keyframes wapSheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
