/* ===== 基础变量 ===== */
:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --header-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== 头部 ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.logo span { color: var(--color-primary); }

.logo .logo-name { color: var(--color-text); }

.logo img {
  display: block;
  height: 36px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  padding: 6px 12px;
  border-radius: 6px;
}

.nav-link:hover { background: var(--color-bg); color: var(--color-primary); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover { background: var(--color-border); color: var(--color-text); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }

.btn-block { width: 100%; }

/* ===== 商品网格 ===== */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 24px 0 20px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 40px;
}

@media (min-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

.product-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  color: inherit;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.product-card-image {
  aspect-ratio: 1;
  width: 100%;
  object-fit: contain;
  object-position: center;
  background: #fff;
}

.product-card-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-card-name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-danger);
  margin-top: auto;
}

.product-card-price small,
.price-from {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-left: 2px;
}

/* ===== 商品详情 ===== */
/* 跟随屏幕变宽，超宽屏停在 1600，避免一行拉得过长 */
.page-product .site-header .container,
.product-page {
  width: 100%;
  max-width: 1600px;
}

.product-detail-page {
  padding: 20px 0 40px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.product-page .product-detail-page {
  max-width: none;
}

.product-detail-alerts:empty {
  display: none;
}

.product-page .product-detail-layout {
  display: flex;
  flex-direction: column;
}

.product-page .product-detail-side {
  display: contents;
}

.product-page .product-detail-title { order: 1; }
.product-page .product-detail-alerts { order: 2; }
.product-page .carousel { order: 3; }
.product-page .product-specs-section { order: 4; }

@media (min-width: 768px) {
  .product-page .product-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.75fr);
    column-gap: clamp(20px, 2vw, 40px);
    align-items: start;
    margin-bottom: 24px;
  }

  .product-page .product-detail-side {
    display: flex;
    flex-direction: column;
    grid-column: 2;
    min-width: 0;
  }

  .product-page .product-detail-layout .carousel {
    grid-column: 1;
    margin-bottom: 0;
    order: 0;
  }

  .product-page .product-detail-title,
  .product-page .product-detail-alerts,
  .product-page .product-specs-section {
    order: 0;
  }

  .product-page .product-detail-layout .product-specs-section {
    margin-bottom: 0;
  }
}

.product-detail-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .product-detail-title { font-size: 1.75rem; margin-bottom: 20px; }
}

.page-product .product-detail-title { font-size: 1rem; }
.page-product .price-display { font-size: 1.5rem; }
.page-product .section-title { font-size: 1rem; }
.page-product .product-detail-desc { font-size: 0.875rem; }
.page-product .back-link { font-size: 0.8125rem; }
.page-product .spec-label,
.page-product .spec-option,
.page-product .stock-display { font-size: 0.875rem; }
.page-product .qty-input,
.page-product .add-cart-row,
.page-product .btn { font-size: 0.875rem; }
.page-product .rich-content h1 { font-size: 1.25rem; }
.page-product .rich-content h2 { font-size: 1.125rem; }
.page-product .rich-content h3 { font-size: 1rem; }

@media (min-width: 768px) {
  .page-product .product-detail-title { font-size: 1.25rem; }
}

/* 轮播 */
.carousel {
  position: relative;
  margin-bottom: 24px;
}

.carousel-viewport {
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
  aspect-ratio: 1;
}

.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.35s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  height: 100%;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text);
  z-index: 2;
}

.carousel-btn:hover { background: #fff; }

.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--color-border);
  cursor: pointer;
  padding: 0;
}

.carousel-dot.active {
  background: var(--color-primary);
  transform: scale(1.2);
}

.product-specs-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}

.product-desc-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.product-detail-desc {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.rich-content img { max-width: 100%; height: auto; border-radius: 8px; margin-top: 8px; margin-bottom: 8px; }
.rich-content p { margin-bottom: 0.75em; }
.rich-content .ql-align-center { text-align: center; }
.rich-content .ql-align-right { text-align: right; }
.rich-content .ql-align-justify { text-align: justify; }
.rich-content .ql-align-center img,
.rich-content [style*="text-align: center"] img,
.rich-content [style*="text-align:center"] img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.rich-content .ql-align-right img,
.rich-content [style*="text-align: right"] img,
.rich-content [style*="text-align:right"] img {
  display: block;
  margin-left: auto;
  margin-right: 0;
}
.rich-content ul, .rich-content ol { margin: 0.5em 0 0.75em 1.5em; }
.rich-content h1, .rich-content h2, .rich-content h3 { margin: 0.75em 0 0.5em; color: var(--color-text); }
.rich-content a { color: var(--color-primary); }

/* ===== 富文本编辑器 ===== */
#editor {
  min-height: 200px;
  background: var(--color-surface);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.ql-toolbar.ql-snow {
  border: 1px solid var(--color-border);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  background: var(--color-bg);
}

.ql-container.ql-snow {
  border: 1px solid var(--color-border);
  border-top: none;
  font-family: var(--font);
  font-size: 0.9375rem;
}

/* ===== 图片上传 ===== */
.image-upload-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .image-upload-area {
    flex-direction: row;
    align-items: flex-start;
  }
}

.image-preview {
  width: 160px;
  height: 160px;
  border: 2px dashed var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  flex-shrink: 0;
}

.image-preview:empty::after {
  content: "暂无图片";
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload-controls { flex: 1; }

.image-upload-controls input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--color-surface);
}

.upload-hint, .specs-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.specs-hint { margin-bottom: 12px; }

.spec-label {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.spec-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.spec-option {
  padding: 8px 16px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.875rem;
  transition: border-color 0.2s, background 0.2s;
}

.spec-option:hover { border-color: var(--color-primary); }

.spec-option.active {
  border-color: var(--color-primary);
  background: #eff6ff;
  color: var(--color-primary);
  font-weight: 600;
}

.spec-option.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}

.price-display {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-danger);
  margin-bottom: 8px;
}

.stock-display {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

.stock-display.in-stock { color: var(--color-success); }

/* ===== 管理后台 ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 220px;
  background: #1e293b;
  color: #fff;
  flex-shrink: 0;
  display: none;
  border-radius: 0 14px 14px 0;
  box-shadow: 4px 0 18px rgba(15, 23, 42, 0.16);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  transition: width 0.2s ease;
  z-index: 2;
}

.admin-sidebar.is-collapsed { width: 76px; }

@media (min-width: 768px) {
  .admin-sidebar { display: block; }
}

.admin-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 16px 18px;
  font-size: 1.125rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.admin-sidebar.is-collapsed .admin-sidebar-header { justify-content: center; padding: 16px 8px; }
.admin-sidebar.is-collapsed .admin-sidebar-title { display: none; }

.admin-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-sidebar-toggle svg { width: 18px; height: 18px; }
.admin-sidebar.is-collapsed .admin-sidebar-toggle svg { transform: scaleX(-1); }
.admin-sidebar-toggle:hover { background: rgba(255,255,255,0.16); }

.admin-sidebar nav { padding: 12px 8px; }

.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.9375rem;
}

.admin-sidebar.is-collapsed nav a { justify-content: center; padding: 10px 0; }
.admin-sidebar.is-collapsed .admin-nav-label { display: none; }

.admin-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon-products { color: #60a5fa; }
.icon-categories { color: #fbbf24; }
.icon-bundles { color: #c084fc; }
.icon-users { color: #2dd4bf; }
.icon-orders { color: #fb923c; }
.icon-visits { color: #4ade80; }
.icon-payment { color: #f472b6; }
.icon-site { color: #818cf8; }
.icon-version { color: #facc15; }
.icon-account { color: #f9a8d4; }
.icon-shop { color: #38bdf8; }
.icon-logout { color: #fb7185; }

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.version-text {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.7;
}

.admin-main { flex: 1; min-width: 0; }

.admin-topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-topbar h1 {
  font-size: 1.125rem;
  font-weight: 600;
}

.admin-content { padding: 20px 16px; }

.visit-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.visit-ranges,
.visit-date-form,
.visit-product-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.visit-date-form input[type="date"],
.visit-product-form input[type="text"] {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9375rem;
}

.visit-product-form input[type="text"] { width: 160px; }

.visit-summary {
  margin: 0 0 16px;
  font-weight: 600;
}

.visit-error {
  margin: 0 0 12px;
  color: var(--color-danger);
}

.visit-section-title {
  margin: 20px 0 12px;
  font-size: 1rem;
}

@media (min-width: 768px) {
  .admin-content { padding: 24px 32px; }
}

/* ===== 表格 ===== */
.table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }

td.product-name-cell {
  white-space: normal;
  min-width: 160px;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active { background: #dcfce7; color: #166534; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-inactive { background: #fee2e2; color: #991b1b; }

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ===== 表单 ===== */
.form-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 900px;
}

.product-edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.78fr);
  gap: 24px;
  align-items: start;
  width: 100%;
}

.product-edit-main,
.product-edit-side {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  min-width: 0;
}

.product-edit-main .tox-tinymce {
  border-radius: 8px;
  border-color: var(--color-border);
}

.product-edit-side .spec-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
}

.product-edit-side .spec-name-field,
.product-edit-side .spec-image-cell {
  grid-column: 1 / -1;
}

.product-edit-side .spec-image-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.product-edit-side .spec-image-cell label {
  margin-bottom: 0;
}

.spec-row input[type="text"],
.spec-row input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.spec-price-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spec-price-line input[type="number"] {
  flex: 1;
  min-width: 0;
  width: auto;
}

.spec-row .spec-price-from {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.spec-price-from-check {
  width: 16px;
  height: 16px;
  margin: 0;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-family: var(--font);
  transition: border-color 0.2s;
  background: var(--color-surface);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group textarea { resize: vertical; min-height: 100px; }

.form-row {
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  align-items: center;
}

.save-status {
  color: var(--color-success);
  font-weight: 600;
  font-size: 0.9375rem;
}

/* ===== 规格编辑器 ===== */
.specs-section h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.spec-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 8px;
  margin-bottom: 8px;
  align-items: end;
}

@media (min-width: 768px) {
  .spec-row {
    grid-template-columns: 100px 2fr 1fr 1fr 1fr auto;
    gap: 10px;
  }
}

.spec-image-cell { min-width: 0; }

.spec-image-preview {
  width: 80px;
  height: 80px;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.spec-image-preview:empty::after {
  content: "无图";
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

.spec-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spec-image-input {
  width: 100%;
  font-size: 0.75rem;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
}

.list-image-preview {
  width: 160px;
  height: 160px;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.list-image-preview:empty::after {
  content: "暂无列表图";
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.list-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.spec-image-cell .image-actions .btn {
  padding: 4px 8px;
}

.desc-images {
  margin-top: 16px;
}

.desc-images-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.desc-image-list,
.library-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.desc-image-item,
.library-item {
  width: 120px;
  background: var(--color-bg);
  border-radius: 8px;
  padding: 8px;
}

.product-image-library .btn-danger,
.desc-image-item .btn-danger,
#listImageDelete,
.spec-image-delete {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.product-image-library .btn-danger:hover,
.desc-image-item .btn-danger:hover,
#listImageDelete:hover,
.spec-image-delete:hover {
  background: #fff;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.desc-image-item img,
.library-item img {
  width: 100%;
  height: 88px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
}

.library-uses {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 6px 0;
}

.product-image-library {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.product-image-library h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.spec-row label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  display: block;
}

.spec-row .btn-remove {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 8px;
  line-height: 1;
  align-self: center;
}

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.login-card p {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.error-msg {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.success-msg {
  background: #dcfce7;
  color: #166534;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 16px;
  max-width: 900px;
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.logo-preview {
  font-weight: 700;
  color: var(--color-text);
}

.logo-preview span {
  color: var(--color-primary);
}

.brand-asset-preview {
  width: 180px;
  height: 72px;
  margin-top: 8px;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.brand-asset-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-asset-preview.favicon {
  width: 64px;
  height: 64px;
}

.form-group label.brand-asset-remove {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin-top: 8px;
  margin-bottom: 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.form-group label.brand-asset-remove input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 16px;
}

.form-group input[type="file"] {
  display: block;
  margin-top: 8px;
}

.form-group input.image-file-input,
input.image-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state p { margin-bottom: 16px; }

/* ===== 页脚 ===== */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

.delete-form { display: inline; }

/* ===== 图片点击放大 ===== */
main img:not(.product-card-image),
.site-footer img {
  cursor: zoom-in;
}

.product-detail-desc img,
.rich-content img,
main .product-detail-desc img,
main .rich-content img {
  cursor: default;
}

.product-detail-desc a,
.rich-content a,
main .product-detail-desc a img,
main .rich-content a img {
  cursor: pointer;
}

.product-card-image,
.bundle-card .product-card-image {
  cursor: pointer;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.image-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.image-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.image-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.image-lightbox-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.image-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.image-lightbox-img.zoomed {
  cursor: zoom-out;
}

/* ===== 首页 Tab ===== */
.home-tabs-wrap {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: var(--header-h);
  z-index: 90;
}

.home-tabs {
  display: flex;
  gap: 0;
}

.home-tab {
  flex: 1;
  max-width: 200px;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  font-family: var(--font);
}

.home-tab.active {
  color: var(--color-primary);
}

.home-tab.active::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 3px 3px 0 0;
}

.home-panel {
  display: none;
  padding: 20px 0 40px;
}

.home-panel.active {
  display: block;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

.category-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
  font-family: var(--font);
}

.category-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.category-card-name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.category-card-count {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.category-back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-view-title {
  font-size: 1.125rem;
  font-weight: 600;
}

/* ===== 组合 ===== */
.bundle-card-tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-primary);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.product-card-meta {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.bundle-badge {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
  background: #eff6ff;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.bundle-cover {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
  max-width: 720px;
  margin: 0 auto 24px;
  background: var(--color-bg);
}

.bundle-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bundle-price-hint {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.bundle-item-list {
  list-style: none;
}

.bundle-item-entry {
  border-bottom: 1px solid var(--color-border);
}

.bundle-item-entry:last-child {
  border-bottom: none;
}

.bundle-item-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: inherit;
}

.bundle-item-link:hover {
  color: var(--color-primary);
}

.bundle-item-link img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.bundle-item-name {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
}

.bundle-item-qty {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.bundle-item-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 8px;
  margin-bottom: 8px;
  align-items: end;
}

@media (min-width: 640px) {
  .bundle-item-row {
    grid-template-columns: 2fr 120px auto;
    gap: 10px;
  }
}

.home-tab {
  max-width: none;
}

/* ===== 用户与导航 ===== */
.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link-primary {
  color: var(--color-primary);
  font-weight: 600;
}

@media (max-width: 767px) {
  html:not(:has(.admin-layout)) {
    font-size: 14px;
    --header-h: 52px;
  }

  .site-header .container {
    gap: 8px;
    min-width: 0;
  }

  .logo {
    gap: 6px;
    min-width: 0;
    flex: 1;
    font-size: 1rem;
  }

  .logo img {
    height: 28px;
    max-width: 64px;
    flex-shrink: 0;
  }

  .logo .logo-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .site-nav {
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 0;
  }

  .nav-link {
    padding: 6px;
  }
}

.back-link {
  margin: 12px 0;
  font-size: 0.875rem;
}

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-weight: 600;
  line-height: 1;
}

.back-home:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.back-home-icon {
  width: 16px;
  height: 16px;
  display: block;
  color: var(--color-primary);
}

.site-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 4px 4px 12px;
  margin: 16px 0 0;
}

.site-search-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.site-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--color-text);
  outline: none;
  padding: 6px 0;
}

.product-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 4px;
}

.product-toolbar .back-link,
.product-toolbar .site-search {
  margin: 0;
}

.product-toolbar .site-search {
  flex: 1;
}

@media (max-width: 767px) {
  .product-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

.user-auth-page {
  padding: 40px 0 60px;
  display: flex;
  justify-content: center;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 1.375rem;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.user-page {
  padding: 20px 0 40px;
  max-width: 720px;
  margin: 0 auto;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.user-menu-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .user-menu-grid { grid-template-columns: repeat(3, 1fr); }
}

.user-menu-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  color: inherit;
  transition: transform 0.2s;
}

.user-menu-card:hover {
  transform: translateY(-2px);
  color: var(--color-primary);
}

.user-menu-title {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.user-menu-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.add-cart-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.add-cart-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.qty-input {
  width: 80px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9375rem;
}

.cart-list {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  align-items: center;
}

@media (min-width: 640px) {
  .cart-item { grid-template-columns: 80px 1fr auto auto; }
}

.cart-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
}

.cart-item-name {
  font-weight: 600;
  color: inherit;
}

.cart-item-spec {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.cart-item-price {
  color: var(--color-danger);
  font-weight: 600;
  margin-top: 4px;
}

.cart-qty-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.cart-summary {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cart-total strong {
  font-size: 1.25rem;
  color: var(--color-danger);
}

.address-list, .order-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.address-card, .order-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  color: inherit;
}

.order-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.address-card-body p {
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.address-option {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
}

.address-option:has(input:checked) {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.address-text {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.checkout-summary {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.order-card-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.order-card-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
}

.order-card-total {
  margin-top: 10px;
  font-weight: 600;
  color: var(--color-danger);
}

.order-meta {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.order-total-row {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  text-align: right;
}

.checkout-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ===== 个人中心 ===== */
.account-page {
  padding: 20px 0 48px;
  max-width: 800px;
  margin: 0 auto;
}

.profile-header-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.profile-meta {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 2px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.profile-stat-item {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
  color: inherit;
  transition: transform 0.2s;
}

.profile-stat-item:hover {
  transform: translateY(-2px);
  color: var(--color-primary);
}

.profile-stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.profile-stat-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.account-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .account-grid { grid-template-columns: 1fr 1fr; }
}

.account-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.account-section .section-title {
  margin-bottom: 16px;
  padding-bottom: 0;
  border-bottom: none;
  font-size: 1.0625rem;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-header-row .section-title {
  margin-bottom: 0;
}

.section-hint {
  margin-bottom: 16px;
}

.profile-form .form-group {
  margin-bottom: 14px;
}

.text-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.875rem;
}

.address-list.compact,
.order-list.compact {
  gap: 10px;
}

.address-card.compact,
.order-card.compact {
  padding: 14px;
}

.address-card-top {
  margin-bottom: 4px;
}

.empty-state.compact {
  padding: 24px 16px;
}

.account-quick-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.account-quick-links .user-menu-card {
  text-align: center;
  padding: 14px 8px;
  font-size: 0.875rem;
}

.admin-user-password {
  margin-top: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.admin-detail-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 16px;
  margin: 0;
}

.admin-detail-grid dt {
  color: var(--text-muted, #6b7280);
  font-size: 0.875rem;
}

.admin-detail-grid dd {
  margin: 0;
}

.admin-link {
  color: var(--primary, #2563eb);
  text-decoration: none;
}

.admin-link:hover {
  text-decoration: underline;
}

.text-muted {
  color: var(--text-muted, #6b7280);
  font-size: 0.875rem;
}

.admin-order-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-order-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
