/* Правильный Су-Вид — мини-приложение. Тема подхватывается из Telegram. */

:root {
  --brand: #41b619;
  --brand-dark: #2f8f10;
  --brand-soft: rgba(65, 182, 25, .12);
  --accent: #eb6623;

  --bg: var(--tg-theme-bg-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #f3f5f6);
  --surface-2: color-mix(in srgb, var(--surface) 65%, var(--bg));
  --text: var(--tg-theme-text-color, #14171a);
  --hint: var(--tg-theme-hint-color, #8a9299);
  --line: color-mix(in srgb, var(--hint) 24%, transparent);

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;

  --tabbar-h: 62px;
  --safe: env(safe-area-inset-bottom, 0px);
  --shadow: 0 8px 24px rgba(0, 0, 0, .10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #17191c);
    --surface: var(--tg-theme-secondary-bg-color, #212428);
    --text: var(--tg-theme-text-color, #eef1f3);
    --hint: var(--tg-theme-hint-color, #8d959c);
    --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overscroll-behavior-y: none;
}
body { padding-bottom: calc(var(--tabbar-h) + var(--safe)); }
h1, h2, h3 { margin: 0; letter-spacing: -.3px; }
button { font: inherit; cursor: pointer; }

.tab[hidden] { display: none; }

/* ---------- шапка ---------- */
.hero { position: relative; height: 188px; overflow: hidden; background: #1b2024; }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(175deg, rgba(10, 14, 16, .30) 0%, rgba(10, 14, 16, .55) 45%, rgba(10, 14, 16, .88) 100%);
}
.hero-body { position: absolute; inset: auto 0 0 0; padding: 0 16px 14px; color: #fff; }
.hero-kicker {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px;
  color: rgba(255, 255, 255, .72); margin-bottom: 5px;
}
.hero-title { font-size: 25px; font-weight: 800; line-height: 1.1; }
.hero-sub { margin: 5px 0 10px; font-size: 12.5px; color: rgba(255, 255, 255, .85); }
.hero-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  padding: 4px 9px; border-radius: 999px; font-size: 11.5px;
  background: rgba(255, 255, 255, .16); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .18);
}
.badge b { font-weight: 700; }

/* ---------- липкая панель поиска и категорий ---------- */
.sticky {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg); padding: 10px 0 8px;
  border-bottom: 1px solid var(--line);
}
.search-row { position: relative; margin: 0 16px 9px; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 12px; font-size: 17px; color: var(--hint); pointer-events: none;
}
#search {
  width: 100%; padding: 11px 38px 11px 34px; font-size: 16px;
  color: var(--text); background: var(--surface);
  border: 1.5px solid transparent; border-radius: 12px; outline: none; appearance: none;
}
#search:focus { border-color: var(--brand); background: var(--bg); }
#search::-webkit-search-cancel-button, #search::-webkit-search-decoration { appearance: none; }
.icon-btn {
  width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: transparent; color: var(--hint); font-size: 15px;
}
.search-row .icon-btn { position: absolute; right: 4px; }

.rail-wrap { position: relative; display: flex; align-items: center; gap: 6px; padding: 0 16px; }
.rail {
  display: flex; gap: 7px; overflow-x: auto; scroll-behavior: smooth;
  scrollbar-width: none; scroll-snap-type: x proximity; flex: 1; padding: 2px 0;
  -webkit-overflow-scrolling: touch;
}
.rail::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; scroll-snap-align: start;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); color: var(--text);
  border: 1.5px solid transparent; font-size: 13.5px;
}
.chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.chip .n { font-size: 11.5px; color: var(--hint); }
.chip[aria-selected="true"] {
  background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600;
}
.chip[aria-selected="true"] .n { color: rgba(255, 255, 255, .8); }

.rail-arrow {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font-size: 17px; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow);
}
.rail-all {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--brand); background: var(--brand-soft); color: var(--brand-dark);
}
.rail-all-lines { width: 12px; height: 9px; position: relative; display: inline-block; }
.rail-all-lines::before, .rail-all-lines::after {
  content: ""; position: absolute; left: 0; right: 0; height: 1.8px;
  background: currentColor; border-radius: 2px;
}
.rail-all-lines::before { top: 0; box-shadow: 0 3.6px 0 currentColor; }
.rail-all-lines::after { bottom: 0; }

/* ---------- списки и карточки ---------- */
.list { padding: 10px 16px 4px; }
.group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--hint); margin: 16px 0 8px;
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.list > .group-title:first-child { margin-top: 4px; }

.card {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin-bottom: 8px;
  background: var(--surface); border-radius: var(--r-md);
  border: 1.5px solid transparent;
}
.card.in-cart { border-color: var(--brand); background: var(--bg); box-shadow: 0 2px 10px var(--brand-soft); }
.card.cart-row { flex-wrap: wrap; }
.card.cart-row .stepper { width: 100%; justify-content: flex-end; margin-top: 8px; }
.card.cart-row .stepper input { width: 62px; }
.thumb {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: var(--r-sm);
  object-fit: cover; background: var(--surface-2);
}
.thumb-stub {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--surface-2);
  color: var(--hint); font-size: 19px; font-weight: 700;
}
.card-main { flex: 1; min-width: 0; }
.card-title { font-size: 14.5px; font-weight: 600; line-height: 1.28; }
.card-meta { font-size: 11.5px; color: var(--hint); margin-top: 3px; }

.add {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--brand); color: #fff; font-size: 21px; line-height: 1;
}
.add:active { background: var(--brand-dark); transform: scale(.94); }

.stepper { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; }
.stepper button {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 17px; line-height: 1;
}
.stepper input {
  width: 52px; padding: 6px 2px; text-align: center; font-size: 15px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.unit {
  padding: 6px 3px; font-size: 12.5px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}

.sentinel { height: 1px; }

/* ---------- заголовки страниц ---------- */
.page-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.page-head h2 { font-size: 19px; font-weight: 700; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 14px; padding: 4px; }

/* ---------- форма ---------- */
.form { padding: 4px 16px 20px; }
.form-title { font-size: 15.5px; margin: 18px 0 12px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--hint); margin-bottom: 5px; }
.field i { color: var(--accent); font-style: normal; }
.field input, .field textarea {
  width: 100%; padding: 11px 13px; font-size: 16px; font-family: inherit;
  color: var(--text); background: var(--surface);
  border: 1.5px solid transparent; border-radius: 11px; outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); background: var(--bg); }
.field.invalid input, .field.invalid textarea { border-color: var(--accent); }
.note { font-size: 12.5px; color: var(--hint); margin: 2px 0 16px; }

/* ---------- кнопки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 14px; border: 0; border-radius: var(--r-md);
  font-size: 15.5px; font-weight: 600;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .55; }
.btn-ghost {
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--line); margin: 8px 16px; width: calc(100% - 32px);
}
.btn-sm { padding: 9px 14px; width: auto; font-size: 13.5px; border-radius: var(--r-sm); }

.cta-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe));
  z-index: 40; padding: 8px 16px 10px;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.cta { pointer-events: auto; box-shadow: 0 6px 22px rgba(65, 182, 25, .35); }
.cta-count {
  min-width: 24px; padding: 1px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .25); font-size: 13px;
}

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + var(--safe)); padding-bottom: var(--safe);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--hint); font-size: 10.5px; font-weight: 600;
  padding-top: 4px;
}
.tabbtn.is-active { color: var(--brand); }
.tabico { font-size: 20px; line-height: 1; position: relative; }
.tabbtn.is-active .tabico { transform: translateY(-1px); }
.dot {
  position: absolute; top: -3px; right: -7px; min-width: 15px; height: 15px;
  padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 10px; font-style: normal; font-weight: 700; line-height: 15px; text-align: center;
}

/* ---------- шторка категорий ---------- */
.sheet { position: fixed; inset: 0; z-index: 90; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh;
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding-bottom: var(--safe); animation: rise .24s cubic-bezier(.2, .8, .3, 1);
}
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(100%) } }
.sheet-grip {
  width: 38px; height: 4px; border-radius: 2px; background: var(--line);
  margin: 8px auto 2px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 10px; border-bottom: 1px solid var(--line);
}
.sheet-head h3 { font-size: 17px; }
.sheet-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 16px 20px; overflow-y: auto;
}
.cat-tile {
  position: relative; height: 92px; border: 0; padding: 0; overflow: hidden;
  border-radius: var(--r-md); background: var(--surface); text-align: left;
}
.cat-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cat-tile .tile-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8, 12, 14, .85) 8%, rgba(8, 12, 14, .15) 75%);
}
.cat-tile .tile-text {
  position: absolute; inset: auto 0 0 0; padding: 8px 10px; color: #fff;
}
.cat-tile .tile-name { font-size: 13px; font-weight: 700; line-height: 1.2; }
.cat-tile .tile-n { font-size: 11px; color: rgba(255, 255, 255, .8); }
.cat-tile[aria-selected="true"] { outline: 2.5px solid var(--brand); outline-offset: -2.5px; }

/* ---------- мои заявки ---------- */
.order {
  background: var(--surface); border-radius: var(--r-md);
  padding: 12px 13px; margin-bottom: 10px; border: 1.5px solid transparent;
}
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-id { font-size: 15px; font-weight: 700; }
.order-date { font-size: 11.5px; color: var(--hint); margin-top: 2px; }
.status {
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap;
}
.status-new { background: var(--brand-soft); color: var(--brand-dark); }
.status-in_work { background: rgba(235, 102, 35, .14); color: var(--accent); }
.status-done { background: rgba(120, 130, 140, .16); color: var(--hint); }
.status-canceled { background: rgba(200, 60, 60, .13); color: #c23b3b; }
.order-items { margin: 9px 0 0; padding: 0; list-style: none; font-size: 13px; }
.order-items li { padding: 3px 0; display: flex; justify-content: space-between; gap: 10px; }
.order-items li span:last-child { color: var(--hint); white-space: nowrap; }
.order-more { font-size: 12.5px; color: var(--hint); padding-top: 3px; }
.order-meta { font-size: 12px; color: var(--hint); margin-top: 8px; line-height: 1.5; }
.order-actions { display: flex; gap: 8px; margin-top: 11px; }
.order-actions .btn { width: auto; flex: 1; }

/* ---------- инфо-карточки ---------- */
.info-card {
  margin: 10px 16px; padding: 14px 15px;
  background: var(--surface); border-radius: var(--r-lg);
}
.info-card h3 { font-size: 15.5px; margin-bottom: 8px; }
.info-card p { margin: 0 0 8px; font-size: 13.5px; color: var(--text); }
.info-card p:last-child { margin-bottom: 0; }
.steps { margin: 0; padding-left: 18px; font-size: 13.5px; }
.steps li { margin-bottom: 6px; }
.contacts-card { padding-bottom: 6px; }
.contact-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 0; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none; font-size: 13.5px;
}
.contact-row small { color: var(--hint); font-size: 11.5px; }
.contact-ico { font-size: 19px; }
.version { text-align: center; font-size: 11px; color: var(--hint); margin: 14px 0 6px; }

/* ---------- прочее ---------- */
.empty, .cart-empty { padding: 44px 32px; text-align: center; color: var(--hint); }
.empty-emoji { font-size: 34px; margin-bottom: 10px; }
.cart-empty .btn { max-width: 260px; margin: 10px auto 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe) + 16px); z-index: 100;
  max-width: 88%; padding: 11px 16px; border-radius: 11px;
  background: rgba(20, 23, 26, .93); color: #fff; font-size: 13.5px; text-align: center;
  box-shadow: var(--shadow); animation: fade .15s ease;
}

.skeleton {
  height: 68px; margin-bottom: 8px; border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0 } }
