/* Тёмная тема магазина. Цвета Telegram подставляются в JS через CSS-переменные. */
:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f232c;
  --line: #2a2f3a;
  --text: #eef1f6;
  --text-dim: #98a1b3;
  --accent: #4c8bf5;
  --accent-soft: rgba(76, 139, 245, 0.14);
  --ok: #3ecf8e;
  --warn: #f2b544;
  --danger: #f2585b;
  --radius: 16px;
  --tabbar-h: 62px;
  --topbar-h: 54px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ верх */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(15, 17, 21, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar__back {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--bg-elev-2);
  font-size: 24px;
  line-height: 1;
  padding: 0 0 3px 0;
  cursor: pointer;
}

.topbar__title {
  flex: 1;
  font-weight: 650;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__balance {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* --------------------------------------------------------------- контент */
.screen {
  flex: 1;
  padding: 14px 12px calc(var(--tabbar-h) + 24px);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.loader { color: var(--text-dim); text-align: center; padding: 48px 0; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 56px 16px;
}
.empty__icon { font-size: 40px; display: block; margin-bottom: 10px; }

/* ----------------------------------------------------------------- поиск */
.search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search__input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
.search__input:focus { border-color: var(--accent); }

/* --------------------------------------------------------------- карточки */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 10px;
}

.product {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.product:active { transform: scale(0.985); border-color: var(--accent); }

.product__icon {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.product__body { flex: 1; min-width: 0; }

.product__name {
  font-weight: 600;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product__meta { font-size: 12.5px; color: var(--text-dim); display: flex; gap: 8px; flex-wrap: wrap; }

.product__price {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-elev-2);
  color: var(--text-dim);
}
.badge--instant { background: rgba(62, 207, 142, 0.15); color: var(--ok); }
.badge--queue { background: rgba(242, 181, 68, 0.15); color: var(--warn); }
.badge--low { background: rgba(242, 88, 91, 0.15); color: var(--danger); }

/* ------------------------------------------------------------- пагинация */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 4px;
  color: var(--text-dim);
  font-size: 13px;
}

.pager__btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 10px;
  padding: 7px 14px;
  cursor: pointer;
}
.pager__btn[disabled] { opacity: 0.35; cursor: default; }

/* ---------------------------------------------------------------- кнопки */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 13px;
  padding: 14px;
  font-size: 15.5px;
  font-weight: 650;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-top: 10px;
}
.btn:active { filter: brightness(0.92); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn--ghost { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--line); }
.btn--ok { background: var(--ok); color: #06281a; }
.btn--danger { background: transparent; color: var(--danger); border: 1px solid rgba(242, 88, 91, 0.4); }
.btn--sm { padding: 9px; font-size: 14px; border-radius: 11px; margin-top: 0; }

.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; }

/* -------------------------------------------------------- карточка товара */
.detail__head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.detail__icon {
  flex: 0 0 58px; height: 58px; border-radius: 16px;
  background: var(--accent-soft); display: grid; place-items: center; font-size: 28px;
}
.detail__name { font-size: 18px; font-weight: 700; line-height: 1.3; }
.detail__price { font-size: 26px; font-weight: 800; margin: 2px 0 10px; }

.kv { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv__key { color: var(--text-dim); }
.kv__val { font-weight: 600; }

.desc { color: var(--text-dim); font-size: 14px; white-space: pre-wrap; word-break: break-word; margin-top: 10px; }

/* ------------------------------------------------------------- количество */
.qty { display: flex; align-items: center; gap: 12px; }
.qty__btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-elev-2); font-size: 19px; line-height: 1; cursor: pointer;
}
.qty__value { min-width: 34px; text-align: center; font-weight: 700; }

.cart-item { display: flex; gap: 12px; align-items: center; }
.cart-item__body { flex: 1; min-width: 0; }
.cart-item__name { font-weight: 600; margin-bottom: 6px; }
.cart-item__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }

.total {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 17px; font-weight: 700; padding: 12px 0 4px;
}
.total__sum { font-size: 21px; }

.note { color: var(--text-dim); font-size: 13px; margin-top: 8px; }
.note--warn { color: var(--warn); }
.note--danger { color: var(--danger); }

/* ---------------------------------------------------------------- ключи */
.keys { margin-top: 10px; }
.key {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 8px;
}
.key__text {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
}
.key__copy {
  flex: 0 0 auto; border: none; background: var(--accent-soft); color: var(--accent);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer;
}

.result__icon { font-size: 46px; text-align: center; display: block; margin-bottom: 6px; }
.result__title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.result__text { text-align: center; color: var(--text-dim); margin-bottom: 14px; }

/* -------------------------------------------------------------- заказы */
.order__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.order__id { font-weight: 700; }
.order__status { font-size: 12.5px; color: var(--text-dim); }
.order__line { font-size: 13.5px; color: var(--text-dim); margin-top: 6px; }

/* -------------------------------------------------------------- профиль */
.profile__balance { text-align: center; padding: 10px 0 4px; }
.profile__sum { font-size: 34px; font-weight: 800; }
.profile__label { color: var(--text-dim); font-size: 13px; }

.field {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
  margin-top: 10px;
}
.field:focus { border-color: var(--accent); }

/* ------------------------------------------------------------- таб-бар */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(15, 17, 21, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tabbar__item {
  position: relative;
  flex: 1;
  border: none;
  background: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  cursor: pointer;
}
.tabbar__item.is-active { color: var(--accent); }
.tabbar__icon { font-size: 19px; line-height: 1; }

.tabbar__badge {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* --------------------------------------------------------------- тосты */
.toast-host {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease;
}
.toast--error { border-color: rgba(242, 88, 91, 0.55); color: #ffd9da; }
.toast--ok { border-color: rgba(62, 207, 142, 0.5); color: #d6ffee; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.skeleton {
  height: 70px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-elev-2) 37%, var(--bg-elev) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
  margin-bottom: 10px;
}

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
