:root {
  --app-w: 430px;          /* 手机宽度上限：电脑上居中显示这个宽度 */
  --bg: #1a1d21;           /* 电脑两侧的背景（深色，凸显手机竖屏） */
  --surface: #f5f6f8;      /* 内容区底色 */
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --accent-2: #2563eb;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ===== 顶部导航（居中手机宽度，常驻）===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  max-width: var(--app-w);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.navbar-inner {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.navbar .logo { font-size: 19px; font-weight: 700; letter-spacing: 0.5px; }
.navbar .logo span { color: var(--accent-2); }
.nav-links { display: none; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.cart-link { position: relative; font-size: 15px; color: var(--muted); }
.cart-link:hover { color: var(--text); }
.cart-badge {
  position: absolute;
  top: -8px;
  right: -12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent-2);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  display: none;
}

/* ===== 内容区（居中手机宽度）===== */
.container {
  max-width: var(--app-w);
  margin: 0 auto;
  padding: 20px 16px 92px;   /* 底部留出 Tab 空间 */
  background: var(--surface);
  min-height: 100vh;
}

.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

/* ===== 商品/品牌网格：固定双列 ===== */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.card:active { transform: scale(0.98); }
.card-body { padding: 12px; }
.card .name {
  font-size: 14px; font-weight: 600; line-height: 1.4; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.8em;
}
.card .brand { color: var(--muted); font-size: 12px; margin: 0 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.price { color: var(--accent-2); font-weight: 700; font-size: 15px; white-space: nowrap; }
.card .row .btn { flex-shrink: 0; white-space: nowrap; }
.card .add-cart { width: 100%; margin-top: 8px; padding: 7px 0; }

/* 商品缩略图 / 占位 */
.thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #e0e7ff 0%, #f1f5f9 60%, #fde68a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  color: #334155;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===== 按钮 / 表单 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; }
.btn.primary { background: var(--accent-2); }
.btn.outline { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

/* ===== 详情页（单列）===== */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.detail-grid .thumb { border-radius: var(--radius); }
.detail-name { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.detail-brand { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.detail-price { font-size: 24px; color: var(--accent-2); font-weight: 700; margin: 0 0 16px; }
.detail-desc { color: var(--muted); margin: 0 0 24px; }
.stock-tip { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ===== 购物车卡片 ===== */
.cart-list { display: flex; flex-direction: column; gap: 12px; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.cart-item .thumb { width: 64px; height: 64px; min-width: 64px; flex-shrink: 0; font-size: 32px; }
.cart-info { flex: 1; min-width: 0; }
.cart-info .name { font-weight: 600; margin: 0 0 4px; font-size: 14px; }
.cart-info .price { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.cart-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.cart-right .subtotal { font-weight: 700; color: var(--accent-2); margin: 0; }
.qty-ctrl { display: inline-flex; align-items: center; gap: 8px; }
.qty-ctrl button { width: 26px; height: 26px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.cart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; flex-wrap: wrap; gap: 16px; }
.cart-total { font-size: 20px; font-weight: 700; }

/* ===== 空状态 ===== */
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty .emoji { font-size: 56px; display: block; margin-bottom: 12px; }

/* ===== 后台 ===== */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; }
.product-check, #selectAll { width: 18px; height: 18px; cursor: pointer; accent-color: #2563eb; vertical-align: middle; }
.status-pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; background: #fef3c7; color: #92400e; }
.status-pill.done { background: #dcfce7; color: #166534; }
.status-pill.cancel { background: #fee2e2; color: #991b1b; }

.hidden { display: none !important; }
.alert { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }

.tabs { display: flex; gap: 10px; margin-bottom: 16px; }
.tabs button { flex: 1; padding: 9px 0; border: 1px solid var(--line); background: #fff; border-radius: 9px; cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: #fff; border-radius: var(--radius); padding: 20px; width: 92%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; }

/* ===== 品牌卡片 ===== */
.brand-card { display: block; text-align: center; }
.brand-logo {
  aspect-ratio: 2 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 2px;
  overflow: hidden;
}
.brand-logo.has-img {
  aspect-ratio: auto;
  display: block;
  padding: 0;
  background: transparent;
}
.brand-card .card-body { padding: 5px 8px 7px; }
.brand-card .name { font-size: 20px; font-weight: 700; margin: 0; line-height: 1.3; min-height: 0; display: block; -webkit-line-clamp: unset; overflow: visible; }
.brand-card .count { color: var(--muted); font-size: 11px; margin: 2px 0 0; line-height: 1.3; }
.brand-logo img { width: 100%; height: auto; display: block; }

/* 後台品牌管理 */
.brand-admin-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px; border-bottom: 1px solid var(--line);
}
.brand-admin-logo {
  width: 48px; height: 48px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.brand-admin-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-admin-name { font-weight: 600; font-size: 16px; }

/* ===== 联系我们 ===== */
.contact-list { display: flex; flex-direction: column; gap: 12px; }
.contact-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.contact-item .ico {
  width: 48px; height: 48px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: var(--surface); border-radius: 12px;
}
.contact-item .label { font-size: 12px; color: var(--muted); margin: 0 0 2px; }
.contact-item .value { font-size: 16px; font-weight: 600; margin: 0; word-break: break-all; }

/* ===== 公告欄 ===== */
.announce {
  max-width: var(--app-w);
  margin: 0 auto;
  background: #111827;
  color: #fff;
  text-align: center;
  font-size: 13px;
  padding: 8px 16px;
}

/* ===== 左下角「返回上一頁」懸浮按鈕 ===== */
.back-btn {
  position: fixed;
  left: 12px;
  bottom: 56px;
  z-index: 40;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(17, 24, 39, 0.7);
  color: #fff;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  text-decoration: none;
  cursor: pointer;
}
@media (min-width: 769px) {
  .back-btn { left: max(16px, calc(50% - var(--app-w) / 2 + 16px)); }
}

/* ===== 右下角 LINE / WhatsApp 懸浮按鈕（跟隨居中容器）===== */
.float-btns {
  position: fixed;
  bottom: 100px;
  right: max(16px, calc(50% - var(--app-w) / 2 + 16px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.float-btn {
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.float-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 詳情頁圖集 */
.detail-images { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.detail-images img { width: 100%; border-radius: 10px; display: block; }

/* 後台詳情圖片縮圖 */
.img-thumb { position: relative; display: inline-block; width: 64px; height: 64px; margin: 0 8px 8px 0; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.img-thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; cursor: pointer;
}

/* 商品列表主圖縮略圖 */
.prod-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.prod-thumb-empty { display: flex; align-items: center; justify-content: center; background: var(--surface); font-size: 24px; }

/* ===== 後台桌面版：後台不受手機寬度限制，全寬便於操作 ===== */
body.admin-page { background: #f5f6f8; }
body.admin-page .navbar { max-width: none; margin: 0; }
body.admin-page .navbar-inner { max-width: 1200px; margin: 0 auto; }
body.admin-page .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  background: transparent;
  min-height: auto;
}
body.admin-page .panel { padding: 20px; }
body.admin-page .tabs { max-width: 320px; }
body.admin-page .modal { max-width: 560px; }

/* ===== 首頁輪播 ===== */
.banner { position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 20px; }
.banner-track { display: flex; transition: transform 0.4s ease; }
.banner-slide { min-width: 100%; aspect-ratio: 16 / 9; }
.banner-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-static {
  aspect-ratio: 16 / 9;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #fff; font-size: 60px;
}
.banner-static p { font-size: 22px; font-weight: 700; margin: 8px 0 0; }
.banner-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.banner-dots .dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.5); }
.banner-dots .dot.active { background: #fff; }

/* 首頁熱賣區標題 */
.section-title { font-size: 18px; font-weight: 700; margin: 20px 0 12px; }

/* ===== 底部 Tab 导航（常驻，居中手机宽度）===== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-w);
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  text-align: center;
  padding: 9px 0 8px;
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
}
.tabbar a .ico { display: inline-block; position: relative; font-size: 25px; line-height: 1; margin-bottom: 3px; }
.tab-badge {
  position: absolute;
  top: -7px; right: -14px;
  min-width: 16px; height: 16px;
  background: var(--accent-2); color: #fff;
  border-radius: 8px; font-size: 10px; line-height: 16px;
  text-align: center; padding: 0 4px;
  display: none;
}
.tabbar a.active { color: var(--accent-2); font-weight: 600; }
