:root {
  --bg: #f5f2ec;
  --surface: #ffffff;
  --surface-soft: #faf8f4;
  --border: #e6e1d7;
  --text: #2b2b2b;
  --text-soft: #6b6b6b;
  --accent: #c98b5a;
  --accent-dark: #a66a3c;
  --danger: #d9534f;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: linear-gradient(135deg, #e9c9a9 0%, #c98b5a 100%);
  color: #fff;
  padding: 36px 0 28px;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.header-left h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 1px;
}

.back-link {
  display: inline-block;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 8px;
  opacity: 0.9;
}

.back-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: var(--accent-dark);
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-add:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-add-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  line-height: 1;
}

.subtitle {
  margin: 0;
  opacity: 0.9;
  font-size: 14px;
}

main.container {
  margin-top: 28px;
  margin-bottom: 40px;
}

.main-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  margin-top: 28px;
  margin-bottom: 40px;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--accent-dark);
  border-bottom: 1px dashed var(--border);
  padding-bottom: 10px;
}

.add-panel-single {
  max-width: 720px;
  margin: 0 auto;
}

.row {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row.two-col {
  flex-direction: row;
  gap: 12px;
}

.row.two-col > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  color: var(--text-soft);
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

textarea {
  resize: vertical;
}

.image-uploader {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-uploader input[type="file"] {
  font-size: 13px;
}

.image-preview {
  width: 100%;
  min-height: 140px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-preview img {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}

.preview-hint {
  color: var(--text-soft);
  font-size: 13px;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.img-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #eee;
}

.img-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.img-thumb-wrap img:hover {
  opacity: 0.85;
}

.img-thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.img-thumb-del:hover {
  background: var(--danger);
}

.row.actions {
  flex-direction: row;
  gap: 10px;
  margin-top: 8px;
}

.row.actions-stretch {
  margin-top: 16px;
}

.row.actions-stretch .btn-primary {
  flex: 2;
}

.row.actions-stretch a.btn-ghost,
.row.actions-stretch button.btn-ghost {
  flex: 1;
  text-align: center;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  font-size: 14px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  flex: 1;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-ghost {
  background: var(--surface-soft);
  color: var(--text);
}

.btn-ghost:hover {
  background: #eee7da;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding: 4px 8px;
  font-size: 13px;
}

.btn-danger:hover {
  background: #fdecea;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

.list-header h2 {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
  color: var(--accent-dark);
}

.stats {
  display: flex;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  font-size: 13px;
  border: 1px solid var(--border);
}

.chip-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar #search {
  flex: 2;
  min-width: 200px;
}

.toolbar select {
  flex: 1;
  min-width: 120px;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.item {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}

.item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.item-image {
  width: 100%;
  height: 160px;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  overflow: hidden;
  position: relative;
}

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

.item-image .placeholder {
  font-size: 40px;
  color: #ccc;
}

.item-gallery {
  width: 100%;
  height: 160px;
  position: relative;
  overflow: hidden;
  background: #eee;
}

.item-gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}

.item-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.item-gallery-nav:hover {
  background: rgba(0,0,0,0.6);
}

.item-gallery-prev { left: 6px; }
.item-gallery-next { right: 6px; }

.item-gallery-counter {
  position: absolute;
  bottom: 6px;
  right: 8px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
}

.item-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.item-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.item-meta {
  font-size: 12px;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8d9c6;
  color: var(--accent-dark);
  font-size: 11px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.status-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.status-待发货 {
  background: #fdecea;
  color: #d9534f;
}

.status-已发货 {
  background: #fff3e0;
  color: #e67e22;
}

.status-已收货 {
  background: #e8f5e9;
  color: #388e3c;
}

.status-已完成 {
  background: #e3f2fd;
  color: #1976d2;
}

.item-price {
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 14px;
}

.item-note {
  font-size: 12.5px;
  color: var(--text-soft);
  background: #fff;
  border-left: 3px solid var(--accent);
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 6px;
}

.item-footer {
  padding: 8px 14px 12px;
  display: flex;
  justify-content: flex-end;
}

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

.empty-icon {
  font-size: 48px;
  margin-bottom: 10px;
  opacity: 0.6;
}

.empty-link {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

.empty-link:hover {
  text-decoration: underline;
}

.site-footer {
  text-align: center;
  padding: 20px 0;
  color: var(--text-soft);
  font-size: 12px;
}

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

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.modal-body {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

.modal-body img {
  max-width: 85vw;
  max-height: 85vh;
  display: block;
  border-radius: 6px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.modal-prev, .modal-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 60px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
}

.modal-prev { left: 8px; }
.modal-next { right: 8px; }

.modal-prev:hover, .modal-next:hover {
  background: rgba(0, 0, 0, 0.7);
}

.modal-counter {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.6);
}

.hidden {
  display: none !important;
}
