:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #69727d;
  --line: #d9dde2;
  --line-strong: #b9c0c8;
  --paper: #ffffff;
  --canvas: #f2f3f5;
  --accent: #173f6b;
  --accent-soft: #eaf0f6;
  --available: #19613b;
  --available-soft: #e8f2ec;
  --unavailable: #8a3131;
  --unavailable-soft: #f5eaea;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #e9ebee 0, #f2f3f5 180px, #f2f3f5 100%);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.catalog-shell {
  width: min(1780px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(360px, 680px) 270px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.08);
  backdrop-filter: blur(12px);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(23, 63, 107, 0.12);
}

.search-mark {
  position: relative;
  width: 18px;
  height: 18px;
  margin: 0 12px 0 15px;
  flex: 0 0 auto;
  border: 2px solid #64707c;
  border-radius: 50%;
}

.search-mark::after {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 7px;
  height: 2px;
  content: "";
  background: #64707c;
  transform: rotate(45deg);
  transform-origin: left center;
}

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

.search-field input::placeholder {
  color: #89919a;
}

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

.clear-search {
  display: none;
  align-items: center;
  height: 30px;
  margin-right: 7px;
  padding: 0 10px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.clear-search.visible {
  display: inline-flex;
}

.sort-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
}

.sort-field > span {
  padding-left: 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.sort-field select {
  width: 100%;
  height: 100%;
  padding: 0 34px 0 10px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.result-count {
  justify-self: end;
  padding-right: 4px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

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

.product-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(23, 32, 42, 0.045);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.product-card:hover {
  z-index: 1;
  border-color: #9ca6b0;
  box-shadow: 0 10px 26px rgba(23, 32, 42, 0.12);
  transform: translateY(-2px);
}

.product-image-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(45deg, #f3f4f5 25%, transparent 25%),
    linear-gradient(-45deg, #f3f4f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f3f4f5 75%),
    linear-gradient(-45deg, transparent 75%, #f3f4f5 75%),
    #fafafa;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  transition: transform 220ms ease;
}

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

.product-image.is-missing {
  display: none;
}

.image-unavailable {
  display: none;
  color: #8a929a;
  font-size: 12px;
}

.product-image.is-missing + .image-unavailable {
  display: inline;
}

.stock-flag {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 8px;
  border: 1px solid rgba(25, 97, 59, 0.22);
  border-radius: 2px;
  color: var(--available);
  background: rgba(232, 242, 236, 0.94);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stock-flag.empty {
  border-color: rgba(138, 49, 49, 0.2);
  color: var(--unavailable);
  background: rgba(245, 234, 234, 0.95);
}

.product-info {
  padding: 14px 14px 12px;
}

.product-code {
  overflow: hidden;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.product-name {
  display: -webkit-box;
  min-height: 42px;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 15px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}

.product-metrics > div {
  min-width: 0;
  padding: 0 8px;
  text-align: center;
}

.product-metrics > div:first-child {
  padding-left: 0;
  text-align: left;
}

.product-metrics > div:last-child {
  padding-right: 0;
  text-align: right;
}

.product-metrics > div + div {
  border-left: 1px solid var(--line);
}

.product-metrics dt {
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.025em;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.product-metrics dd {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.product-metrics .stock-quantity {
  color: var(--available);
}

.product-card.out-of-stock .product-metrics .stock-quantity {
  color: var(--unavailable);
}

.loose-units {
  min-height: 15px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.empty-state {
  min-height: 360px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-align: center;
}

.empty-state:not([hidden]) {
  display: flex;
}

.empty-state strong {
  font-size: 17px;
}

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

.pagination {
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 26px;
}

.pagination:not([hidden]) {
  display: flex;
}

.pagination button {
  min-width: 106px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 650;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled {
  cursor: default;
  opacity: 0.42;
}

.pagination span {
  min-width: 110px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.product-card.skeleton-card {
  pointer-events: none;
}

.skeleton-block {
  position: relative;
  overflow: hidden;
  background: #e7e9ec;
}

.skeleton-block::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.72) 45%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 1.25s infinite;
}

.skeleton-image {
  aspect-ratio: 4 / 3;
}

.skeleton-body {
  padding: 14px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 10px;
}

.skeleton-line.short {
  width: 44%;
}

.skeleton-line.medium {
  width: 74%;
}

.skeleton-metrics {
  height: 48px;
  margin-top: 18px;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

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

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

@media (max-width: 980px) {
  .catalog-shell { width: min(100% - 28px, 900px); padding-top: 14px; }
  .toolbar { grid-template-columns: 1fr 250px; }
  .result-count { grid-column: 1 / -1; justify-self: start; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}

@media (max-width: 720px) {
  .catalog-shell { width: calc(100% - 20px); padding-top: 10px; }
  .toolbar { position: relative; grid-template-columns: 1fr; gap: 9px; padding: 10px; }
  .sort-field { grid-template-columns: 100px 1fr; }
  .result-count { grid-column: auto; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .product-info { padding: 11px 10px 9px; }
  .product-name { min-height: 38px; font-size: 13px; }
  .product-metrics { margin-top: 11px; padding-top: 10px; }
  .product-metrics > div { padding: 0 4px; }
  .product-metrics dt { font-size: 8px; }
  .product-metrics dd { font-size: 12px; }
  .stock-flag { top: 7px; right: 7px; padding: 4px 6px; font-size: 8px; }
}

@media (max-width: 430px) {
  .product-grid { grid-template-columns: 1fr; }
  .product-image-frame { aspect-ratio: 16 / 10; }
}

@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;
  }
}

