@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@600;700&family=Noto+Sans+SC:wght@400;500;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e6e8ec;
  --ink: #1c2130;
  --ink-soft: #666e80;
  --mist: #9099ab;
  --primary: #3457d5;
  --primary-dark: #2942a8;
  --stamp: #a63d40;
  --paper: #fbf9f4;
  --paper-shadow: #e3ddc9;

  --font-display: 'Noto Serif SC', serif;
  --font-body: 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}
body { -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

/* ---------- 顶部导航 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot { color: var(--primary); }
.topnav { display: flex; align-items: center; gap: 22px; font-size: 13.5px; color: var(--ink-soft); }
.topnav a:hover { color: var(--primary); }
.topnav .divider { width: 1px; height: 14px; background: var(--border); }

/* ---------- 布局 ---------- */
.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 80px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
}

/* ---------- 分类侧栏 ---------- */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  height: fit-content;
}
.sidebar-title {
  font-size: 12px;
  color: var(--mist);
  padding: 10px 12px 4px;
  letter-spacing: 0.06em;
}
.cat-item {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  margin-bottom: 2px;
}
.cat-item:hover { background: var(--bg); }
.cat-item.active {
  background: rgba(52, 87, 213, 0.08);
  color: var(--primary);
  font-weight: 500;
}

/* ---------- 商品区 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0;
}
.section-head .count { font-size: 12.5px; color: var(--mist); font-family: var(--font-mono); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.product-card:hover {
  box-shadow: 0 12px 24px -14px rgba(28, 33, 48, 0.18);
  transform: translateY(-2px);
}
.product-card h3 {
  font-size: 15.5px;
  margin: 0;
  line-height: 1.45;
}
.product-card .desc {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.6;
  min-height: 34px;
}
.product-card .meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--mist);
  font-family: var(--font-mono);
}
.stock-badge { color: var(--stamp); }

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 2px;
}
.price {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--stamp);
}
.price .unit { font-size: 11px; font-weight: 500; margin-right: 1px; color: var(--ink-soft); }

.qty-row { display: flex; align-items: center; gap: 8px; }
.qty-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.qty-stepper button {
  background: var(--bg);
  border: none;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
}
.qty-stepper input {
  width: 34px;
  text-align: center;
  border: none;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 4px 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13.5px;
  border-radius: 7px;
  padding: 9px 16px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-stamp { background: var(--stamp); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 票据风结算卡片（承接原设计签名元素）---------- */
.wrap { max-width: 520px; margin: 0 auto; padding: 40px 24px 80px; }

.checkout-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 16px 30px -18px rgba(28, 33, 48, 0.35);
  border: 1px solid var(--paper-shadow);
}
.checkout-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed var(--paper-shadow);
  font-size: 14px;
}
.checkout-row:last-child { border-bottom: none; }
.checkout-row .label { color: var(--ink-soft); }
.checkout-row .value { font-family: var(--font-mono); font-weight: 500; }

.field-block { margin: 16px 0; }
.field-block label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
.field-block input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--paper-shadow);
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fff;
}
.field-block select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--paper-shadow);
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fff;
}

.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0; }
.pay-method {
  border: 1.5px solid var(--paper-shadow);
  border-radius: 9px;
  padding: 12px 14px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pay-method svg { width: 20px; height: 20px; flex-shrink: 0; }
.pay-method.active { border-color: var(--primary); background: rgba(52, 87, 213, 0.06); color: var(--primary); }

.pay-panel { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--paper-shadow); text-align: center; }

.qr-box img {
  width: 200px; height: 200px;
  border: 1px solid var(--paper-shadow);
  border-radius: 8px; padding: 8px; background: #fff;
}

.status-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(144, 153, 171, 0.15);
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.status-pill.paid { background: rgba(166, 61, 64, 0.12); color: var(--stamp); }

.stamp {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--stamp);
  border: 3px solid var(--stamp);
  border-radius: 10px;
  padding: 10px 22px;
  transform: rotate(-6deg);
  letter-spacing: 0.08em;
  animation: stamp-in 0.35s cubic-bezier(0.2, 1.4, 0.5, 1) both;
}
@keyframes stamp-in {
  from { transform: rotate(-6deg) scale(2.2); opacity: 0; }
  to { transform: rotate(-6deg) scale(1); opacity: 1; }
}

.center { text-align: center; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.mt-24 { margin-top: 24px; }
.mt-40 { margin-top: 40px; }

.notice-banner {
  background: rgba(52, 87, 213, 0.07);
  border: 1px solid rgba(52, 87, 213, 0.25);
  color: var(--primary-dark);
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-family: var(--font-mono);
}

/* ---------- 后台 ---------- */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.admin-tab {
  padding: 10px 16px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin-table th, table.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-family: var(--font-mono);
  white-space: nowrap;
}
table.admin-table th { background: var(--bg); font-family: var(--font-body); font-weight: 500; color: var(--ink-soft); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.full { grid-template-columns: 1fr; }
.form-field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px;
  font-family: var(--font-mono); font-size: 13px; background: #fff;
}
.form-field textarea { font-family: var(--font-mono); resize: vertical; min-height: 70px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-family: var(--font-mono); }
.badge-pending { background: rgba(144,153,171,0.15); color: var(--ink-soft); }
.badge-paid { background: rgba(166,61,64,0.12); color: var(--stamp); }
.badge-closed { background: rgba(28,33,48,0.08); color: var(--mist); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: var(--font-body);
}

/* ---------- 开关（支付方式启用/禁用）---------- */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d5d8de; transition: background-color .15s ease; border-radius: 24px;
}
.toggle-slider::before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: #fff; transition: transform .15s ease; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background-color: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---------- 支付方式配置卡片 ---------- */
.payment-card { border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; background: var(--surface); }
.payment-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.payment-card-head h3 { margin: 0; font-family: var(--font-display); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.payment-card-head .sub { font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 0; line-height: 1.6; }
.payment-status { display: inline-block; font-size: 11px; font-family: var(--font-mono); padding: 2px 8px; border-radius: 20px; }
.payment-status.on { background: rgba(52,87,213,0.1); color: var(--primary); }
.payment-status.off { background: rgba(28,33,48,0.06); color: var(--mist); }
.payment-fields { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); transition: opacity .15s ease; }
.payment-fields.disabled-look { opacity: 0.45; pointer-events: none; }
.field-group-label { font-size: 11.5px; color: var(--mist); letter-spacing: .05em; text-transform: uppercase; margin: 0 0 10px; }

/* ---------- 商品图片 ---------- */
.product-card .thumb {
  width: 100%; aspect-ratio: 4/3; border-radius: 7px; overflow: hidden;
  background: var(--bg); display:flex; align-items:center; justify-content:center;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; display:block; }
.product-card .thumb .placeholder { color: var(--mist); font-size: 12px; font-family: var(--font-mono); }
.product-card h3 { cursor: pointer; }
.product-card h3:hover { color: var(--primary); }

/* ---------- 商品详情页 ---------- */
.detail-shell { max-width: 880px; margin: 0 auto; padding: 28px 24px 80px; display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 720px) { .detail-shell { grid-template-columns: 1fr; } }
.detail-hero { width: 100%; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); display:flex; align-items:center; justify-content:center; }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-gallery { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.detail-gallery img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; }
.detail-desc { white-space: pre-wrap; font-size: 14px; line-height: 1.8; color: var(--ink-soft); margin: 16px 0; }

/* ---------- 支付后展示内容（发货内容）---------- */
.delivery-box {
  margin-top: 20px; padding: 16px; background: #fff; border: 1px dashed var(--primary);
  border-radius: 8px; text-align: left;
}
.delivery-box .title { font-size: 12px; color: var(--primary); font-weight: 500; margin-bottom: 8px; letter-spacing: .04em; }
.delivery-box .content { white-space: pre-wrap; font-size: 13.5px; line-height: 1.7; font-family: var(--font-mono); word-break: break-all; }

/* ---------- 后台：数据统计 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-card .label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.stat-card .value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--stamp); }
.region-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; }
.region-row .name { width: 120px; flex-shrink: 0; }
.region-bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.region-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.region-row .pct { width: 70px; text-align: right; font-family: var(--font-mono); color: var(--ink-soft); flex-shrink: 0; }

/* ---------- 图片上传控件 ---------- */
.upload-box { border: 1.5px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center; cursor: pointer; }
.upload-box:hover { border-color: var(--primary); }
.upload-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.upload-preview .item { position: relative; }
.upload-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.upload-preview .remove { position: absolute; top: -6px; right: -6px; background: var(--stamp); color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; display:flex; align-items:center; justify-content:center; cursor: pointer; }

/* ---------- 分页控件（前台商品列表 / 后台商品列表 / 后台热门页面）---------- */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 24px; flex-wrap: wrap; }
.pagination button {
  min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); cursor: pointer;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .jump { display: flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 12.5px; color: var(--ink-soft); }
.pagination .jump input {
  width: 44px; text-align: center; padding: 5px 4px; border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-mono); font-size: 12.5px;
}

/* ---------- 轻提示 Toast（操作成功等反馈）---------- */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,0.35); opacity: 0; transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--primary); }
.toast.error { background: var(--stamp); }

/* ---------- 顶部导航：醒目链接 + 商品搜索框 ---------- */
.nav-highlight {
  background: rgba(52, 87, 213, 0.1);
  color: var(--primary) !important;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 500;
}
.nav-highlight:hover { background: rgba(52, 87, 213, 0.18); }

.nav-search {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 4px 4px 12px;
}
.nav-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  font-family: var(--font-body);
  width: 120px;
  color: var(--ink);
}
.nav-search button {
  border: none;
  background: var(--primary);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-search button:hover { background: var(--primary-dark); }

/* ---------- 紧凑分页（窄空间，比如侧边栏分类列表）---------- */
.pagination.compact { gap: 4px; margin-top: 10px; padding: 0 12px; }
.pagination.compact button { min-width: 24px; height: 24px; padding: 0 6px; font-size: 11.5px; }
.pagination.compact .page-info { font-size: 11.5px; color: var(--mist); font-family: var(--font-mono); margin: 0 4px; }
