:root {
  --red: #e31b2f;
  --red-dark: #b3141f;
  --black: #09090d;
  --black-2: #14141c;
  --gray-bg: #f5f5f8;
  --gray-border: #e4e4ec;
  --text: #1a1a22;
  --text-2: #6b6b7a;
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1200px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--gray-bg);
  color: var(--text);
  font-size: 14px;
  padding-top: 56px;
}

/* ====== 顶部导航 ====== */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: linear-gradient(135deg, var(--black), #1a0a10);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.nav-inner {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 56px;
}
.nav-brand { cursor: pointer; color: #fff; line-height: 1.3; }
.nav-logo { font-size: 18px; font-weight: 700; display: block; }
.nav-desc { font-size: 11px; color: rgba(255,255,255,0.5); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  color: rgba(255,255,255,0.6); font-size: 14px; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-sm); transition: all .18s;
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(227,27,47,0.2); }
.nav-menu-btn { display: none; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }

/* ====== 页面容器 ====== */
.page { display: none; max-width: var(--max-width); margin: 0 auto; padding: 16px; }
.page.active { display: block; }

/* ====== 轮播 ====== */
.banner-section { margin-bottom: 16px; border-radius: var(--radius); overflow: hidden; }
.banner-item {
  background: linear-gradient(135deg, var(--black), #1a0a10);
  color: #fff; padding: 32px 24px; text-align: center;
  border-radius: var(--radius); min-height: 160px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.banner-badge { font-size: 12px; color: var(--red); font-weight: 600; margin-bottom: 8px; }
.banner-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.banner-subtitle { font-size: 14px; color: rgba(255,255,255,0.7); margin-bottom: 4px; }
.banner-desc { font-size: 12px; color: rgba(255,255,255,0.4); }

/* ====== 三角洲密码 ====== */
.delta-section {
  background: #fff; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.delta-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.delta-title { font-size: 16px; font-weight: 700; }
.delta-update { font-size: 12px; color: var(--text-2); }
.delta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.delta-item {
  background: var(--gray-bg); border-radius: var(--radius-sm); padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.delta-area { font-size: 13px; color: var(--text-2); }
.delta-code { font-size: 18px; font-weight: 700; color: var(--red); letter-spacing: 2px; }

/* ====== 筛选栏 ====== */
.filter-bar { margin-bottom: 16px; }
.search-box { margin-bottom: 12px; }
.search-input {
  width: 100%; height: 44px; padding: 0 16px; border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm); font-size: 14px; outline: none;
  transition: border-color .18s;
}
.search-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,27,47,0.08); }
.category-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-tab {
  padding: 8px 16px; border-radius: 999px; font-size: 13px; cursor: pointer;
  background: #fff; color: var(--text-2); border: 1px solid var(--gray-border);
  transition: all .18s; white-space: nowrap;
}
.cat-tab:hover { border-color: var(--red); color: var(--red); }
.cat-tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.cat-tab.ent { background: rgba(114,46,209,0.08); border-color: rgba(114,46,209,0.2); color: #722ed1; }
.cat-tab.ent.active { background: #722ed1; color: #fff; border-color: #722ed1; }

/* ====== 商品卡片 ====== */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.product-card {
  background: #fff; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); transition: all .2s; border: 2px solid transparent;
}
.product-card:hover { border-color: var(--red); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(227,27,47,0.12); }
.card-image {
  width: 100%; height: 160px; background: var(--black-2); object-fit: cover;
  display: flex; align-items: center; justify-content: center; font-size: 40px;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 14px 16px; }
.card-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-subtitle { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.card-price { font-size: 20px; font-weight: 700; color: var(--red); }
.card-unit { font-size: 12px; color: var(--text-3); margin-left: 4px; }
.card-sales { font-size: 12px; color: var(--text-3); }
.card-badges { display: flex; gap: 6px; margin-top: 8px; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; }
.badge-red { background: rgba(227,27,47,0.1); color: var(--red); }
.badge-ent { background: rgba(114,46,209,0.1); color: #722ed1; }
.badge-cat { background: rgba(0,0,0,0.06); color: var(--text-2); }

/* ====== 商品详情 ====== */
.detail-images {
  width: 100%; height: 360px; background: var(--black-2); border-radius: var(--radius);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.detail-images img { width: 100%; height: 100%; object-fit: cover; }
.detail-info {
  background: #fff; border-radius: var(--radius); padding: 24px; margin-top: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.detail-price-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.detail-price { font-size: 36px; font-weight: 700; color: var(--red); }
.detail-unit { font-size: 16px; color: var(--text-3); margin-left: 4px; }
.detail-sales { font-size: 14px; color: var(--text-3); }
.detail-name { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.detail-subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ent-tag-detail { background: linear-gradient(135deg, #722ed1, #9254de); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.detail-section {
  background: #fff; border-radius: var(--radius); padding: 24px; margin-top: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.detail-section h3 { font-size: 18px; font-weight: 700; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid var(--red); }
.detail-section p { font-size: 14px; color: #555; line-height: 1.8; white-space: pre-wrap; }

/* 详情页底部操作栏 */
.detail-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08); z-index: 100;
}
.detail-bar-inner { max-width: var(--max-width); margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.detail-qty { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--gray-border);
  background: var(--gray-bg); display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; user-select: none;
}
.qty-btn:active { background: #e0e0e4; }
.qty-num { font-size: 16px; font-weight: 600; min-width: 32px; text-align: center; }
.detail-total { flex: 1; }
.detail-total-label { font-size: 12px; color: var(--text-3); }
.detail-total-price { font-size: 24px; font-weight: 700; color: var(--red); }
.order-btn-det {
  padding: 12px 28px; border-radius: 8px; border: none; background: linear-gradient(135deg, var(--black), var(--red));
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* 协议勾选 */
.detail-agree {
  max-width: var(--max-width); margin: 0 auto; display: flex; align-items: center;
  padding: 8px 0 0; font-size: 12px; color: var(--text-2);
}
.agree-check {
  width: 20px; height: 20px; border-radius: 4px; border: 2px solid #ccc;
  margin-right: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .2s;
}
.agree-check.checked { background: var(--red); border-color: var(--red); }
.agree-check.checked::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 700; }
.agree-link { color: #2563eb; cursor: pointer; font-weight: 500; }

/* ====== 订单列表 ====== */
.orders-tabs {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.order-tab {
  padding: 8px 20px; border-radius: 999px; font-size: 13px; cursor: pointer;
  background: #fff; color: var(--text-2); border: 1px solid var(--gray-border);
  transition: all .18s;
}
.order-tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.order-list { display: flex; flex-direction: column; gap: 12px; }
.order-card {
  background: #fff; border-radius: var(--radius); padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.order-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.order-card-name { font-weight: 600; font-size: 15px; }
.order-status {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
}
.status-paid { background: rgba(34,197,94,0.1); color: #16a34a; }
.status-unpaid { background: rgba(234,179,8,0.1); color: #ca8a04; }
.status-claimed { background: rgba(59,130,246,0.1); color: #2563eb; }
.status-completed { background: rgba(107,114,128,0.1); color: #6b7280; }
.order-card-info { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.order-card-price { font-size: 18px; font-weight: 700; color: var(--red); margin-top: 8px; }
.order-card-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ====== 按钮 ====== */
.btn-primary {
  padding: 10px 24px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .18s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  padding: 10px 24px; border-radius: var(--radius-sm); border: 1px solid var(--gray-border);
  background: #fff; color: var(--text-2); font-size: 14px; cursor: pointer;
}
.btn-sm { padding: 6px 14px; font-size: 13px; }
.full-width { width: 100%; }

/* ====== 返回按钮 ====== */
.back-btn {
  background: none; border: 1px solid var(--gray-border); border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: 14px; cursor: pointer; margin-bottom: 12px;
  transition: all .18s;
}
.back-btn:hover { background: var(--black); color: #fff; border-color: var(--black); }

/* ====== 弹窗 ====== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 300;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: #fff; border-radius: var(--radius); padding: 28px 24px;
  width: 90%; max-width: 400px; position: relative; animation: fadeIn .2s ease;
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; text-align: center; }
.modal-close {
  position: absolute; top: 12px; right: 16px; font-size: 28px; color: #999;
  cursor: pointer; line-height: 1;
}
.modal-switch { text-align: center; margin-top: 14px; font-size: 13px; color: #2563eb; cursor: pointer; }
.login-error {
  background: rgba(227,27,47,0.1); color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 12px; font-size: 13px;
}

/* 底部弹出面板 */
.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; background: #f6f3f3;
  border-radius: 20px 20px 0 0; max-height: 85vh; display: flex; flex-direction: column;
  animation: slideUp .3s ease;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 14px; background: #fff; border-radius: 20px 20px 0 0; border-bottom: 1px solid #f0f0f0;
}
.sheet-title { font-size: 18px; font-weight: 700; }
.sheet-body { flex: 1; padding: 16px 20px; overflow-y: auto; }
.sheet-footer {
  display: flex; align-items: center; padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #f0f0f0; gap: 14px;
}
.sheet-summary { flex: 1; }
.sheet-price { font-size: 24px; font-weight: 700; color: var(--red); display: block; }

/* 支付弹窗 */
.pay-card { text-align: center; }
.pay-amount { font-size: 32px; font-weight: 700; color: var(--red); margin-bottom: 8px; }
.pay-tip { font-size: 13px; color: var(--text-2); margin-bottom: 18px; }
.qrcode-wrap { margin: 0 auto 16px; width: 200px; height: 200px; }
.qrcode-wrap img { width: 100%; height: 100%; }

/* 表单 */
.form-input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm); font-size: 14px; outline: none; margin-bottom: 12px;
  font-family: inherit; transition: border-color .18s;
}
.form-input:focus { border-color: var(--red); }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.flex-1 { flex: 1; }
.form-textarea { resize: vertical; min-height: 60px; }
.form-label { font-size: 13px; font-weight: 600; color: #555; display: block; margin-bottom: 6px; }
.required { color: var(--red); }

/* 加载 */
.loading-wrap { display: flex; justify-content: center; padding: 40px 0; }
.spinner {
  width: 36px; height: 36px; border: 3px solid #e0e0e0;
  border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Toast */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 9999;
  background: rgba(0,0,0,0.8); color: #fff; padding: 10px 24px; border-radius: 999px;
  font-size: 14px; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }

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

/* ====== PC 端适配 ====== */
@media (min-width: 768px) {
  body { padding-top: 60px; }
  .page { padding: 24px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .delta-grid { grid-template-columns: repeat(6, 1fr); }
  .nav-links { gap: 16px; }
  .nav-link { font-size: 15px; padding: 8px 18px; }
  .detail-images { height: 440px; }
  .detail-bar { padding: 16px 0; }
  .detail-bar-inner { padding: 0 16px; }
  .modal-card { max-width: 440px; }
  .bottom-sheet { max-width: 500px; left: 50%; transform: translateX(-50%); }
  .order-card { padding: 20px 24px; }
}

/* 移动端适配 */
@media (max-width: 767px) {
  .nav-links { display: none; }
  .nav-links.open { 
    display: flex; flex-direction: column; position: absolute; 
    top: 56px; left: 0; right: 0; background: var(--black-2); padding: 12px 16px;
    gap: 4px; 
  }
  .nav-menu-btn { display: block; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-image { height: 120px; }
  .card-body { padding: 10px 12px; }
  .card-name { font-size: 13px; }
  .card-price { font-size: 16px; }
  .detail-images { height: 240px; }
  .delta-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-bar-inner { flex-wrap: wrap; gap: 8px; }
  .order-btn-det { width: 100%; text-align: center; }
  .detail-total { width: 100%; }
}
