:root {
  --primary: #c0392b;
  --primary-dark: #96281b;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #2c3038;
  --text-2: #8a9099;
  --line: #eceef1;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

body { display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(192, 57, 43, .25);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}
.back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  color: #fff; border-radius: 50%;
  transition: background .15s;
}
.back-btn:active { background: rgba(255,255,255,.18); }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.95);
  border-radius: 999px; padding: 8px 14px;
  color: var(--text-2);
}
.search-box input {
  border: none; outline: none; background: transparent;
  width: 100%; font-size: 14px; color: var(--text);
}
.topbar-title { font-size: 16px; font-weight: 600; white-space: nowrap; }

/* ---------- 主区域 ---------- */
main {
  flex: 1; width: 100%; max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px calc(64px + env(safe-area-inset-bottom));
}

/* ---------- 类目页 ---------- */
.banner {
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e74c3c, #c0392b 60%, #96281b);
  color: #fff; padding: 22px 20px; margin-bottom: 12px;
}
.banner h1 { font-size: 20px; margin-bottom: 6px; }
.banner p { font-size: 13px; opacity: .85; }
.banner-top { display: flex; align-items: center; gap: 12px; }
.banner-top > div { flex: 1; min-width: 0; }
.banner-btn {
  flex-shrink: 0;
  border: none; cursor: pointer;
  background: #fff; color: var(--primary);
  font-size: 13px; font-weight: 600;
  border-radius: 999px; padding: 9px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.banner-btn:active { transform: scale(.95); }

.section-title {
  font-size: 15px; font-weight: 600; margin: 16px 2px 10px;
  display: flex; align-items: center; gap: 6px;
}
.section-title::before {
  content: ""; width: 4px; height: 16px; border-radius: 2px;
  background: var(--primary);
}

.category-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.category-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 4px 12px; text-align: center; text-decoration: none;
  color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .15s, box-shadow .15s;
}
.category-card:active { transform: scale(.95); }
.category-card .icon {
  font-size: 30px; line-height: 1;
  width: 52px; height: 52px; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; background: #fdf1ef;
}
.category-card .name { font-size: 13px; font-weight: 500; }
.category-card .count { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* ---------- 列表页 ---------- */
.list-layout { display: flex; gap: 10px; }
.side-cats {
  width: 96px; flex-shrink: 0;
  background: var(--card); border-radius: var(--radius);
  overflow-y: auto; align-self: flex-start;
  position: sticky; top: 62px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.side-cats a {
  display: block; padding: 14px 8px;
  font-size: 13px; text-align: center; text-decoration: none;
  color: var(--text); border-left: 3px solid transparent;
}
.side-cats a.active {
  color: var(--primary); font-weight: 600;
  background: #fdf1ef; border-left-color: var(--primary);
}
.product-list { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.product-card {
  display: flex; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--card); border-radius: var(--radius); padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .15s;
}
.product-card:active { transform: scale(.98); }
.product-thumb {
  width: 92px; height: 92px; flex-shrink: 0;
  border-radius: 10px; background: #fdf1ef;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
}
.product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.product-name {
  font-size: 14px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  font-size: 10px; color: var(--primary);
  border: 1px solid currentColor; border-radius: 4px; padding: 0 4px;
}
.product-meta { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.product-price { color: var(--primary); font-size: 17px; font-weight: 700; }
.product-price small { font-size: 11px; font-weight: 400; }
.product-sales { font-size: 11px; color: var(--text-2); }

.del-act-btn {
  margin-left: auto;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  color: var(--text-2); font-size: 11px;
  border-radius: 6px; padding: 3px 10px;
}
.del-act-btn:active { background: var(--bg); }

/* ---------- 详情页 ---------- */
.detail-hero {
  background: var(--card); border-radius: var(--radius);
  padding: 26px 0; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.detail-hero .emoji {
  width: 150px; height: 150px; margin: 0 auto;
  background: #fdf1ef; border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 84px;
}
.detail-card {
  background: var(--card); border-radius: var(--radius);
  margin-top: 10px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.detail-name { font-size: 17px; font-weight: 600; line-height: 1.45; }
.detail-price-row {
  display: flex; align-items: baseline; gap: 10px; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--line);
}
.detail-price { color: var(--primary); font-size: 26px; font-weight: 700; }
.detail-price small { font-size: 13px; font-weight: 400; }
.detail-sales { font-size: 12px; color: var(--text-2); }
.detail-spec {
  margin-top: 14px; font-size: 13px;
  background: var(--bg); border-radius: 10px; padding: 12px 14px;
  line-height: 2; color: var(--text);
}
.detail-spec b { color: var(--text-2); font-weight: 400; margin-right: 10px; }
.detail-desc-title {
  font-size: 15px; font-weight: 600; margin: 4px 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.detail-desc-title::before {
  content: ""; width: 4px; height: 15px; border-radius: 2px; background: var(--primary);
}
.detail-desc { font-size: 14px; line-height: 1.8; color: #555b64; }

/* ---------- 弹窗表单 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 380px;
  padding: 20px 18px; max-height: 85vh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 600; text-align: center; margin-bottom: 16px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.form-grid input, .form-grid select {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font-size: 14px; color: var(--text);
  outline: none; background: #fff; font-family: inherit;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button {
  flex: 1; border: none; border-radius: 999px;
  padding: 11px 0; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-plain { background: var(--bg); color: var(--text-2); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }

/* ---------- 其他 ---------- */
.empty {
  text-align: center; padding: 60px 0; color: var(--text-2); font-size: 14px;
}
.empty .big { font-size: 46px; margin-bottom: 10px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: flex; width: 100%; max-width: 760px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 7px 0 6px; text-decoration: none;
  color: var(--text-2); font-size: 11px;
}
.tab.active { color: var(--primary); }

@media (min-width: 700px) {
  .category-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ================= 后台管理 ================= */
.admin-body { background: #f2f4f7; min-height: 100vh; display: block; }
.admin-header {
  background: #23272f; color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.admin-header-inner {
  max-width: 960px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.admin-header nav { display: flex; gap: 16px; }
.admin-header a { color: #cfd4dc; text-decoration: none; font-size: 14px; }
.admin-header a:hover { color: #fff; }
.admin-main { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }
.admin-main h2 { font-size: 17px; margin: 24px 0 10px; padding-left: 8px; border-left: 4px solid var(--primary); }
.admin-msg {
  background: #e8f7ee; color: #1c7c46; border: 1px solid #bce5cc;
  border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px;
}
.login-box {
  background: #fff; border-radius: 16px; padding: 28px 22px;
  max-width: 360px; margin: 60px auto;
  box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.admin-table {
  width: 100%; border-collapse: collapse;
  background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  font-size: 14px;
}
.admin-table td {
  padding: 8px 10px; border-top: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table td:first-child { width: 48px; font-size: 20px; text-align: center; }
.edit-row td { background: #fafbfc; }
.row-actions { width: 80px; text-align: right; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }
.new-box {
  background: #fff; border-radius: 10px;
  padding: 12px; margin-top: 12px; font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.prod-form {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  font-size: 13px; color: var(--text-2);
}
.prod-form label { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.prod-form label.wide { flex-basis: 100%; }
.prod-form input, .prod-form select, .prod-form textarea {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; font-size: 13px; font-family: inherit;
  outline: none; background: #fff; width: 100%;
}
.prod-form input:focus, .prod-form select:focus, .prod-form textarea:focus { border-color: var(--primary); }
.mini {
  border: 1px solid var(--line); background: #fff;
  border-radius: 6px; padding: 6px 14px;
  font-size: 13px; cursor: pointer; color: var(--text);
}
.mini.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.mini.danger { color: var(--primary); }
.mini:active { opacity: .8; }
.admin-tip { margin-top: 24px; font-size: 13px; color: var(--text-2); }
