:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-strong: #f9fafb;
  --text: #17191c;
  --muted: #69707a;
  --line: #e3e6eb;
  --accent: #e52228;
  --accent-dark: #be141a;
  --charcoal: #15171b;
  --success: #157f3b;
  --shadow: 0 16px 45px rgba(21, 23, 27, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.top-strip {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px clamp(16px, 3vw, 40px);
  background: var(--charcoal);
  color: #f3f5f8;
  font-size: 13px;
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(180px, 250px) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 20px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px clamp(16px, 3vw, 40px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand strong {
  font-size: 19px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.header-search svg {
  width: 20px;
  height: 20px;
  fill: var(--muted);
  flex: 0 0 20px;
}

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

.primary-contact,
.secondary-button,
.product-order,
.detail-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
}

.primary-contact,
.product-order,
.detail-order {
  background: var(--accent);
  color: white;
}

.primary-contact:hover,
.product-order:hover,
.detail-order:hover {
  background: var(--accent-dark);
}

.back-link {
  justify-self: start;
  color: var(--accent);
  font-weight: 800;
}

main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 40px) 48px;
}

.catalog-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  min-width: 0;
}

.filters {
  position: sticky;
  top: 99px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.filters h2 {
  margin: 0;
  font-size: 18px;
}

#resetFilters {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.category-list {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 10px;
}

.category-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.category-button:hover,
.category-button.active {
  border-color: #f1c7c9;
  background: #fff4f4;
}

.category-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button span:last-child {
  color: var(--muted);
}

.products-panel {
  min-width: 0;
  overflow: hidden;
}

.catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.catalog-toolbar strong,
.catalog-toolbar span {
  display: block;
}

.catalog-toolbar span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.sort-control select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 0 10px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
  min-width: 0;
  --card-media-height: 238px;
}

.product-card {
  display: grid;
  grid-template-rows: var(--card-media-height) 1fr auto;
  min-width: 0;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: #f0b3b6;
  box-shadow: var(--shadow);
}

.product-media {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: var(--card-media-height);
  border: 0;
  padding: 0;
  background: #f7f8fa;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
}

.product-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 16px;
}

.discount-flag {
  position: absolute;
  left: 10px;
  top: 10px;
  border-radius: 5px;
  background: var(--accent);
  color: white;
  padding: 5px 7px;
  font-size: 12px;
  font-weight: 800;
}

.product-body {
  display: grid;
  grid-template-rows: 34px minmax(61px, auto) auto auto;
  align-content: start;
  gap: 9px;
  padding: 14px;
}

.product-category {
  display: -webkit-box;
  min-height: 34px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.product-title {
  display: -webkit-box;
  min-height: 61px;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 15px;
  line-height: 1.35;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.product-meta span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-box {
  display: grid;
  gap: 3px;
  min-height: 52px;
}

.old-price {
  color: var(--muted);
  font-size: 13px;
  text-decoration: line-through;
}

.new-price {
  color: var(--accent);
  font-size: 20px;
  font-weight: 800;
}

.product-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 0 14px 14px;
  align-self: end;
}

.product-order {
  min-height: 40px;
  padding: 0 12px;
}

.details-button {
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.load-row {
  display: flex;
  justify-content: center;
  padding: 22px 0 0;
}

.product-dialog {
  width: min(960px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.22);
}

.product-dialog::backdrop {
  background: rgba(10, 12, 15, 0.55);
}

.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  cursor: pointer;
  font-size: 24px;
}

.detail-view {
  display: grid;
  grid-template-columns: 42% minmax(0, 1fr);
  gap: 24px;
  padding: 26px;
}

.product-page-main {
  padding-top: 28px;
}

.product-page-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.detail-image {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f8fa;
}

.detail-image img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  padding: 22px;
}

.detail-copy h1,
.detail-copy h2 {
  margin: 0 36px 10px 0;
  font-size: 28px;
  line-height: 1.15;
}

.detail-copy p {
  color: var(--muted);
  line-height: 1.6;
}

.detail-price {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 18px 0;
}

.detail-price strong {
  color: var(--accent);
  font-size: 30px;
}

.detail-props {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.detail-prop {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.detail-prop span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-prop strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 26px clamp(16px, 3vw, 40px);
  background: var(--charcoal);
  color: white;
}

.site-footer strong,
.site-footer span {
  display: block;
}

.site-footer span {
  margin-top: 4px;
  color: #b8bec7;
  font-size: 13px;
}

.site-footer a {
  color: white;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    --card-media-height: 220px;
  }
}

@media (max-width: 920px) {
  .header-inner,
  .product-header-inner,
  .catalog-shell,
  .detail-view {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }

  .category-list {
    display: flex;
    width: 100%;
    max-width: 100%;
    max-height: none;
    overflow-x: auto;
  }

  .category-button {
    flex: 0 0 min(220px, 78vw);
    min-width: 0;
  }
}

@media (max-width: 680px) {
  .top-strip,
  .catalog-toolbar,
  .site-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .header-inner {
    gap: 12px;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    --card-media-height: 150px;
  }

  .product-body {
    padding: 11px;
  }

  .product-actions {
    grid-template-columns: 1fr;
    padding: 0 11px 11px;
  }

  .details-button {
    width: 100%;
  }

  .detail-props {
    grid-template-columns: 1fr;
  }

  .detail-copy h1,
  .detail-copy h2 {
    font-size: 23px;
  }
}
