:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #111418;
  --muted: #65707c;
  --line: #d9dee5;
  --accent: #d71920;
  --accent-dark: #a80f15;
  --ok: #116b37;
  --warn-bg: #fff4f0;
  --warn: #8a1f11;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 14px max(24px, calc((100vw - 1180px) / 2));
  background: #111418;
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #fff;
  border-radius: 6px;
  background: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.brand__name,
.brand__tag {
  display: block;
}

.brand__name {
  font-size: 18px;
  font-weight: 800;
}

.brand__tag {
  margin-top: 3px;
  color: #bac2cb;
  font-size: 13px;
}

.contacts {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: 0;
}

.status {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 240px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search span,
.select span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="search"],
select {
  width: 100%;
  height: 44px;
  border: 1px solid #cbd2da;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: 16px/1.2 Arial, Helvetica, sans-serif;
}

input[type="search"]:focus,
select:focus {
  border-color: #111418;
  outline: none;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #cbd2da;
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.summary strong {
  color: var(--ink);
}

.catalog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.catalog__head,
.product {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 130px 130px 112px;
  gap: 14px;
  align-items: center;
}

.catalog__head {
  min-height: 42px;
  padding: 0 14px;
  background: #eef1f4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.product {
  min-height: 142px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.product__image {
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border: 1px solid #edf0f3;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
}

.product__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product__image span {
  color: #9aa3ad;
  font-size: 12px;
  font-weight: 800;
}

.product h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.product__title-button {
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
}

.product__image {
  padding: 0;
  font: inherit;
  color: inherit;
}

.product__title-button {
  background: transparent;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}

.product__image:hover {
  border-color: var(--accent-dark);
}

.product__title-button:hover {
  color: var(--accent-dark);
}

.product p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.product__stock {
  display: inline-flex;
  justify-content: center;
  width: fit-content;
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid #b9d6c4;
  border-radius: 6px;
  background: #effaf3;
  color: var(--ok);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.product__stock.is-empty {
  border-color: #f0c9bf;
  background: var(--warn-bg);
  color: var(--warn);
}

.product__price {
  justify-self: end;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.product__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.product__action:hover {
  background: var(--accent-dark);
}

.empty {
  padding: 26px 14px;
  color: var(--muted);
}

.modal,
.lightbox,
.order-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal[hidden],
.lightbox[hidden],
.order-modal[hidden] {
  display: none;
}

.modal__backdrop,
.order-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 20, 24, 0.62);
}

.modal__panel {
  position: relative;
  width: min(1120px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  margin: 20px auto;
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.modal__close,
.lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

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

.gallery__stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 360px;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
  overflow: visible;
}

.gallery__stage img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 240px);
  object-fit: contain;
  display: block;
}

.gallery__stage span {
  color: #9aa3ad;
  font-size: 24px;
  font-weight: 800;
}

.gallery__controls {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.gallery__nav {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}

.gallery__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.gallery__thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.gallery__thumb {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: #fff;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.gallery__thumb.is-active {
  border-color: var(--accent);
}

.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail__code {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail__info h2 {
  margin: 0 44px 18px 0;
  font-size: 28px;
  line-height: 1.2;
}

.detail__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.detail__facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.detail__facts span,
.detail__facts strong {
  display: block;
}

.detail__facts span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail__facts strong {
  font-size: 20px;
}

.detail__description {
  min-height: 120px;
  margin-bottom: 22px;
  color: #2a3036;
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-line;
}

.detail__description.is-empty {
  color: var(--muted);
}

.detail__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.lightbox {
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(17, 20, 24, 0.88);
}

.order-modal {
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.order-modal__panel {
  position: relative;
  width: min(620px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.order-modal__panel h2 {
  margin: 0 44px 10px 0;
  font-size: 26px;
  line-height: 1.2;
}

.order-modal__product {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

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

.order-modal__grid label {
  display: block;
}

.order-modal__grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-modal__grid input {
  width: 100%;
  height: 44px;
  border: 1px solid #cbd2da;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  font: 16px/1.2 Arial, Helvetica, sans-serif;
}

.order-modal__grid input:focus {
  border-color: #111418;
  outline: none;
}

.order-modal__quantity {
  grid-column: 1 / -1;
}

.qty-stepper {
  display: grid;
  grid-template-columns: 44px 96px 44px;
  gap: 8px;
  align-items: center;
}

.qty-stepper button {
  height: 44px;
  border: 1px solid #cbd2da;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}

.qty-stepper input {
  text-align: center;
  font-weight: 800;
}

.order-modal__check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  color: #2a3036;
  font-size: 13px;
  line-height: 1.4;
}

.order-modal__check input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--accent);
}

.order-modal__check a {
  color: var(--accent-dark);
  font-weight: 800;
}

.order-modal__hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.order-modal__status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.order-modal__status.is-error {
  color: var(--warn);
}

.order-modal__status.is-success {
  color: var(--ok);
}

.order-modal__submit {
  width: 100%;
  margin-top: 12px;
  border: 0;
  cursor: pointer;
}

.order-modal__submit:disabled {
  opacity: 0.55;
  cursor: wait;
}

.legal-page {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.legal-page h1 {
  margin-bottom: 18px;
}

.legal-page p {
  color: #2a3036;
  font-size: 16px;
  line-height: 1.6;
}

.lightbox__toolbar {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 2;
  display: flex;
  gap: 6px;
  transform: translateX(-50%);
}

.lightbox__toolbar button {
  min-width: 42px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.lightbox__viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
}

.lightbox__viewport.is-dragging {
  cursor: grabbing;
}

.lightbox img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: min(100%, 1600px);
  max-height: min(100%, 1200px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
}

@media (max-width: 860px) {
  .topbar,
  .intro,
  .summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar,
  .contacts,
  .summary {
    display: flex;
  }

  .intro,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .catalog__head {
    display: none;
  }

  .product {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 10px 12px;
  }

  .product__image {
    width: 96px;
    height: 96px;
  }

  .detail {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .gallery__stage {
    min-height: 260px;
    max-height: 55vh;
  }

  .gallery__stage img {
    max-height: 55vh;
  }

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

  .order-modal__grid {
    grid-template-columns: 1fr;
  }

  .detail__info h2 {
    font-size: 22px;
  }

  .product__stock,
  .product__price,
  .product__action {
    grid-column: 2;
    justify-self: start;
  }
}
