/* ===== 全局变量 ===== */
:root {
  --bg: #fafaf9;
  --bg-soft: #f5f4f0;
  --surface: #ffffff;
  --border: #e8e5df;
  --border-light: #f0ede8;
  --text: #1c1917;
  --text-secondary: #78716c;
  --text-muted: #a8a29e;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --primary-glow: rgba(99,102,241,.12);
  --accent: #0ea5e9;
  --accent-light: #e0f2fe;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
  --shadow: 0 2px 8px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.03);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.03);
  --shadow-glow: 0 0 0 1px rgba(99,102,241,.08), 0 4px 20px rgba(99,102,241,.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --header-h: 52px;
  --tab-h: 44px;
  --footer-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== 基础重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
  letter-spacing: -.01em;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea { font-family: inherit; outline: none; }

/* ===== 动画关键帧 ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,.2); }
  50% { box-shadow: 0 0 0 8px rgba(99,102,241,0); }
}

/* ===== 顶部导航 ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(250,250,249,.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-light);
}
.header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-actions { display: flex; gap: 6px; }
.header-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: var(--text-secondary);
  transition: all .2s;
  font-size: 18px;
}
.header-icon:active { background: var(--bg-soft); color: var(--text); }

/* ===== 标签栏 ===== */
.tab-bar {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 99;
  height: var(--tab-h);
  background: rgba(250,250,249,.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; overflow-x: auto;
  border-bottom: 1px solid var(--border-light);
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-item {
  flex-shrink: 0;
  padding: 0 16px;
  display: flex; align-items: center;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all .2s;
  white-space: nowrap;
}
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== 视图容器 ===== */
#viewContainer {
  position: fixed;
  top: calc(var(--header-h) + var(--tab-h));
  left: 0; right: 0;
  bottom: var(--footer-h);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 24px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
#viewContainer > * {
  animation: fadeInUp .45s ease both;
}

/* ===== 底部导航 ===== */
.footer-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--footer-h);
  padding-bottom: var(--safe-bottom);
  background: rgba(250,250,249,.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  border-top: 1px solid var(--border-light);
}
.footer-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; font-weight: 500;
  color: var(--text-muted);
  transition: all .2s;
}
.footer-tab.active { color: var(--primary); font-weight: 600; }
.footer-tab span { font-size: 10px; }

/* ===== 通用卡片 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.card:active {
  transform: scale(.985);
  box-shadow: var(--shadow-xs);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  font-size: 14px; font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all .2s;
  letter-spacing: -.01em;
  cursor: pointer;
  border: none;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.btn-primary:active { transform: scale(.97); opacity: .9; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:active { background: var(--bg-soft); }

/* ===== 标签 ===== */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 6px;
  letter-spacing: .02em;
}
.tag-primary { background: var(--primary-light); color: var(--primary); }
.tag-accent { background: var(--accent-light); color: var(--accent); }
.tag-success { background: #ecfdf5; color: var(--success); }
.tag-warning { background: #fffbeb; color: var(--warning); }

/* ===== Hero Banner ===== */
.hero-banner {
  background: linear-gradient(155deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #1e1b4b 100%);
  border-radius: var(--radius-lg);
  padding: 28px 22px 22px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  animation: fadeInUp .5s .05s ease both;
}
.hero-banner::before {
  content: '';
  position: absolute; top: -40%; right: -20%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(139,92,246,.3) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-banner::after {
  content: '';
  position: absolute; bottom: -30%; left: -10%;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(99,102,241,.25) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  margin-bottom: 14px;
  position: relative; z-index: 1;
  border: 1px solid rgba(255,255,255,.15);
}
.hero-title {
  font-size: 20px; font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
  margin-bottom: 6px;
  position: relative; z-index: 1;
}
.hero-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,.65);
  letter-spacing: .04em;
  position: relative; z-index: 1;
  margin-bottom: 18px;
}
.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  position: relative; z-index: 1;
}
.hero-stat {
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.08);
}
.hero-stat-val {
  font-size: 18px; font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.hero-stat-label {
  font-size: 10px; font-weight: 500;
  color: rgba(255,255,255,.5);
  margin-top: 2px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* ===== 快捷操作 ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
  animation: fadeInUp .5s .15s ease both;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.quick-action:active {
  transform: scale(.94);
  background: var(--primary-light);
  border-color: rgba(99,102,241,.15);
}
.quick-action-icon {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #faf5ff 100%);
  color: var(--primary);
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.quick-action:active .quick-action-icon {
  background: linear-gradient(135deg, #ddd6fe 0%, #ede9fe 100%);
  transform: scale(.92);
}
.quick-action-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .02em;
}

/* ===== 区块标题 ===== */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  animation: fadeInUp .5s .18s ease both;
}
.section-title {
  font-size: 16px; font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.section-more {
  font-size: 12px; font-weight: 500;
  color: var(--primary);
  display: flex; align-items: center; gap: 2px;
}

/* ===== 列表卡片 ===== */
.list-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  transition: all .2s;
  animation: fadeInUp .5s .22s ease both;
}
.list-card:active {
  background: var(--bg-soft);
  transform: scale(.985);
}
.list-card-thumb {
  width: 48px; height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.list-card-body { flex: 1; min-width: 0; }
.list-card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.list-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.list-card-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: .5;
}

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.search-bar input {
  flex: 1; border: none; background: transparent;
  font-size: 14px; color: var(--text);
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar-icon { color: var(--text-muted); flex-shrink: 0; }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex; gap: 8px; overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 12px; font-weight: 500;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  transition: all .2s;
  white-space: nowrap;
}
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ===== 商品卡片 ===== */
.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all .2s;
}
.product-card:active { transform: scale(.98); }
.product-card-img {
  width: 100%; aspect-ratio: 1;
  background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
}
.product-card-info { padding: 12px; }
.product-card-name {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card-price {
  font-size: 15px; font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* ===== 详情页 ===== */
.detail-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.detail-back {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}
.detail-title { font-size: 17px; font-weight: 700; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: all .2s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { appearance: none; cursor: pointer; }

/* ===== Tabs（子标签） ===== */
.sub-tabs {
  display: flex; gap: 4px;
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}
.sub-tab {
  flex: 1;
  padding: 7px 12px;
  font-size: 12px; font-weight: 500;
  text-align: center;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: all .2s;
}
.sub-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .4;
}
.empty-state-text {
  font-size: 14px; font-weight: 500;
}

/* ===== Toast ===== */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 999;
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  background: var(--text);
  color: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp .3s ease;
}

/* ===== Modal / Sheet ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-sheet {
  width: 100%; max-height: 70vh;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  animation: fadeInUp .3s ease;
}

/* ===== 加载 ===== */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 加载更多 ===== */
.load-more {
  display: block; width: 100%;
  padding: 12px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  font-size: 14px;
  font-weight: 500;
  margin-top: 8px;
}
.load-more:active { background: var(--bg-soft); }

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  #viewContainer { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .app-header { padding: 0 calc((100vw - 480px)/2 + 18px); }
  .tab-bar { padding: 0 calc((100vw - 480px)/2); }
  .footer-nav { padding: 0 calc((100vw - 480px)/2); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}
