:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #1a1a1a;
  --accent-fg: #ffffff;
  --border: #e5e5e5;
  --danger: #c0392b;
  --success: #1f7a3d;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
}

a { color: inherit; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

header.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
header.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.02em; text-decoration: none; }
.header-nav { display: flex; align-items: center; gap: 18px; }
.header-nav a { text-decoration: none; font-size: 0.95rem; }
.cart-link { position: relative; }
.cart-badge {
  position: absolute; top: -8px; right: -12px;
  background: var(--accent); color: var(--accent-fg);
  border-radius: 999px; font-size: 0.7rem; min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.cart-badge:empty { display: none; }

main { padding: 32px 0 64px; }

.product-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
@media (max-width: 820px) { .product-layout { grid-template-columns: 1fr; } }

.gallery-main img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.gallery-thumbs button {
  width: 64px; height: 64px; padding: 0; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; overflow: hidden; background: none;
}
.gallery-thumbs button.active { border-color: var(--accent); border-width: 2px; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }

.product-info h1 { font-size: 1.7rem; margin: 0 0 8px; }
.price { font-size: 1.4rem; font-weight: 700; }
.compare-at { color: var(--muted); text-decoration: line-through; margin-left: 10px; font-weight: 400; font-size: 1.1rem; }
.vendor { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; margin-bottom: 8px; }

.product-description { margin: 22px 0; font-size: 0.95rem; color: #333; }
.product-description p { margin: 0 0 12px; }
/* 详情描述为 Markdown 渲染结果 */
.product-description h2,
.product-description h3,
.product-description h4,
.product-description h5 { margin: 18px 0 8px; font-size: 1rem; }
.product-description ul,
.product-description ol { margin: 0 0 12px; padding-left: 1.3em; }
.product-description li { margin-bottom: 4px; }
.product-description blockquote {
  margin: 0 0 12px; padding: 6px 12px; border-left: 3px solid var(--border); color: #555;
}
.product-description code {
  background: #f3f3f3; padding: 1px 4px; border-radius: 4px; font-size: 0.9em;
}
.product-description pre {
  background: #f6f6f6; padding: 10px 12px; border-radius: var(--radius); overflow-x: auto;
}
.product-description pre code { background: none; padding: 0; }
.product-description hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.product-description a { text-decoration: underline; }
.product-description > :last-child { margin-bottom: 0; }

.option-row { margin: 20px 0; }
.option-row label { display: block; font-size: 0.9rem; margin-bottom: 8px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); padding: 0;
}
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px #fff inset; }

/* 颜色缩略图（用商品第一张图） */
.swatch-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 2px solid var(--border); border-radius: 8px;
  padding: 4px; cursor: pointer; width: 72px;
}
.swatch-thumb img {
  width: 60px; height: 60px; object-fit: cover; border-radius: 5px; display: block;
}
.swatch-thumb .swatch-label { font-size: 0.72rem; color: var(--muted); line-height: 1.2; }
.swatch-thumb.active { border-color: var(--accent); }
.swatch-thumb.active .swatch-label { color: var(--fg); }

.qty-row { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.qty-row input { width: 64px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: var(--radius); padding: 12px 22px;
  font-size: 1rem; cursor: pointer; text-decoration: none;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }

.info-sections { margin-top: 56px; }
.info-sections figure { margin: 0 0 40px; }
.info-sections img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }

.notice { background: #f6f6f6; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 16px 0; }
.notice.error { background: #fdf1f0; border-color: #f2c4c0; color: var(--danger); }
.notice.success { background: #eef8f1; border-color: #c4e6cf; color: var(--success); }

form .field { margin-bottom: 16px; }
form label { display: block; font-size: 0.9rem; margin-bottom: 6px; }
form input, form select, form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem;
}
form textarea { font: inherit; resize: vertical; }

.cart-lines { border-top: 1px solid var(--border); }
.cart-line {
  display: grid; grid-template-columns: 64px 1fr auto auto; gap: 14px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.cart-line img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.cart-line .line-title { font-weight: 600; }
.cart-line .line-meta { color: var(--muted); font-size: 0.85rem; }

.totals { margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.totals .row { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .row.total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; font-weight: 700; font-size: 1.1rem; }

.section-title { font-size: 1rem; margin: 24px 0 6px; }
.ship-address { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.ship-address .line-title { font-weight: 600; }
.ship-address .line-meta { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.return-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.return-item span:first-child { min-width: 80px; font-weight: 500; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.page-title { font-size: 1.6rem; margin: 0 0 24px; }

.timeline { list-style: none; padding: 0; margin: 24px 0; }
.timeline li { display: flex; gap: 12px; align-items: center; padding: 10px 0; color: var(--muted); }
.timeline li .dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--border); flex: none;
}
.timeline li.done { color: var(--fg); }
.timeline li.done .dot { background: var(--success); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #fafafa; }

.admin-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.badge-status { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.badge-status.paid { background: #eef8f1; color: var(--success); border-color: #c4e6cf; }
.badge-status.shipped { background: #eef4fd; color: #1d5f9e; border-color: #c4ddf2; }
.badge-status.delivered { background: #f0f0f0; color: #444; }
.badge-status.pending { background: #fdf6e3; color: #8a6d1a; border-color: #f0e2b6; }

/* 状态类别 */
.badge-status.normal { background: #eef8f1; color: var(--success); border-color: #c4e6cf; }
.badge-status.warning { background: #fdf6e3; color: #8a6d1a; border-color: #f0e2b6; }
.badge-status.danger { background: #fdf1f0; color: var(--danger); border-color: #f2c4c0; }
.badge-status.muted { background: #f2f2f2; color: #666; border-color: #e0e0e0; }

.item-status { font-size: 0.85rem; color: var(--muted); }
.order-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.order-head .page-title { margin: 0; }

.notice.warning { background: #fdf6e3; border-color: #f0e2b6; color: #8a6d1a; }

/* 筛选与操作 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 0.85rem; cursor: pointer;
}
.chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.action-panel { display: flex; flex-wrap: wrap; gap: 8px; }

/* 退货 */
.return-list { display: flex; flex-direction: column; gap: 10px; }
.return-line {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  cursor: pointer;
}
.return-line .return-qty { margin-left: auto; font-size: 0.85rem; color: var(--muted); }
.return-line .return-qty input { width: 60px; padding: 4px 6px; margin-left: 4px; }

.return-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.return-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.return-review { margin-top: 12px; }
.return-review label { display: block; font-size: 0.86rem; color: var(--muted); margin-bottom: 6px; }
.return-review textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 0.95rem; resize: vertical;
}

/* 弹窗 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.modal h3 { margin-top: 0; }

/* 邮件记录 */
.mail-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 8px;
}
.mail-item summary { cursor: pointer; }
.mail-body {
  margin-top: 10px; padding: 12px; background: #fafafa;
  border-radius: 6px; font-size: 0.9rem; overflow-x: auto;
}

/* 商品 / SKU 编辑 */
.thumb {
  width: 40px; height: 40px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border); vertical-align: middle;
}
.cell-input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; font: inherit; font-size: 0.88rem;
}
.cell-input[readonly] { background: #f7f7f7; color: var(--muted); }
.image-gallery { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.image-card {
  width: 132px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; text-align: center;
}
.image-card img {
  width: 100%; height: 96px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border); margin-bottom: 6px;
}
.image-card .line-meta { font-size: 0.72rem; word-break: break-all; }
.image-card .btn { margin-top: 6px; }
#sku-table td { vertical-align: middle; }
#sku-table code { font-size: 0.82rem; }

/* 导航未读角标 */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 4px;
  background: #c0392b; color: #fff; border-radius: 999px;
  font-size: 0.68rem; line-height: 1;
}

/* 收件箱 */
.inbox-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.inbox-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; background: #fff;
}
.inbox-card.unread { border-left: 3px solid #d68a1e; background: #fffdf7; }
.inbox-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.inbox-body { white-space: pre-wrap; word-break: break-word; font-size: 0.94rem; margin-bottom: 8px; }
.reply-box { margin-top: 8px; }

/* 沟通记录 */
.message-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 20px; }
.message-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; background: #fff;
}
.message-item.inbound { background: #f7fbf8; border-color: #d6ead9; }
.message-item.outbound { background: #fafafa; }
.message-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.message-body { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }

footer.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 0.85rem; }

