/* ===== 全局样式 - 移动端优先，响应式设计 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #07C160;
  --primary-dark: #06AD56;
  --primary-light: #E8F8EE;
  --danger: #FA5151;
  --warning: #FF8C00;
  --warning-light: #FFF3E0;
  --info: #1890FF;
  --text: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #E5E5E5;
  --bg: #f5f6f8;
  --card-bg: #fff;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.06);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== 公共按钮 ===== */
.btn-primary {
  width: 100%;
  height: 44px;
  line-height: 44px;
  text-align: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  height: 44px;
  line-height: 44px;
  text-align: center;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 22px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:active { opacity: 0.85; }

.btn-danger {
  width: 100%;
  height: 44px;
  line-height: 44px;
  text-align: center;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.btn-disabled { opacity: 0.5; pointer-events: none; }

/* 小按钮 */
.btn-sm {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-sm-green { background: var(--primary); color: #fff; }
.btn-sm-blue { background: var(--info); color: #fff; }
.btn-sm-orange { background: var(--warning); color: #fff; }
.btn-sm-red { background: var(--danger); color: #fff; }
.btn-sm-gray { background: #eee; color: var(--text-secondary); }
.btn-sm-outline { background: #fff; border: 1px solid var(--border); color: var(--text-secondary); }

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ===== 状态标签 ===== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  white-space: nowrap;
}
.tag-success { background: var(--primary-light); color: var(--primary); }
.tag-warning { background: var(--warning-light); color: var(--warning); }
.tag-danger { background: #FEE; color: var(--danger); }
.tag-info { background: #E8F0FE; color: var(--info); }

/* ===== 输入框 ===== */
.input-group { margin-bottom: 16px; }
.input-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}
.input-field {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.input-field:focus { border-color: var(--primary); }
.textarea-field {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-input {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: var(--primary); }
.btn-search {
  height: 36px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-clear {
  height: 36px;
  padding: 0 12px;
  background: #eee;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

/* ===== 筛选标签 ===== */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.filter-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== 统计卡片 ===== */
.stats-cards {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.stat-card.stat-active { border: 2px solid var(--primary); }
.stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: block;
}
.stat-num.stat-green { color: var(--primary); }
.stat-num.stat-orange { color: var(--warning); }
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 30px;
  color: var(--text-muted);
}
.empty-icon-text { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-text { font-size: 14px; }
.empty-subtext { font-size: 12px; margin-top: 6px; }

/* ===== 加载 ===== */
.loading-wrap {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.load-more, .no-more {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
}
.modal-content {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  z-index: 101;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex;
  padding: 12px 16px 16px;
  gap: 12px;
}
.modal-footer button { flex: 1; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  max-width: 80%;
  text-align: center;
  pointer-events: none;
}

/* ===== 页面容器 ===== */
.page {
  min-height: 100vh;
  padding-bottom: 20px;
}

/* ===== Flex 辅助 ===== */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }

/* ===== 日期筛选 ===== */
.date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.date-picker {
  flex: 1;
  height: 36px;
  line-height: 36px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  background: #fff;
  cursor: pointer;
}
.date-separator { color: var(--text-muted); font-size: 13px; }

/* ===== 管理后台 ===== */
.admin-header {
  background: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-header h1 { font-size: 17px; font-weight: 600; }
.admin-back { font-size: 14px; color: var(--primary); cursor: pointer; }

.admin-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.admin-menu-item {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.admin-menu-item:active { transform: scale(0.97); }
.menu-icon { font-size: 32px; margin-bottom: 8px; }
.menu-text { font-size: 14px; font-weight: 600; display: block; }
.menu-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: block; }

/* ===== 订单/券码列表项 ===== */
.list-item {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.list-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.list-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #f5f5f5;
}
.list-item-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}
.list-item-label { color: var(--text-muted); }
.list-item-value { color: var(--text); text-align: right; max-width: 65%; word-break: break-all; }

/* ===== 操作链接 ===== */
.action-link {
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
}
.action-link-danger { color: var(--danger); }

/* ===== FAB 按钮 ===== */
.fab-btn {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(7, 193, 96, 0.4);
  cursor: pointer;
  z-index: 50;
}

/* ===== 桌面端适配 ===== */
@media (min-width: 768px) {
  body {
    max-width: 500px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
  }
  .page { max-width: 500px; }
  .modal-content { max-width: 500px; left: 50%; transform: translateX(-50%); }
}

/* Fix: limit product image sizes */
.summary-image { width: 60px !important; height: 60px !important; object-fit: cover; border-radius: 8px; }
.product-card img, .product-thumb { width: 60px !important; height: 60px !important; object-fit: cover; border-radius: 8px; }
.image-preview { width: 60px !important; height: 60px !important; object-fit: cover; }
/* Limit any image in card areas to prevent overflow */
.card img:not(.summary-image) { max-width: 200px; max-height: 200px; object-fit: contain; }


/* Fix: ensure modal is above all page content */
.modal-mask { z-index: 9999 !important; }
.modal-content { z-index: 10000 !important; }

