:root {
  --bg: var(--tg-theme-bg-color, #f4f4f7);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(0,0,0,0.08);
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

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

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.title { font-size: 18px; font-weight: 700; }
.subtitle { font-size: 13px; color: var(--hint); margin-top: 2px; }
.cart-count {
  min-width: 28px; height: 28px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text);
  border-radius: 14px; font-weight: 700; font-size: 14px;
}

.list { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.loader { text-align: center; color: var(--hint); padding: 40px 0; }

.card {
  width: 100%;
  box-sizing: border-box;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card-media {
  width: 100%; height: 180px; object-fit: cover; display: block;
  background: #e9e9ef;
}
.card-media.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: #c7c7cc;
}
.card-body { padding: 12px 14px; }
.card-name { font-size: 16px; font-weight: 700; }
.card-desc { font-size: 13px; color: var(--hint); margin-top: 2px; }
.card-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--hint); margin-top: 6px;
}
.tag { background: rgba(0,0,0,0.05); padding: 3px 8px; border-radius: 8px; }
.tag.soldout { background: #ffe5e5; color: #d23; }

.card-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 12px; flex-wrap: wrap;
}
.price { font-weight: 700; font-size: 16px; white-space: nowrap; }
.stepper {
  display: flex; align-items: center; gap: 14px;
  margin-left: auto; flex-shrink: 0;
}
.stepper button.minus, .stepper button.plus {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; font-size: 22px; font-weight: 700; line-height: 1;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
}
.stepper button:disabled { opacity: 0.35; }
.stepper .qty { min-width: 22px; text-align: center; font-weight: 700; font-size: 17px; }
.add-btn {
  border: none; padding: 10px 22px; border-radius: 12px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 700; font-size: 15px; white-space: nowrap; flex-shrink: 0;
}

.footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.total { flex: 1; font-weight: 700; font-size: 15px; }
.submit-btn {
  border: none; padding: 13px 22px; border-radius: 12px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 700; font-size: 15px;
}
.submit-btn:disabled { opacity: 0.5; }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff; padding: 10px 18px;
  border-radius: 12px; font-size: 14px; z-index: 50;
}
.empty { text-align: center; color: var(--hint); padding: 40px 16px; line-height: 1.5; }

/* ---------- Admin panel ---------- */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.stat-card {
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-card.big { grid-column: 1 / -1; }
.stat-label { font-size: 13px; color: var(--hint); }
.stat-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.stat-card.big .stat-value { font-size: 26px; color: var(--accent); }

.panel {
  background: var(--card); border-radius: 14px; padding: 14px;
  margin-top: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.panel-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(0,0,0,0.05); padding: 6px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
}
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th, .stat-table td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border);
}
.stat-table th { color: var(--hint); font-weight: 600; }
.stat-table td:last-child, .stat-table th:last-child { text-align: right; }
.hint-box {
  margin-top: 14px; padding: 12px; border-radius: 12px;
  background: rgba(46,166,255,0.1); font-size: 13px; color: var(--hint);
  text-align: center;
}
