/* InOrder Mini App - Mobile first, Telegram WebApp style */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0f172a);
  --hint: var(--tg-theme-hint-color, #64748b);
  --link: var(--tg-theme-link-color, #0891b2);
  --button: var(--tg-theme-button-color, #0891b2);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --section-bg: var(--tg-theme-secondary-bg-color, #f1f5f9);
  --primary: #0891b2;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --border: rgba(0,0,0,0.08);
  --radius: 14px;
}

* { 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, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  padding: 16px;
  padding-bottom: 100px;
}

/* === STATUS / LOADING === */
#status-view {
  display: flex;
  align-items: center;
  justify-content: center;
}
.status-content {
  text-align: center;
  max-width: 400px;
  padding: 32px;
}
.status-icon { font-size: 64px; margin-bottom: 16px; }
.status-content h1 { margin: 0 0 8px; font-size: 24px; }
.status-content p { color: var(--hint); margin: 0 0 24px; line-height: 1.5; }

/* === HOME === */
.welcome {
  text-align: center;
  margin-bottom: 32px;
  padding: 24px 16px 8px;
}
.user-greeting {
  font-size: 18px;
  margin-bottom: 4px;
}
.welcome p { color: var(--hint); margin: 0; }

.big-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 8px;
}
.big-btn {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--section-bg);
  border: none;
  border-radius: var(--radius);
  padding: 28px 24px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  text-align: left;
  transition: transform 0.1s, background 0.15s;
}
.big-btn:active { transform: scale(0.98); }
.big-btn-icon { font-size: 48px; }
.big-btn-label { flex: 1; }
.big-btn--occupied {
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  color: white !important;
  border: 2px solid #15803d !important;
}
.big-btn--occupied .big-btn-icon { filter: brightness(1.1); }
.big-btn-badge {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 3px;
  opacity: 0.92;
}
.big-btn[data-type="dine_in"] {
  background: linear-gradient(135deg, #0891b2, #06b6d4);
  color: white;
}
.big-btn[data-type="takeaway"] {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: white;
}

/* === VIEW HEADER === */
.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 8px 0 12px;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}
.view-header h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
}
.back-btn {
  background: none;
  border: none;
  color: var(--link);
  font-size: 16px;
  padding: 6px 4px;
}
.cart-badge {
  background: var(--accent);
  color: white;
  border-radius: 14px;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  padding: 0 8px;
}
.cart-badge.empty { display: none; }

/* === ZONES TABS === */
.zones-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.zone-tab {
  background: var(--section-bg);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text);
}
.zone-tab.active {
  background: var(--primary);
  color: white;
}

/* === TABLES GRID === */
.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
}
.table-btn {
  background: var(--section-bg);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  transition: all 0.1s;
}
.table-btn:active { transform: scale(0.95); border-color: var(--primary); }

/* === CATEGORIES === */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.cat-btn {
  background: var(--section-bg);
  border: none;
  border-radius: var(--radius);
  padding: 24px 12px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s;
}
.cat-btn:active { transform: scale(0.96); }
.cat-emoji { font-size: 36px; line-height: 1; }
.cat-name { line-height: 1.2; }

/* === PRODUCTS === */
.prod-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prod-card {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid transparent;
  transition: border 0.1s;
}
.prod-card:active { border-color: var(--primary); }
.prod-info { flex: 1; min-width: 0; }
.prod-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}
.prod-price {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--hint);
  background: white;
  padding: 4px 10px;
  border-radius: 6px;
}
.prod-price-edit { display: none; }
.prod-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tag-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.1s;
}
.tag-btn:active { opacity: 0.7; }
.prod-add {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}

/* === CART === */
.cart-info {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.cart-info strong { color: var(--primary); }

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.cart-item {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.cart-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; font-size: 14px; }
.cart-item-price { color: var(--hint); font-size: 13px; margin-top: 2px; }
.cart-item-comment {
  color: var(--hint);
  font-size: 12px;
  font-style: italic;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.cart-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border-radius: 20px;
  padding: 2px;
}
.cart-qty button {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  border-radius: 50%;
}
.cart-qty span { min-width: 20px; text-align: center; font-weight: 600; }
.cart-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  padding: 4px;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--section-bg);
  border-radius: var(--radius);
  font-size: 18px;
  margin-bottom: 12px;
}
.cart-total strong { color: var(--primary); font-size: 22px; }

#cart-comment {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 16px;
  background: var(--bg);
  color: var(--text);
}
#cart-comment:focus { outline: none; border-color: var(--primary); }

.btn-print {
  width: 100%;
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-print:active { transform: scale(0.98); }
.btn-print:disabled { opacity: 0.6; }

/* === MODAL === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 500px;
  animation: slideUp 0.2s;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-content h3 {
  margin: 0 0 16px;
  font-size: 18px;
  text-align: center;
}

.qty-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 24px 0;
}
.qty-selector button {
  background: var(--section-bg);
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}
.qty-selector span {
  font-size: 36px;
  font-weight: 700;
  min-width: 60px;
  text-align: center;
}

#add-comment, #price-input {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 16px;
  background: var(--bg);
  color: var(--text);
}
#price-input { min-height: auto; font-size: 24px; text-align: center; font-weight: 700; }
#add-comment:focus, #price-input:focus { outline: none; border-color: var(--primary); }

.add-actions {
  display: flex;
  gap: 10px;
}
.btn-primary, .btn-secondary {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  border: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--section-bg); color: var(--text); }

/* === TOAST === */
#toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 90%;
  text-align: center;
}
#toast.show { opacity: 0.95; }

/* ===== OPEN ORDERS ===== */
.open-order-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.875rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.open-order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.open-order-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.625rem;
}
.order-item-chip {
  background: #f1f5f9;
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  color: var(--hint);
}
.open-order-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.open-order-actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}
.oa-btn {
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.oa-btn:active { background: #e2e8f0; }

/* Shift summary view */
#shift-summary-view .view-header {
  justify-content: center;
}

/* Secondary button */
.btn-secondary {
  background: var(--section-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:active { background: #e2e8f0; }

/* Danger button */
.btn-danger 