:root {
  --bg: #f2f5f3;
  --card: #ffffff;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 带 hidden 属性的元素强制隐藏，防止被 display:flex 覆盖 */
[hidden] { display: none !important; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo-icon { font-size: 26px; }
.nav { display: flex; gap: 22px; color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--primary); }

/* Hero */
.hero {
  background: linear-gradient(135deg, #14532d 0%, #16a34a 55%, #4ade80 100%);
  color: #fff;
  padding: 56px 0;
  text-align: center;
}
.hero h1 { font-size: 34px; margin-bottom: 10px; letter-spacing: 2px; }
.hero p { opacity: 0.95; font-size: 16px; max-width: 720px; margin: 0 auto; }

/* 工具栏 */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 28px 0 18px; flex-wrap: wrap;
}
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  padding: 8px 18px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-weight: 500; transition: all .2s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.search {
  width: 260px; max-width: 100%;
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); outline: none;
}
.search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }

/* 商品网格 */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  padding-bottom: 40px;
}
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-img { width: 100%; height: 170px; object-fit: cover; background: var(--primary-light); display: block; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: space-between; }
.badge {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500;
}
.badge.item { background: #e0f2fe; color: #0284c7; }
.badge.client { background: var(--primary-light); color: var(--primary-dark); }
.card-desc {
  color: var(--muted); font-size: 13px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.price { color: var(--primary-dark); font-weight: 800; font-size: 20px; }
.price::before { content: '¥'; font-size: 14px; margin-right: 2px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px; font-weight: 600;
  transition: all .2s; border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* 表单 */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
label span { color: var(--muted); }
.input, input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], input[type="file"], select, textarea {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; outline: none; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12); }
.input.auto, select.auto { width: auto; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto; position: relative;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}
.modal-close {
  position: absolute; right: 14px; top: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: #f1f5f9; color: var(--muted); font-size: 14px;
}
.modal-close:hover { background: #fee2e2; color: var(--danger); }
.modal-body { padding: 26px; }
.product-detail { display: flex; gap: 16px; margin-bottom: 20px; }
.product-detail img { width: 140px; height: 140px; object-fit: cover; border-radius: 12px; background: var(--primary-light); }
.product-detail h3 { font-size: 20px; margin-bottom: 4px; }
.product-detail .price { font-size: 24px; }
.order-form { display: flex; flex-direction: column; gap: 14px; }
.order-form h3 { font-size: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.check-label { flex-direction: row; align-items: center; gap: 8px; }
.check-label input { width: auto; }

/* 订单结果 */
.order-result h3 { margin-bottom: 8px; }
.pay-box {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 14px; border-radius: 10px; margin: 12px 0; white-space: pre-wrap; font-size: 14px;
}
.download-box { margin: 14px 0; padding: 16px; background: var(--primary-light); border-radius: 12px; }
.download-box p { margin-bottom: 8px; font-weight: 600; color: var(--primary-dark); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* FAQ & 页脚 */
.faq { padding: 20px 20px 40px; }
.faq h2 { margin-bottom: 12px; }
.faq ol { padding-left: 22px; color: var(--muted); }
.footer {
  border-top: 1px solid var(--border); padding: 22px 0;
  color: var(--muted); text-align: center; font-size: 14px;
}

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 22px; border-radius: 10px;
  z-index: 200; font-size: 14px; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary-dark); }

/* ---------- 后台 ---------- */
.admin-body { background: #f8fafc; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 380px; padding: 34px;
  display: flex; flex-direction: column; gap: 16px;
}
.logo-center { justify-content: center; }
.login-card p { text-align: center; }

#adminView { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: #0f172a; color: #fff;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 0 8px; }
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-link {
  padding: 11px 14px; border-radius: 10px; color: #cbd5e1; font-weight: 500;
  transition: all .2s;
}
.side-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-link.active { background: var(--primary); color: #fff; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-footer a { color: #94a3b8; font-size: 13px; padding: 0 8px; }
.sidebar-footer a:hover { color: #fff; }

.admin-main { flex: 1; padding: 28px 30px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.view-head h2 { font-size: 22px; }

.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th, .table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; background: var(--primary-light); display: block; }
.table .status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status.pending { background: #fef3c7; color: #b45309; }
.status.paid { background: #dbeafe; color: #1d4ed8; }
.status.delivered { background: var(--primary-light); color: var(--primary-dark); }
.status.cancelled { background: #fee2e2; color: var(--danger); }
.table a { color: var(--primary); word-break: break-all; }
.table .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table select { width: auto; padding: 6px 10px; }

.form-card { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.tip-card { padding: 20px; margin-top: 18px; max-width: 640px; }
.tip-card h3 { margin-bottom: 8px; }
.tip-card code { background: #f1f5f9; padding: 2px 8px; border-radius: 6px; color: var(--primary-dark); word-break: break-all; }

@media (max-width: 768px) {
  .topbar-inner { height: auto; flex-direction: column; gap: 8px; padding: 12px 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .product-detail { flex-direction: column; }
  .product-detail img { width: 100%; height: 200px; }
  .form-row { grid-template-columns: 1fr; }
  #adminView { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { margin-top: 0; flex-direction: row; }
  .admin-main { padding: 18px 14px; }
}
