:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--tg-theme-text-color, #21152b);
  background: var(--tg-theme-bg-color, #f7f3f9);
  --purple: #6b2fa0;
  --purple2: #8f4cc1;
  --card: var(--tg-theme-secondary-bg-color, #fff);
  --muted: var(--tg-theme-hint-color, #746c78);
}
* { box-sizing: border-box; }
body { margin: 0; padding: 0 0 96px; background: linear-gradient(160deg, #fbf7fd, #f3edf8 60%, #fbf9ef); min-height: 100vh; }
.header { padding: calc(18px + env(safe-area-inset-top)) 18px 14px; display: flex; align-items: center; justify-content: space-between; background: linear-gradient(135deg, #54227f, #8f4cc1); color: #fff; }
.eyebrow { font-size: 11px; letter-spacing: .18em; font-weight: 800; opacity: .82; }
.header h1 { font-size: 22px; margin: 3px 0 0; }
.badge { font-size: 12px; background: rgba(255,255,255,.18); padding: 8px 10px; border-radius: 999px; max-width: 150px; text-align: center; }
.badge.allowed { background: #daf5dd; color: #165e25; }
.badge.locked { background: #fff0c7; color: #74510b; }
main { padding: 16px; max-width: 720px; margin: auto; }
h2 { font-size: 17px; margin: 18px 0 10px; }
.notice { background: #fff3cd; border: 1px solid #f1d986; border-radius: 14px; padding: 12px; margin-bottom: 12px; font-size: 14px; }
.hidden { display: none !important; }
.currency-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 14px; font-weight: 800; }
.currency-selector { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 12px; background: #e9dff0; min-width: 148px; }
.currency-selector button { border: 0; border-radius: 9px; padding: 8px 13px; background: transparent; color: #54227f; font-weight: 800; }
.currency-selector button.active { background: var(--purple); color: #fff; box-shadow: 0 2px 8px rgba(84,34,127,.22); }
.search-row { display: flex; gap: 8px; }
.search-row input, label input, label select { width: 100%; border: 1px solid #ddd3e3; border-radius: 13px; padding: 13px; background: var(--card); color: inherit; font-size: 15px; }
.primary { border: 0; border-radius: 13px; background: linear-gradient(135deg, var(--purple), var(--purple2)); color: #fff; font-weight: 700; padding: 13px 16px; }
.compact { padding: 0 17px; }
.catalog-layout { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: start; margin-top: 14px; }
.brand-sidebar { position: sticky; top: 8px; max-height: calc(100vh - 190px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; scrollbar-width: thin; }
.brand-sidebar h2 { margin: 4px 0 10px; }
.catalog-content { min-width: 0; }
.catalog-content .section-title h2 { margin-top: 4px; }
.chips { display: flex; flex-direction: column; gap: 7px; padding: 1px 2px 8px; }
.chip { width: 100%; border: 1px solid #ddcee9; background: var(--card); padding: 9px 8px; border-radius: 12px; white-space: normal; overflow-wrap: anywhere; text-align: left; color: inherit; font-size: 12px; line-height: 1.2; }
.chip.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.section-title { display: flex; align-items: center; gap: 10px; }
.spinner { width: 18px; height: 18px; border: 2px solid #d8c4e7; border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.products { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
.product { background: var(--card); border-radius: 17px; padding: 12px; box-shadow: 0 5px 20px rgba(57,27,75,.07); display: flex; flex-direction: column; min-height: 260px; overflow: hidden; }
.product-image { width: 100%; height: 150px; border-radius: 12px; background: #fff; display: grid; place-items: center; font-size: 28px; overflow: hidden; }
.product-image img { width: 100%; height: 100%; display: block; object-fit: contain; object-position: center; background: #fff; }
.product h3 { font-size: 14px; line-height: 1.3; margin: 10px 0 6px; }
.meta { font-size: 12px; color: var(--muted); margin: 2px 0; }
.price { font-size: 17px; font-weight: 800; margin: 8px 0; }
.description { font-size: 12px; color: var(--muted); margin: 6px 0; }
.description summary { color: var(--purple); font-weight: 700; cursor: pointer; }
.description p { white-space: pre-line; line-height: 1.35; margin: 5px 0; }
.product-actions { margin-top: auto; display: flex; gap: 6px; }
.product-actions button { flex: 1; border: 0; border-radius: 10px; padding: 9px 5px; background: #eee5f4; color: #54227f; font-weight: 700; }
.product-actions .add { background: var(--purple); color: #fff; }
.cart-button { position: fixed; z-index: 5; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 688px; min-height: 56px; max-height: 64px; margin: auto; border: 0; border-radius: 17px; padding: 10px 16px; background: #21152b; color: #fff; display: grid; grid-template-columns: auto auto minmax(0,1fr); align-items: center; gap: 10px; font-size: 16px; line-height: 1.15; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.25); overflow: hidden; }
.cart-label, .cart-count { white-space: nowrap; }
.cart-count { font-variant-numeric: tabular-nums; }
.cart-total { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.cart-button:disabled { opacity: .45; }
dialog { border: 0; padding: 0; border-radius: 22px 22px 0 0; width: min(720px,100%); max-width: none; margin: auto 0 0; max-height: 90vh; background: var(--tg-theme-bg-color,#fff); color: inherit; }
dialog::backdrop { background: rgba(20,8,28,.55); }
.dialog-shell { padding: 18px; overflow: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.icon-button { border: 0; background: #eee; border-radius: 50%; width: 34px; height: 34px; font-size: 25px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px; border-bottom: 1px solid #eee; padding: 12px 0; }
.cart-line strong { font-size: 14px; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { border: 0; border-radius: 8px; width: 30px; height: 30px; }
.dialog-shell label { display: block; font-size: 13px; font-weight: 700; margin: 15px 0 5px; }
.dialog-shell label input, .dialog-shell label select { display: block; margin-top: 6px; }
.full { width: 100%; margin-top: 14px; }
.error { color: #9a2232; background: #fde8eb; padding: 10px; border-radius: 10px; font-size: 13px; }
@media (max-width: 420px) {
  main { padding-left: 10px; padding-right: 10px; }
  .catalog-layout { grid-template-columns: 82px minmax(0, 1fr); gap: 8px; }
  .products { grid-template-columns: 1fr; }
  .chip { font-size: 11px; padding: 8px 6px; }
  .cart-button { left: 10px; right: 10px; padding: 9px 12px; gap: 7px; font-size: 14px; }
  .cart-total { font-size: 12px; }
}
@media (min-width: 760px) { .products { grid-template-columns: repeat(3,minmax(0,1fr)); } }
