/* 文件作用：全站样式，移动端优先，响应式 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #e4393c;
  --primary-dark: #c8282b;
  --orange: #ff6f20;
  --blue: #1677ff;
  --green: #52c41a;
  --text: #333;
  --text-light: #666;
  --text-muted: #999;
  --bg: #f4f5f7;
  --card-bg: #fff;
  --border: #eee;
  --radius: 10px;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}
.logo { font-size: 20px; font-weight: 700; color: var(--primary); text-decoration: none; }
.header-search { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.search-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 18px;
  padding: 8px 16px;
  font-size: 14px;
  outline: none;
  background: #fafafa;
}
.search-input:focus { border-color: var(--primary); background: #fff; }
.search-btn {
  border: none;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
}
.search-btn:hover { background: var(--primary-dark); }
.main-nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.nav-link { font-size: 14px; color: var(--text-light); text-decoration: none; padding: 4px 2px; }
.nav-link:hover { color: var(--primary); }

.page-main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 12px 0 32px; }

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: #fff;
  border-top: 1px solid var(--border);
}
.footer-links { margin-top: 6px; }
.footer-links a { color: var(--text-muted); text-decoration: none; margin: 0 4px; }
.footer-links a:hover { color: var(--primary); }

/* ---------- 频道入口 ---------- */
.channel-entry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 12px;
}
.channel-card {
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.channel-hot { background: linear-gradient(135deg, #ff6f20, #e4393c); }
.channel-cheap { background: linear-gradient(135deg, #36cfc9, #1677ff); }
.channel-items { background: linear-gradient(135deg, #9254de, #597ef7); }
.channel-title { font-size: 16px; font-weight: 700; }
.channel-sub { margin-top: 4px; font-size: 11px; opacity: 0.9; }

/* ---------- 分类导航 ---------- */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}
.category-chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text-light);
  text-decoration: none;
}
.category-chip em { font-style: normal; color: var(--text-muted); font-size: 11px; margin-left: 4px; }
.category-chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 热搜词 ---------- */
.hot-keywords {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 12px 12px;
  font-size: 13px;
}
.hot-keywords-label { color: var(--text-muted); }
.hot-keyword {
  color: var(--text-light);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 10px;
}
.hot-keyword em { font-style: normal; color: var(--orange); font-size: 11px; margin-left: 3px; }
.hot-keyword:hover { border-color: var(--orange); color: var(--orange); }

/* ---------- 标题 ---------- */
.page-heading { font-size: 20px; padding: 12px 12px 4px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); padding: 0 12px 8px; }
.section-title { font-size: 17px; padding: 16px 12px 8px; }
.result-summary { font-size: 13px; color: var(--text-muted); padding: 4px 12px 8px; }

/* ---------- 排序栏 ---------- */
.sort-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #fff;
  border-radius: var(--radius);
  padding: 6px;
  margin: 4px 12px 8px;
}
.sort-item {
  font-size: 13px;
  color: var(--text-light);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
}
.sort-item.current { background: var(--primary); color: #fff; }
.sort-item:hover:not(.current) { background: #f5f5f5; color: var(--primary); }

/* ---------- 商品网格（移动端 2 列） ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px;
}
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); }
.card-img-wrap { position: relative; }
.card-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #eee; display: block; }
.card-coupon {
  position: absolute;
  top: 8px;
  left: 0;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 0 10px 10px 0;
}
.card-body { padding: 8px 10px 10px; }
.card-title {
  font-size: 13px;
  line-height: 1.4;
  height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-price { margin-top: 6px; font-size: 17px; font-weight: 700; color: var(--primary); }
.card-discount {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 400;
  color: #fff;
  background: var(--primary);
  border-radius: 4px;
  padding: 1px 4px;
  vertical-align: 2px;
}
.card-coupon-price { margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--orange); }
.card-origin { margin-top: 2px; font-size: 11px; color: var(--text-muted); text-decoration: line-through; }
.card-meta { margin-top: 4px; display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.card-commission { color: var(--orange); }

.empty-tip { text-align: center; padding: 48px 16px; color: var(--text-muted); font-size: 14px; }
.empty-tip a { color: var(--primary); }
.empty-tip.small { padding: 16px; font-size: 13px; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
}
.page-btn {
  font-size: 13px;
  color: var(--text-light);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  min-width: 34px;
  text-align: center;
}
.page-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:hover:not(.current) { border-color: var(--primary); color: var(--primary); }
.page-btn.ellipsis { border: none; background: transparent; }

/* ---------- 榜单 ---------- */
.rank-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 8px 12px;
}
.rank-board { background: #fff; border-radius: var(--radius); padding: 12px; }
.rank-board-title { font-size: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.rank-board-title.sales { color: var(--primary); }
.rank-board-title.commission { color: var(--orange); }
.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid #f5f5f5;
  text-decoration: none;
}
.rank-item:last-child { border-bottom: none; }
.rank-no {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #eee;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rank-1 { background: #ff4d4f; color: #fff; }
.rank-2 { background: #ff7a45; color: #fff; }
.rank-3 { background: #ffa940; color: #fff; }
.rank-img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #eee; flex-shrink: 0; }
.rank-info { flex: 1; min-width: 0; }
.rank-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-meta { margin-top: 4px; display: flex; gap: 10px; font-size: 12px; color: var(--text-muted); }
.rank-price { color: var(--primary); font-weight: 700; }
.rank-commission { color: var(--orange); }

/* ---------- 详情页 ---------- */
.product-detail { background: #fff; border-radius: var(--radius); margin: 8px 12px; padding: 16px; }
.detail-main { display: grid; grid-template-columns: 1fr; gap: 16px; }
.detail-gallery { display: flex; flex-direction: column; gap: 6px; }
.detail-img { width: 100%; border-radius: 8px; background: #eee; }
.detail-title { font-size: 17px; font-weight: 600; line-height: 1.5; }
.detail-price { margin-top: 10px; font-size: 28px; font-weight: 700; color: var(--primary); }
.detail-origin { margin-left: 8px; font-size: 14px; font-weight: 400; color: var(--text-muted); text-decoration: line-through; }
.detail-discount {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 400;
  color: #fff;
  background: var(--primary);
  border-radius: 4px;
  padding: 2px 6px;
  vertical-align: 4px;
}
.coupon-banner {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, #fff4e8, #ffe6d1);
  border: 1px dashed var(--orange);
  border-radius: 8px;
  padding: 10px 12px;
}
.coupon-amount {
  color: var(--orange);
  font-weight: 700;
  font-size: 15px;
  background: #fff;
  border-radius: 4px;
  padding: 2px 8px;
}
.coupon-after { margin-left: 10px; font-size: 13px; color: var(--text-light); }
.coupon-after b { color: var(--orange); }
.coupon-btn {
  flex-shrink: 0;
  background: var(--orange);
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 16px;
}
.detail-stats {
  margin-top: 12px;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.detail-stats li {
  background: #fafafa;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}
.detail-stats span { color: var(--text-muted); }
.detail-stats b { color: var(--text); }
.detail-desc { margin-top: 14px; font-size: 14px; color: var(--text-light); line-height: 1.6; }
.detail-notice { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.detail-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.buy-btn {
  flex: 1;
  min-width: 160px;
  text-align: center;
  background: linear-gradient(135deg, #ff6f20, var(--primary));
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  padding: 13px;
  border-radius: 24px;
  box-shadow: 0 4px 10px rgba(228, 57, 60, 0.3);
}
.fav-form, .inline-form { display: inline; }
.fav-btn, .copy-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-light);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 24px;
  cursor: pointer;
}
.fav-btn:hover, .copy-btn:hover { border-color: var(--primary); color: var(--primary); }
.back-link { display: block; margin: 16px 12px 0; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---------- 后台登录 ---------- */
.login-panel {
  background: #fff;
  max-width: 360px;
  margin: 48px auto;
  padding: 32px 24px;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.login-title { font-size: 20px; text-align: center; }
.login-form { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.login-input {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
}
.login-input:focus { border-color: var(--blue); }
.login-btn {
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  padding: 11px;
  border-radius: 8px;
  cursor: pointer;
}
.login-btn:hover { background: #0e5fd8; }
.login-error { margin-top: 12px; text-align: center; font-size: 13px; color: var(--primary); }

/* ---------- 后台通用 ---------- */
.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
}
.admin-title { font-size: 20px; }
.admin-topbar-actions { display: flex; gap: 10px; }
.admin-link {
  font-size: 13px;
  color: var(--text-light);
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
}
.admin-link:hover { color: var(--blue); border-color: var(--blue); }
.admin-link.danger:hover { color: var(--primary); border-color: var(--primary); }
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 0 12px 8px;
}
.sync-btn {
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  padding: 9px 22px;
  border-radius: 6px;
  cursor: pointer;
}
.sync-btn:hover { background: #0e5fd8; }
.sync-result { font-size: 13px; color: var(--green); }
.admin-search-form { display: flex; gap: 8px; padding: 0 12px 8px; max-width: 420px; }
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 4px 12px 12px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.admin-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 0 12px;
}
.admin-panel { background: #fff; border-radius: var(--radius); padding: 14px; }
.panel-title { font-size: 15px; padding-bottom: 10px; }

/* 趋势图（纯 CSS 柱状图） */
.trend-chart {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 140px;
  padding-top: 4px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.trend-count { font-size: 11px; color: var(--text-muted); }
.trend-bar {
  width: 70%;
  max-width: 34px;
  min-height: 3px;
  background: linear-gradient(180deg, var(--blue), #69b1ff);
  border-radius: 4px 4px 0 0;
}
.trend-date { font-size: 10px; color: var(--text-muted); }

/* 热门/热搜列表 */
.hot-list { list-style: none; }
.hot-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
}
.hot-list-item:last-child { border-bottom: none; }
.hot-rank {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: #f0f0f0;
  color: var(--text-muted);
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hot-list-item:nth-child(-n+3) .hot-rank { background: var(--primary); color: #fff; }
.hot-title {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hot-title:hover { color: var(--blue); }
.hot-clicks { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }

/* 表格 */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td { padding: 8px 6px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-muted); }
.product-cell { max-width: 320px; }
.product-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.product-link:hover .row-title { color: var(--blue); }
.row-img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: #eee; flex-shrink: 0; }
.row-title {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tag { font-size: 11px; border-radius: 4px; padding: 2px 6px; }
.tag.on { background: #f6ffed; color: var(--green); border: 1px solid #b7eb8f; }
.tag.off { background: #fff1f0; color: var(--primary); border: 1px solid #ffa39e; }
.mini-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-light);
  font-size: 12px;
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  margin-right: 4px;
}
.mini-btn:hover { color: var(--blue); border-color: var(--blue); }
.mini-btn.danger:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- 平板 / 桌面断点 ---------- */
@media (min-width: 600px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 12px; }
  .stat-cards { grid-template-columns: repeat(4, 1fr); }
  .detail-stats { grid-template-columns: repeat(4, 1fr); }
  .rank-layout { grid-template-columns: 1fr 1fr; }
  .detail-main { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
  .admin-panels { grid-template-columns: 1fr 1fr; }
  .channel-entry { padding: 8px 12px; }
}
