:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --hint: var(--tg-theme-hint-color, #888888);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f5f4f2);
  --radius: 14px;
  --orange: #E85420;
  --btn: #E85420;
  --btn-text: #ffffff;
  --link: #E85420;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

h1, h2, .home-title {
  font-family: Georgia, 'Times New Roman', serif;
}

.hidden { display: none !important; }

/* Loading */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: var(--hint);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Home screen ──────────────────────────────────────────────────────────── */

#home-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.home-hero {
  background: var(--orange);
  padding: 44px 28px 36px;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 30px 30px;
}

.home-hero-mascot {
  position: absolute;
  right: 10px;
  bottom: -4px;
  width: 130px;
  color: rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

.home-hero-text { position: relative; z-index: 1; }

.home-title {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.home-subtitle {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.home-menu {
  padding: 22px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  flex: 1;
}

.home-btn {
  width: 100%;
  padding: 14px 18px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  font-family: inherit;
}

.home-btn:active { opacity: 0.82; }

.home-btn-outline {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--secondary-bg);
}

.home-btn-mascot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  color: rgba(255, 255, 255, 0.92);
}

.home-btn-outline .home-btn-mascot { color: var(--orange); }

.home-btn-label { flex: 1; }

/* ─── Fullscreen panels ────────────────────────────────────────────────────── */

.fullscreen-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  overflow-y: auto;
  padding-bottom: 100px;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--secondary-bg);
}

.header-back {
  background: none;
  border: none;
  color: var(--link);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
}

#cart-badge {
  background: var(--btn);
  color: var(--btn-text);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

/* ─── Location strip ───────────────────────────────────────────────────────── */

.location-strip {
  background: var(--secondary-bg);
  padding: 7px 16px;
  font-size: 13px;
  color: var(--hint);
}

/* ─── Search ───────────────────────────────────────────────────────────────── */

#search-bar { padding: 10px 16px; }
.search-bar-inner { padding: 10px 16px; }

#search-input, #info-search-input {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--secondary-bg);
  border-radius: var(--radius);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
}

#search-input:focus, #info-search-input:focus { border-color: var(--orange); }

/* ─── Category tabs ────────────────────────────────────────────────────────── */

#category-tabs, #info-category-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
#category-tabs::-webkit-scrollbar,
#info-category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--secondary-bg);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.cat-tab.active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}

/* ─── Catalog ──────────────────────────────────────────────────────────────── */

#catalog { padding: 0 16px 80px; }

.supplier-section { margin-bottom: 20px; }

.supplier-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 0 6px;
}

.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.product-info { flex: 1; min-width: 0; }

.product-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.product-price {
  font-size: 13px;
  color: var(--link);
  margin-top: 2px;
}

/* ─── Quantity control ─────────────────────────────────────────────────────── */

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 10px;
}

.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:active { opacity: 0.75; }

.qty-value {
  min-width: 24px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

/* ─── Panel header ─────────────────────────────────────────────────────────── */

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--secondary-bg);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 700;
  font-family: Georgia, 'Times New Roman', serif;
}

.panel-header button {
  background: none;
  border: none;
  color: var(--link);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
}

/* ─── Location screen ──────────────────────────────────────────────────────── */

#location-list { padding: 12px 16px; }

.location-card {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.location-card.selected { border-color: var(--orange); }
.location-card:active { opacity: 0.8; }

.location-info { flex: 1; }
.location-name { font-size: 16px; font-weight: 500; }
.location-address { font-size: 13px; color: var(--hint); margin-top: 2px; }

.location-check {
  color: var(--orange);
  font-size: 20px;
  font-weight: 700;
  margin-left: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}
.location-card.selected .location-check { opacity: 1; }

/* ─── Cart panel ───────────────────────────────────────────────────────────── */

#cart-content { padding: 12px 16px; }

.cart-location-badge {
  font-size: 14px;
  color: var(--hint);
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--secondary-bg);
  margin-bottom: 12px;
}

.cart-supplier-group { margin-bottom: 20px; }

.cart-supplier-title {
  font-size: 14px;
  font-weight: 700;
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--secondary-bg);
  margin-bottom: 8px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--secondary-bg);
}

.cart-item-name { font-size: 15px; flex: 1; }
.cart-item-qty { color: var(--hint); font-size: 13px; margin-left: 8px; white-space: nowrap; }

.cart-item-remove {
  background: none;
  border: none;
  color: #e53935;
  font-size: 18px;
  cursor: pointer;
  padding: 0 0 0 10px;
}

/* ─── Order panel ──────────────────────────────────────────────────────────── */

.order-hint {
  padding: 14px 16px 6px;
  color: var(--hint);
  font-size: 14px;
}

#order-list { padding: 8px 16px; }

.order-location-badge {
  font-size: 14px;
  color: var(--hint);
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--secondary-bg);
  margin-bottom: 12px;
}

.order-supplier-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: opacity 0.15s;
  border: 2px solid transparent;
}

.order-supplier-card:active { opacity: 0.7; }
.order-supplier-card.sent { border-color: var(--orange); }

.order-supplier-info { flex: 1; }
.order-supplier-name { font-size: 16px; font-weight: 600; }
.order-supplier-summary { font-size: 13px; color: var(--hint); margin-top: 3px; }

.wa-icon {
  width: 38px;
  height: 38px;
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  margin-left: 12px;
}
.order-supplier-card.sent .wa-icon { background: var(--orange); }

/* ─── Info screen ──────────────────────────────────────────────────────────── */

#info-catalog { padding: 0 16px 80px; }

.info-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.info-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.info-card-name {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.info-card-price {
  font-size: 15px;
  color: var(--link);
  font-weight: 600;
  white-space: nowrap;
}

.info-card-category {
  font-size: 12px;
  color: var(--hint);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.info-card-desc {
  font-size: 14px;
  line-height: 1.5;
  margin-top: 8px;
}

.info-card-storage {
  font-size: 13px;
  color: var(--hint);
  margin-top: 6px;
}

/* ─── Bottom action bar ────────────────────────────────────────────────────── */

.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--secondary-bg);
}

#cart-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--secondary-bg);
  display: flex;
  gap: 10px;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn-primary {
  flex: 1;
  width: 100%;
  padding: 13px;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-secondary {
  padding: 13px 18px;
  background: var(--secondary-bg);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}

/* ─── FAB ──────────────────────────────────────────────────────────────────── */

#fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 50;
}

#fab-btn {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: 28px;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(232, 84, 32, 0.4);
  cursor: pointer;
  font-family: inherit;
}

/* ─── Error ────────────────────────────────────────────────────────────────── */

#error-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.error-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--hint);
  line-height: 1.6;
}

/* ─── History screen ───────────────────────────────────────────────────────── */

#history-list { padding: 12px 16px 80px; }

.history-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.history-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
}

.history-user {
  font-size: 12px;
  color: var(--hint);
}

.history-location {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 10px;
}

.history-supplier {
  padding: 8px 0;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.history-supplier-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.history-items {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.5;
}

.history-reorder-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

.history-reorder-btn:active { opacity: 0.8; }

/* ─── Order confirmation ───────────────────────────────────────────────────── */

.sent-confirmation {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px 20px;
  gap: 8px;
}

.sent-check { font-size: 48px; line-height: 1; }

.sent-text {
  font-size: 15px;
  color: var(--hint);
  text-align: center;
}

.sent-type {
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
  text-align: center;
}

.order-summary-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 16px 10px;
}

.order-items-text {
  font-size: 13px;
  color: var(--hint);
  margin-top: 5px;
  line-height: 1.7;
}

/* ─── Toast ────────────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 999;
  max-width: 90vw;
  white-space: normal;
  text-align: center;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Order type modal ─────────────────────────────────────────────────────── */

#order-type-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

#order-type-modal.hidden { display: none; }

.modal-box {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 32px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  color: var(--text);
}

.modal-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.modal-btn:active { opacity: 0.8; }

.modal-btn-tomorrow {
  background: var(--btn);
  color: var(--btn-text);
}

.modal-btn-today {
  background: var(--secondary-bg);
  color: var(--text);
}

.modal-btn-cancel {
  background: transparent;
  color: var(--hint);
  font-size: 15px;
  font-weight: 400;
  padding: 10px;
}

/* --- Comments (cart / order / history) --- */

.cart-comment {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--secondary-bg);
  border-radius: 12px;
  border: 1px solid transparent;
}

.cart-comment.filled { border-color: var(--orange); }

.cart-comment-general {
  margin: 18px 0 8px;
  padding: 12px;
}

.cart-comment-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 6px;
}

.cart-comment-general .cart-comment-label { color: var(--text); }

.cart-comment-input {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}

.cart-comment-input:focus { border-color: var(--orange); }

.order-comment-text {
  font-size: 13px;
  line-height: 1.6;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
}

.order-general-comment { border: 1px solid var(--orange); }

.history-comment {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-top: 5px;
}

.history-comment-general {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ─── Карточка кофе для гостя ─────────────────────────────────────────── */

.coffee-hint {
  padding: 12px 16px 0;
  font-size: 13px;
  color: var(--hint);
  line-height: 1.4;
}

#coffee-location-list { padding: 12px 16px 24px; }

#coffee-drink-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 4px;
}

#coffee-drink-tabs .cat-tab { flex: 1; text-align: center; }

#coffee-form { padding: 8px 16px 16px; }

.coffee-field { margin-top: 14px; }

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

.coffee-input {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--secondary-bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  outline: none;
}

.coffee-input:focus { border-color: var(--orange); }

.coffee-row {
  display: flex;
  gap: 8px;
}

.coffee-row .coffee-field { flex: 1; }

.coffee-section-title {
  margin-top: 22px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--orange);
}

.coffee-meta {
  margin-top: 18px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--hint);
  background: var(--secondary-bg);
  border-radius: var(--radius);
}

.coffee-meta.stale {
  color: #B0300A;
  background: #FDEDE7;
}
