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

:root {
  --green: #00b14f;
  --green-dark: #009643;
  --text: #1c1c1c;
  --muted: #7a7a7a;
  --bg: #f5f5f5;
  --line: #eeeeee;
  --danger: #e53935;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #e8e8e8;
  color: var(--text);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  box-shadow: 0 0 24px rgba(0,0,0,.12);
  position: relative;
}

.loading { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ===== Header ===== */
.cover { position: relative; padding-bottom: 46px; }
.cover-img { width: 100%; height: 170px; object-fit: cover; display: block; }
.restaurant-card {
  position: absolute; left: 16px; right: 16px; bottom: 0;
  background: #fff; border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}
.restaurant-name { font-size: 19px; font-weight: 700; }
.restaurant-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.restaurant-address { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== Category bar ===== */
.category-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 8px; align-items: center;
  background: #fff; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.category-chips {
  display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0;
  scrollbar-width: none;
}
.category-chips::-webkit-scrollbar { display: none; }
.cat-dd-btn {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 7px 11px; border-radius: 999px; border: none;
  background: #e6f7ee; color: var(--green);
  font-size: 13px; font-weight: 700; cursor: pointer;
  max-width: 128px; white-space: nowrap;
}
.cat-dd-btn span { overflow: hidden; text-overflow: ellipsis; }
.search-btn {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: var(--bg); font-size: 15px; cursor: pointer;
}
.cat-dd, .search-panel {
  position: absolute; top: calc(100% + 4px); left: 12px; right: 12px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 25;
  max-height: 62vh; overflow-y: auto;
}
.cat-dd.hidden, .search-panel.hidden { display: none; }
.cat-dd-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 12px 16px; border: none; background: #fff;
  font-size: 14.5px; font-weight: 500; cursor: pointer;
  border-bottom: 1px solid var(--line); text-align: left;
}
.cat-dd-item:last-child { border-bottom: none; }
.cat-dd-item:hover { background: var(--bg); }
.cat-dd-item span { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.search-panel { padding: 10px 14px; }
#search-results .dish { padding: 10px 0; }
.search-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.category-chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--bg); color: var(--text);
  font-size: 13.5px; font-weight: 500; border: none; cursor: pointer;
  white-space: nowrap;
}
.category-chip.active { background: #e6f7ee; color: var(--green); font-weight: 700; }

/* ===== Menu sections ===== */
#menu-sections { padding-bottom: 90px; }
.menu-section { background: #fff; margin-top: 8px; padding: 14px 16px 4px; }
.menu-section h2 { font-size: 16.5px; font-weight: 700; margin-bottom: 6px; }

.dish {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.dish:last-child { border-bottom: none; }
.dish-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dish-name { font-size: 15px; font-weight: 600; }
.dish-desc {
  font-size: 12.5px; color: var(--muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dish-price-row { margin-top: auto; padding-top: 6px; display: flex; align-items: baseline; gap: 8px; }
.dish-price { font-size: 14.5px; font-weight: 700; }
.dish-price-old { font-size: 12.5px; color: var(--muted); text-decoration: line-through; }
.dish-sale-tag {
  font-size: 11px; color: var(--danger); border: 1px solid var(--danger);
  border-radius: 4px; padding: 0 4px; font-weight: 600;
}
.dish-thumb { position: relative; flex: 0 0 auto; }
.dish.sold-out { opacity: .5; cursor: default; }
.dish.sold-out img { filter: grayscale(.8); }
.soldout-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.65); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap;
}
.dish-thumb img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; display: block; }
.dish-add {
  position: absolute; right: -6px; bottom: -6px;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; color: var(--green);
  border: 1.5px solid var(--green);
  font-size: 20px; line-height: 1; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.12); cursor: pointer;
}
.quick-qty { position: absolute; right: -6px; bottom: -6px; }
.quick-qty .dish-add { position: static; }
.qty-inline {
  display: flex; align-items: center; gap: 2px;
  background: #fff; border: 1.5px solid var(--green);
  border-radius: 999px; padding: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.qty-inline .dish-add {
  width: 24px; height: 24px; border: none; box-shadow: none; font-size: 16px;
}
.qty-inline-num { min-width: 18px; text-align: center; font-size: 13px; font-weight: 700; }

/* ===== Cart bar ===== */
.cart-bar {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  width: calc(min(480px, 100vw) - 24px);
  background: var(--green); color: #fff;
  border-radius: 12px; padding: 13px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,177,79,.4);
  cursor: pointer; z-index: 30;
}
.cart-bar.hidden { display: none; }
.cart-bar-info { display: flex; align-items: center; gap: 8px; }
.cart-bar-total { margin-left: auto; }
.cart-bar-cta { font-weight: 500; font-size: 13.5px; opacity: .95; }

/* ===== Bottom sheet ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: min(480px, 100vw); max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 18px 18px 0 0;
  animation: slideUp .22s ease;
  display: flex; flex-direction: column;
}
@keyframes slideUp { from { transform: translateY(40%); } to { transform: translateY(0); } }
.sheet-close {
  position: sticky; top: 10px; margin: 10px 12px 0 auto; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.45); color: #fff; font-size: 16px; cursor: pointer;
}
.sheet-img { width: 100%; height: 210px; object-fit: cover; margin-top: -42px; }
.sheet-body { padding: 14px 16px 16px; }
.sheet-title { font-size: 18px; font-weight: 700; }
.sheet-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.sheet-price { font-size: 16px; font-weight: 700; margin-top: 8px; }
.sheet-price .old { font-size: 13px; color: var(--muted); text-decoration: line-through; font-weight: 400; margin-left: 8px; }

.variant-group { margin-top: 16px; }
.variant-label { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.variant-hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.option-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 14.5px; cursor: pointer;
}
.option-row:last-child { border-bottom: none; }
.option-row input { width: 18px; height: 18px; accent-color: var(--green); }
.option-price { margin-left: auto; color: var(--muted); font-size: 13.5px; }

.note-input {
  width: 100%; margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: var(--bg);
}

.sheet-footer {
  position: sticky; bottom: 0; background: #fff;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--line);
}
.qty-stepper { display: flex; align-items: center; gap: 12px; }
.qty-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--green); background: #fff; color: var(--green);
  font-size: 18px; font-weight: 600; cursor: pointer;
}
.qty-btn:disabled { border-color: #ccc; color: #ccc; }
.qty-value { font-size: 15px; font-weight: 700; min-width: 20px; text-align: center; }
.btn-primary {
  flex: 1; background: var(--green); color: #fff; border: none;
  border-radius: 10px; padding: 13px 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { background: var(--green-dark); }
.btn-primary:disabled { background: #b8e6cc; }

/* ===== Cart sheet ===== */
.cart-item { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 14.5px; font-weight: 600; }
.cart-item-opts { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cart-item-price { font-size: 13.5px; font-weight: 600; margin-top: 4px; }
.cart-item-qty { display: flex; align-items: center; gap: 10px; }
.cart-item-qty .qty-btn { width: 26px; height: 26px; font-size: 15px; }
.cart-total-row {
  display: flex; justify-content: space-between;
  padding: 14px 0 4px; font-size: 15.5px; font-weight: 700;
}

/* ===== Checkout form ===== */
.form-group { margin-top: 14px; }
.form-label { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; display: block; }
.form-input {
  width: 100%; padding: 11px 12px; border: 1px solid #ddd;
  border-radius: 10px; font-size: 14.5px; font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--green); }
.addr-wrap { position: relative; }
.addr-suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); overflow: hidden;
}
.addr-suggest.hidden { display: none; }
.addr-item {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px; font-size: 13.5px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.addr-item:last-child { border-bottom: none; }
.addr-item:hover { background: var(--bg); }
.addr-dist { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.addr-status { font-size: 13px; margin-top: 6px; min-height: 16px; }
.addr-ok { color: var(--green); font-weight: 600; }
.addr-bad { color: var(--danger); font-weight: 600; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }
.saved-chips { display: flex; flex-direction: column; gap: 8px; }
.saved-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 9px 12px; cursor: pointer; background: var(--bg);
}
.saved-chip.active { border-color: var(--green); background: #e6f7ee; }
.saved-chip-text { flex: 1; font-size: 13px; line-height: 1.4; }
.saved-chip-text small { color: var(--muted); }
.saved-chip-del {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: #eee; color: #777; font-size: 12px; cursor: pointer;
}
.pf-save-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; margin-top: 14px; cursor: pointer;
}
.pf-save-check input { width: 17px; height: 17px; accent-color: var(--green); }

/* ===== Promo ===== */
.promo-banner {
  background: #fff8e1; border-bottom: 1px solid #ffe082;
  padding: 8px 16px;
}
.promo-line { font-size: 13px; color: #7a5c00; padding: 2px 0; }
.promo-line b { color: #e65100; }
.promo-row { display: flex; gap: 8px; }
.promo-row .form-input { flex: 1; }
.promo-apply {
  flex: 0 0 auto; padding: 0 16px; border-radius: 10px;
  border: 1.5px solid var(--green); background: #fff; color: var(--green);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.checkout-summary { margin-top: 14px; }
.checkout-summary > div {
  display: flex; justify-content: space-between;
  font-size: 14px; padding: 4px 0;
}
.checkout-summary .discount-line { color: var(--green); font-weight: 600; }
.checkout-summary .final-line {
  font-size: 15.5px; font-weight: 800;
  border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px;
}

/* ===== Mốc ưu đãi (thanh đo kiểu Grab) ===== */
.ms-wrap {
  background: #f0faf4; border: 1px solid #c8ecd7;
  border-radius: 12px; padding: 12px 14px; margin: 10px 0 4px;
}
.ms-text { font-size: 13px; }
.ms-text b { color: var(--green); }
.ms-bar {
  position: relative; height: 12px; margin-top: 10px;
  background: #dfe8e2; border-radius: 999px;
}
.ms-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #7bd9a4, var(--green));
  transition: width .4s ease;
}
.ms-lock {
  position: absolute; right: -4px; top: 50%; transform: translateY(-50%);
  font-size: 15px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}
.ms-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ms-chip {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: #fff; border: 1px solid #dfe8e2; color: var(--muted);
}
.ms-chip.unlocked { border-color: var(--green); color: var(--green); font-weight: 600; }
.ms-note { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

#ms-strip {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
  width: calc(min(480px, 100vw) - 24px);
  background: #fff; border: 1px solid #c8ecd7; border-radius: 10px;
  padding: 6px 12px; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 3px 12px rgba(0,0,0,.12); z-index: 28;
}
#ms-strip.with-cart { bottom: 72px; }
.ms-strip-main { flex: 1; min-width: 0; padding-right: 10px; }
.ms-strip-text { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-strip-text b { color: var(--green); }
.ms-bar-thin { height: 6px; margin-top: 9px; margin-bottom: 5px; overflow: visible; }
.ms-marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; border: 1.5px solid #cfd8d3;
  font-size: 9.5px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.ms-marker.unlocked {
  border-color: var(--green); background: var(--green);
  color: #fff; font-weight: 900; font-size: 11px;
}

/* ===== Payment QR ===== */
.pay-qr {
  width: 230px; height: 230px; margin: 14px auto 0;
  display: block; border: 1px solid var(--line); border-radius: 12px;
}
.pay-info {
  margin: 14px auto 0; max-width: 320px; text-align: left;
  background: var(--bg); border-radius: 10px; padding: 4px 14px;
}
.pay-info > div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid var(--line);
}
.pay-info > div:last-child { border-bottom: none; }
.pay-info span { color: var(--muted); }
.pay-waiting {
  margin-top: 14px; font-size: 13px; color: #7a5c00;
  background: #fff8e1; border-radius: 8px; padding: 9px 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pay-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #ffd54f; border-top-color: #f9a825;
  display: inline-block; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.paid-check {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-size: 40px; font-weight: 900; line-height: 68px;
  margin: 10px auto 6px; animation: popIn .3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* ===== Vòng quay may mắn ===== */
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
#wheel-fab {
  position: fixed; right: calc(50% - min(240px, 50vw) + 14px); bottom: 128px;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #ff9800, #e53935);
  border: none; font-size: 26px; cursor: pointer; z-index: 29;
  box-shadow: 0 4px 14px rgba(229,57,53,.45);
  animation: pulse 1.8s infinite;
}
.wheel-modal { align-items: center; justify-content: center; padding: 16px; }
.wheel-popup {
  position: relative; overflow: hidden;
  background: #fff; border-radius: 20px;
  width: min(350px, 94vw); padding: 18px 16px 20px;
  text-align: center;
  animation: popIn .28s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes popIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.wheel-close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.08); color: #555; font-size: 14px; cursor: pointer;
}
.wheel-popup-title { font-size: 18px; font-weight: 800; margin-top: 2px; }
.wheel-popup-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.wheel-tap { cursor: pointer; }
.wheel-hub {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 62px; height: 62px; border-radius: 50%;
  background: #fff; border: 4px solid #ffb300;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #e65100;
  box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; z-index: 2;
}
.wheel-seg-img {
  display: block; width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; margin: 0 auto 2px;
  border: 1.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.confetti-piece {
  position: absolute; top: -16px; z-index: 5;
  border-radius: 2px; pointer-events: none;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(560px) rotate(720deg); opacity: .2; }
}
.wheel-wrap { position: relative; width: 270px; margin: 18px auto 8px; }
.wheel-pointer {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 26px; color: #e53935; z-index: 2;
  text-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.wheel {
  width: 270px; height: 270px; border-radius: 50%;
  border: 8px solid #fff; box-shadow: 0 4px 20px rgba(0,0,0,.25);
  position: relative; overflow: hidden;
}
.wheel-label {
  position: absolute; transform: translate(-50%, -50%);
  width: 66px; text-align: center; pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
}
.wheel-label span {
  font-size: 10.5px; font-weight: 800; color: #fff; line-height: 1.15;
  letter-spacing: -0.2px;
  padding: 2px 5px; border-radius: 8px;
  background: rgba(0,0,0,.32);
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.spin-win { margin-top: 14px; }
.spin-win-title { font-size: 15px; }
.spin-code {
  font-size: 24px; font-weight: 900; letter-spacing: 2px;
  color: var(--green); margin: 10px 0 4px;
  border: 2px dashed var(--green); border-radius: 10px;
  padding: 8px 14px; display: inline-block; background: #e6f7ee;
}
.spin-note { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.spin-lose { margin-top: 14px; font-size: 14.5px; color: var(--muted); }
.spin-saved {
  margin-top: 10px; font-size: 12.5px; color: var(--green); font-weight: 600;
  background: #e6f7ee; border-radius: 8px; padding: 8px 10px;
}

/* ===== Ví mã khuyến mãi ===== */
.voucher-title { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.voucher-card {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px dashed #cfd8d3; border-radius: 10px;
  padding: 9px 12px; margin-bottom: 8px; cursor: pointer; background: var(--bg);
}
.voucher-card.active { border-color: var(--green); border-style: solid; background: #e6f7ee; }
.voucher-main { flex: 1; font-size: 13px; min-width: 0; }
.voucher-main b { color: var(--green); }
.voucher-cond { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.voucher-apply {
  flex: 0 0 auto; font-size: 12.5px; font-weight: 700; color: var(--green);
  border: 1.5px solid var(--green); border-radius: 999px; padding: 4px 10px;
  background: #fff; white-space: nowrap;
}
.voucher-card.active .voucher-apply { background: var(--green); color: #fff; }

/* ===== Success ===== */
.success-box { text-align: center; padding: 34px 20px 26px; }
.success-icon { font-size: 52px; }
.success-title { font-size: 19px; font-weight: 700; margin-top: 12px; }
.success-code { font-size: 15px; margin-top: 8px; }
.success-code b { color: var(--green); font-size: 20px; }
.success-note { font-size: 13.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
