:root {
  --bg: #f4f7fc;
  --ink: #16181d;
  --muted: #727986;
  --line: #d6deea;
  --blue-surface: #e8edff;
  --panel: #ffffff;
  --red: #e43d34;
  --green: #229957;
  --blue: #2675e8;
  --shadow: 0 14px 34px rgb(51 65 85 / 10%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, #e8efff 0, transparent 40%),
    var(--bg);
  font-family: Inter, Arial, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

button,
input {
  font: inherit;
}

.product-nav {
  border-bottom: 1px solid #202a3b;
  background: #101a2f;
}

.product-nav-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  width: min(1520px, calc(100% - 40px));
  min-height: 60px;
  margin: 0 auto;
}

.product-nav a {
  color: #dbe4f4;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.product-nav-brand {
  color: #fff !important;
  white-space: nowrap;
  font-size: 16px !important;
}

.product-nav-links {
  display: flex;
  align-items: stretch;
  gap: 4px;
  align-self: stretch;
}

.product-nav-links a {
  display: grid;
  place-items: center;
  padding: 0 12px;
  border-bottom: 3px solid transparent;
}

.product-nav-links a:hover,
.product-nav-links a.active {
  color: #fff;
  background: rgb(255 255 255 / 8%);
  border-bottom-color: #7ba7ff;
}

.app-shell {
  width: min(1520px, calc(100% - 40px));
  margin: 32px auto 64px;
}

@media (max-width: 640px) {
  .product-nav-inner {
    align-items: flex-start;
    gap: 10px;
    width: calc(100% - 24px);
    padding: 12px 0;
  }

  .product-nav-links {
    flex-wrap: wrap;
    gap: 0;
  }

  .product-nav-links a {
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }
}

.toolbar {
  position: sticky;
  z-index: 40;
  top: 10px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 28px;
  padding: 22px 28px;
  border: 1px solid #b8c7f3;
  border-radius: 18px;
  background: rgb(232 237 255 / 94%);
  box-shadow: 0 12px 28px rgb(54 78 145 / 12%);
  backdrop-filter: blur(14px);
}

.search-box,
.vendor-filter {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #525b6c;
  font-size: 12px;
  font-weight: 800;
}

.search-input-shell {
  position: relative;
  display: block;
}

.search-box input,
.vendor-combobox input {
  width: 100%;
  height: 52px;
  border: 1px solid #d2d9e6;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  outline: none;
}

.search-box input {
  padding: 0 46px 0 16px;
}

.search-box input::-webkit-search-cancel-button,
.vendor-combobox input::-webkit-search-cancel-button {
  display: none;
}

.vendor-combobox {
  position: relative;
}

.vendor-combobox input {
  padding: 0 86px 0 16px;
}

.search-box input:focus,
.vendor-combobox input:focus {
  border-color: #8ba4ec;
  box-shadow: 0 0 0 3px rgb(74 110 213 / 12%);
}

.vendor-combobox > #vendorToggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 46px;
  height: 50px;
  border: 0;
  border-left: 1px solid #e1e5ed;
  border-radius: 0 9px 9px 0;
  background: transparent;
  color: #4d5666;
  font-size: 22px;
  cursor: pointer;
}

.input-clear {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: 7px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  transform: translateY(-50%);
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #707887;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.input-clear:hover {
  background: #eef1f6;
  color: var(--ink);
}

.input-clear[hidden] {
  display: none;
}

.vendor-clear {
  right: 47px;
}

.vendor-selected-display {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 88px;
  left: 17px;
  overflow: hidden;
  transform: translateY(-50%);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vendor-selected-display[hidden] {
  display: none;
}

.vendor-combobox.has-selection input:not(:focus)::placeholder {
  color: transparent;
}

.vendor-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  right: 0;
  width: min(520px, calc(100vw - 40px));
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.vendor-panel-title {
  margin: 0 0 14px;
  color: #25315e;
  font-size: 16px;
  font-weight: 900;
}

.vendor-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: min(250px, 35vh);
  margin: 0;
  padding: 0 2px 4px 0;
  overflow-y: auto;
  list-style: none;
}

.vendor-options li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  background: #eef0f3;
  color: #4d5563;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.vendor-options li:hover {
  background: #e3e8f2;
}

.vendor-options li[aria-selected="true"] {
  background: var(--blue);
  color: #fff;
}

.option-check {
  visibility: hidden;
  color: #fff;
  font-size: 16px;
}

.vendor-options li[aria-selected="true"] .option-check {
  visibility: visible;
}

.selected-vendors {
  margin-top: 16px;
  padding: 14px;
  border-radius: 11px;
  background: #f6f7f9;
}

.selected-vendors strong {
  display: block;
  margin-bottom: 10px;
  color: #3b4674;
  font-size: 12px;
}

#selectedVendorChips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

#selectedVendorChips button {
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

#selectedVendorChips button span {
  margin-left: 3px;
}

.no-vendor-selection {
  color: #89909c;
  font-size: 12px;
}

.vendor-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.vendor-panel-actions button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid #8ba4ec;
  border-radius: 7px;
  background: #fff;
  color: #5168aa;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.vendor-panel-actions .primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.metric-filter {
  min-width: 540px;
  margin: 0;
  padding: 0;
  border: 0;
}

.metric-filter legend {
  margin-bottom: 6px;
  color: #525b6c;
  font-size: 12px;
  font-weight: 800;
}

.metric-switches {
  display: grid;
  grid-template-columns: repeat(6, minmax(76px, 1fr));
  gap: 8px;
}

.metric-switch {
  position: relative;
  cursor: pointer;
}

.metric-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.metric-switch span {
  display: grid;
  min-height: 52px;
  padding: 0 12px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.metric-switch:hover span {
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgb(15 23 42 / 13%);
}

.metric-switch.ordered span {
  background: #1c1d20;
}

.metric-switch.stock span {
  background: var(--green);
}

.metric-switch.unarrived span {
  background: var(--blue);
}

.metric-switch.restock span {
  background: var(--red);
}

.metric-switch.suggested-price span {
  background: #7568c9;
}

.metric-switch.cost span {
  background: #697586;
}

.metric-switch input:not(:checked) + span {
  color: #7a8290;
  border-color: #cfd6e1;
  background: #fff;
  opacity: 0.7;
  box-shadow: none;
}

.metric-switch input:focus-visible + span {
  outline: 3px solid rgb(38 117 232 / 22%);
  outline-offset: 2px;
}

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

.product-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease;
  animation: card-in 260ms ease both;
}

.vendor-banner {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  max-width: 140px;
  padding: 8px 14px;
  overflow: hidden;
  border-radius: 0 17px 0 11px;
  background: #17181b;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgb(51 65 85 / 14%);
}

.product-card-main {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  padding: 22px;
}

.product-media {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 270px;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: #f0f1f3;
  color: #9299a5;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.product-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}

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

.product-info {
  min-width: 0;
}

.product-heading {
  padding: 3px 120px 16px 0;
  border-bottom: 1px solid #e1e5eb;
}

.product-heading h2 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0;
  line-height: 1.18;
}

.product-heading h2 strong {
  flex: 0 0 auto;
  font-size: clamp(24px, 2vw, 31px);
  letter-spacing: -0.02em;
}

.product-heading h2 span {
  min-width: 0;
  font-size: clamp(18px, 1.5vw, 24px);
  font-weight: 650;
}

.price-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 28px;
  margin: 14px 0 0;
  color: var(--muted);
}

.price-row span {
  display: grid;
  gap: 3px;
}

.price-row small {
  font-size: 12px;
  font-weight: 750;
}

.price-row b {
  color: #535a66;
  font-size: 18px;
  line-height: 1;
}

.price-row .sale-price b {
  color: var(--red);
  font-size: 30px;
  letter-spacing: -0.02em;
}

.inventory-scroll {
  overflow-x: auto;
}

.inventory-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  table-layout: fixed;
}

.inventory-table th,
.inventory-table td {
  height: 44px;
  padding: 7px 9px;
  border-bottom: 1px solid #e4e7ec;
  text-align: center;
  vertical-align: middle;
}

.inventory-table thead th {
  color: #343942;
  font-size: 14px;
  font-weight: 850;
}

.inventory-table thead th:first-child,
.inventory-table tbody th {
  width: 104px;
  text-align: left;
}

.inventory-table tbody th {
  color: #505762;
  font-size: 14px;
}

.inventory-table tbody tr:last-child th,
.inventory-table tbody tr:last-child td {
  border-bottom: 0;
}

.color-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.color-label::before {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid rgb(15 23 42 / 14%);
  border-radius: 50%;
  background: var(--swatch);
  content: "";
}

.metric-link {
  color: inherit;
  text-decoration: none;
}

.metric {
  display: inline-grid;
  gap: 6px 10px;
  align-items: center;
  justify-content: center;
}

.metric span {
  min-width: 23px;
  padding: 3px 2px;
  font-size: clamp(16px, 1.15vw, 18px);
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
}

.metric-count-1 {
  grid-template-columns: 1fr;
}

.metric-count-2 {
  grid-template-columns: repeat(2, minmax(16px, 1fr));
}

.metric-count-3 {
  grid-template-columns: repeat(3, minmax(16px, 1fr));
}

.metric-count-4 {
  grid-template-columns: repeat(2, minmax(16px, 1fr));
}

.metric.single-size {
  grid-auto-flow: column;
  grid-template-columns: none;
  gap: 14px;
}

.metric.single-size span {
  min-width: 28px;
  font-size: 19px;
}

.ordered {
  color: #191a1d;
}

.stock {
  color: var(--green);
}

.unarrived {
  color: var(--blue);
}

.restock {
  color: var(--red);
}

.metric-empty {
  color: #a1a7b0;
}

.empty-state {
  margin: 70px 0;
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  font-weight: 750;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-filter {
    grid-column: 1 / -1;
    min-width: 0;
  }

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

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1520px);
    margin-top: 10px;
  }

  .toolbar {
    top: 4px;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px;
    border-radius: 13px;
  }

  .search-box,
  .vendor-filter {
    font-size: 11px;
  }

  .search-box input,
  .vendor-combobox input {
    height: 42px;
    font-size: 13px;
  }

  .vendor-combobox > #vendorToggle {
    width: 38px;
    height: 40px;
  }

  .vendor-clear {
    right: 39px;
  }

  .metric-switches {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  .metric-switch span {
    min-height: 38px;
    padding: 0 2px;
    border-radius: 8px;
    font-size: 11px;
  }

  .product-grid {
    gap: 16px;
  }

  .product-card {
    border-radius: 14px;
  }

  .vendor-banner {
    max-width: 110px;
    padding: 6px 10px;
    border-radius: 0 13px 0 9px;
    font-size: 11px;
  }

  .product-card-main {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .product-media {
    grid-column: 1;
    grid-row: 1;
    width: 72px;
    height: 100%;
    min-height: 118px;
    align-self: stretch;
    border-radius: 11px;
  }

  .product-info {
    display: contents;
  }

  .product-heading {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    padding: 22px 0 12px;
  }

  .product-heading h2 {
    display: flex;
    align-items: baseline;
    gap: 9px;
    min-width: 0;
    white-space: nowrap;
  }

  .product-heading h2 strong {
    flex: 0 0 auto;
    font-size: 23px;
  }

  .product-heading h2 span {
    overflow: hidden;
    flex: 1 1 auto;
    font-size: 17px;
    text-overflow: ellipsis;
  }

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

  .price-row .sale-price {
    grid-column: auto;
  }

  .price-row b {
    font-size: 14px;
  }

  .price-row .sale-price b {
    font-size: 22px;
  }

  .inventory-scroll {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .inventory-table th,
  .inventory-table td {
    height: 42px;
    padding: 6px 5px;
  }

  .inventory-table thead th:first-child,
  .inventory-table tbody th {
    width: 86px;
  }

  .inventory-table thead th,
  .inventory-table tbody th {
    font-size: 12px;
  }

  .metric {
    gap: 4px 7px;
  }

  .metric span {
    min-width: 20px;
    padding: 3px 1px;
    font-size: 16px;
  }

  .metric.single-size {
    gap: 11px;
  }

  .metric.single-size span {
    min-width: 25px;
    font-size: 17px;
  }

}

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