/* Цвета берём из темы Telegram — витрина сама становится светлой или тёмной */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --accent: var(--tg-theme-button-color, #0a84ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #0a84ff);
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --tile: #ffffff;            /* фон под фото товаров (у фото Apple белый или светло-серый фон) */
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; }

.screen { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); animation: in .22s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- шапка каталога ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.top h1 { font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
.top .sub { color: var(--hint); font-size: 14px; margin-top: 2px; }
.icon-btn {
  position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%;
  background: var(--card); display: grid; place-items: center;
}
.icon-btn svg { width: 22px; height: 22px; }
.top-actions { display: flex; gap: 8px; flex: none; }
.badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

.search {
  display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px;
  padding: 0 12px; height: 42px; margin-bottom: 12px;
}
.search svg { width: 18px; height: 18px; color: var(--hint); flex: none; }
.search input { border: 0; outline: 0; background: none; width: 100%; height: 100%; font-size: 16px; }
.search input::placeholder { color: var(--hint); }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card);
  font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s;
}
.chip.on { background: var(--text); color: var(--bg); }

/* ---------- сетка товаров ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; text-align: left;
  display: flex; flex-direction: column; transition: transform .12s;
}
.card:active { transform: scale(.97); }
.card .pic { background: var(--tile); aspect-ratio: 1; overflow: hidden; }
.card .pic img { width: 100%; height: 100%; object-fit: cover; }
.card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card .name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.card .price { font-size: 14px; color: var(--hint); }
.card .price b { color: var(--text); font-weight: 600; }
.card.out { opacity: .55; }
.tag {
  align-self: flex-start; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); margin-bottom: 2px;
}
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 18px 2px 10px; }
.section-title:first-child { margin-top: 4px; }
.section-title.small { font-size: 15px; font-weight: 600; color: var(--hint); margin: 14px 2px 8px; }
.mini-dots { display: flex; gap: 4px; margin: 3px 0 2px; }
.mini-dots i { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- карточка товара ---------- */
.hero { position: relative; background: var(--tile); border-radius: 24px; overflow: hidden; margin-bottom: 16px; }
.hero-cart {
  position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.85); color: #111114; display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.12); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.hero-cart svg { width: 22px; height: 22px; }
.hero img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.p-name { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 2px 2px; line-height: 1.15; }
.p-note { color: var(--accent); font-size: 14px; font-weight: 600; margin: 0 2px 6px; }
.p-price { font-size: 22px; font-weight: 600; margin: 4px 2px 0; }
.p-price small { color: var(--hint); font-size: 14px; font-weight: 400; margin-left: 6px; }

.block { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 14px; }
.block h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .05em; }
.block h3 span { text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 500; margin-left: 4px; }

.colors { display: flex; flex-wrap: wrap; gap: 12px; }
.dot {
  width: 36px; height: 36px; border-radius: 50%; position: relative;
  box-shadow: inset 0 0 0 1px var(--line), inset 0 0 0 1.5px rgba(127,127,127,.25);
}
.dot::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent; transition: border-color .15s;
}
.dot.on::after { border-color: var(--accent); }

.mem { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt {
  border-radius: 14px; padding: 10px 12px; text-align: left;
  box-shadow: inset 0 0 0 1.5px var(--line); transition: box-shadow .15s, background .15s;
}
.opt .m { font-weight: 600; font-size: 16px; }
.opt .p { font-size: 13px; color: var(--hint); }
.opt.on { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.opt:disabled { opacity: .4; }
.opt:disabled .p { text-decoration: none; }
.mem.wide { grid-template-columns: 1fr; }

.perks { display: grid; gap: 10px; }
.perk { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.perk i { font-style: normal; font-size: 20px; width: 28px; text-align: center; }

/* ---------- оформление ---------- */
.summary { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; }
.summary-list { display: grid; gap: 12px; }
.summary-list .summary .noimg { width: 72px; height: 72px; border-radius: 14px; background: var(--tile); flex: none; }
.summary-list .spec.total { border-top: 1px solid var(--line); padding-top: 12px; padding-bottom: 0; }
.summary img { width: 72px; height: 72px; border-radius: 14px; background: var(--tile); object-fit: cover; }
.summary .t { font-weight: 600; }
.summary .s { color: var(--hint); font-size: 14px; }
.summary .pr { font-weight: 600; margin-top: 2px; }
.field { display: block; margin-top: 12px; }
.field span { display: block; font-size: 13px; color: var(--hint); margin: 0 2px 6px; }
.field input {
  width: 100%; height: 48px; border-radius: 12px; border: 0; outline: 0; padding: 0 14px;
  background: var(--bg); font-size: 17px;
}
.field input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.link-btn { color: var(--link); font-size: 14px; font-weight: 500; margin: 8px 2px 0; }
.error { color: var(--danger); font-size: 14px; margin: 10px 2px 0; min-height: 1em; }
.fine { color: var(--hint); font-size: 12px; margin: 14px 4px 0; text-align: center; }

/* ---------- результат / заказы / пусто ---------- */
.center { text-align: center; padding-top: 12vh; }
.big-icon {
  width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 18px; display: grid; place-items: center;
  background: color-mix(in srgb, #34c759 16%, transparent); color: #34c759; font-size: 44px;
}
.center h2 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.01em; }
.center p { color: var(--hint); margin: 0 auto 22px; max-width: 300px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 48px; padding: 0 22px;
  border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.btn.ghost { background: var(--card); color: var(--link); }

.order {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--card); border-radius: var(--radius); padding: 10px; margin-bottom: 10px;
  transition: transform .12s;
}
.order:active { transform: scale(.98); }
.order img, .order .noimg { width: 76px; height: 76px; border-radius: 14px; background: var(--tile); object-fit: cover; flex: none; }
.o-body { flex: 1; min-width: 0; }
.order .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.order .num { font-size: 13px; color: var(--hint); }
.order .what { font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order .meta { color: var(--hint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-price { font-weight: 600; font-size: 14px; margin-top: 2px; }
.st { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; white-space: nowrap; background: var(--bg); }
.st-new { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.st-confirmed { background: color-mix(in srgb, #34c759 16%, transparent); color: #2fa84f; }
.st-done { background: var(--bg); color: var(--hint); }
.st-canceled { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

.row-between { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 4px; }
.row-between .p-note { margin: 0; }
.specs { display: grid; gap: 0; padding: 4px 14px; }
.spec { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; font-size: 15px; }
.spec + .spec { border-top: 1px solid var(--line); }
.spec span { color: var(--hint); }
.spec b { font-weight: 500; text-align: right; }
.status-help { font-size: 14px; line-height: 1.45; }
.actions { display: grid; gap: 10px; margin-top: 16px; }
.actions .btn { width: 100%; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn:disabled { opacity: .5; }
.empty { color: var(--hint); text-align: center; padding: 40px 0; }

.contacts { margin-top: 18px; }
.contacts a { color: var(--link); text-decoration: none; }

/* ---------- кнопка вне Telegram ---------- */
.fallback-main {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 52px;
  border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 17px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.fallback-main:disabled { opacity: .6; }

.loader { display: grid; place-items: center; height: 80vh; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- корзина ---------- */
.in-cart {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 0;
  padding: 8px 8px 8px 14px; border-radius: 14px; background: color-mix(in srgb, #34c759 12%, var(--card));
}
.in-cart span { color: #2fa84f; font-weight: 600; font-size: 15px; }
.stepper { display: inline-flex; align-items: center; border-radius: 10px; background: var(--bg); overflow: hidden; }
.stepper button { width: 34px; height: 32px; font-size: 20px; line-height: 1; color: var(--accent); }
.stepper button:disabled { color: var(--hint); opacity: .5; }
.stepper span { min-width: 22px; text-align: center; font-weight: 600; font-size: 15px; }
.in-cart .stepper { background: var(--card); }

.title-row { display: flex; justify-content: space-between; align-items: baseline; }
.title-row .link-btn { margin: 0; }
.danger-link { color: var(--danger); }

.cart-line {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px;
}
.cl-pic { flex: none; }
.cl-pic img { width: 84px; height: 84px; border-radius: 14px; background: var(--tile); object-fit: cover; }
.cl-body { flex: 1; min-width: 0; padding-top: 2px; }
.cl-name { font-weight: 600; line-height: 1.2; }
.cl-meta { color: var(--hint); font-size: 13px; margin-top: 2px; }
.cl-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.cl-bottom b { font-weight: 600; white-space: nowrap; }
.cl-out { color: var(--danger); font-size: 13px; margin-top: 8px; }
.cl-remove { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--hint); }
.cl-remove:active { background: var(--bg); color: var(--danger); }
.cl-remove svg { width: 20px; height: 20px; }
.cart-line.unavailable .cl-pic, .cart-line.unavailable .cl-name, .cart-line.unavailable .cl-meta { opacity: .5; }
.spec.total span { color: var(--text); font-weight: 600; }
.spec.total b { font-weight: 700; font-size: 17px; }
.btn.wide { width: 100%; margin-top: 14px; }
.big-icon.neutral { background: var(--card); color: var(--hint); }
.big-icon.neutral svg { width: 40px; height: 40px; }

.o-pics { position: relative; width: 76px; height: 76px; flex: none; }
.o-pics img, .o-pics .noimg { width: 76px; height: 76px; border-radius: 14px; background: var(--tile); object-fit: cover; display: block; }
.o-pics .more {
  position: absolute; right: -4px; bottom: -4px; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--card);
}

/* ---------- наличие ---------- */
.card .stock { font-size: 12px; color: #2fa84f; margin-top: 2px; }
.card .stock.none { color: var(--hint); }
.p-stock { margin: 6px 2px 0; font-size: 14px; font-weight: 600; color: #2fa84f; }
.p-stock.none { color: var(--danger); }
.opt.soldout { opacity: .55; }
.opt.soldout .p { color: var(--danger); }
.cl-stock { font-size: 12px; color: #2fa84f; margin-top: 4px; }

/* ---------- таблица заказов (для продавца) ---------- */
.table-sum { font-size: 14px; color: var(--hint); margin: 0 2px 10px; }
.table-sum b { color: var(--text); }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.orders-table {
  border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%;
  background: var(--card); border-radius: 14px; overflow: hidden;
}
.orders-table th, .orders-table td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.orders-table th {
  position: sticky; top: 0; background: var(--card); color: var(--hint); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
.orders-table tr:last-child td { border-bottom: 0; }
.orders-table td small { color: var(--hint); }
.orders-table .num { text-align: right; }
.nowrap { white-space: nowrap; }
.orders-table td:first-child, .orders-table th:first-child { position: sticky; left: 0; background: var(--card); }
.orders-table td:nth-child(2) { min-width: 140px; }

/* ---------- способ получения ---------- */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); }
.segmented button { height: 40px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--hint); }
.segmented button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
