:root {
  --ink: #111820;
  --muted: #626a70;
  --line: #ede5d8;
  --surface: #ffffff;
  --page: #f7f3ec;
  --accent: #c77a3a;
  --accent-dark: #8f4e20;
  --accent-soft: #f1e2d3;
  --signal: #1565ff;
  --titanium: #2b2e34;
  --good: #168455;
  --warn: #b26a00;
  --shadow: 0 16px 42px rgba(17, 24, 32, 0.13);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
}

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

button.secondary,
.category-list button,
.panel button,
.cart-panel header button,
.checkout-form header button {
  background: #eef4f9;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 3px solid var(--signal);
  background: rgba(255, 255, 255, 0.97);
}

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

.brand-mark {
  display: flex;
  align-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: transparent;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: auto;
  height: 48px;
  max-height: none;
  object-fit: cover;
  object-position: left center;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--accent-dark);
  letter-spacing: 0.02em;
}

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

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.cart-button {
  white-space: nowrap;
}

.cart-button span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  margin-left: 6px;
  border-radius: 12px;
  background: #fff;
  color: var(--accent-dark);
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.panel button {
  width: 100%;
  margin-top: 10px;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
}

.category-list button.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 3px 0 0 var(--signal);
}

.catalog {
  min-width: 0;
}

.catalog-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.catalog-head h1 {
  margin: 2px 0 0;
  font-size: 30px;
}

.mode-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.catalog-head select {
  max-width: 220px;
}

.status {
  min-height: 28px;
  color: var(--muted);
}

.status.error {
  color: #a83232;
}

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

.product-card {
  display: grid;
  grid-template-rows: 180px 1fr auto;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.product-card:hover {
  border-color: #e0c7ad;
  box-shadow: 0 12px 30px rgba(17, 24, 32, 0.1);
}

.product-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #e8eef5;
}

.product-body {
  padding: 14px;
}

.product-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.product-card h3 {
  min-height: 48px;
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

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

.product-footer {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

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

.price {
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
}

.stock {
  color: var(--good);
  font-size: 12px;
}

.stock.low {
  color: var(--warn);
}

.cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

.cart-drawer.open {
  display: block;
}

.cart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 25, 47, 0.46);
}

.cart-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(440px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: var(--shadow);
}

.cart-panel header,
.checkout-form header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.cart-panel h2,
.checkout-form h2 {
  margin: 0;
  font-size: 20px;
}

.cart-items {
  overflow: auto;
  padding: 16px;
}

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

.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.cart-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: #e8eef5;
}

.cart-item h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.cart-item p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.cart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-controls button {
  min-width: 34px;
  min-height: 34px;
  padding: 0;
}

.cart-panel footer {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

dialog {
  width: min(520px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 25, 47, 0.46);
}

.checkout-form {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.checkout-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.order-result {
  margin: 0;
  color: var(--good);
  line-height: 1.45;
}

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

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    padding: 14px;
  }

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

  .catalog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .catalog-head select {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .search {
    grid-template-columns: 1fr;
  }

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