/* ===== CSS Variables ===== */
:root {
  --primary: #e85d04;
  --primary-dark: #c44a03;
  --primary-light: #fff7f0;
  --spicy-color: #dc2626;
  --spicy-bg: #fef2f2;
  --non-spicy-color: #16a34a;
  --non-spicy-bg: #f0fdf4;
  --staple-color: #2563eb;
  --staple-bg: #eff6ff;
  --bg: #f2f3f5;
  --surface: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Leelawadee UI", "Thonburi", "Noto Sans Thai", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
input, button { font-family: inherit; font-size: inherit; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ===== App Layout ===== */
#app { max-width: 600px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

/* ===== Header ===== */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(232,93,4,0.3);
  gap: 8px; min-height: 56px;
}
.header-left { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.logo { font-size: 1.45rem; flex-shrink: 0; line-height: 1; }
.app-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.date-badge {
  background: rgba(255,255,255,0.2); border-radius: 20px;
  padding: 4px 10px; font-size: 0.78rem; font-weight: 600;
  backdrop-filter: blur(4px); white-space: nowrap; flex-shrink: 0;
}

/* Sync badge */
.sync-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.6rem; padding: 2px 6px; border-radius: 10px;
  font-weight: 600; background: rgba(255,255,255,0.25); flex-shrink: 0;
}
.sync-badge.online { background: rgba(255,255,255,0.25); color: #fff; }
.sync-badge.offline { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7); }

/* ===== Main ===== */
#main { flex: 1; padding: 14px; }

/* ===== Section Title ===== */
.section-title {
  font-size: 1.05rem; font-weight: 700; margin: 24px 0 12px;
  color: var(--text); display: flex; align-items: center; gap: 6px;
}

/* ===== Meal Card - Complete Redesign ===== */
.meal-card {
  background: var(--surface); border-radius: var(--radius);
  margin-bottom: 18px;
  box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
}
.meal-card:active { transform: scale(0.985); }
.meal-card.active-card {
  border-color: var(--primary); border-width: 2px;
  box-shadow: 0 4px 20px rgba(232,93,4,0.15);
}

/* Meal card image */
.meal-card-img {
  width: 100%; height: 180px;
  background-color: #f8f9fa;
  position: relative; overflow: hidden;
}
.meal-card-img img.meal-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  /* 图片加载完成后淡入，避免闪烁 */
  opacity: 0; transition: opacity 0.3s ease;
}
.meal-card-img img.meal-img.loaded { opacity: 1; }
.meal-card-img::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 40px; background: linear-gradient(transparent, rgba(0,0,0,0.15));
  pointer-events: none;
}
.meal-card-img-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 3.5rem; background: linear-gradient(135deg, #fef3e6, #fff7f0);
}
/* Price badge overlay on image */
.meal-img-price {
  position: absolute; top: 12px; right: 12px;
  background: rgba(0,0,0,0.65); color: #fff; backdrop-filter: blur(6px);
  padding: 4px 12px; border-radius: 20px;
  font-size: 1.1rem; font-weight: 800;
}

/* Card body (below image) */
.meal-card-body { padding: 16px 18px; }

.meal-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.meal-card-title { font-size: 1.15rem; font-weight: 800; color: var(--text); line-height: 1.3; }
.meal-card-desc { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 14px; margin-top: 4px; line-height: 1.4; }

/* ===== Form Fields inside Card ===== */
.meal-card-form { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); }

/* ===== Big Number Input ===== */
.form-portions-row { display: flex; align-items: center; gap: 12px; }
.form-portions-row label { font-size: 0.9rem; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.big-number-input { display: flex; align-items: stretch; border-radius: var(--radius-xs); overflow: hidden; border: 2px solid var(--border-dark); }
.big-num-btn {
  width: 46px; min-height: 44px; border: none; background: var(--surface);
  font-size: 1.3rem; font-weight: 700; cursor: pointer; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.big-num-btn:hover { background: var(--primary-light); }
.big-num-btn:active { background: var(--primary); color: #fff; }
.big-num-val {
  width: 60px; text-align: center; border: none;
  border-left: 2px solid var(--border-dark);
  border-right: 2px solid var(--border-dark);
  font-size: 1.15rem; font-weight: 800;
  background: var(--surface); outline: none; padding: 0;
}

/* ===== Spicy Toggle ===== */
.toggle-row { display: flex; border-radius: var(--radius-xs); overflow: hidden; border: 2px solid var(--border-dark); }
.toggle-btn-cust {
  flex: 1; padding: 11px 10px; border: none; background: var(--surface);
  cursor: pointer; font-size: 0.9rem; font-weight: 700; color: var(--text-secondary);
  transition: all 0.15s; border-right: 2px solid var(--border-dark);
  -webkit-tap-highlight-color: transparent;
}
.toggle-btn-cust:last-child { border-right: none; }
.toggle-btn-cust.active-sp { background: var(--spicy-color); color: #fff; }
.toggle-btn-cust.active-ns { background: var(--non-spicy-color); color: #fff; }
.toggle-btn-cust:not(.active-sp):not(.active-ns):hover { background: var(--bg); }

/* ===== Spicy Split (多份辣度分配) ===== */
.spicy-split { display: flex; flex-direction: column; gap: 8px; }
.spicy-split-row { display: flex; align-items: center; gap: 8px; }
.spicy-split-tag {
  font-size: 0.85rem; font-weight: 700; padding: 3px 10px;
  border-radius: 12px; white-space: nowrap;
}
.spicy-split-tag.spicy-tag { background: var(--spicy-bg); color: var(--spicy-color); }
.spicy-split-tag.non-spicy-tag { background: var(--non-spicy-bg); color: var(--non-spicy-color); }
.spicy-split-unit { font-size: 0.82rem; color: var(--text-secondary); }
.spicy-split-auto { font-size: 1rem; font-weight: 700; color: var(--text); min-width: 30px; text-align: center; }
.spicy-split-hint { font-size: 0.72rem; color: var(--text-secondary); opacity: 0.7; }

/* ===== Dual Staple ===== */
.dual-staple { display: flex; flex-direction: column; gap: 8px; }
.staple-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.staple-label { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.staple-label small { font-weight: 400; color: var(--text-secondary); }
.staple-toggle-row { display: flex; align-items: center; gap: 6px; }
.staple-onoff {
  padding: 6px 14px; border: 2px solid var(--border-dark);
  border-radius: 20px; background: var(--surface); cursor: pointer;
  font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  transition: all 0.15s; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.staple-onoff.active-staple { background: var(--staple-color); color: #fff; border-color: var(--staple-color); }
.staple-onoff:hover:not(.active-staple) { border-color: var(--staple-color); color: var(--staple-color); }

/* Staple summary */
.staple-summary { margin-top: 4px; padding: 4px 10px; border-radius: 12px; font-size: 0.73rem; font-weight: 600; text-align: center; display: inline-block; }
.staple-summary.free { background: #e8f5e9; color: #2e7d32; }
.staple-summary.charged { background: #fff3e0; color: #e65100; }
.staple-summary.no-staple { background: #f5f5f5; color: #999; }

/* Mini qty */
.qty-mini { display: flex; align-items: center; gap: 0; border: 2px solid var(--border-dark); border-radius: 20px; overflow: hidden; }
.qty-mini-btn {
  width: 30px; height: 30px; border: none; background: var(--surface);
  font-size: 1rem; font-weight: 700; cursor: pointer; color: var(--staple-color);
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.qty-mini-btn:hover { background: var(--staple-bg); }
.qty-mini-val { width: 26px; text-align: center; font-size: 0.85rem; font-weight: 800; color: var(--staple-color); background: var(--staple-bg); padding: 4px 0; }

/* ===== Price Bar (Bottom of Card) ===== */
.price-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin: 0 -18px -16px -18px;
  background: var(--primary-light); border-top: 1px solid rgba(232,93,4,0.1);
}
.price-bar-label { font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.price-bar-value { font-size: 1.35rem; font-weight: 800; color: var(--primary); flex: 1; }

.btn-order {
  padding: 12px 28px; border: none; border-radius: 24px;
  background: var(--primary); color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(232,93,4,0.3);
  -webkit-tap-highlight-color: transparent;
}
.btn-order:hover { background: var(--primary-dark); }
.btn-order:active { transform: scale(0.95); box-shadow: none; }

/* Select meal button (inside meal card) */
.btn-select-meal {
  padding: 10px 18px; border: 2px dashed var(--border-dark); border-radius: 20px;
  background: var(--surface); color: var(--text-secondary); font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-select-meal:hover { border-color: var(--primary); color: var(--primary); }
.btn-select-meal.selected {
  border-color: var(--primary); background: var(--primary-light);
  color: var(--primary); border-style: solid;
}

/* ===== Cart Summary (订单汇总) ===== */
.cart-summary {
  background: var(--surface); border-radius: var(--radius); margin-top: 16px;
  box-shadow: var(--shadow); border: 2px solid var(--primary);
  overflow: hidden; animation: cartSlideUp 0.3s ease;
}
@keyframes cartSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.cart-summary-row {
  padding: 14px 16px 8px;
  border-bottom: 1px dashed var(--border);
}
.cart-meal-info {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.cart-meal-name { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.cart-meal-portions { font-size: 0.85rem; font-weight: 700; color: var(--primary); background: var(--primary-light); padding: 2px 8px; border-radius: 10px; }
.cart-meal-subtotal { margin-left: auto; font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.cart-tag { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 8px; background: #fef2f2; color: #dc2626; }
.cart-tag-green { background: #f0fdf4; color: #16a34a; }
.cart-extra-items {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.cart-extra-item {
  font-size: 0.82rem; color: var(--text-secondary); background: var(--bg);
  padding: 4px 10px; border-radius: 12px; display: inline-flex; align-items: center; gap: 4px;
}
.cart-extra-price { font-weight: 700; color: var(--primary); }
.cart-extra-empty { font-size: 0.8rem; color: #9ca3af; }
.cart-total-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary-light), #fff7ed);
}
.cart-total-label { font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.cart-total-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); flex: 1; }
.btn-order-lg {
  padding: 14px 32px; border: none; border-radius: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(232,93,4,0.35);
  -webkit-tap-highlight-color: transparent;
}
.btn-order-lg:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232,93,4,0.4); }
.btn-order-lg:active { transform: scale(0.95); }

/* ===== Order List ===== */
.order-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface); border-radius: var(--radius);
  margin-bottom: 6px; box-shadow: var(--shadow-sm); flex-wrap: wrap;
}
.order-row.my-order { border-left: 4px solid var(--primary); background: var(--primary-light); }
.order-row-left { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.88rem; }
.order-row-name { font-weight: 700; color: var(--text); }
.order-row-anonymous { font-weight: 400; color: var(--text-secondary); opacity: 0.7; }
.order-row-meal { color: var(--text-secondary); }
.order-row-right { font-size: 1rem; font-weight: 700; color: var(--primary); white-space: nowrap; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 60px 30px; color: var(--text-secondary); }
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; margin-top: 6px; }

/* ===== Footer (fixed promo bar) ===== */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 600px;
  width: 100%;
  background: linear-gradient(135deg, #fff7ed, #fff1f2);
  border-top: 1px solid #fde68a;
  padding: 10px 16px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  z-index: 99;
  box-shadow: 0 -2px 12px rgba(232,93,4,0.08);
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  letter-spacing: 0.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(232,93,4,0.1);
  transition: background 0.2s;
}
.app-footer:active { background: linear-gradient(135deg, #ffedd5, #ffe4e6); }

/* ICP 备案号 */
.icp-beian {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.6;
  margin-top: 2px;
}
.icp-beian a {
  color: var(--text-secondary, #666);
  text-decoration: none;
}

/* Footer share button */
.footer-share-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; /* always visible */
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(232,93,4,0.25);
  padding: 0;
}
.footer-share-btn:active { transform: scale(0.9); box-shadow: 0 1px 4px rgba(232,93,4,0.3); }

/* ===== Extra Products Grid (四宫格) ===== */
.extra-products-section {
  margin: 16px 0;
}

.extra-products-section .section-title {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-left: 4px;
}

.extra-products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.extra-product-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.extra-product-card:active { transform: scale(0.95); }

.extra-product-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff7ed, #fff1f2);
  box-shadow: 0 2px 12px rgba(232,93,4,0.15);
}

.extra-product-card .ep-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 4px;
}

.extra-product-card .ep-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.extra-product-card .ep-price {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
}

.extra-product-card.selected .ep-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  margin-top: 2px;
  font-weight: 600;
}

.ep-badge { display: none; }
.extra-product-card.selected .ep-badge { display: inline-block; }

/* Member points bar */
.member-points-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #fef3c7, #fef9c3);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.member-points-bar .mp-icon { font-size: 1rem; }
.member-points-bar .mp-label { font-weight: 600; color: #92400e; }
.member-points-bar .mp-value {
  font-weight: 800;
  font-size: 1rem;
  color: #b45309;
  margin-left: 2px;
}
.member-points-bar .mp-hint {
  font-size: 0.7rem;
  color: #a16207;
  margin-left: auto;
}
.member-points-bar .mp-balances {
  display: flex;
  gap: 8px;
  align-items: center;
}
.member-points-bar .mp-balance-thb {
  font-weight: 700;
  color: #0d9488;
  font-size: 0.82rem;
}
.member-points-bar .mp-balance-cny {
  font-weight: 700;
  color: #dc2626;
  font-size: 0.82rem;
}
.member-points-bar .mp-balance-sep {
  color: #d1d5db;
  font-size: 0.7rem;
}
.member-points-bar .mp-points-section {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 8px;
  border-left: 1px solid #fcd34d;
}
.member-points-bar .mp-points-val {
  font-weight: 800;
  color: #9333ea;
  font-size: 0.95rem;
}
.member-points-bar .mp-points-label {
  font-size: 0.7rem;
  color: #92400e;
}

/* Redeemed product card */
.extra-product-card.redeemed {
  border-color: #0891b2;
  background: linear-gradient(135deg, #ecfeff, #f0f9ff);
  box-shadow: 0 2px 12px rgba(8,145,178,0.15);
  cursor: default;
}
.ep-price-redeemed { color: var(--text-secondary) !important; }
.ep-badge-redeemed {
  display: inline-block !important;
  background: #0891b2 !important;
  color: #fff !important;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  margin-top: 2px;
  font-weight: 600;
}
.ep-redeem-btn {
  display: block;
  margin: 4px auto 0;
  padding: 3px 10px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(135deg, #0891b2, #06b6d4);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.ep-redeem-btn:active { transform: scale(0.95); }
.ep-redeem-disabled {
  display: block;
  margin: 4px auto 0;
  font-size: 0.62rem;
  color: #9ca3af;
  font-weight: 500;
}
.ep-unredeem-btn {
  display: block;
  margin: 4px auto 0;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #dc2626;
  font-size: 0.62rem;
  cursor: pointer;
}
.ep-unredeem-btn:active { transform: scale(0.95); }

/* Cart redeemed item */
.cart-extra-redeemed {
  background: #ecfeff;
  border-color: #0891b2 !important;
  color: #0891b2 !important;
}
.cart-extra-redeemed .cart-extra-price {
  color: #0891b2 !important;
  font-weight: 600;
}

/* Extra items summary in order total */
.extra-items-summary {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Desktop adaptation */
@media (min-width: 769px) {
  .extra-products-grid {
    gap: 12px;
  }
  .extra-product-card {
    padding: 14px 10px;
  }
  .extra-product-card .ep-emoji { font-size: 2.4rem; }
  .extra-product-card .ep-name { font-size: 0.82rem; }
  .extra-product-card .ep-price { font-size: 0.9rem; }
}

/* ===== Order list scroll window ===== */
.order-list-scroll {
  max-height: 240px;
  overflow: hidden;
  position: relative;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.order-list-scroll-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.order-list-scroll::before,
.order-list-scroll::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  z-index: 2;
  pointer-events: none;
  height: 20px;
}
.order-list-scroll::before {
  top: 0;
  background: linear-gradient(to bottom, var(--surface) 0%, transparent 100%);
}
.order-list-scroll::after {
  bottom: 0;
  background: linear-gradient(to top, var(--surface) 0%, transparent 100%);
}
.order-list-static {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 确保底部内容不被 fixed footer 遮挡 */
#main {
  padding-bottom: 70px;
}

/* ===== Toast ===== */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--text); color: #fff; padding: 12px 24px;
  border-radius: 24px; font-size: 0.95rem; font-weight: 600;
  z-index: 2000; opacity: 0; pointer-events: none;
  transition: all 0.3s; box-shadow: var(--shadow-lg); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--non-spicy-color); }
.toast.error { background: #dc2626; }
.toast.warn { background: #f59e0b; }

/* ===== Language Button ===== */
.lang-btn {
  background: rgba(255,255,255,0.2); border: none; color: #fff;
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px;
  border-radius: 12px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.lang-btn:hover { background: rgba(255,255,255,0.35); }

/* 醒目语言切换按钮 */
.lang-btn-prominent {
  font-size: 0.85rem; padding: 6px 14px; border-radius: 20px;
  background: rgba(255,255,255,0.3); border: 1.5px solid rgba(255,255,255,0.5);
  font-weight: 800; letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(255,255,255,0.15);
  animation: langPulse 4s ease-in-out infinite;
}
.lang-btn-prominent:hover {
  background: rgba(255,255,255,0.5); border-color: #fff;
  transform: scale(1.05); box-shadow: 0 0 18px rgba(255,255,255,0.3);
}
@keyframes langPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,255,255,0.15); }
  50% { box-shadow: 0 0 20px rgba(255,255,255,0.35); }
}

/* ===== Name Bar ===== */
.name-bar {
  background: var(--surface); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; border: 2px dashed var(--border-dark); transition: border-color 0.15s;
}

/* ===== 顾客端时段指示器 ===== */
.cust-slot-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 10px;
  border-left: 4px solid #3b82f6;
}
.csi-icon { font-size: 1.2rem; }
.csi-label { font-weight: 700; font-size: 0.88rem; color: #1e40af; }
.csi-time { font-size: 0.75rem; color: #6366f1; }

/* ===== 顾客端时段分组 ===== */
.cust-slot-group {
  margin-bottom: 14px;
}
.cust-slot-group.cust-slot-current {
  border: 2px solid #3b82f6;
  border-radius: 12px;
  padding: 0 0 4px 0;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}
.cust-slot-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 8px;
  margin-bottom: 8px;
}
.cust-slot-group:not(.cust-slot-current) .cust-slot-header {
  opacity: 0.65;
}
.cust-slot-icon { font-size: 1rem; }
.cust-slot-name { font-weight: 700; font-size: 0.85rem; color: var(--text-primary, #111827); }
.cust-slot-time { font-size: 0.7rem; color: var(--text-secondary, #6b7280); }
.cust-slot-now {
  font-size: 0.65rem; font-weight: 600;
  background: #3b82f6; color: #fff; border-radius: 10px;
  padding: 2px 7px;
}
.name-bar:hover { border-color: var(--primary); }
.name-bar-left { display: flex; align-items: center; gap: 8px; }
.name-bar-icon { font-size: 1.4rem; }
.name-bar-text { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); }
.name-bar-text b { color: var(--primary); }
.name-bar-btn {
  padding: 7px 16px; border: 2px solid var(--primary); border-radius: 20px;
  background: var(--surface); color: var(--primary); font-size: 0.82rem;
  font-weight: 700; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.name-bar-btn:hover { background: var(--primary-light); }
.name-bar-worksite {
  font-size: 0.8rem; color: #f59e0b; font-weight: 700;
  padding: 4px 10px; background: #fffbeb; border-radius: 12px;
  margin-right: 8px; white-space: nowrap;
}

/* ===== Profile Modal Styles ===== */
.profile-label {
  display: block; font-size: 0.85rem; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 6px;
}
.worksite-modal-select {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border-dark);
  border-radius: var(--radius-xs); font-size: 1rem; font-weight: 600;
  background: var(--surface); outline: none; transition: border-color 0.2s;
  /* 保留原生 select 外观以确保华为等安卓浏览器兼容性 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.worksite-modal-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,93,4,0.12); }

/* ===== Modal Overlay ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 400px; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.close-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-secondary); padding: 4px 8px; }
.close-btn:hover { color: var(--text); }
.modal-body { padding: 16px; }

.name-modal-input {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border-dark);
  border-radius: var(--radius-xs); font-size: 1.1rem; font-weight: 600;
  background: var(--surface); outline: none; transition: border-color 0.2s;
}
.name-modal-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,93,4,0.12); }

.btn-primary {
  padding: 12px 20px; border: none; border-radius: var(--radius-xs);
  background: var(--primary); color: #fff; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s; display: block; text-align: center;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-large { width: 100%; font-size: 1.05rem; padding: 14px; }

/* ===== Payment Modal (YunGouOS JSAPI) ===== */
.payment-modal { max-width: 380px; width: 90%; }
.payment-modal .modal-body { text-align: center; padding: 20px; }
.payment-amount-display { font-size: 2rem; font-weight: 800; color: var(--primary); margin: 8px 0 16px; }
.payment-order-info { background: #f8f8f8; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; text-align: left; font-size: 0.85rem; }
.payment-order-info .poi-name { font-weight: 600; font-size: 0.95rem; }
.payment-order-info .poi-detail { color: var(--text-secondary); margin-top: 2px; }

/* JSAPI 微信支付按钮 */
.payment-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.payment-actions .btn-pay-jsapi { background: #07c160; color: #fff; border: none; border-radius: 24px; padding: 14px 0; font-size: 1.05rem; font-weight: 700; cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 12px rgba(7,193,96,0.3); }
.payment-actions .btn-pay-jsapi:active { transform: scale(0.97); }
/* 支付宝 H5 支付按钮 */
.payment-actions .btn-pay-alipay { background: #1677ff; color: #fff; border: none; border-radius: 24px; padding: 14px 0; font-size: 1.05rem; font-weight: 700; cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 12px rgba(22,119,255,0.3); }
.payment-actions .btn-pay-alipay:active { transform: scale(0.97); }
.payment-actions .btn-pay-manual { background: #fff; color: var(--text-primary); border: 2px solid var(--border); border-radius: 24px; padding: 12px 0; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.payment-actions .btn-pay-manual:active { background: #f5f5f5; }
.payment-hint-safe { margin-top: 16px; font-size: 0.75rem; color: var(--text-secondary); }

/* 支付状态区 */
.payment-status-area { margin: 16px 0; padding: 16px; border-radius: 12px; }
.payment-loading { color: var(--text-secondary); font-size: 0.9rem; }
.payment-loading::before { content: ''; display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; vertical-align: middle; }
.payment-error { color: #e74c3c; font-size: 0.9rem; font-weight: 600; }
.payment-success { text-align: center; padding: 8px; }
.payment-success-icon { font-size: 3rem; margin-bottom: 8px; }
.payment-success-text { font-size: 1.2rem; font-weight: 700; color: #07c160; margin-bottom: 4px; }
.payment-success-sub { font-size: 0.85rem; color: var(--text-secondary); }
.payment-success .btn-primary { display: inline-block; min-width: 120px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 非微信浏览器提示 */
.payment-wechat-warning { background: #e3f2fd; border: 1px solid #90caf9; border-radius: 10px; padding: 14px; margin-bottom: 16px; text-align: center; }
.payment-wechat-warning .payment-warn-icon { font-size: 2rem; margin-bottom: 6px; }
.payment-wechat-warning .payment-warn-title { font-weight: 700; font-size: 0.95rem; color: #1565c0; margin-bottom: 4px; }
.payment-wechat-warning .payment-warn-text { font-size: 0.82rem; color: #1565c0; line-height: 1.5; }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  #main { padding: 10px; }
  .meal-card-body { padding: 14px 14px; }
  .meal-card-title { font-size: 1.05rem; }
  .meal-card-img { height: 140px; }
  .btn-order { padding: 10px 22px; font-size: 0.95rem; }
  .big-num-btn { width: 40px; min-height: 40px; }
  .big-num-val { width: 52px; }
  .price-bar { margin: 0 -14px -14px -14px; padding: 10px 14px; }
  .price-bar-value { font-size: 1.2rem; }
  .cart-total-bar { padding: 10px 14px; }
  .cart-total-value { font-size: 1.3rem; }
  .btn-order-lg { padding: 12px 24px; font-size: 0.95rem; }
  .cart-meal-name { font-size: 0.88rem; }
  /* Header compact */
  .app-header { padding: 10px 12px; gap: 6px; min-height: 50px; }
  .logo { font-size: 1.3rem; }
  .app-header h1 { font-size: 1rem; }
  .date-badge { padding: 3px 8px; font-size: 0.72rem; }
  .lang-btn { padding: 3px 8px; font-size: 0.68rem; }
  .lang-btn-prominent { padding: 4px 10px; font-size: 0.72rem; }
  .sync-badge { font-size: 0.55rem; padding: 1px 5px; }
}

/* ===== Ultra-small screens (≤360px) ===== */
@media (max-width: 360px) {
  .app-header h1 { font-size: 0.92rem; letter-spacing: 0; }
  .logo { font-size: 1.2rem; }
  .header-right { gap: 4px; }
  .date-badge { padding: 3px 7px; font-size: 0.68rem; }
  .lang-btn-prominent { padding: 3px 8px; font-size: 0.68rem; }
}

/* ===== Hidden ===== */
.hidden { display: none !important; }

/* ===== 微信内访问引导遮罩 ===== */
.wx-guide-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(0,0,0,0.85);
  flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 40px 24px 24px;
}
.wx-guide-overlay.show { display: flex; }
.wx-guide-arrow {
  position: absolute; top: 16px; right: 20px;
  font-size: 3rem; color: #fff;
  animation: wx-bounce 1s ease-in-out infinite;
}
@keyframes wx-bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.wx-guide-content {
  margin-top: 100px;
  text-align: center; color: #fff;
  max-width: 320px;
}
.wx-guide-icon { font-size: 3rem; margin-bottom: 12px; }
.wx-guide-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
.wx-guide-text { font-size: 0.9rem; line-height: 1.6; color: rgba(255,255,255,0.85); margin-bottom: 16px; }
.wx-guide-steps {
  background: rgba(255,255,255,0.1);
  border-radius: 12px; padding: 16px;
  text-align: left; margin-bottom: 20px;
}
.wx-guide-steps p { font-size: 0.85rem; color: rgba(255,255,255,0.9); margin-bottom: 8px; }
.wx-guide-steps p:last-child { margin-bottom: 0; }
.wx-guide-steps .step-num {
  display: inline-block; width: 20px; height: 20px;
  background: #e85d04; border-radius: 50%;
  text-align: center; line-height: 20px;
  font-size: 0.75rem; font-weight: 700; margin-right: 8px;
}
.wx-copy-btn {
  background: #e85d04; color: #fff; border: none;
  border-radius: 24px; padding: 12px 32px;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.wx-copy-btn:active { transform: scale(0.96); }
.wx-copy-tip { font-size: 0.78rem; color: rgba(255,255,255,0.6); margin-top: 8px; }

/* ===== 微信内提示条（不阻断点餐，可关闭） ===== */
.wx-hint-bar {
  display: flex; align-items: center; gap: 8px;
  background: #fff7ed; color: #9a3412;
  border-bottom: 1px solid #fed7aa;
  padding: 8px 12px; font-size: 0.78rem; line-height: 1.4;
  flex-shrink: 0;
}
.wx-hint-bar .wx-hint-text { flex: 1; min-width: 0; }
.wx-hint-how {
  flex-shrink: 0; background: #e85d04; color: #fff; border: none;
  border-radius: 14px; padding: 4px 10px; font-size: 0.72rem; font-weight: 600;
  cursor: pointer;
}
.wx-hint-close {
  flex-shrink: 0; background: transparent; border: none;
  color: #9a3412; font-size: 0.9rem; padding: 2px 6px; cursor: pointer; line-height: 1;
}
.wx-guide-close {
  position: absolute; top: 14px; left: 16px; z-index: 10;
  background: rgba(255,255,255,0.16); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.wx-guide-skip {
  margin-top: 14px; background: transparent; color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.4); border-radius: 22px;
  padding: 10px 26px; font-size: 0.9rem; cursor: pointer;
}

/* ===== Desktop Responsive（顾客端平板 / 桌面适配） ===== */
@media (min-width: 769px) {
  #app { max-width: 800px; }
  #main { padding: 24px; }

  /* Header */
  .app-header { padding: 16px 24px; min-height: 60px; }
  .app-header h1 { font-size: 1.25rem; }
  .logo { font-size: 1.7rem; }
  .date-badge { font-size: 0.88rem; padding: 5px 14px; }
  .lang-btn { font-size: 0.8rem; padding: 5px 12px; }

  /* Section */
  .section-title { font-size: 1.15rem; margin: 28px 0 14px; }

  /* Meal card */
  .meal-card { margin-bottom: 22px; }
  .meal-card-body { padding: 20px 24px; }
  .meal-card-title { font-size: 1.2rem; }
  .meal-card-desc { font-size: 0.88rem; }
  .meal-card-img { height: 220px; }
  .meal-img-price { font-size: 1.2rem; padding: 6px 14px; }

  /* Form elements inside card */
  .form-field label { font-size: 0.88rem; }
  .form-portions-row label { font-size: 0.95rem; }
  .big-num-btn { width: 50px; min-height: 48px; font-size: 1.4rem; }
  .big-num-val { width: 64px; font-size: 1.2rem; }
  .toggle-btn-cust { padding: 13px 16px; font-size: 0.95rem; }
  .staple-label { font-size: 0.92rem; }
  .staple-onoff { padding: 8px 16px; font-size: 0.88rem; }

  /* Price bar */
  .price-bar { padding: 14px 20px; margin: 0 -24px -20px -24px; }
  .price-bar-label { font-size: 0.9rem; }
  .price-bar-value { font-size: 1.5rem; }

  /* Order button */
  .btn-order { padding: 14px 32px; font-size: 1.05rem; }
  .btn-select-meal { padding: 12px 22px; font-size: 0.92rem; }

  /* Cart summary */
  .cart-summary-row { padding: 18px 24px 10px; }
  .cart-total-bar { padding: 16px 24px; }
  .cart-total-value { font-size: 1.6rem; }
  .btn-order-lg { padding: 16px 36px; font-size: 1.1rem; }
  .cart-meal-name { font-size: 1rem; }

  /* Order list */
  .order-row { padding: 14px 20px; gap: 14px; }
  .order-row-left { font-size: 0.92rem; }
  .order-row-right { font-size: 1.05rem; }

  /* Name bar */
  .name-bar { padding: 10px 16px; }
  .name-bar-text { font-size: 1rem; }
  .name-bar-btn { font-size: 0.88rem; padding: 8px 18px; }

  /* Modal */
  .modal { max-width: 480px; }
  .modal-header { padding: 18px 20px; }
  .modal-header h2 { font-size: 1.2rem; }
  .modal-body { padding: 20px; }
  .name-modal-input { font-size: 1.15rem; padding: 16px; }
  .worksite-modal-select { font-size: 1.05rem; padding: 16px; }
  .payment-modal { max-width: 420px; }
  .payment-amount-display { font-size: 2.2rem; }

  /* Footer */
  .app-footer { padding: 16px 32px; font-size: 0.95rem; letter-spacing: 1px; }
  #main { padding-bottom: 80px; }
  .footer-share-btn { width: 40px; height: 40px; font-size: 1.15rem; line-height: 40px; }
  .order-list-scroll { max-height: 320px; }

  /* Empty state */
  .empty-state { padding: 80px 40px; }
  .empty-icon { font-size: 4rem; }
  .empty-state p { font-size: 1rem; }

  /* Toast */
  .toast { font-size: 1rem; padding: 14px 28px; }

  /* Hide WeChat browser guide on desktop */
  .wx-guide-overlay.show { display: none !important; }

  /* Profile / Reorder desktop scaling */
  .profile-hint { font-size: 0.85rem; }
  .prefs-badge { font-size: 0.75rem; padding: 3px 10px; }
  .preferred-badge { font-size: 0.75rem; padding: 3px 10px; }
  .btn-reorder { font-size: 0.78rem; padding: 3px 12px; border-radius: 16px; }

  /* Language button */
  .lang-btn { font-size: 0.8rem; padding: 5px 12px; }
  .lang-btn-prominent { font-size: 0.9rem; padding: 7px 16px; }
}

/* ===== Large Desktop（顾客端大屏 1025px+） ===== */
@media (min-width: 1025px) {
  #app { max-width: 920px; }
  #main { padding: 28px; }

  .meal-card-img { height: 260px; }
  .meal-card-body { padding: 24px 28px; }
  .meal-card-title { font-size: 1.3rem; }

  .price-bar { padding: 16px 24px; margin: 0 -28px -24px -28px; }
  .price-bar-value { font-size: 1.6rem; }

  .app-header { padding: 18px 28px; min-height: 64px; }
  .app-header h1 { font-size: 1.35rem; }

  .section-title { font-size: 1.25rem; }
  .modal { max-width: 520px; }
}

/* ===== 电话输入 & 档案提示 ===== */
.profile-hint {
  margin-top: 6px; padding: 8px 12px;
  border-radius: 8px; font-size: 0.82rem;
  line-height: 1.4; background: #f0fdf4;
}

/* ===== 偏好标记 ===== */
.prefs-badge {
  display: inline-block; font-size: 0.7rem;
  background: linear-gradient(135deg, #f59e0b, #e85d04);
  color: #fff; padding: 2px 8px; border-radius: 10px;
  margin-left: 6px; vertical-align: middle;
  font-weight: 500; white-space: nowrap;
}
.preferred-badge {
  display: inline-block; font-size: 0.7rem;
  background: #fffbeb; color: #f59e0b;
  border: 1px solid #fde68a; padding: 2px 8px;
  border-radius: 10px; margin-left: 6px;
  vertical-align: middle; font-weight: 600;
}
.preferred-meal {
  border: 2px solid #f59e0b !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}
.preferred-highlight {
  animation: prefHl 2s ease-out;
}
@keyframes prefHl {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  50% { box-shadow: 0 0 24px 8px rgba(245, 158, 11, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ===== 再来一单按钮 ===== */
.btn-reorder {
  display: inline-block; font-size: 0.72rem;
  background: #fff; color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 2px 10px; border-radius: 14px;
  cursor: pointer; font-weight: 600;
  margin-left: 8px; vertical-align: middle;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-reorder:hover { background: var(--primary); color: #fff; }
.btn-reorder:active { transform: scale(0.95); }
