:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14110f);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --card: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --sep: color-mix(in srgb, var(--text) 8%, transparent);
  /* фирменный акцент бренда (инъектится в index.html, фолбэк — зелёный) */
  --accent: var(--brand-accent, #16a34a);
  --accent-press: color-mix(in srgb, var(--accent) 82%, #000);
  --accent-weak: color-mix(in srgb, var(--accent) 12%, var(--bg));
  --on-accent: #ffffff;
  --gap: 16px;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: 96px; font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ───────── шапка ───────── */
#topbar {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  padding: 12px var(--gap) 8px; border-bottom: 1px solid var(--sep);
}
#shop-title { font-weight: 800; font-size: 20px; letter-spacing: -.01em; margin-bottom: 10px; }
#cats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
#cats::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; padding: 8px 14px; border-radius: 999px;
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: background .15s, color .15s;
}
.chip.active { background: var(--accent); color: var(--on-accent); }

/* ───────── баннер-карусель ───────── */
#promo { margin: 12px var(--gap) 6px; }
.banners {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  border-radius: var(--radius); scrollbar-width: none;
}
.banners::-webkit-scrollbar { display: none; }
.banner {
  position: relative; min-width: 100%; height: 140px; scroll-snap-align: center;
  overflow: hidden; border-radius: var(--radius);
}
.banner .bn-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.banner .bn-ov {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(8,30,15,.86) 0%, rgba(8,30,15,.62) 52%, rgba(8,30,15,.30) 100%);
}
.banner .bn-text {
  position: relative; z-index: 1; height: 100%; padding: 18px 20px;
  display: flex; flex-direction: column; justify-content: center; color: #fff;
}
.banner .bn-title {
  font-size: 19px; font-weight: 800; line-height: 1.2; margin-bottom: 7px;
  text-shadow: 0 1px 6px rgba(0,0,0,.45); max-width: 88%;
}
.banner .bn-sub {
  font-size: 13.5px; line-height: 1.4; max-width: 78%; color: rgba(255,255,255,.92);
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sep); transition: width .25s, background .25s; }
.dot.active { background: var(--accent); width: 18px; border-radius: 3px; }

/* ───────── экраны ───────── */
.screen { display: none; padding: 12px var(--gap) 0; }
.screen.active { display: block; }

/* ───────── карточка товара ───────── */
.product {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; margin-bottom: 12px;
  background: var(--card); border-radius: var(--radius);
}
.product img {
  width: 72px; height: 72px; border-radius: 12px; object-fit: cover;
  background: color-mix(in srgb, var(--text) 6%, transparent); flex: none;
}
.product .info { flex: 1; min-width: 0; }
.product .name {
  font-weight: 650; font-size: 15px; line-height: 1.25; margin-bottom: 3px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.product .desc {
  color: var(--hint); font-size: 12px; line-height: 1.35; margin-bottom: 8px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.product .price {
  font-weight: 800; font-size: 16px; color: var(--accent); letter-spacing: -.01em; white-space: nowrap;
}
.product .price .unit { color: var(--hint); font-weight: 600; font-size: 13px; }
.product .price .price-req { color: var(--hint); font-weight: 600; font-size: 14px; }
.product .out { color: var(--hint); font-size: 12px; font-weight: 600; }
.product .ctl { flex: none; align-self: center; }
.product .more {
  margin-top: 7px; padding: 0; border: none; background: none; cursor: pointer;
  color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px;
}
.product img { cursor: pointer; }

/* ───────── модалка «Подробнее» (bottom sheet) ───────── */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 520px; background: var(--bg); border-radius: 20px 20px 0 0;
  max-height: 88vh; overflow-y: auto; transform: translateY(20px); transition: transform .25s;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet-overlay.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--sep); margin: 10px auto 4px; cursor: pointer; }
.sheet-img { width: 100%; height: 220px; object-fit: cover; background: var(--card); }
.sheet-body { padding: 16px var(--gap) 8px; }
.sheet-name { font-size: 20px; font-weight: 800; line-height: 1.2; }
.sheet-price { font-size: 18px; font-weight: 800; color: var(--accent); margin: 8px 0 12px; }
.sheet-price .unit { color: var(--hint); font-weight: 600; font-size: 14px; }
.sheet-price .price-req { color: var(--hint); font-weight: 600; font-size: 15px; }
.sheet-desc { font-size: 14px; line-height: 1.5; color: var(--text); margin-bottom: 14px; }
.sheet-meta .m-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 11px 0; border-top: 1px solid var(--sep); font-size: 14px;
}
.sheet-meta .m-row span { color: var(--hint); flex: none; }
.sheet-meta .m-row b { font-weight: 700; text-align: right; }
.sheet-meta .m-row.col { flex-direction: column; gap: 5px; }
.sheet-meta .m-ingr { color: var(--text); line-height: 1.45; }
.sheet-add {
  margin: 12px var(--gap) 0; width: calc(100% - 2 * var(--gap)); padding: 14px;
  border: none; border-radius: 12px; background: var(--accent); color: var(--on-accent);
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.sheet-add:active { background: var(--accent-press); }

/* кол-во / добавить */
.qty { display: flex; align-items: center; gap: 6px; }
.qty button {
  width: 34px; height: 34px; border-radius: 10px; border: none; font-size: 20px; line-height: 1;
  background: var(--accent); color: var(--on-accent); cursor: pointer;
}
.qty button:active { background: var(--accent-press); }
.qty .n { min-width: 22px; text-align: center; font-weight: 700; font-size: 15px; }
.add-btn {
  padding: 9px 13px; border-radius: 11px; border: none; white-space: nowrap;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14px; cursor: pointer;
}
.add-btn:active { background: var(--accent-press); }

/* ───────── заявка ───────── */
#cart-screen h2 { font-size: 20px; font-weight: 800; margin: 4px 0 14px; }
#cart-lines .line {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--sep); font-size: 14px;
}
#cart-lines .line span:last-child { font-weight: 700; color: var(--accent); white-space: nowrap; }
.total { font-weight: 800; font-size: 19px; margin: 16px 0 4px; text-align: right; }
.hint-note { font-size: 12px; color: var(--hint); margin: 0 0 18px; text-align: right; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.field input[type=text], .field input[type=tel] {
  width: 100%; padding: 12px 14px; border-radius: 12px; font-size: 16px;
  border: 1px solid var(--sep); background: var(--card); color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input[readonly] { color: var(--hint); background: color-mix(in srgb, var(--text) 4%, var(--card)); }
.pickup-addr {
  padding: 12px 14px; border-radius: 12px; background: var(--accent-weak);
  font-size: 15px; font-weight: 600; color: var(--text);
}
.pickup-addr::before { content: "📍 "; }
.seg { display: flex; gap: 10px; }
.seg label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 8px; border-radius: 12px; background: var(--card); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); }
.seg input { accent-color: var(--accent); }

/* ───────── прочее ───────── */
/* ───────── фирменная панель корзины (как на топ-сайтах) ───────── */
.cartbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  height: 58px; border: none; border-radius: 16px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; font-size: 16px; font-weight: 700; cursor: pointer; z-index: 25;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 42%, transparent);
  transform: translateY(160%); opacity: 0;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .2s;
}
.cartbar.show { transform: translateY(0); opacity: 1; }
.cartbar:active { background: var(--accent-press); }
.cb-left { display: flex; align-items: center; gap: 9px; }
.cb-ico { display: inline-flex; color: #fff; }
.cb-ico svg { width: 23px; height: 23px; display: block; }
.cb-badge {
  background: #fff; color: var(--accent); min-width: 22px; height: 22px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; padding: 0 7px; margin-left: -3px;
}
.cb-sum { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }

#toast {
  position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%);
  background: #1c1c1e; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 30; max-width: 86%; text-align: center;
}
#toast.show { opacity: .96; }
.empty { color: var(--hint); text-align: center; padding: 48px 16px; font-size: 15px; }
