:root {
  --green: #2f9e44;
  --green-dark: #237a35;
  --green-light: #e8f6ec;
  --orange: #f08c00;
  --red: #e03131;
  --text: #222;
  --muted: #777;
  --border: #e6e8e6;
  --bg: #f5f7f5;
  --card: #fff;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: 15px; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 12px;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  background: var(--green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 700;
}
.logo img { height: 32px; width: auto; border-radius: 6px; background: #fff; }
.nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.nav a { opacity: .92; }
.nav a:hover, .nav a.on { opacity: 1; font-weight: 600; }
.cart-dot {
  background: var(--orange);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 12px;
  margin-left: 4px;
}

/* ---------- 通用块 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 10px;
  font-size: 17px;
  font-weight: 700;
}
.section-title small { font-weight: 400; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.tiny { font-size: 13px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.empty .ico { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  border: 0;
  background: var(--green);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
}
.btn:hover { background: var(--green-dark); }
.btn.block { display: block; width: 100%; }
.btn.ghost { background: #fff; color: var(--green); border: 1px solid var(--green); }
.btn.ghost:hover { background: var(--green-light); }
.btn.gray { background: #9aa0a6; }
.btn.gray:hover { background: #868c92; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn.danger { background: var(--red); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 14px; margin-bottom: 5px; font-weight: 600; }
.form-row label .req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.input:focus { border-color: var(--green); }
textarea.input { min-height: 70px; resize: vertical; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }

/* ---------- 首页横幅 ---------- */
.banner {
  background: linear-gradient(135deg, #2f9e44, #57b864);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 18px;
  margin: 14px 0 4px;
}
.banner h1 { margin: 0 0 6px; font-size: 22px; }
.banner p { margin: 0; opacity: .95; font-size: 14px; }

.notice {
  background: #fff8e6;
  border: 1px solid #ffe3a3;
  color: #8a5a00;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 14px;
}

/* ---------- 分类 ---------- */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.cat-chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  white-space: nowrap;
  font-size: 14px;
}
.cat-chip.on { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- 商品网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.goods {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.goods .thumb {
  aspect-ratio: 4 / 3;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  overflow: hidden;
}
.goods .thumb img { width: 100%; height: 100%; object-fit: cover; }
.goods .body { padding: 10px; }
.goods .name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.goods .price { color: var(--orange); font-weight: 700; font-size: 17px; }
.goods .price small { font-size: 12px; font-weight: 400; color: var(--muted); }
.goods .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 商品详情 ---------- */
.pd-media {
  background: var(--green-light);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 70px;
  max-height: 320px;
}
.pd-media img { width: 100%; }
.pd-price { color: var(--orange); font-size: 24px; font-weight: 700; }
.pd-title { font-size: 20px; font-weight: 700; margin: 10px 0 6px; }

.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin: 16px 0 12px; }
.tabs a { padding-bottom: 6px; color: var(--muted); }
.tabs a.on { color: var(--green); font-weight: 700; border-bottom: 2px solid var(--green); }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--green-light); padding: 0 0 16px 16px; position: relative; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}
.timeline .date { font-size: 13px; color: var(--muted); }
.timeline .t { font-weight: 600; }
.timeline video, .timeline img { border-radius: 8px; margin-top: 6px; max-height: 260px; }

.grow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.grow-item { background: #fff; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.grow-item .m { aspect-ratio: 4/3; background: #eee; }
.grow-item .m img, .grow-item .m video { width: 100%; height: 100%; object-fit: cover; }
.grow-item .c { padding: 8px; font-size: 13px; }

/* ---------- 购物车 ---------- */
.cart-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-row:last-child { border-bottom: 0; }
.cart-row .pic { width: 64px; height: 64px; border-radius: 8px; background: var(--green-light); object-fit: cover; flex: none; }
.cart-row .info { flex: 1; min-width: 0; }
.cart-row .nm { font-weight: 600; }
.qty { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.qty button { width: 30px; height: 30px; border: 0; background: #fff; cursor: pointer; }
.qty input { width: 46px; text-align: center; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); height: 30px; }

.summary { display: flex; justify-content: space-between; padding: 6px 0; }
.summary.total { font-size: 18px; font-weight: 700; }
.summary.total .v { color: var(--orange); }

/* ---------- 订单 ---------- */
.order-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: #fff; }
.order-card .head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.order-card .items { margin: 8px 0; font-size: 14px; }
.order-card .items div { display: flex; justify-content: space-between; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--green-light); color: var(--green-dark); }
.tag.gray { background: #eee; color: #666; }
.tag.orange { background: #fff1db; color: #a86a00; }
.tag.red { background: #ffe3e3; color: #c92a2a; }
.tag.blue { background: #e7f0ff; color: #1c5fb0; }

/* ---------- 底部导航（移动端） ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: 12px; color: var(--muted); }
.tabbar a.on { color: var(--green); font-weight: 600; }
.tabbar .ico { display: block; font-size: 20px; line-height: 1.2; }
body.has-tabbar { padding-bottom: 60px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0 30px;
}

/* ---------- 消息 ---------- */
.flash {
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 0;
  font-size: 14px;
}
.flash.ok { background: var(--green-light); color: var(--green-dark); }
.flash.err { background: #ffe9e9; color: #c92a2a; }

/* ---------- 后台 ---------- */
.admin-wrap { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: #1f2933;
  color: #cfd6dd;
  flex: none;
  display: none;
  flex-direction: column;
}
.sidebar .brand { padding: 18px 16px; font-size: 18px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.sidebar .brand img { height: 28px; border-radius: 6px; }
.sidebar a { padding: 12px 18px; border-left: 3px solid transparent; }
.sidebar a:hover { background: #2a3541; color: #fff; }
.sidebar a.on { background: #2a3541; border-left-color: var(--green); color: #fff; font-weight: 600; }
.admin-main { flex: 1; min-width: 0; padding: 0 0 30px; }
.admin-top {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-top .t { font-weight: 700; }
.admin-top .sp { margin-left: auto; font-size: 13px; color: var(--muted); }
.admin-nav {
  display: flex;
  overflow-x: auto;
  background: #1f2933;
  padding: 0 8px;
}
.admin-nav a { color: #cfd6dd; padding: 12px 14px; white-space: nowrap; font-size: 14px; }
.admin-nav a.on { color: #fff; font-weight: 600; border-bottom: 2px solid var(--green); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat { background: #fff; border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.tb { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.tb th, table.tb td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.tb th { background: #fafbfa; font-weight: 600; }
table.tb td.wrap { white-space: normal; }
table.tb tr:hover td { background: #fcfdfc; }

.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bar-chart .col { flex: 1; text-align: center; }
.bar-chart .bar { background: var(--green); border-radius: 4px 4px 0 0; margin: 0 auto; width: 60%; min-height: 2px; }
.bar-chart .lb { font-size: 11px; color: var(--muted); margin-top: 4px; }

.login-box { max-width: 380px; margin: 60px auto; }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .admin-nav { display: none; }
  .admin-top .menu-btn { display: none; }
}
@media (min-width: 768px) {
  .tabbar { display: none; }
  body.has-tabbar { padding-bottom: 0; }
  .grid-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (max-width: 767px) {
  .topbar .nav { display: none; }
}
