/* Мини-апп всегда светлый по требованию заказчика, независимо от темы
   Telegram у пользователя. Цвета фиксированные, без какой-либо привязки
   к теме клиента — так надёжнее и не зависит от того, что именно прислал
   конкретный клиент Telegram. */
:root {
  --bg: #ffffff;
  --text: #222222;
  --hint: #888888;
  --link: #2a7de1;
  --button: #2a9d4a;
  --button-text: #ffffff;
  --secondary-bg: #f4f4f5;
  --card-bg: #ffffff;
  --border: #e5e5e5;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 64px;
}

header.topbar {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1.1em;
  border-bottom: 1px solid var(--border);
}

main {
  flex: 1;
  padding: 12px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.search-row input {
  flex: 1;
  min-width: 0;
}
.search-row button {
  flex: none;
  padding: 9px 12px;
}

.fav-heart {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 0.95em;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

input, textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95em;
  background: var(--card-bg);
  color: var(--text);
}

.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.categories .chip {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
}
.categories .chip.active {
  background: var(--button);
  color: var(--button-text);
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--secondary-bg);
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.skeleton-block, .skeleton-line {
  background: var(--secondary-bg);
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}
.skeleton-block {
  width: 100%;
  aspect-ratio: 1;
}
.skeleton-line {
  height: 0.9em;
  border-radius: 4px;
  margin: 6px 0;
}

.card .body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.card .title {
  font-size: 0.9em;
  font-weight: 600;
  line-height: 1.25;
  min-height: 2.5em;
}

.card .price {
  font-weight: 700;
}

.rating {
  font-size: 0.8em;
}

.badge-new {
  position: absolute;
  margin: 6px;
  padding: 2px 8px;
  background: var(--button);
  color: var(--button-text);
  border-radius: 6px;
  font-size: 0.75em;
}

.card-media { position: relative; }

button {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--button);
  color: var(--button-text);
  font-size: 0.95em;
  cursor: pointer;
}
button.secondary {
  background: var(--secondary-bg);
  color: var(--text);
}
button.danger {
  background: var(--danger);
  color: #fff;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.small {
  padding: 5px 10px;
  font-size: 0.85em;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qty-control button {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
}

.cart-item, .order-row, .tx-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.cart-item img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--secondary-bg);
}
.cart-item .info { flex: 1; }

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--secondary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4em;
  flex: none;
}

.cashback-card {
  background: var(--button);
  color: var(--button-text);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.cashback-card .muted { color: rgba(255, 255, 255, 0.8); }

.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 1em;
  text-align: left;
  cursor: pointer;
}
.menu-row .chevron { margin-left: auto; color: var(--hint); }

.tx-row.clickable { cursor: pointer; }
.tx-row .tx-icon { font-size: 1.3em; flex: none; }

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.summary-row.total {
  font-weight: 700;
  font-size: 1.05em;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

.muted { color: var(--hint); }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8em;
  background: var(--secondary-bg);
}
.status-pill.confirmed { background: #dcf5df; color: #1a7431; }
.status-pill.cancelled { background: #fbe0de; color: var(--danger); }

.empty-state {
  text-align: center;
  color: var(--hint);
  padding: 40px 20px;
}

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
nav.bottom-nav .nav-item {
  flex: 1;
  text-align: center;
  font-size: 0.8em;
  color: var(--hint);
  cursor: pointer;
  padding: 4px 0;
  position: relative;
}
nav.bottom-nav .nav-item.active {
  color: var(--button);
  font-weight: 600;
}
nav.bottom-nav .nav-icon { font-size: 1.3em; display: block; }
.cart-badge {
  position: absolute;
  top: -2px;
  right: 22%;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 0.7em;
  padding: 0 5px;
}

.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85em;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 0.95; }

form .field { margin-bottom: 10px; }
form label { display: block; font-size: 0.85em; margin-bottom: 4px; color: var(--hint); }

.admin-table {
  width: 100%;
  border-collapse: collapse;
}
.admin-table th, .admin-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.85em;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tabs .tab {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--secondary-bg);
  cursor: pointer;
  font-size: 0.85em;
}
.tabs .tab.active {
  background: var(--button);
  color: var(--button-text);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-sheet {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  max-height: 88vh;
  overflow-y: auto;
}
