/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --grad: linear-gradient(135deg, #0bb39a 0%, #0a84e8 100%);
  --primary: #0a84e8;
  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --placeholder: #9ca3af;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(17,24,39,.06);
  --ease: cubic-bezier(.22,.61,.36,1);
}
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.price { color: var(--danger); font-weight: 700; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ============ 未授权横幅 ============ */
.license-bar {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; text-align: center; padding: 10px 16px;
  font-size: 14px; font-weight: 600;
}

/* ============ 前台顶栏 ============ */
.topbar {
  background: #fff;
  box-shadow: 0 2px 8px rgba(17,24,39,.04);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.brand-name { font-weight: 700; font-size: 17px; }
.topnav { display: flex; gap: 20px; }
.topnav a { color: var(--muted); font-size: 14px; }
.topnav a:hover { color: var(--primary); text-decoration: none; }

/* ============ 公告条 ============ */
.notice-bar {
  max-width: 1100px; margin: 16px auto 0; padding: 10px 18px;
  background: #ecfdf5; color: #065f46; border-radius: 10px;
  font-size: 14px; border-left: 3px solid var(--success);
}

/* ============ 页面容器 ============ */
.page-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { margin: 10px 0 20px; }
.page-head h1 { font-size: 24px; margin-bottom: 4px; }

/* ============ 商品网格 ============ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
  animation: fadeUp .3s var(--ease) both;
}
.product-card:nth-child(1) { animation-delay: 0s; }
.product-card:nth-child(2) { animation-delay: .04s; }
.product-card:nth-child(3) { animation-delay: .08s; }
.product-card:nth-child(4) { animation-delay: .12s; }
.product-card:nth-child(5) { animation-delay: .16s; }
.product-card:nth-child(6) { animation-delay: .20s; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 10px 32px rgba(17,24,39,.1); }
.product-card.soldout { opacity: .6; }
.product-cat {
  display: inline-block; align-self: flex-start;
  background: var(--grad); color: #fff;
  font-size: 12px; padding: 2px 10px; border-radius: 20px;
}
.product-name { font-size: 17px; font-weight: 700; }
.product-desc { color: var(--muted); font-size: 13px; min-height: 38px; }
.product-meta { display: flex; justify-content: space-between; align-items: baseline; }
.product-meta .price { font-size: 22px; }

/* ============ 卡片通用 ============ */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
  animation: fadeUp .3s var(--ease) both;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-block; padding: 10px 20px;
  border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; text-align: center;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s;
  background: #f3f4f6; color: var(--text); font-weight: 500;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(10,132,232,.3); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(10,132,232,.4); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 16px; min-height: 44px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-disabled { background: #e5e7eb; color: var(--placeholder); cursor: not-allowed; }
.btn-copy { background: var(--grad); color: #fff; }

/* ============ 表单 ============ */
.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 13px; color: var(--muted); font-weight: 500; }
.form-row input, .form-row textarea, .form-row select {
  padding: 11px 14px; border: 1.5px solid #e5e7eb; border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff;
  transition: border-color .18s, box-shadow .18s;
  min-height: 44px;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10,132,232,.15);
}
.form-row textarea { resize: vertical; }
.form-inline { display: flex; gap: 10px; align-items: center; }
.form-inline select { padding: 10px 14px; border: 1.5px solid #e5e7eb; border-radius: 10px; min-height: 44px; }
.buy-form { margin-top: 16px; }

/* ============ 详情/收银台/结果 ============ */
.detail-wrap { max-width: 700px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; }
.detail-name { font-size: 24px; margin: 8px 0; }
.detail-desc { color: var(--muted); margin: 12px 0; padding: 12px; background: #f9fafb; border-radius: 10px; }
.detail-price { font-size: 28px; margin: 10px 0; }
.checkout-card, .result-card, .query-card { max-width: 560px; margin: 20px auto; }
.checkout-title { margin-bottom: 16px; }
.checkout-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid #f3f4f6; font-size: 14px;
}
.checkout-row span { color: var(--muted); }
.checkout-row.total { border-bottom: none; font-size: 18px; padding-top: 16px; }
.checkout-row.total .price { font-size: 24px; }
.mock-box { margin-top: 20px; padding: 20px; background: #fffbeb; border-radius: 10px; text-align: center; }
.warn-box {
  background: #fef2f2; color: var(--danger); padding: 10px 14px;
  border-radius: 8px; font-size: 13px; margin: 10px 0;
}

/* ============ 结果页 ============ */
.result-success { text-align: center; padding: 10px 0 20px; }
.result-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  animation: popIn .4s var(--ease);
}
.result-pending { text-align: center; padding: 30px 0; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ============ 卡密列表 ============ */
.cards-title { margin: 20px 0 10px; font-size: 16px; }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #f9fafb; border-radius: 10px;
  animation: fadeUp .25s var(--ease) both;
}
.card-content { font-size: 14px; word-break: break-all; background: transparent; padding: 0; }

/* ============ 查询 ============ */
.query-form { display: flex; gap: 10px; margin: 14px 0; }
.query-form input {
  flex: 1; padding: 11px 14px; border: 1.5px solid #e5e7eb;
  border-radius: 10px; font-size: 15px; min-height: 44px;
}
.query-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,132,232,.15); }

/* ============ 徽章 ============ */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; background: #f3f4f6; color: var(--muted);
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* ============ 页脚 ============ */
.footer { background: #fff; border-top: 1px solid #f3f4f6; padding: 24px 20px; margin-top: 40px; }
.footer-inner { max-width: 1100px; margin: 0 auto; text-align: center; color: var(--muted); font-size: 13px; }
.footer-contact { margin-bottom: 6px; }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 999;
  background: #1f2937; color: #fff; padding: 12px 20px;
  border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(-12px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ============ 动画 ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  0% { opacity: 0; transform: scale(.5); }
  100% { opacity: 1; transform: scale(1); }
}

/* ============ 后台布局 ============ */
.admin-body { background: #f5f7fa; }
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #1f2937; color: #d1d5db;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px; border-bottom: 1px solid #374151;
}
.sidebar-brand .brand-logo { width: 32px; height: 32px; font-size: 16px; }
.sidebar-brand .brand-name { color: #fff; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 0; display: flex; flex-direction: column; }
.sidebar-nav a {
  color: #d1d5db; padding: 11px 20px; font-size: 14px;
  transition: background .18s, color .18s; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: #374151; color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: #374151; color: #fff; border-left-color: #0bb39a; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid #374151; display: flex; gap: 12px; }
.sidebar-footer a { color: #9ca3af; font-size: 13px; }
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  background: #fff; padding: 14px 28px; text-align: right;
  border-bottom: 1px solid #f3f4f6; color: var(--muted); font-size: 14px;
}
.admin-content { padding: 24px 28px; flex: 1; }
.page-title { font-size: 20px; margin-bottom: 18px; }
.page-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* ============ 后台统计 ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card { padding: 20px; }
.stat-num { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.stat-label { color: var(--muted); font-size: 13px; }

/* ============ 表格 ============ */
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f3f4f6; }
.table th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9fafb; }

/* ============ 表单卡片 ============ */
.form-card { max-width: 600px; margin-bottom: 20px; }
.form-card h3 { margin-bottom: 12px; font-size: 16px; }
.info-card { max-width: 600px; }
.info-card ol { padding-left: 20px; margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 2; }
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; }

/* ============ 登录页 ============ */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0bb39a10, #0a84e810); }
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-card { text-align: center; }
.login-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--grad); color: #fff; font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.login-card h2 { margin-bottom: 20px; }
.login-card form { text-align: left; }

/* ============ 移动端 ============ */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; overflow-x: auto; padding: 0;
  }
  .sidebar-brand { padding: 12px 16px; border-bottom: none; border-right: 1px solid #374151; }
  .sidebar-nav { flex-direction: row; padding: 0; overflow-x: auto; }
  .sidebar-nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; padding: 14px 14px; }
  .sidebar-nav a.active { border-bottom-color: #0bb39a; }
  .sidebar-footer { display: none; }
  .admin-content { padding: 16px; }
  .product-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: 12px 16px; }
  .page-wrap { padding: 16px 12px 40px; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 10px; }
}
