/* ==================== 管理后台 H5 公共样式 ==================== */
:root {
  --primary: #2B4C7E;
  --primary-dark: #1F3A5F;
  --primary-light: #4a6fa5;
  --danger: #dc2626;
  --text: #1f2937;
  --text-2: #4b5563;
  --text-3: #9aa5b5;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e9f0;
  --radius: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* ---------- 布局 ---------- */
.page {
  min-height: 100vh;
  padding-bottom: 40px;
}

.topbar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-title {
  font-size: 19px;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
}

.btn-plain {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  padding: 4px 16px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}

.btn-plain:hover {
  background: rgba(255, 255, 255, 0.15);
}

.subscribe-note {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(7, 193, 96, 0.15);
  border: 1px solid rgba(7, 193, 96, 0.4);
  border-radius: 6px;
  padding: 4px 10px;
  max-width: 420px;
  line-height: 1.5;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 10px rgba(31, 58, 95, 0.06);
  margin-bottom: 16px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding-left: 10px;
  border-left: 4px solid var(--primary);
}

/* ---------- 表单 ---------- */
.field,
.form-item {
  margin-bottom: 16px;
}

.field label,
.form-item label {
  display: block;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.req {
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0 20px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.88;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.btn-secondary {
  background: #e8eef6;
  color: var(--primary);
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-outline-danger {
  background: #fff;
  color: #9ca3af;
  border: 1px solid #e5e7eb;
  font-size: 14px;
  padding: 6px 10px;
}
.btn-outline-danger:hover {
  background: #f9fafb;
  color: #6b7280;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 6px;
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  background: #f8fafc;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}

.table tr:hover td {
  background: #fafbfd;
}

/* ---------- 标签（卡片徽章） ---------- */
.tag {
  display: inline-block;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  padding: 4px 12px;
  margin-right: 6px;
  white-space: nowrap;
}

.tag.green {
  color: #059669;
  background: #d1fae5;
}

.tag.gray {
  color: #6b7280;
  background: #f3f4f6;
}

.tag-main {
  color: #b45309;
  background: #fef3c7;
}

.tag-off {
  color: #6b7280;
  background: #f3f4f6;
}

.tag-deleted {
  color: #dc2626;
  background: #fee2e2;
}

.tag-admin {
  color: #b45309;
  background: #fef3c7;
}

.tag-op {
  color: var(--primary);
  background: #e8eef6;
}

.tag-on {
  color: #059669;
  background: #d1fae5;
}

.tag-offline {
  color: #6b7280;
  background: #f3f4f6;
}

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .input {
  flex: 1;
  min-width: 200px;
}

.toolbar .select {
  width: auto;
  min-width: 140px;
}

.summary {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ---------- 订单状态分类卡 ---------- */
/* PC/桌面（≥900px 媒体查询控制）：7 张卡等宽一行排开 */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-cards .sc {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  text-align: center;
}
.stat-cards .sc .num {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-cards .sc .label {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}
.stat-cards .sc:hover {
  border-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(31, 58, 95, 0.08);
}
.stat-cards .sc.active {
  background: var(--primary);
  border-color: var(--primary);
}
.stat-cards .sc.active .num,
.stat-cards .sc.active .label {
  color: #fff;
}

/* ---------- 商品卡片列表 ---------- */
.goods-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.goods-item {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 2px 8px rgba(31, 58, 95, 0.05);
  gap: 14px;
}

.goods-img {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f2f5;
  flex-shrink: 0;
}

.goods-body {
  flex: 1;
  min-width: 0;
}

.goods-name {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.goods-meta {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-3);
}

.goods-price {
  margin-top: 6px;
  font-size: 14px;
}

.price-retail {
  color: #ff5777;
  font-weight: 700;
  font-size: 17px;
}

.price-vip {
  color: var(--text-2);
  margin-left: 10px;
}

.goods-ops {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  transition: 0.2s;
}

.switch-slider:before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

/* 主推开关：橙色，与上/下架开关区分 */
.switch input:checked + .switch-slider.switch-promo {
  background: #f59e0b;
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-2);
}

/* ---------- 空态 ---------- */
.empty {
  text-align: center;
  color: var(--text-3);
  padding: 60px 0;
  font-size: 16px;
}

/* ---------- 弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  width: 480px;
  max-width: 92vw;
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 18px;
  text-align: center;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* ---------- 图片上传 ---------- */
.img-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.img-item {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f0f2f5;
}

.img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-item.main {
  border: 2px solid var(--primary);
}

.img-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #c4cdd8;
  background: #fafbfd;
  cursor: pointer;
  color: var(--text-3);
  font-size: 14px;
}

.img-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.img-add .plus {
  font-size: 30px;
  line-height: 1;
}

.img-tip {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-3);
}

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 40%, var(--bg) 40.1%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.login-card {
  width: 400px;
  max-width: 92vw;
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(31, 58, 95, 0.25);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 64px;
  height: 64px;
  line-height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff5777, #ff7a5c);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  margin: 0 auto 12px;
}

.login-name {
  font-size: 21px;
  font-weight: 700;
}

.login-sub {
  font-size: 14px;
  color: var(--text-3);
  margin-top: 4px;
}

.login-msg {
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--danger);
  min-height: 20px;
}

.btn-block {
  width: 100%;
}

/* ---------- 工作台网格 ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

/* ---------- 数据看板 · 会员拓扑入口 ---------- */
.topo-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #f6f9fd;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s, background 0.15s;
}
.topo-entry:hover {
  background: #eef4fb;
  box-shadow: 0 4px 14px rgba(31, 58, 95, 0.08);
}
.topo-entry-btn {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.module {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(31, 58, 95, 0.05);
  cursor: pointer;
  border: none;
  font: inherit;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.module:hover:not(.module-disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(31, 58, 95, 0.12);
}

.module-icon {
  width: 48px;
  height: 48px;
  line-height: 48px;
  margin: 0 auto 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 23px;
  font-weight: 700;
}

.module-name {
  font-size: 16px;
  font-weight: 600;
}

.module-desc {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-3);
}

.module-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.module-disabled .module-icon {
  background: #d8dee8;
  color: #aab3c0;
}

.module-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  color: var(--text-3);
  background: #f0f2f5;
  border-radius: 10px;
  padding: 1px 8px;
}

/* ---------- 人员列表 ---------- */
.staff-ops {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 消息 ---------- */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 16px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .container {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .goods-list {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    padding: 12px 14px;
  }

  .topbar-user {
    font-size: 14px;
  }
}

/* ==================== 移动端响应式增强（手机/平板自动适配） ==================== */
/* 依赖 admin-api.js 自动为表格 td 注入 data-label（取表头文本），桌面端无影响 */
@media (max-width: 720px) {
  /* 顶部栏压缩 */
  .topbar {
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 90;
  }
  .topbar-title {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-user #userRole {
    display: none;
  }
  .topbar-user #userName {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-user .btn-plain {
    font-size: 14px;
    padding: 3px 10px;
  }

  /* 容器与卡片 */
  .container {
    padding: 10px;
  }
  .card {
    padding: 14px;
    border-radius: 10px;
  }
  .card-title {
    font-size: 16px;
  }

  /* 工具条：输入框整行、按钮自适应 */
  .toolbar {
    gap: 8px;
  }
  .toolbar .input {
    flex: 1 1 100%;
    min-width: 0;
  }
  .toolbar .select {
    flex: 1;
    min-width: 0;
    width: auto;
  }
  .toolbar .btn {
    flex: 1;
    padding: 10px 12px;
    text-align: center;
  }

  /* 表格卡片化：表头隐藏，每行变卡片，字段名+值左右排 */
  .table thead {
    display: none;
  }
  .table tbody {
    display: block;
  }
  .table tbody tr {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    margin-bottom: 7px;
    box-shadow: 0 1px 3px rgba(31, 58, 95, 0.04);
  }
  .table td {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    border-bottom: 1px dashed var(--border);
    padding: 4px 1px;
    text-align: left;
    white-space: normal;
    word-break: break-all;
    vertical-align: middle;
    font-size: 14px;
  }
  .table td:last-child {
    border-bottom: none;
  }
  .table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-3);
    font-size: 12px;
    text-align: left;
    flex-shrink: 0;
    min-width: 54px;
  }
  .table td:not([data-label]) {
    justify-content: flex-end;
  }
  .table tr:hover td {
    background: transparent;
  }
  /* 卡片内按钮区与标签换行友好 */
  .table td .btn {
    margin-top: 2px;
    margin-bottom: 2px;
  }

  /* 弹窗：手机端水平垂直居中（92% 宽度），四周可点遮罩关闭；标题/内容/按钮分区块 */
  .modal {
    width: 92% !important;
    max-width: 92% !important;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 14px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 0 0 14px;
  }
  .modal-title {
    font-size: 17px;
    /* 标题贴顶钉住，不随内容滚动、不与内容穿插 */
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
    padding: 13px 16px 11px;
    margin: 0 0 10px;
    border-bottom: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    text-align: center;
  }
  .modal > div:not(.modal-title):not(.modal-actions) {
    padding: 0 16px;
  }
  .modal-actions {
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 0 16px;
  }
  .modal-actions .btn {
    flex: 1;
    text-align: center;
    padding: 11px 14px;
    font-size: 16px;
  }

  /* 分页 */
  .pagination {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* 统计卡片（看板） */
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 12px;
  }
  .stat-card .num {
    font-size: 23px;
  }

  /* 按钮触控尺寸 */
  .btn {
    padding: 10px 14px;
  }
  .btn-sm {
    padding: 6px 10px;
  }

  /* 商品卡片 */
  .goods-item {
    padding: 12px;
    gap: 10px;
  }
  .goods-img {
    width: 72px;
    height: 72px;
  }

  /* 表单与字段 */
  .field,
  .form-item {
    margin-bottom: 6px;
  }
  .field label,
  .form-item label {
    font-size: 14px;
    margin-bottom: 3px;
  }
  .input,
  .select,
  .textarea {
    padding: 8px 10px;
    font-size: 16px;
    border-radius: 6px;
  }
  .form-grid {
    gap: 0 0;
  }

  /* 详情弹窗内字段行（k/v 两列）紧凑 */
  .modal table.table tbody tr {
    margin-bottom: 3px;
    padding: 2px 8px;
    border-radius: 6px;
  }
  .modal table.table td {
    padding: 3px 0;
    font-size: 14.5px;
  }

  /* 详情弹窗的"字段名+值"表格：保持原生两列表格（不卡片化），紧凑排列 */
  .table-detail,
  .table-detail tbody {
    display: table !important;
  }
  .table-detail thead {
    display: table-header-group !important;
  }
  .table-detail tbody tr {
    display: table-row !important;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
  }
  .table-detail td {
    display: table-cell !important;
    justify-content: flex-start;
    gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 5px 6px;
    font-size: 16px;
    text-align: left;
    white-space: normal;
    vertical-align: middle;
  }
  .table-detail td:not([data-label]) {
    justify-content: flex-start;
  }
  .table-detail td::before {
    content: none;
  }
  .table-detail td:first-child {
    width: 88px;
    color: var(--text-3);
    font-size: 14px;
    flex-shrink: 0;
  }

  /* 图片上传格 */
  .img-item {
    width: 84px;
    height: 84px;
  }

  /* 会员列表：手机端只保留关键字段（卡号/姓名/手机号/卡类型/余额/状态/操作），
     可用积分/累计消费/注册时间/归属 收进详情，卡片更短 */
  .table-member td:nth-child(6),
  .table-member td:nth-child(7),
  .table-member td:nth-child(8),
  .table-member td:nth-child(9) {
    display: none;
  }

  /* 卡片内操作按钮：换行均匀排列 */
  .table td .btn {
    margin: 3px 2px;
  }
}

/* 订单状态分类卡：窄屏/平板/手机（≤899px）改横向滑动胶囊条，7 张不换行不参差；
   ≥900px 桌面端使用上方 grid 7 列一行布局 */
@media (max-width: 899px) {
  .stat-cards {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    margin-bottom: 14px;
    padding: 2px 2px 6px;
    scrollbar-width: none;
  }
  .stat-cards::-webkit-scrollbar {
    display: none;
  }
  .stat-cards .sc {
    flex: 0 0 auto;
    min-width: 116px;
    padding: 10px 14px;
    text-align: center;
    border-radius: 10px;
  }
  .stat-cards .sc .num {
    font-size: 22px;
  }
  .stat-cards .sc .label {
    font-size: 13px;
    margin-top: 3px;
    white-space: nowrap;
  }
}

/* ---------- 全局组件（不受媒体查询影响） ---------- */
/* 配送详情信息格子：电脑双列（手机单列规则见下方媒体查询） */
.dl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 14px;
}

/* 手机端配送详情信息格子单列（置于全局双列之后，命中时覆盖） */
@media (max-width: 720px) {
  .dl-grid {
    grid-template-columns: 1fr;
  }
}

/* 弹窗内 k/v 详情行：浅色卡片底，弹窗更明亮有层次 */
.modal .table-detail tbody tr {
  background: #f8fafc;
}
.modal .table-detail td {
  padding: 6px 10px;
}
.modal .table-detail td:first-child {
  color: var(--text-3);
  width: 92px;
}
