:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #65706a;
  --line: #dfe5de;
  --accent: #176b5b;
  --accent-strong: #0f4f43;
  --gold: #c78b2f;
  --danger: #b93434;
  --shadow: 0 18px 50px rgba(31, 45, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(246, 247, 244, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand,
.nav-actions,
.hero-metrics,
.toolbar,
.admin-panel,
.product-head,
.facts,
.modal-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.nav-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

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

.danger-button {
  background: #fff3f3;
  color: var(--danger);
  border-color: #efc8c8;
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: clamp(20px, 4vw, 48px);
  align-items: end;
  padding: clamp(38px, 7vw, 76px) 0 28px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 6vw, 70px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy > p:last-child {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.hero-metrics {
  justify-content: stretch;
  gap: 10px;
}

.hero-metrics div {
  flex: 1;
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero-metrics strong,
.hero-metrics span {
  display: block;
}

.hero-metrics strong {
  font-size: 28px;
}

.hero-metrics span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  margin: 4px 0 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toolbar label {
  min-width: 180px;
}

.toolbar .search-box {
  flex: 1;
  min-width: min(320px, 100%);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
}

.admin-panel {
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  padding: 14px 16px;
  background: #edf7f2;
  border: 1px solid #c8e4d7;
  border-radius: 8px;
}

.admin-panel strong,
.admin-panel span {
  display: block;
}

.admin-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

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

.product-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(31, 45, 38, 0.03);
}

.image-wrap {
  position: relative;
  height: 210px;
  padding: 10px;
  background: #eef1ed;
}

.image-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.thumbs {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.thumbs button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.thumbs button.active {
  border-color: var(--gold);
}

.thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-body {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.product-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sku {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-head h2 {
  margin: 4px 0 0;
  font-size: 21px;
  line-height: 1.2;
}

.price {
  white-space: nowrap;
  color: var(--accent);
  font-size: 20px;
}

.description,
.detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.facts {
  align-items: stretch;
  gap: 8px;
  margin: 0;
}

.facts div {
  flex: 1;
  padding: 10px;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.facts dt,
.facts dd {
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
}

.facts dd {
  margin-top: 5px;
  font-weight: 800;
}

.edit-button {
  width: 100%;
}

.modal {
  width: min(440px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(820px, calc(100% - 24px));
}

.modal::backdrop {
  background: rgba(16, 26, 22, 0.5);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 15px;
  padding: 24px;
}

.modal-card h2 {
  margin: 0;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upload-zone {
  padding: 14px;
  border: 1px dashed #b8c7bd;
  border-radius: 8px;
  background: #fbfcfa;
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.image-preview figure {
  position: relative;
  margin: 0;
  overflow: hidden;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f1;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview button {
  position: absolute;
  top: 5px;
  right: 5px;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(23, 33, 29, 0.8);
  color: #fff;
}

.modal-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
}

small {
  min-height: 18px;
  color: var(--danger);
}

@media (max-width: 920px) {
  .hero,
  .product-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-copy {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .topbar,
  .admin-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions,
  .toolbar label,
  .toolbar button,
  .hero-metrics,
  .product-grid,
  .form-grid {
    width: 100%;
  }

  .hero,
  .product-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    flex-direction: column;
  }

  .image-wrap {
    height: 230px;
  }

  .modal-card {
    padding: 20px;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}
