:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #202421;
  --muted: #68706a;
  --line: #dfe3df;
  --accent: #176b4d;
  --accent-dark: #0f5039;
  --price: #b33a2b;
  --shadow: 0 10px 30px rgba(30, 38, 33, 0.11);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

button, input, select { font: inherit; }

button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(223, 227, 223, 0.9);
  background: rgba(247, 247, 245, 0.94);
  backdrop-filter: blur(14px);
}

.topbar__inner {
  width: min(1380px, 100%);
  min-height: 76px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.supplier {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.total {
  min-width: 70px;
  text-align: right;
}

.total strong { display: block; font-size: 20px; }
.total span { color: var(--muted); font-size: 12px; }

main {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 18px 20px 56px;
}

.controls {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.search {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.1);
}

.search__icon { color: var(--muted); font-size: 25px; line-height: 1; }

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

.search input::-webkit-search-cancel-button { display: none; }

.icon-button, .dialog-close {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover, .dialog-close:hover { background: #edf0ed; color: var(--text); }

.control-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.select-wrap {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.select-wrap span { color: var(--muted); font-size: 12px; }

.select-wrap select {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.result-line {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.product-grid {
  width: 100%;
  min-width: 0;
  padding-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.product-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: #c8cec9;
  box-shadow: 0 8px 24px rgba(30, 38, 33, 0.08);
}

.product-card__button {
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.product-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: contain;
  background: #fff;
}

.product-info { min-width: 0; padding: 10px 11px 12px; overflow: hidden; }

.product-number {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.product-name {
  height: 40px;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 14px;
  line-height: 20px;
}

.product-meta {
  min-width: 0;
  margin-top: 10px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
}

.dimension {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price { color: var(--price); font-size: 16px; font-weight: 700; white-space: nowrap; }
.price small { font-size: 11px; font-weight: 500; }

.load-area { padding: 24px 0 0; text-align: center; }

.load-more {
  min-width: 160px;
  height: 44px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.load-more:hover { background: var(--accent-dark); }
.load-more[hidden] { display: none; }

.empty {
  min-height: 220px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty strong { color: var(--text); }

.detail-dialog {
  width: min(920px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop { background: rgba(22, 26, 23, 0.64); }

.detail-dialog__body { position: relative; }

.dialog-close {
  position: sticky;
  top: 10px;
  z-index: 2;
  float: right;
  margin: 10px 10px -44px 0;
  color: #fff;
  background: rgba(20, 24, 21, 0.72);
}

.dialog-close:hover { color: #fff; background: rgba(20, 24, 21, 0.9); }

.detail-dialog img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: contain;
  background: #fff;
}

.detail-content { padding: 20px; }

.detail-category { margin: 0 0 8px; color: var(--accent); font-size: 13px; font-weight: 700; }
.detail-content h2 { margin: 0; font-size: 20px; line-height: 1.35; }
.detail-content dl { margin: 20px 0 0; }
.detail-content dl div { padding: 10px 0; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
.detail-content dt { color: var(--muted); font-size: 13px; }
.detail-content dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.detail-price { color: var(--price); font-weight: 700; }

@media (min-width: 680px) {
  .topbar__inner { min-height: 86px; }
  main { padding-top: 24px; }
  .controls { display: grid; grid-template-columns: minmax(280px, 1.35fr) minmax(360px, 1fr); column-gap: 12px; align-items: start; }
  .control-row { margin-top: 0; }
  .result-line { grid-column: 1 / -1; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .detail-dialog__body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); }
  .detail-dialog img { aspect-ratio: 1 / 1; }
  .detail-content { padding: 54px 28px 28px; }
  .dialog-close { position: absolute; right: 0; float: none; color: var(--muted); background: transparent; }
  .dialog-close:hover { color: var(--text); background: #edf0ed; }
}

@media (max-width: 420px) {
  .topbar__inner { padding-inline: 14px; }
  main { padding-inline: 14px; }
  .product-grid { gap: 10px; }
  .product-info { padding-inline: 9px; }
  .price { font-size: 15px; }
}

@media (min-width: 980px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
}

@media (min-width: 1280px) {
  .product-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
