/* ── Reset & Telegram theme vars ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       var(--tg-theme-bg-color,       #ffffff);
  --bg2:      var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text:     var(--tg-theme-text-color,     #111111);
  --hint:     var(--tg-theme-hint-color,     #888888);
  --link:     var(--tg-theme-link-color,     #3b82f6);
  --btn:      var(--tg-theme-button-color,   #3b82f6);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent:   #f97316;
  --green:    #22c55e;
  --red:      #ef4444;
  --radius:   14px;
  --shadow:   0 2px 12px rgba(0,0,0,.08);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
  overflow-x: hidden;
}

/* ── Screens ──────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
}
.screen.active { display: flex; }

/* ── Loading ──────────────────────────────────────────────────── */
#loading {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.loading-inner { text-align: center; }
.logo { font-size: 64px; margin-bottom: 8px; }
.loading-text { font-size: 24px; font-weight: 700; color: var(--accent); }
.spinner {
  margin: 24px auto 0;
  width: 36px; height: 36px;
  border: 3px solid var(--bg2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 17px; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text); padding: 4px 8px;
  border-radius: 8px;
}
.icon-btn:active { background: var(--bg2); }
.back-btn { font-size: 14px; color: var(--link); font-weight: 600; }

/* ── Category tabs ────────────────────────────────────────────── */
.category-tabs {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid transparent;
  background: var(--bg2);
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.cat-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Menu list ────────────────────────────────────────────────── */
.menu-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 100px;
}
.menu-category-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 16px 0 8px;
}
.menu-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.menu-emoji { font-size: 36px; flex-shrink: 0; }
.menu-info { flex: 1; min-width: 0; }
.menu-name { font-weight: 700; font-size: 15px; }
.menu-desc { color: var(--hint); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-price { font-weight: 700; color: var(--accent); margin-top: 4px; }
.qty-control {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 50%; border: none;
  background: var(--accent); color: #fff;
  font-size: 18px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .1s;
}
.qty-btn:active { opacity: .7; }
.qty-btn.minus { background: var(--bg2); color: var(--text); }
.qty-num { font-weight: 700; min-width: 22px; text-align: center; }

/* ── Cart FAB ─────────────────────────────────────────────────── */
.cart-fab {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px; right: 16px;
  background: var(--btn);
  color: var(--btn-text);
  border: none; border-radius: 14px;
  padding: 14px 20px;
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  transition: transform .15s;
  z-index: 20;
}
.cart-fab:active { transform: scale(.97); }
.cart-fab.hidden { display: none; }
.cart-total-fab { font-size: 14px; opacity: .85; }

/* ── Cart list ────────────────────────────────────────────────── */
.cart-list {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
}
.cart-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 700; }
.cart-item-price { color: var(--hint); font-size: 13px; margin-top: 2px; }
.empty-cart {
  text-align: center; color: var(--hint);
  padding: 48px 0; font-size: 15px;
}

/* ── Cart footer ──────────────────────────────────────────────── */
.cart-footer {
  background: var(--bg);
  padding: 16px;
  border-top: 1px solid rgba(0,0,0,.06);
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.voucher-row { display: flex; gap: 8px; }
.voucher-row input {
  flex: 1; padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 10px; font-size: 14px;
  background: var(--bg2); color: var(--text);
  outline: none;
}
.voucher-row input:focus { border-color: var(--accent); }
.btn-sm {
  padding: 10px 14px; border: none;
  background: var(--accent); color: #fff;
  border-radius: 10px; font-weight: 700;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.voucher-msg { font-size: 13px; margin-top: 6px; min-height: 18px; }
.voucher-msg.ok { color: var(--green); }
.voucher-msg.err { color: var(--red); }

.note-row { margin-top: 12px; }
.note-row textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 10px; font-size: 14px;
  background: var(--bg2); color: var(--text);
  resize: none; outline: none; font-family: inherit;
}
.note-row textarea:focus { border-color: var(--accent); }

.price-summary { margin-top: 14px; border-top: 1px solid rgba(0,0,0,.07); padding-top: 12px; }
.price-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; color: var(--hint); }
.total-row { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 4px; }
.discount-row { color: var(--green); }
.discount-row.hidden { display: none; }
.green { color: var(--green); }

.btn-primary {
  width: 100%; margin-top: 14px; padding: 14px;
  background: var(--btn); color: var(--btn-text);
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-voucher {
  width: 100%; padding: 11px;
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent); border-radius: 12px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all .15s;
}
.btn-voucher.active {
  background: var(--accent); color: #fff;
}
.pay-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; margin-left: 6px;
}
.pay-badge.paid   { background: #dcfce7; color: #166534; }
.pay-badge.unpaid { background: #fee2e2; color: #991b1b; }
.section-label { font-size: 13px; color: var(--hint); display: block; margin-bottom: 8px; }
.cart-emoji { font-size: 28px; flex-shrink: 0; }
.empty-hint { color: var(--hint); padding: 32px; text-align: center; }

.btn-secondary {
  width: 100%; margin-top: 10px; padding: 12px;
  background: transparent; color: var(--link);
  border: 1.5px solid var(--link); border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ── Success screen ───────────────────────────────────────────── */
#screen-success {
  align-items: center; justify-content: center;
  background: var(--bg);
}
.success-inner { text-align: center; padding: 32px; max-width: 320px; }
.success-icon { font-size: 72px; margin-bottom: 16px; }
.success-inner h2 { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.success-inner p { color: var(--hint); font-size: 15px; margin-bottom: 6px; }
.success-total { font-size: 18px !important; color: var(--text) !important; font-weight: 700; margin-top: 12px !important; }

/* ── Orders list ──────────────────────────────────────────────── */
.orders-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
.order-card {
  background: var(--bg);
  border-radius: var(--radius); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .1s;
}
.order-card:active { transform: scale(.98); }
.order-card-header { display: flex; justify-content: space-between; align-items: center; }
.order-id { font-weight: 700; }
.order-status-badge {
  font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; background: var(--bg2); color: var(--text);
}
.order-status-badge.pending   { background: #fef3c7; color: #92400e; }
.order-status-badge.confirmed { background: #dcfce7; color: #166534; }
.order-status-badge.preparing { background: #dbeafe; color: #1e40af; }
.order-status-badge.ready     { background: #f0fdf4; color: #15803d; }
.order-status-badge.done      { background: #f3f4f6; color: #374151; }
.order-status-badge.cancelled { background: #fee2e2; color: #991b1b; }
.order-card-meta { color: var(--hint); font-size: 13px; margin-top: 6px; }
.order-card-total { font-weight: 700; color: var(--accent); margin-top: 4px; }
.empty-orders { text-align: center; color: var(--hint); padding: 48px 0; }

/* ── Order detail ─────────────────────────────────────────────── */
.order-detail-body { padding: 16px; }
.detail-status-big {
  text-align: center; font-size: 18px; font-weight: 700;
  padding: 16px; background: var(--bg); border-radius: var(--radius);
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.detail-items {
  background: var(--bg); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.detail-item-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.05); font-size: 14px;
}
.detail-item-row:last-child { border-bottom: none; }
.detail-summary {
  background: var(--bg); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.detail-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; color: var(--hint); }
.detail-total { font-size: 16px; font-weight: 700; color: var(--text); }
.detail-note { color: var(--hint); font-size: 13px; margin-top: 10px; }
