/* ===== Токены ===== */
:root {
  --color-bg: #f6f7fb;
  --color-surface: #ffffff;
  --color-border: #e2e5ee;
  --color-text: #1a243f;
  --color-text-muted: #6c7688;
  --color-primary: #5774dc;
  --color-primary-dark: #3e328c;
  --color-danger: #d95e2d;
  --radius: 12px;
  --font-main: "sans-serif";
  --header-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header__title {
  font-size: 1.3rem;
  margin: 0;
}

.cart-toggle {
  position: relative;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cart-toggle:hover { background: var(--color-bg); }

.cart-toggle__badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.catalog {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.catalog__title {
  margin: 0 0 16px;
  font-size: 1.3rem;
}

.catalog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-card__image {
  height: 110px;
  border-radius: 8px;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
}

.product-card__name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.product-card__desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  flex: 1;
}

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

.product-card__price {
  font-weight: 700;
  font-size: 1.05rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}
.btn:hover { background: var(--color-bg); }
.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--full { width: 100%; }
.btn--small { padding: 5px 9px; font-size: 0.8rem; }

.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 360px;
  max-width: 92vw;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 40;
}
.cart-panel.is-open { transform: translateX(0); }

.cart-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
}
.cart-panel__header h2 { margin: 0; font-size: 1.1rem; }
.cart-panel__close {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

.cart-list {
  list-style: none;
  margin: 0;
  padding: 10px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 10px;
}

.cart-item__image {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.cart-item__info {
  flex: 1;
  min-width: 0;
}
.cart-item__name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cart-item__price {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.cart-item__qty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qty-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.qty-btn:hover { background: var(--color-bg); }
.cart-item__qty-value {
  min-width: 20px;
  text-align: center;
  font-size: 0.88rem;
}

.cart-item__remove {
  border: none;
  background: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.cart-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 30px 10px;
  font-size: 0.9rem;
}

.cart-panel__footer {
  padding: 14px 18px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#cartOverlay[hidden] { display: none; }
#orderModal[hidden] { display: none; }
#orderSuccess[hidden] { display: none; }
#orderFormError[hidden] { display: none; }
#orderFormSuccess[hidden] { display: none; }
#orderForm[hidden] { display: none; }

.cart-total {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}

.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 30;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.modal__content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 26px 22px;
  max-width: 420px;
  width: 100%;
  z-index: 1;
  max-height: 90vh;
  overflow-y: auto;
}
.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text-muted);
}
.modal__title { margin: 0 0 16px; font-size: 1.2rem; }

.order-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.order-form__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.order-form__field label {
  font-size: 0.85rem;
  font-weight: 600;
}
.order-form__field input {
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}
.order-form__field input:focus { outline: none; border-color: var(--color-primary); }
.order-form__field input.is-invalid { border-color: var(--color-danger); }

.order-form__error {
  color: var(--color-danger);
  font-size: 0.82rem;
}

.order-success {
  text-align: center;
  padding: 20px 0;
}
.order-success__message {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 16px;
}

@media (max-width: 900px) {
  .catalog__grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 640px) {
  .site-header { padding: 0 12px; }
  .site-header__title { font-size: 1.1rem; }
  .catalog { padding: 16px 12px 50px; }
  .catalog__grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .product-card { padding: 10px; }
  .product-card__image { height: 80px; font-size: 2rem; }
  .cart-panel { width: 100%; }
}
