:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-alt: #F2F1ED;
  --text: #1E1E1B;
  --text-mid: #57564F;
  --text-muted: #8A887F;
  --line: #E7E5DF;
  --line-strong: #D5D2C9;
  --accent: #1C5D4E;
  --accent-soft: #E7F1EC;
  --danger: #B3261E;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(30, 30, 27, .04);
  --shadow-md: 0 6px 24px rgba(30, 30, 27, .08);
  --shadow-lg: 0 24px 64px rgba(30, 30, 27, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------- 顶栏 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent);
  display: inline-block;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 3px;
  border: 1.5px solid rgba(255, 255, 255, .9);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .2px;
  user-select: none;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 10px;
  height: 38px;
  min-width: 240px;
  flex: 1;
  max-width: 380px;
  color: var(--text-muted);
  transition: border-color .15s, box-shadow .15s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  height: 100%;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}

.search-box input::placeholder { color: var(--text-muted); }

.icon-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}

.icon-btn:hover { color: var(--text); background: var(--surface-alt); }

select {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%238A887F' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>") no-repeat right 12px center;
  padding: 0 30px 0 12px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  color: var(--text-mid);
}

select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- 主体 ---------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.result-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--text-muted);
  font-size: 13px;
  min-height: 20px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-alt);
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}

.card:hover .card-media img { transform: scale(1.04); }

.no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #C6C3B9;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 2px;
  background:
    repeating-linear-gradient(45deg, transparent 0 10px, rgba(0, 0, 0, .012) 10px 20px),
    var(--surface-alt);
  user-select: none;
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(28, 93, 78, .92);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .3px;
}

.card-badge.sold-out { background: rgba(87, 86, 79, .88); }

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-cat {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .5px;
}

.card-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  font-size: 12.5px;
  color: var(--text-mid);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
}

.chip {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.6;
}

/* ---------- 空状态 / 分页 ---------- */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
}

.empty-title {
  font-size: 15px;
  color: var(--text-mid);
  margin: 0 0 6px;
}

.empty-hint { font-size: 13px; margin: 0; }

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.pager button {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-mid);
  font-size: 13px;
}

.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.pager button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 页脚 ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.footer-dot { opacity: .5; }

/* ---------- 弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(30, 30, 27, .38);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 48px);
  overflow: auto;
  animation: pop .18s ease;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  background: rgba(255, 255, 255, .9);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--text-mid);
  cursor: pointer;
  z-index: 2;
}

.modal-close:hover { background: var(--surface-alt); color: var(--text); }

/* ---------- 详情 ---------- */

.detail-card {
  width: min(920px, 100%);
}

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.detail-gallery {
  background: var(--surface-alt);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gallery-main {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.gallery-thumbs:empty { display: none; }

.gallery-thumbs img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface);
  flex-shrink: 0;
}

.gallery-thumbs img.active { border-color: var(--accent); }

.detail-info {
  padding: 34px 34px 34px 30px;
  min-width: 0;
}

.detail-info h2 {
  font-size: 22px;
  line-height: 1.35;
  margin: 8px 0 10px;
  font-weight: 600;
}

.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.detail-summary {
  color: var(--text-mid);
  font-size: 13.5px;
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-stock {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.detail-desc {
  font-size: 13.5px;
  color: var(--text-mid);
  white-space: pre-wrap;
  line-height: 1.75;
}

.detail-desc:empty { display: none; }

.spec-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 13px;
}

.spec-table td {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  vertical-align: top;
}

.spec-table td:first-child {
  color: var(--text-muted);
  width: 38%;
  padding-right: 16px;
}

/* ---------- 登录 ---------- */

.login-card {
  width: min(360px, 100%);
  padding: 30px 28px 24px;
}

.login-card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }

.login-hint { color: var(--text-muted); font-size: 13px; margin: 0 0 18px; }

.login-card input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
  background: var(--surface);
}

.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.login-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.form-error {
  color: var(--danger);
  font-size: 12.5px;
  margin: 10px 0 0;
}

/* ---------- 按钮 ---------- */

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover { background: #17493d; }

.btn.ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text-mid);
}

.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn.danger-ghost {
  background: var(--surface);
  border-color: #E8C9C6;
  color: var(--danger);
}

.btn.danger-ghost:hover { background: #FBF1F0; }

.btn.small { height: 30px; padding: 0 10px; font-size: 12px; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

.file-btn { position: relative; }

/* ---------- 后台 ---------- */

.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-panel[hidden] { display: none; }

.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.admin-title { display: flex; align-items: center; gap: 10px; }

.admin-title strong { font-size: 15px; font-weight: 600; }

.admin-badge {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 12px;
}

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-search { padding: 16px 24px 0; }

.admin-search input {
  width: min(360px, 100%);
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 12px;
  outline: none;
  background: var(--surface);
}

.admin-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.admin-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 16px 24px 32px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #FBFAF8;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: 0; }

.admin-table tr:hover td { background: #FBFAF8; }

.thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-alt);
  display: block;
}

.thumb-empty {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}

.row-name { font-weight: 500; color: var(--text); }

.row-sub { font-size: 11.5px; color: var(--text-muted); }

.state-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-mid);
}

.state-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #B9B6AC;
}

.state-dot.on::before { background: #3F8F5F; }

.row-actions { display: flex; gap: 6px; }

.row-actions button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-mid);
  white-space: nowrap;
  flex-shrink: 0;
}

.row-actions button:hover { border-color: var(--accent); color: var(--accent); }

.row-actions button.del:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 编辑表单 ---------- */

.edit-card { width: min(720px, 100%); }

.edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 14px;
  border-bottom: 1px solid var(--line);
}

.edit-head h3 { margin: 0; font-size: 16px; font-weight: 600; }

.edit-head .modal-close { position: static; background: transparent; }

.edit-body {
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.field-grow { flex: 2 1 220px; }

.field > span {
  font-size: 12.5px;
  color: var(--text-mid);
  font-weight: 500;
}

.field input[type="text"],
.field input[type="number"],
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  background: var(--surface);
  font-size: 13.5px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-hint { font-size: 12px; color: var(--text-muted); align-self: center; }

.image-list { display: flex; gap: 8px; flex-wrap: wrap; }

.image-item {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}

.image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.image-item .cover-flag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(28, 93, 78, .88);
  color: #fff;
  font-size: 10px;
  text-align: center;
  line-height: 16px;
}

.image-item .remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.image-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pick-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  background: #FBFAF8;
}

.pick-panel img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px;
  cursor: pointer;
  border: 2px solid transparent;
}

.pick-panel img:hover { border-color: var(--accent); }

.spec-rows { display: flex; flex-direction: column; gap: 8px; }

.spec-row { display: flex; gap: 8px; align-items: center; }

.spec-row input {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  font-size: 13px;
  background: var(--surface);
}

.spec-row input:focus { border-color: var(--accent); }

.spec-row .remove {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 7px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
}

.spec-row .remove:hover { border-color: var(--danger); color: var(--danger); }

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-mid);
  cursor: pointer;
}

.switch-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.edit-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 26px 22px;
  border-top: 1px solid var(--line);
}

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: #1E1E1B;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-md);
  animation: pop .18s ease;
}

.toast[hidden] { display: none; }

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  .detail-body { grid-template-columns: 1fr; }
  .detail-info { padding: 24px; }
  .detail-card { width: min(520px, 100%); }
  .gallery-main { aspect-ratio: 4 / 3; }
  .header-inner { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .toolbar { max-width: none; width: 100%; justify-content: flex-start; }
  .search-box { max-width: none; }
  .page { padding: 20px 16px 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .card-body { padding: 11px 12px 13px; }
  .card-name { font-size: 14px; }
  .admin-header { padding: 12px 16px; }
  .admin-table-wrap { padding: 12px 16px 24px; }
  .admin-search { padding: 12px 16px 0; }
  .field-row { flex-direction: column; }
  .edit-body { padding: 16px 18px; }
  .edit-head, .edit-foot { padding-left: 18px; padding-right: 18px; }
}
