:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2630;
  --muted: #667281;
  --line: #dfe5ec;
  --accent: #1478ff;
  --accent-strong: #045fd0;
  --success: #137c43;
  --warning: #9b5b00;
  --shadow: 0 12px 30px rgba(25, 35, 48, 0.08);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --panel: #1a2028;
    --text: #eef3f8;
    --muted: #98a4b2;
    --line: #2b3542;
    --accent: #63a4ff;
    --accent-strong: #8abcff;
    --success: #48c77e;
    --warning: #ffc062;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(104px + env(safe-area-inset-bottom));
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 18px;
  max-width: 980px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 {
  font-size: 28px;
  line-height: 1.12;
  margin: 0;
}

.icon-button,
.secondary-button,
.add-button,
.cart button,
.ghost-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  align-items: center;
  aspect-ratio: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--accent);
  display: grid;
  flex: 0 0 44px;
  font-size: 24px;
  width: 44px;
}

.icon-button.compact {
  box-shadow: none;
  flex-basis: 36px;
  font-size: 24px;
  width: 36px;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 0 auto 12px;
  max-width: 980px;
  padding: 12px;
}

.search,
.filter-field {
  display: grid;
  gap: 6px;
}

.search span,
.filter-field span,
.field span {
  color: var(--muted);
  font-size: 13px;
}

.search input,
.filter-field select,
.field input {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 44px;
  outline: none;
  padding: 0 12px;
}

.search input:focus,
.filter-field select:focus,
.field input:focus {
  border-color: var(--accent);
}

.filter-field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  padding-right: 34px;
}

.toggle-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.toggle {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  gap: 8px;
}

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

.secondary-button {
  background: transparent;
  color: var(--accent);
  padding: 8px 0;
}

.status-line {
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin: 0 auto 10px;
  max-width: 980px;
}

.catalog {
  display: grid;
  gap: 10px;
  margin: 0 auto;
  max-width: 980px;
}

.product {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 44px;
  min-height: 128px;
  padding: 14px;
}

.product:focus-within,
.product:hover {
  border-color: color-mix(in srgb, var(--accent), var(--line) 55%);
}

.article {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.brand,
.category {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.category {
  margin-bottom: 8px;
}

.product h2 {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.28;
  margin: 0 0 12px;
}

.meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.stock {
  border: 1px solid color-mix(in srgb, var(--success), transparent 60%);
  border-radius: 999px;
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
}

.stock.empty {
  border-color: color-mix(in srgb, var(--warning), transparent 55%);
  color: var(--warning);
}

.add-button {
  align-items: center;
  aspect-ratio: 1;
  background: var(--accent);
  border-radius: 8px;
  color: white;
  display: grid;
  font-size: 24px;
  font-weight: 500;
  width: 44px;
}

.add-button:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.empty-state {
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
}

.cart {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  bottom: 0;
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  left: 50%;
  max-width: 980px;
  padding: 14px max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  position: fixed;
  transform: translateX(-50%);
  width: 100%;
}

.cart div {
  display: grid;
  gap: 2px;
}

.cart span {
  color: var(--muted);
  font-size: 13px;
}

.cart-actions {
  display: flex;
  gap: 8px;
}

.cart button {
  background: var(--accent);
  border-radius: 8px;
  color: white;
  min-height: 44px;
  min-width: 118px;
  padding: 0 18px;
}

.cart .ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
  min-width: 94px;
}

.cart button:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.cart .ghost-button:disabled {
  background: transparent;
  color: var(--muted);
}

.modal-backdrop {
  align-items: end;
  background: rgba(7, 10, 14, 0.56);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px 14px max(18px, env(safe-area-inset-bottom));
  position: fixed;
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.contact-modal,
.order-modal,
.product-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  max-width: 520px;
  padding: 14px;
  width: 100%;
}

.order-modal {
  max-height: calc(100vh - 32px);
  max-width: 720px;
  overflow: auto;
}

.product-modal {
  max-height: calc(100vh - 32px);
  max-width: 980px;
  overflow: auto;
}

.modal-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.modal-head h2 {
  font-size: 20px;
  margin: 0;
}

.detail-layout {
  display: grid;
  gap: 16px;
}

.gallery {
  display: grid;
  gap: 10px;
}

.image-stage {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  justify-items: center;
  overflow: hidden;
  position: relative;
}

.image-stage img {
  display: block;
  height: 100%;
  object-fit: contain;
  touch-action: pan-y;
  width: 100%;
}

.image-stage img[hidden],
.image-fallback[hidden] {
  display: none;
}

.image-fallback {
  color: var(--muted);
  font-size: 14px;
  padding: 18px;
  text-align: center;
}

.thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.thumbs button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
  min-height: 38px;
  min-width: 48px;
  padding: 0 10px;
}

.thumbs button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.detail-link {
  justify-self: start;
}

.detail-info {
  display: grid;
  gap: 12px;
  align-content: start;
}

.detail-article,
.detail-description {
  margin: 0;
}

.detail-article {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.detail-description {
  line-height: 1.4;
}

.specs {
  display: grid;
  gap: 8px;
  margin: 0;
}

.specs div {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding-top: 8px;
}

.specs dt {
  color: var(--muted);
  font-size: 12px;
}

.specs dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-links button,
.detail-add-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  padding: 0 14px;
}

.detail-links button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
}

.detail-add-button {
  background: var(--accent);
  color: white;
  width: 100%;
}

.detail-add-button:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.field {
  display: grid;
  gap: 6px;
}

.field textarea {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 84px;
  outline: none;
  padding: 10px 12px;
  resize: vertical;
}

.field textarea:focus {
  border-color: var(--accent);
}

.order-items {
  display: grid;
  gap: 10px;
}

.order-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 12px;
}

.order-item h3 {
  font-size: 15px;
  line-height: 1.25;
  margin: 0;
}

.order-item-meta,
.order-item-limit {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.qty-control {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qty-control button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
}

.qty-minus,
.qty-plus {
  background: var(--accent);
  color: white;
  font-size: 20px;
  width: 42px;
}

.qty-minus:disabled,
.qty-plus:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.qty-value {
  font-weight: 800;
  min-width: 30px;
  text-align: center;
}

.remove-item {
  background: transparent;
  border: 1px solid var(--line) !important;
  color: var(--accent);
  padding: 0 12px;
}

.line-total {
  font-size: 16px;
}

.order-total {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
}

.order-total span {
  color: var(--muted);
}

.order-total strong {
  font-size: 22px;
}

.form-error {
  color: #df4d4d;
  font-size: 13px;
  min-height: 18px;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.modal-actions button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  min-height: 44px;
  padding: 0 16px;
}

.modal-actions .ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
}

@media (max-width: 430px) {
  .cart-actions {
    gap: 6px;
  }

  .cart button {
    min-width: 92px;
    padding: 0 12px;
  }

  .cart .ghost-button {
    min-width: 78px;
  }

  .modal-actions {
    display: grid;
  }
}

@media (min-width: 720px) {
  .app {
    padding-left: 24px;
    padding-right: 24px;
  }

  .controls {
    align-items: end;
    grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) minmax(170px, 240px) auto;
  }

  .catalog {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-backdrop {
    align-items: center;
  }

  .detail-layout {
    grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 1.1fr);
  }
}
