:root {
  color-scheme: light;
  --ink: #24221f;
  --muted: #706b63;
  --paper: #f7f4ed;
  --surface: #fffdf9;
  --stage: #ffffff;
  --line: #ded8cd;
  --line-strong: #c9c0b3;
  --accent: #e85f2f;
  --accent-deep: #b93a16;
  --green: #247454;
  --amber: #a76208;
  --red: #b63d32;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
select {
  cursor: pointer;
}

.site-header {
  height: 60px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  padding: 8px 10px 7px;
  color: #fff;
  background: var(--ink);
  border-radius: 4px;
  font: 800 11px/1 system-ui, sans-serif;
  letter-spacing: 0.18em;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.header-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--green);
  border-radius: 50%;
}

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px 58px;
}

.hero {
  min-height: 92px;
  padding: 12px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.hero-copy {
  min-width: 0;
}

.hero h1 {
  margin: 0;
  font-family: "STSong", "Songti SC", serif;
  font-size: clamp(28px, 2.4vw, 38px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.hero h1 span {
  color: var(--accent);
}

.hero-text {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hero-metrics {
  display: none;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-width: 94px;
  padding: 9px 13px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "label label"
    "value unit";
  align-items: baseline;
  column-gap: 4px;
  border-left: 1px solid var(--line);
}

.metric:first-child {
  border-left: 0;
}

.metric span {
  grid-area: label;
  color: var(--muted);
  font-size: 9px;
}

.metric strong {
  grid-area: value;
  margin-top: 3px;
  font: 800 18px/1 "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.metric em {
  grid-area: unit;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.metric.accent strong {
  color: var(--accent);
}

.catalog-shell {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) auto;
  column-gap: 12px;
  row-gap: 8px;
  align-items: center;
}

.category-tabs {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  min-height: 38px;
  padding: 0 13px;
  flex: 0 0 auto;
  color: #5e5952;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.16s, background 0.16s, border-color 0.16s;
}

.category-tab span {
  margin-left: 6px;
  color: #948d83;
  font-size: 10px;
  font-weight: 600;
}

.category-tab i {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  display: inline-block;
  background: var(--accent);
  border-radius: 50%;
  vertical-align: 1px;
}

.category-tab:hover,
.category-tab:focus-visible {
  color: var(--accent-deep);
  border-color: #d5a28e;
}

.category-tab.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.category-tab.active span {
  color: rgba(255, 255, 255, 0.72);
}

.category-tab.today:not(.active) {
  color: var(--accent-deep);
  background: #fff8f3;
  border-color: #efc1ae;
}

.category-tab.today.active {
  background: var(--accent);
  border-color: var(--accent);
}

.category-tab.today.active i {
  background: #fff;
}

.filter-panel {
  min-width: 0;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 160px;
  gap: 10px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-panel label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 95, 47, 0.12);
}

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

.search-box input::placeholder {
  color: #938c82;
}

.clear-search {
  min-width: 42px;
  height: 28px;
  padding: 0 7px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 10px;
}

.clear-search:hover,
.clear-search:focus-visible {
  color: var(--accent-deep);
  background: #f7ece6;
}

.select-wrap select {
  width: 100%;
  height: 42px;
  padding: 0 32px 0 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  font-size: 13px;
}

.select-wrap select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 95, 47, 0.12);
}

.stock-tabs {
  min-height: 64px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scrollbar-width: none;
}

.stock-tabs::-webkit-scrollbar {
  display: none;
}

.stock-tab {
  min-height: 40px;
  padding: 0 11px;
  flex: 0 0 auto;
  color: #645f57;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  transition: color 0.16s, background 0.16s;
}

.stock-tab span {
  margin-left: 5px;
  color: #8d877f;
  font-size: 10px;
}

.stock-tab:hover,
.stock-tab:focus-visible {
  color: var(--ink);
  background: var(--stage);
}

.stock-tab.active {
  color: #fff;
  background: var(--ink);
}

.stock-tab.active span {
  color: rgba(255, 255, 255, 0.72);
}

.result-head,
.catalog-grid,
.empty-state,
.load-more-wrap {
  grid-column: 1 / -1;
}

.result-head {
  min-height: 28px;
  padding: 3px 2px 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.result-head p {
  margin: 0;
  font-family: "STSong", "Songti SC", serif;
  font-size: 18px;
  font-weight: 700;
}

.result-head span {
  color: var(--muted);
  font-size: 10px;
}

.result-head div > span {
  display: inline-block;
  margin-top: 2px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.catalog-card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.16s, transform 0.16s;
}

.catalog-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.catalog-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 95, 47, 0.12);
}

.card-image {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  isolation: isolate;
  background: var(--stage);
  border-bottom: 1px solid #e7e0d5;
}

.card-image .image-fallback {
  width: 100%;
  height: 100%;
}

.card-image:has(img) > .image-fallback,
.dialog-image:has(img) > .image-fallback {
  visibility: hidden;
}

.card-image img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  transition: transform 0.2s;
}

.catalog-card:hover .card-image img {
  transform: scale(1.015);
}

.card-image img[data-image-zoom],
.dialog-image img[data-image-zoom] {
  cursor: zoom-in;
}

.card-image img[data-image-zoom]:focus-visible,
.dialog-image img[data-image-zoom]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.image-fallback {
  display: grid;
  place-items: center;
  color: #b5ada1;
  background: var(--stage);
  font: 800 20px/1 "Arial Narrow", system-ui, sans-serif;
  letter-spacing: 0.04em;
}

.code-label {
  position: absolute;
  z-index: 2;
  top: 7px;
  left: 7px;
  padding: 5px 6px 4px;
  color: #fff;
  background: rgba(36, 34, 31, 0.95);
  border-radius: 5px;
  font: 800 10px/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.new-badge {
  position: absolute;
  z-index: 2;
  top: 7px;
  right: 7px;
  padding: 5px 7px 4px;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 2px 7px rgba(185, 58, 22, 0.22);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.card-body {
  padding: 9px;
}

.card-kicker {
  min-width: 0;
  min-height: 17px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-category {
  min-width: 0;
  margin: 0;
  flex: 1;
  overflow: hidden;
  color: var(--accent-deep);
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fulfillment-tag {
  padding: 3px 5px 2px;
  flex: 0 0 auto;
  border: 1px solid;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.fulfillment-tag.machine {
  color: #9f3b19;
  background: #fff3ec;
  border-color: #edc9b7;
}

.fulfillment-tag.digital {
  color: #59625d;
  background: #f1f4f1;
  border-color: #dbe2dc;
}

.card-body h2 {
  margin: 0;
  min-height: 20px;
}

.detail-button {
  width: 100%;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 20px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-button:hover,
.detail-button:focus-visible {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stock-state {
  margin: 2px 0 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.3;
}

.stock-state.low,
.stock-state.part {
  color: var(--amber);
}

.stock-state.out {
  color: var(--red);
}

.stock-state.unrecorded,
.stock-state.stopped {
  color: var(--muted);
}

.size-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #e6dfd4;
  border-radius: 6px;
}

.size-pill {
  min-width: 0;
  min-height: 47px;
  padding: 6px 4px;
  background: transparent;
  border-left: 1px solid #e6dfd4;
  text-align: center;
}

.size-pill:first-child {
  border-left: 0;
}

.size-pill span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-pill strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font: 800 12px/1.1 "DIN Alternate", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-pill.low strong {
  color: var(--amber);
}

.size-pill.out strong {
  color: var(--red);
}

.size-pill.unrecorded strong,
.size-pill.stopped strong {
  color: var(--muted);
  font-family: inherit;
  font-size: 9px;
}

.size-pill.total strong {
  color: var(--ink);
}

.card-meta {
  color: var(--muted);
  font-size: 10px;
}

.skeleton-card {
  height: 274px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.skeleton-image {
  aspect-ratio: 1;
  background: #e9e3d9;
  animation: pulse 1.1s infinite alternate ease-in-out;
}

.skeleton-line {
  height: 9px;
  margin: 14px 9px 0;
  background: #e9e3d9;
  border-radius: 4px;
  animation: pulse 1.1s infinite alternate ease-in-out;
}

.skeleton-line.short {
  width: 52%;
  margin-top: 8px;
}

@keyframes pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.empty-state {
  padding: 54px 20px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.load-error {
  grid-column: 1 / -1;
}

.empty-state strong {
  font-family: "STSong", "Songti SC", serif;
  font-size: 24px;
}

.empty-state p {
  color: var(--muted);
  font-size: 13px;
}

.empty-state button,
.load-more {
  padding: 10px 18px;
  color: #fff;
  background: var(--ink);
  border: 0;
  border-radius: 7px;
}

.load-more-wrap {
  display: grid;
  place-items: center;
  padding-top: 22px;
}

.load-more {
  min-width: 140px;
}

.load-more:disabled {
  opacity: 0.55;
  cursor: wait;
}

.detail-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 28px 80px rgba(36, 31, 25, 0.28);
}

.detail-dialog::backdrop {
  background: rgba(32, 28, 24, 0.58);
}

.image-zoom-dialog {
  width: min(1180px, calc(100vw - 24px));
  height: min(900px, calc(100vh - 24px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  color: #fff;
  background: #1c1b19;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
}

.image-zoom-dialog::backdrop {
  background: rgba(18, 16, 14, 0.84);
  backdrop-filter: blur(3px);
}

.image-zoom-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  min-width: 54px;
  height: 36px;
  color: #fff;
  background: rgba(28, 27, 25, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.image-zoom-close:hover,
.image-zoom-close:focus-visible {
  background: rgba(232, 95, 47, 0.92);
  border-color: rgba(255, 255, 255, 0.76);
}

.image-zoom-stage {
  width: 100%;
  height: 100%;
  margin: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.image-zoom-stage img {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  object-fit: contain;
}

.image-zoom-stage figcaption {
  min-height: 38px;
  padding: 11px 72px 10px 16px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  line-height: 17px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-close {
  position: sticky;
  z-index: 3;
  top: 10px;
  float: right;
  min-width: 52px;
  height: 34px;
  margin: 10px 10px 0 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  color: var(--accent-deep);
  border-color: var(--accent);
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.86fr) minmax(0, 1.14fr);
}

.dialog-image {
  min-height: 430px;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background: var(--stage);
}

.dialog-image > * {
  grid-area: 1 / 1;
}

.dialog-image img {
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.dialog-content {
  padding: 48px 28px 28px;
}

.dialog-content .dialog-kicker {
  margin-bottom: 8px;
  justify-content: flex-start;
}

.dialog-content .fulfillment-tag {
  padding: 5px 7px 4px;
  font-size: 10px;
}

.dialog-content h2 {
  margin: 0;
  font-family: "STSong", "Songti SC", serif;
  font-size: 31px;
  line-height: 1.2;
}

.dialog-code {
  margin: 7px 0 19px;
  color: var(--muted);
  font-size: 12px;
}

.dialog-total {
  margin-bottom: 20px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
}

.dialog-total span {
  font-size: 11px;
}

.dialog-total strong {
  color: #ff9b74;
  font: 800 27px/1 "DIN Alternate", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.sku-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.sku-table th,
.sku-table td {
  padding: 10px 7px;
  text-align: left;
  border-bottom: 1px solid #e9e2d6;
}

.sku-table th {
  color: var(--muted);
  font-weight: 600;
}

.sku-table td strong {
  font-size: 13px;
}

.sku-status {
  font-weight: 800;
}

.sku-status.low {
  color: var(--amber);
}

.sku-status.out {
  color: var(--red);
}

.dialog-updated {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.hidden {
  display: none !important;
}

footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #837c72;
  font-size: 10px;
}

@media (max-width: 1260px) {
  .catalog-shell {
    grid-template-columns: 1fr;
  }

  .stock-tabs {
    min-height: 54px;
  }

  .catalog-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .site-header,
  main,
  footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .hero {
    align-items: flex-start;
  }

  .hero-metrics {
    display: none;
  }

  .filter-panel {
    grid-template-columns: minmax(220px, 1fr) 140px;
  }

  .catalog-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dialog-layout {
    grid-template-columns: 1fr;
  }

  .dialog-image {
    min-height: 300px;
    max-height: 44vh;
  }
}

@media (max-width: 680px) {
  .site-header {
    height: 56px;
  }

  .brand-name {
    display: none;
  }

  .header-note {
    max-width: 170px;
    justify-content: flex-end;
    text-align: right;
    font-size: 10px;
  }

  main {
    padding-bottom: 40px;
  }

  .hero {
    min-height: 88px;
    padding: 14px 0 12px;
  }

  .hero h1 {
    font-size: 27px;
  }

  .hero-text {
    font-size: 11px;
  }

  .filter-panel {
    grid-template-columns: 1fr 118px;
  }

  .category-tabs {
    margin-right: -18px;
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
  }

  .stock-tabs {
    margin-right: -18px;
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
  }

  .result-head {
    align-items: flex-start;
  }

  .legend {
    max-width: 86px;
    text-align: right;
  }

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .card-body {
    padding: 8px;
  }

  .dialog-content {
    padding: 28px 16px 22px;
    overflow-x: auto;
  }

  .dialog-content h2 {
    font-size: 27px;
  }

  .sku-table {
    min-width: 540px;
  }

  footer {
    display: grid;
    gap: 7px;
  }
}

@media (max-width: 360px) {
  .site-header,
  main,
  footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .filter-panel {
    padding: 9px;
  }

  .catalog-grid {
    gap: 7px;
  }

  .detail-button {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
