:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-light: #ffedd5;
  --bg: var(--tg-theme-bg-color, #fff7f0);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1f2937);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 70px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 28px; }
.brand-name { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; opacity: 0.9; }

.cart-btn {
  position: relative;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #fff;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--orange);
  color: var(--orange-dark);
  background: var(--card);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { background: var(--orange); color: #fff; }

.catalog {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px 16px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  padding: 8px;
}
.card-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.card-body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.card-color { font-size: 12px; color: var(--hint); margin-top: 2px; }
.card-price { margin-top: auto; padding-top: 8px; font-size: 15px; font-weight: 700; color: var(--orange-dark); }

.info-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--orange-light);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--hint);
  text-align: center;
  z-index: 10;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.modal.hidden, .hidden { display: none; }
.modal-sheet {
  background: var(--bg);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 28px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: var(--orange-light);
  color: var(--orange-dark);
  font-size: 15px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  z-index: 2;
}

.product-img {
  width: 70%;
  max-height: 240px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
}
.product-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; padding-right: 36px; }
.product-color { color: var(--hint); font-size: 14px; margin-bottom: 12px; }

.specs { background: var(--card); border-radius: var(--radius); padding: 4px 12px; margin-bottom: 14px; }
.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.spec-row:last-child { border-bottom: none; }
.spec-row span:first-child { color: var(--hint); }
.spec-row span:last-child { font-weight: 600; text-align: right; }

.section-label { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.variant-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.variant {
  border: 1.5px solid #e5e7eb;
  background: var(--card);
  border-radius: 12px;
  padding: 8px 6px;
  min-width: 76px;
  flex: 1 0 28%;
  text-align: center;
  cursor: pointer;
}
.variant.active { border-color: var(--orange); background: var(--orange-light); }
.variant b { display: block; font-size: 14px; }
.variant small { color: var(--hint); font-size: 11.5px; }
.variant .v-price { color: var(--orange-dark); font-weight: 700; font-size: 13px; margin-top: 2px; }

.qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.qty-btn {
  width: 38px;
  height: 38px;
  font-size: 20px;
  border: none;
  background: var(--orange-light);
  color: var(--orange-dark);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.qty-val { font-size: 17px; font-weight: 700; min-width: 24px; text-align: center; }

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:disabled { opacity: 0.6; }

.cart-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
}
.cart-item img { width: 54px; height: 54px; object-fit: contain; background: #fff; border-radius: 8px; }
.ci-info { flex: 1; min-width: 0; }
.ci-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.ci-sub { font-size: 12px; color: var(--hint); }
.ci-price { font-size: 13.5px; font-weight: 700; color: var(--orange-dark); white-space: nowrap; }
.ci-qty { display: flex; align-items: center; gap: 6px; }
.ci-qty button {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: var(--orange-light);
  color: var(--orange-dark);
  font-weight: 700;
  cursor: pointer;
}

#cartSummary { margin: 14px 0; }
.sum-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.sum-row.total { font-size: 17px; font-weight: 700; border-top: 1.5px solid var(--orange-light); margin-top: 6px; padding-top: 10px; }
.sum-note { font-size: 12px; color: var(--hint); }

.order-form h3 { margin: 10px 0 10px; font-size: 16px; }
.order-form input[type="text"], .order-form input[type="tel"], .order-form textarea {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  margin-bottom: 10px;
  background: var(--card);
  color: var(--text);
}
.order-form input:focus, .order-form textarea:focus { outline: none; border-color: var(--orange); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }
.pay-note { font-size: 12px; color: var(--hint); margin-bottom: 12px; }

.empty-cart { text-align: center; color: var(--hint); padding: 30px 0; font-size: 15px; }

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}

.success-screen { text-align: center; padding: 30px 10px; }
.success-screen .big { font-size: 56px; }
.success-screen h2 { margin: 10px 0 6px; }
.success-screen p { color: var(--hint); font-size: 14px; }
