:root {
  --bg: var(--tg-theme-bg-color, #08080a);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #17161c);
  --text: var(--tg-theme-text-color, #f5f5f7);
  --hint: var(--tg-theme-hint-color, #9d99ab);
  --link: var(--tg-theme-link-color, #b794f6);
  --button: var(--tg-theme-button-color, #8b5cf6);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #a855f7;
  --accent-soft: rgba(168, 85, 247, 0.18);
  --border: rgba(255, 255, 255, 0.08);
  --danger: #ff5470;
  --success: #34d399;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Дымка на фоне */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 280px;
  height: 280px;
  top: -80px;
  left: -60px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.45), transparent 70%);
}

body::after {
  width: 320px;
  height: 320px;
  bottom: 5%;
  right: -100px;
  background: radial-gradient(circle, rgba(99, 43, 168, 0.4), transparent 70%);
}

#age-gate, #app {
  position: relative;
  z-index: 1;
}

.hidden { display: none !important; }

/* ---------- Age gate ---------- */

.age-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.age-gate-card {
  max-width: 360px;
  text-align: center;
}

.age-gate-icon { font-size: 48px; margin-bottom: 8px; }

.age-gate-card h2 {
  font-size: 20px;
  margin: 8px 0;
}

.age-gate-card p {
  color: var(--hint);
  font-size: 14px;
  line-height: 1.5;
  margin: 12px 0;
}

.age-gate-warning {
  color: var(--text) !important;
  font-weight: 600;
}

.age-gate-hours {
  background: var(--accent-soft);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text) !important;
  font-size: 13px !important;
  font-weight: 600;
}

/* ---------- Layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.work-hours {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #ffe600;
}

.work-hours-note {
  margin: 2px 0 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--hint);
}

.view {
  padding: 12px 16px 96px;
}

.empty-state {
  text-align: center;
  color: var(--hint);
  padding: 48px 16px;
  font-size: 15px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* ---------- Promo banner ---------- */

.promo-banner {
  background: linear-gradient(135deg, #ffe600, #ffb300);
  color: #1a1400;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.4;
}

.orders-entry-btn {
  display: block;
  width: 100%;
  background: var(--secondary-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  cursor: pointer;
}

.stats-entry-btn {
  display: block;
  width: 100%;
  background: var(--secondary-bg);
  color: #ffe600;
  border: 1px solid rgba(255, 230, 0, 0.4);
  border-radius: 14px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  cursor: pointer;
}

.admin-entry-btn {
  display: block;
  width: 100%;
  background: var(--secondary-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  cursor: pointer;
}

/* ---------- Админ-панель ---------- */

.admin-title {
  font-size: 18px;
  margin: 8px 0 14px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.admin-tab {
  flex: 1;
  background: var(--secondary-bg);
  color: var(--hint);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.admin-tab.active {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

.admin-subtitle {
  font-size: 15px;
  margin: 20px 0 12px;
}

.admin-brand-group {
  margin-bottom: 16px;
}

.admin-brand-group h4 {
  font-size: 13px;
  color: var(--hint);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-product-row {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.admin-product-inactive {
  opacity: 0.5;
}

.admin-field-name {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.admin-product-fields {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-product-fields input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  font-size: 13px;
}

.admin-product-actions {
  display: flex;
  gap: 8px;
}

.admin-save-btn,
.admin-toggle-btn,
.admin-delete-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.admin-save-btn {
  background: var(--button);
  color: var(--button-text);
}

.admin-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--hint);
}

.admin-delete-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.admin-brand-card {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.admin-brand-inactive {
  opacity: 0.5;
}

.admin-brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 10px;
}

.admin-brand-code {
  color: var(--hint);
  font-weight: 400;
}

.admin-brand-order-btns {
  display: flex;
  gap: 6px;
}

.admin-order-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 12px;
  cursor: pointer;
}

.admin-order-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.admin-brand-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-brand-fields input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

.admin-brand-actions {
  display: flex;
  gap: 8px;
}

.admin-save-all-btn {
  width: 100%;
  margin-bottom: 12px;
}

.admin-photo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-photo-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
}

.admin-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-photo-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.admin-photo-upload {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--hint);
  text-align: center;
  cursor: pointer;
}

.stats-title {
  font-size: 18px;
  margin: 8px 0 14px;
}

.stats-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.stats-tab {
  flex-shrink: 0;
  background: var(--secondary-bg);
  color: var(--hint);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.stats-tab.active {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

.stats-summary {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.stats-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--hint);
  padding: 4px 0;
}

.stats-summary-total {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--secondary-bg);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.stats-item-name {
  flex: 1;
  font-weight: 600;
}

.stats-item-qty {
  color: var(--hint);
}

.stats-item-revenue {
  font-weight: 700;
  color: #ffe600;
}

.orders-title {
  font-size: 18px;
  margin: 8px 0 16px;
}

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-card {
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.order-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.order-code {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.03em;
}

.order-status {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.order-items {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.5;
  margin-bottom: 6px;
}

.order-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--hint);
}

.order-total {
  color: var(--text);
  font-weight: 700;
}

.discount-row {
  color: var(--success) !important;
}

.payment-discount {
  color: var(--success);
  font-size: 14px;
  margin: 0 0 4px;
}

/* ---------- Brand cards ---------- */

.brand-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-card {
  position: relative;
  background: linear-gradient(180deg, var(--secondary-bg), #0c0b10);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 18px 76px;
  overflow: hidden;
}

.brand-card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.35), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}

.brand-card.out-of-stock { opacity: 0.6; }

.brand-photo-wrap {
  width: 100%;
  height: 260px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1820, #0c0b10);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.brand-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.22s ease;
}

.brand-photo-wrap img.fading {
  opacity: 0;
}

.brand-photo-wrap .placeholder-icon {
  font-size: 40px;
  opacity: 0.5;
}

.brand-info {
  position: relative;
  z-index: 1;
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
  color: #ffe600;
}

.brand-nicotine {
  font-size: 13px;
  color: #c026ff;
  font-weight: 700;
  margin-bottom: 6px;
}

.brand-price {
  font-size: 16px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.brand-stock {
  font-size: 13px;
  color: var(--hint);
}

.brand-expand-hint {
  position: absolute;
  right: 6px;
  bottom: 80px;
  font-size: 16px;
  font-weight: 800;
  color: #ffe600;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 11px;
  border-radius: 10px;
  z-index: 2;
  animation: hint-bounce 1.6s ease-in-out infinite;
}

.brand-expand {
  position: absolute;
  right: 16px;
  bottom: 22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 30% 30%, var(--accent), #5b21b6);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
  z-index: 2;
  animation: hint-bounce 1.6s ease-in-out infinite;
}

.brand-expand:active { transform: scale(0.94); }

@keyframes hint-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---------- Flavors sub-view ---------- */

.flavors-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.flavors-header h2 {
  font-size: 17px;
  margin: 0;
}

/* ---------- Product cards ---------- */

.products-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-card {
  display: flex;
  gap: 12px;
  background: var(--secondary-bg);
  border-radius: 14px;
  padding: 12px;
  align-items: center;
}

.product-card.out-of-stock { opacity: 0.55; }

.product-photo {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
}

.product-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.product-info { flex: 1; min-width: 0; }

.product-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.product-status.in-stock { color: var(--success); }
.product-status.out-stock { color: var(--danger); }

.product-name {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.3;
}

.product-price {
  font-size: 14px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}

.price-old {
  color: var(--hint);
  text-decoration: line-through;
  font-size: 12px;
}

.price-new {
  font-weight: 700;
  color: #ffe600;
}

.product-price .price-new {
  color: #000;
}

.product-stock {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}

.product-low-stock {
  font-size: 12px;
  color: var(--danger);
  font-weight: 700;
  margin-top: 2px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

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

.stepper button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stepper .qty {
  min-width: 18px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.add-btn {
  border: none;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.out-of-stock-label {
  font-size: 12px;
  color: var(--danger);
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Cart ---------- */

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.cart-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 10px 12px;
}

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

.cart-item-name {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.3;
}

.cart-item-subtotal {
  font-size: 13px;
  color: var(--hint);
}

.cart-remove {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
}

.cart-summary {
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 12px 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 0;
  color: var(--hint);
}

.summary-total {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

/* ---------- Form ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--hint);
}

.form input,
.form textarea,
.form select {
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  width: 100%;
}

.form textarea { min-height: 64px; }

.form input:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--button);
}

.form input.invalid,
.form textarea.invalid {
  border-color: var(--danger);
}

.form-hint {
  font-size: 12px;
  color: var(--hint);
  margin-top: -2px;
}

.form-hint.invalid {
  color: var(--danger);
}

/* ---------- Payment ---------- */

.payment-block { text-align: center; }

.order-code-badge {
  display: inline-block;
  background: var(--accent-soft);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}

.order-code-badge.copyable {
  cursor: pointer;
  user-select: none;
}

.order-code-badge.copyable:active {
  transform: scale(0.97);
}

.copy-icon {
  font-size: 12px;
  opacity: 0.8;
}

.payment-amount {
  font-size: 16px;
  margin: 4px 0 16px;
}

.qr-image {
  width: 100%;
  max-width: 280px;
  border-radius: 14px;
  margin: 0 auto 16px;
  display: block;
}

.payment-hint {
  color: var(--hint);
  font-size: 13px;
  margin-bottom: 16px;
}

.file-label {
  display: inline-block;
  background: var(--secondary-bg);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 16px 22px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
}

.receipt-preview {
  margin-top: 14px;
}

.receipt-preview img {
  max-width: 200px;
  border-radius: 12px;
}

.receipt-pdf-badge {
  display: inline-block;
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delivery-time-note {
  font-size: 12px;
  color: var(--hint);
  line-height: 1.5;
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 12px;
}

.manager-contact {
  margin-top: 20px;
  font-size: 13px;
  color: var(--hint);
}

.manager-contact a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
}

.cancel-order-btn {
  display: block;
  margin: 16px auto 0;
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  text-decoration: underline;
}

.order-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 8px;
}

.order-repeat-btn {
  background: transparent;
  color: #ffe600;
  border: 1px solid #ffe600;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.order-pay-btn {
  background: var(--button);
  color: var(--button-text);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.order-cancel-link {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* ---------- Done ---------- */

.done-block {
  text-align: center;
  padding-top: 40px;
}

.done-icon { font-size: 52px; margin-bottom: 12px; }

.done-block p {
  color: var(--hint);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Buttons ---------- */

.btn-primary {
  background: var(--button);
  color: var(--button-text);
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.fallback-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
