:root {
  color-scheme: light;
  --red: #d8202a;
  --red-dark: #a9141d;
  --ink: #191c1f;
  --text: #2c3237;
  --muted: #66717a;
  --line: #d8dde1;
  --line-dark: #bcc4ca;
  --surface: #ffffff;
  --surface-2: #f4f6f7;
  --surface-3: #e9edef;
  --green: #1f6b46;
  --green-bg: #e8f4ee;
  --amber: #9a5700;
  --amber-bg: #fff1d9;
  --blue: #235f8f;
  --shadow: 0 18px 48px rgba(25, 28, 31, 0.18);
  --radius: 6px;
  --sidebar: 296px;
  --header: 72px;
  font-family: Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.5;
}

body.is-locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: var(--blue);
}

img {
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  min-height: var(--header);
  padding: 10px 20px;
  color: #fff;
  background: var(--ink);
  border-bottom: 4px solid var(--red);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 126px;
  height: 40px;
  flex: 0 0 auto;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}

.brand-logo img {
  width: 110px;
  max-height: 32px;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-family: Bahnschrift, "Aptos Display", "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
}

.brand-copy p {
  margin: 3px 0 0;
  color: #bfc6cb;
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.summary-chip {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #41484d;
  border-radius: 4px;
  color: #cfd4d7;
}

.summary-chip strong {
  color: #fff;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn:hover {
  border-color: #879198;
  background: #f7f8f9;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.tree-button:focus-visible,
.product-card:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(216, 32, 42, 0.24);
  outline-offset: 2px;
}

.btn-primary {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.btn-primary:hover {
  color: #fff;
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.btn-dark {
  color: #fff;
  background: #2d3338;
  border-color: #4a5258;
}

.btn-dark:hover {
  color: #fff;
  background: #3a4147;
  border-color: #6c767d;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.menu-button {
  display: none;
}

.catalog-layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: calc(100vh - var(--header));
}

.sidebar {
  position: sticky;
  top: var(--header);
  align-self: start;
  height: calc(100vh - var(--header));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sidebar-close {
  display: none;
}

.tree {
  padding: 8px 0 24px;
}

.tree-group {
  border-bottom: 1px solid #edf0f2;
}

.tree-button {
  width: 100%;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.tree-button:hover {
  background: var(--surface-2);
}

.tree-button.is-active {
  color: var(--red-dark);
  background: #fff1f2;
  box-shadow: inset 3px 0 0 var(--red);
}

.tree-button .chevron {
  color: var(--muted);
  transition: transform 160ms ease;
}

.tree-group.is-open > .tree-button .chevron {
  transform: rotate(90deg);
}

.tree-label {
  overflow-wrap: anywhere;
}

.tree-count {
  min-width: 24px;
  padding: 1px 5px;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: 10px;
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tree-children {
  display: none;
  padding-bottom: 5px;
}

.tree-group.is-open > .tree-children {
  display: block;
}

.tree-children .tree-button {
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
  padding-left: calc(12px + var(--depth, 0) * 16px);
  font-size: 13px;
}

.tree-children .tree-button::before {
  content: "";
  width: 7px;
  height: 1px;
  background: var(--line-dark);
}

.tree-children .tree-button .chevron {
  display: none;
}

.main {
  min-width: 0;
  padding: 18px 20px 32px;
}

.catalog-title-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.catalog-title {
  min-width: 0;
}

.catalog-title h2 {
  margin: 0;
  color: var(--ink);
  font-family: Bahnschrift, "Aptos Display", "Segoe UI", sans-serif;
  font-size: 24px;
  letter-spacing: 0;
}

.catalog-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 154px auto;
  gap: 8px;
  margin-bottom: 14px;
}

.field {
  min-width: 0;
}

.field input,
.field select,
.field textarea,
.select-control {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-radius: 4px;
}

.search-field {
  position: relative;
}

.search-field input {
  padding-left: 36px;
}

.search-field::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 12px;
  width: 11px;
  height: 11px;
  border: 2px solid #6d767d;
  border-radius: 50%;
}

.search-field::after {
  content: "";
  position: absolute;
  left: 24px;
  top: 24px;
  width: 7px;
  height: 2px;
  background: #6d767d;
  transform: rotate(45deg);
}

.view-toggle {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}

.view-toggle button {
  min-width: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.view-toggle button + button {
  border-left: 1px solid var(--line);
}

.view-toggle button.is-active {
  color: #fff;
  background: var(--ink);
}

.catalog-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.product-grid.is-list {
  grid-template-columns: 1fr;
}

.product-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.product-card:hover {
  border-color: #9fa8ae;
  box-shadow: 0 8px 18px rgba(25, 28, 31, 0.09);
  transform: translateY(-1px);
}

.product-image {
  position: relative;
  aspect-ratio: 1 / 0.76;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  transition: transform 180ms ease;
}

.product-card:hover .product-image img {
  transform: scale(1.025);
}

.image-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #8a949b;
  background: repeating-linear-gradient(135deg, #f7f8f9, #f7f8f9 10px, #eef1f3 10px, #eef1f3 20px);
  font-weight: 700;
}

.card-badges {
  position: absolute;
  inset: 8px 8px auto;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 3px;
  color: #fff;
  background: rgba(25, 28, 31, 0.88);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.product-body {
  padding: 11px 12px 12px;
}

.product-category {
  min-height: 18px;
  margin-bottom: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-name {
  display: -webkit-box;
  min-height: 42px;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--ink);
  font-family: Bahnschrift, "Aptos Display", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.product-facts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #edf0f2;
}

.sku {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.price {
  flex: 0 0 auto;
  color: var(--red-dark);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.product-grid.is-list .product-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
}

.product-grid.is-list .product-image {
  height: 120px;
  aspect-ratio: auto;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

.product-grid.is-list .product-name {
  min-height: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 32px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-dark);
  border-radius: var(--radius);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 17px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 18px;
}

.page-button {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
}

.page-button.is-active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.page-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.sidebar-scrim {
  display: none;
}

.detail-view {
  min-height: calc(100vh - var(--header));
  background: var(--surface-2);
}

.detail-toolbar {
  position: sticky;
  top: var(--header);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.detail-toolbar .detail-position {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.detail-container {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.detail-main {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 20px;
}

.gallery,
.product-summary,
.detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gallery {
  min-width: 0;
  overflow: hidden;
}

.gallery-main {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 18px;
}

.gallery-thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 78px;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
}

.gallery-thumb {
  width: 78px;
  height: 64px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.gallery-thumb.is-active {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-summary {
  padding: 20px;
}

.detail-breadcrumbs {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.product-summary h2 {
  margin: 0;
  color: var(--ink);
  font-family: Bahnschrift, "Aptos Display", "Segoe UI", sans-serif;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.summary-price {
  margin: 14px 0;
  color: var(--red-dark);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.old-price {
  margin-left: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: line-through;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.fact {
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fact span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.short-description {
  color: #495158;
}

.detail-sections {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.detail-section {
  min-width: 0;
  padding: 18px;
}

.detail-section h3 {
  margin: 0 0 12px;
  padding-bottom: 8px;
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
  font-family: Bahnschrift, "Aptos Display", "Segoe UI", sans-serif;
  font-size: 18px;
  letter-spacing: 0;
}

.category-paths,
.attribute-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-paths li,
.attribute-row {
  padding: 8px 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--line-dark);
}

.attribute-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
}

.attribute-row strong {
  color: var(--ink);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
}

.variants-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12px;
}

.variants-table th,
.variants-table td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.variants-table th {
  position: sticky;
  top: 0;
  color: var(--ink);
  background: var(--surface-3);
  font-weight: 700;
}

.variants-table tbody tr:last-child td {
  border-bottom: 0;
}

.source-description {
  max-width: 100%;
  overflow: hidden;
  color: #3f474d;
  line-height: 1.65;
}

.source-editor-block + .source-editor-block {
  margin-top: 16px;
}

.source-description .source-editor-block > img {
  display: block;
  margin-right: auto;
  margin-left: auto;
}

.source-description img,
.source-description video,
.source-description iframe {
  max-width: 100% !important;
  height: auto !important;
}

.source-description table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.source-description td,
.source-description th {
  padding: 6px;
  border: 1px solid var(--line);
}

.source-description [style] {
  max-width: 100%;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 14px;
  color: #fff;
  background: var(--ink);
  border-left: 4px solid var(--red);
  border-radius: 4px;
  box-shadow: var(--shadow);
  animation: toast-in 160ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1240px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  :root {
    --header: 68px;
  }

  .summary-chip {
    display: none;
  }

  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .menu-button {
    display: inline-grid;
  }

  .sidebar {
    position: fixed;
    inset: var(--header) auto 0 0;
    z-index: 60;
    width: min(340px, 88vw);
    height: calc(100vh - var(--header));
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-grid;
  }

  .sidebar-scrim {
    position: fixed;
    inset: var(--header) 0 0;
    z-index: 55;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(25, 28, 31, 0.45);
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  .sidebar-scrim.is-open {
    visibility: visible;
    opacity: 1;
  }

  .detail-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 8px 12px;
  }

  .brand-logo {
    width: 96px;
    height: 36px;
  }

  .brand-logo img {
    width: 84px;
  }

  .brand-copy p {
    display: none;
  }

  .brand-copy h1 {
    font-size: 15px;
  }

  .topbar-actions .btn span {
    display: none;
  }

  .main {
    padding: 14px 12px 24px;
  }

  .catalog-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

  .toolbar .search-field {
    grid-column: 1 / -1;
  }

  .toolbar .view-toggle {
    grid-column: 2 / 3;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-body {
    padding: 9px;
  }

  .product-name {
    font-size: 14px;
  }

  .detail-toolbar {
    top: var(--header);
    padding: 8px 12px;
  }

  .detail-toolbar .detail-position {
    display: none;
  }

  .detail-container {
    padding: 12px;
  }

  .product-summary {
    padding: 15px;
  }

  .product-summary h2 {
    font-size: 23px;
  }

  .status-buttons {
    grid-template-columns: 1fr;
  }

  .attribute-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

@media (max-width: 500px) {
  .brand-copy {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .btn {
    padding-inline: 10px;
  }

  .catalog-title h2 {
    font-size: 21px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar > * {
    grid-column: 1 !important;
  }

  .view-toggle {
    width: 100%;
  }

  .view-toggle button {
    flex: 1;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .product-grid.is-list .product-card {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .product-grid.is-list .product-image {
    height: 116px;
  }

  .product-grid:not(.is-list) .product-image {
    aspect-ratio: 4 / 3;
  }

  .catalog-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-toolbar .btn-secondary {
    display: none;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .topbar,
  .detail-toolbar,
  .gallery-thumbs,
  .toast {
    display: none !important;
  }

  body,
  .detail-view {
    background: #fff;
  }

  .detail-container {
    width: 100%;
    padding: 0;
  }

  .detail-main {
    grid-template-columns: 42% 58%;
  }

  .gallery,
  .product-summary,
  .detail-section {
    break-inside: avoid;
    box-shadow: none;
  }
}
