:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --section-bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --separator: color-mix(in srgb, var(--hint) 25%, transparent);
}

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

body {
  margin: 0;
  padding: 0;
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.screen { padding: 0 0 16px; }

.center-note {
  padding: 48px 24px;
  text-align: center;
  color: var(--hint);
  line-height: 1.5;
}

.big-icon { font-size: 44px; margin-bottom: 12px; }

.screen-title { font-size: 20px; margin: 16px 14px; }

/* Строка-переход (группа / бренд) */
.rows { border-top: 1px solid var(--separator); }

.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--separator);
  color: var(--text);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.nav-row:active { background: var(--section-bg); }
.nav-icon { flex: none; font-size: 18px; }
.nav-title { flex: 1; font-weight: 500; }
.nav-count { color: var(--hint); font-size: 14px; }
.nav-row .chevron { color: var(--hint); flex: none; }

.nav-badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-size: 12px;
  font-weight: 600;
}

.search-header {
  padding: 14px 14px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
}

.plain-text {
  margin: 0 14px;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Поиск */
.searchbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
}

.searchbar input {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--section-bg);
  color: var(--text);
  font-size: 16px; /* меньше 16px — iOS зумит страницу при фокусе */
  outline: none;
}

.notice {
  margin: 0 14px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--section-bg);
  color: var(--hint);
  font-size: 13px;
  white-space: pre-line;
}

.group-header {
  margin: 10px 14px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--link);
}

/* Товар */
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
}

.item.in-cart { background: color-mix(in srgb, var(--button) 8%, transparent); }

.item-main { min-width: 0; flex: 1; }

.item-name {
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.item-sub { margin-top: 2px; font-size: 13px; color: var(--hint); }
.item-price { font-weight: 600; color: var(--text); }
.item-tier { color: var(--link); }
.item-low { color: #e08c1a; }

/* Степпер */
.stepper { display: flex; align-items: center; gap: 2px; flex: none; }

.stepper button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--section-bg);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.stepper button:disabled { opacity: .35; cursor: default; }

.stepper input {
  width: 46px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  outline: none;
}

.stepper.empty input { color: var(--hint); font-weight: 400; }

/* Корзина */
#cart-lines .item { border-bottom: 1px solid var(--separator); }

.summary {
  margin: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--section-bg);
  font-size: 14px;
}

.summary .row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.summary .row:last-child { margin-bottom: 0; }
.summary .total { font-size: 17px; font-weight: 700; }
.summary .saving { color: #34a853; }

.field { display: block; margin: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--hint); }

.field input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.field input:focus { border-color: var(--button); }

.link-btn {
  display: block;
  margin: -4px 14px 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--link);
  font-size: 14px;
  cursor: pointer;
}

.bottom-pad { height: 24px; }

/* Экран «доступ закрыт» */
#error-id { margin-top: 14px; font-size: 14px; }
#error-id code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--section-bg);
  color: var(--text);
  font-size: 15px;
}

.wide-btn {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 20px auto 0;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.wide-btn:disabled { opacity: .6; }

.pending {
  margin: 20px auto 0;
  max-width: 300px;
  padding: 12px;
  border-radius: 10px;
  background: var(--section-bg);
  font-size: 14px;
  line-height: 1.45;
}

.danger-btn {
  display: block;
  width: calc(100% - 28px);
  margin: 22px 14px 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, #e5484d 45%, transparent);
  border-radius: 10px;
  background: none;
  color: #e5484d;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.danger-btn:active { background: color-mix(in srgb, #e5484d 10%, transparent); }

.field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  resize: vertical;
  outline: none;
}

.field textarea:focus { border-color: var(--button); }

.field select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--separator);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.field select:focus { border-color: var(--button); }
