/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
  padding-bottom: 60px;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
input, button, textarea { font-family: inherit; outline: none; border: none; }
ul, ol { list-style: none; }

/* ========== Utility ========== */
.clearfix::after { content: ''; display: table; clear: both; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }

/* ========== Header ========== */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: 44px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 100; border-bottom: 1px solid #eee;
  padding: 0 12px;
}
.header-back {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2'%3E%3Cpath d='M15 18l-6-6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
}
.header-title {
  font-size: 17px; font-weight: 600; color: #333;
}

/* ========== Bottom Tab Bar ========== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 56px; background: #fff;
  display: flex; align-items: center;
  border-top: 1px solid #eee;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4px 0; gap: 2px;
  color: #999; font-size: 10px;
  transition: color .2s;
}
.tab-item.active { color: #ff4757; }
.tab-icon {
  width: 24px; height: 24px; margin-bottom: 1px;
}
.tab-icon-home { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8'%3E%3Cpath d='M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z'/%3E%3Cpolyline points='9 22 9 12 15 12 15 22'/%3E%3C/svg%3E") center/contain no-repeat; }
.tab-icon-category { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8'%3E%3Crect x='3' y='3' width='7' height='7'/%3E%3Crect x='14' y='3' width='7' height='7'/%3E%3Crect x='3' y='14' width='7' height='7'/%3E%3Crect x='14' y='14' width='7' height='7'/%3E%3C/svg%3E") center/contain no-repeat; }
.tab-icon-cart { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6'/%3E%3C/svg%3E") center/contain no-repeat; }
.tab-icon-user { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8'%3E%3Cpath d='M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E") center/contain no-repeat; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 24px; border-radius: 22px;
  font-size: 15px; font-weight: 500;
  cursor: pointer; transition: opacity .2s;
}
.btn:active { opacity: .8; }
.btn-primary {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: #fff;
}
.btn-block { width: 100%; }
.btn-outline {
  border: 1px solid #ff4757; color: #ff4757;
  background: #fff;
}

/* ========== Cards ========== */
.card {
  background: #fff; border-radius: 8px;
  margin: 8px 12px; padding: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

/* ========== Price ========== */
.price { color: #ff4757; font-weight: 600; }
.price-symbol { font-size: 12px; }
.price-value { font-size: 18px; }
.price-original {
  color: #999; font-size: 12px;
  text-decoration: line-through; margin-left: 6px;
}

/* ========== Loading ========== */
.loading-mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; display: none;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid #eee; border-top-color: #ff4757;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Empty State ========== */
.empty-state {
  text-align: center; padding: 60px 20px; color: #999;
}
.empty-state svg { width: 80px; height: 80px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ========== Safe Area ========== */
body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
.has-header { padding-top: 44px; }

/* ========== Page Transition ========== */
.page-enter {
  animation: pageIn .3s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== Toast ========== */
.toast {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75); color: #fff;
  padding: 10px 20px; border-radius: 6px;
  font-size: 14px; z-index: 1000;
  pointer-events: none;
  animation: toastIn .3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ========== Search Bar ========== */
.search-bar {
  padding: 6px 12px; background: #fff;
}
.search-input {
  width: 100%; height: 34px; background: #f5f5f5;
  border-radius: 17px; padding: 0 12px 0 36px;
  font-size: 13px; color: #333;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
}

/* ========== Badge ========== */
.badge {
  position: absolute; top: -4px; right: -6px;
  min-width: 16px; height: 16px;
  background: #ff4757; color: #fff;
  font-size: 10px; line-height: 16px;
  text-align: center; border-radius: 8px;
  padding: 0 4px;
}
