* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #D32F2F;
  --primary-dark: #B71C1C;
  --primary-light: #FFCDD2;
  --accent: #FF6F00;
  --bg: #1A1A1A;
  --bg-card: #2A2A2A;
  --bg-surface: #333;
  --text: #FFFFFF;
  --text-secondary: #B0B0B0;
  --text-muted: #888;
  --success: #4CAF50;
  --warning: #FF9800;
  --border: #3A3A3A;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.app-header .logo { font-size: 1.2rem; font-weight: 700; letter-spacing: 1px; }
.app-header .logo span { color: #FFD54F; }
.app-header .table-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}
.header-actions { display: flex; gap: 8px; }
.header-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 50%;
  color: #fff; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ===== Category Sidebar ===== */
.menu-layout {
  display: flex;
  min-height: calc(100vh - 52px - 65px);
}
.category-sidebar {
  width: 90px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px - 65px);
  -webkit-overflow-scrolling: touch;
}
.sidebar-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  gap: 4px;
}
.sidebar-cat .cat-icon { font-size: 1.3rem; line-height: 1; }
.sidebar-cat .cat-label { text-align: center; line-height: 1.2; }
.sidebar-cat.active {
  color: var(--primary);
  background: rgba(211,47,47,0.08);
  border-left-color: var(--primary);
  font-weight: 600;
}
.menu-content {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

/* ===== Menu Grid ===== */
.menu-section { padding: 12px; }
.category-title {
  font-size: 1rem; font-weight: 600;
  padding: 8px 4px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.menu-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.menu-card:active { transform: scale(0.97); }
.menu-card-img {
  width: 100%; height: 120px;
  background: linear-gradient(135deg, #3A3A3A, #2A2A2A);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  position: relative;
}
.menu-card-img .hot-tag {
  position: absolute; top: 6px; left: 6px;
  background: var(--primary);
  color: #fff; font-size: 0.65rem;
  padding: 2px 6px; border-radius: 4px;
  font-weight: 600;
}
.menu-card-body { padding: 8px 10px 10px; }
.menu-card-name {
  font-size: 0.85rem; font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-card-desc {
  font-size: 0.7rem; color: var(--text-muted);
  margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-card-bottom {
  display: flex; align-items: center;
  justify-content: space-between;
}
.menu-card-price {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}
.menu-card-price::before { content: '¥'; font-size: 0.75rem; }
.menu-card-price small { font-size: 0.65rem; color: var(--text-muted); font-weight: 400; }
.menu-card-add {
  width: 28px; height: 28px;
  background: var(--primary);
  border: none; border-radius: 50%;
  color: #fff; font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.menu-card-add:active { transform: scale(0.9); }
.menu-card-qty {
  display: flex; align-items: center; gap: 4px;
}
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
}
.qty-num { font-size: 0.85rem; min-width: 20px; text-align: center; font-weight: 600; }

/* ===== Bottom Cart Bar ===== */
.cart-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  padding-bottom: calc(8px + var(--safe-bottom));
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.cart-icon-wrap {
  position: relative;
  width: 48px; height: 48px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  cursor: pointer;
}
.cart-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent);
  color: #fff; font-size: 0.65rem;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.cart-info { flex: 1; min-width: 0; }
.cart-total { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.cart-total::before { content: '¥'; font-size: 0.8rem; }
.cart-count { font-size: 0.75rem; color: var(--text-muted); }
.cart-submit {
  background: linear-gradient(135deg, var(--accent), #FF8F00);
  border: none; border-radius: 20px;
  color: #fff; font-weight: 600;
  padding: 10px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.cart-submit:disabled { opacity: 0.4; cursor: not-allowed; }
.cart-submit:active { opacity: 0.8; }

/* ===== Cart Panel (Slide Up) ===== */
.cart-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.5);
  opacity: 0; visibility: hidden;
  transition: all 0.3s;
}
.cart-overlay.show { opacity: 1; visibility: visible; }
.cart-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 301;
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
}
.cart-panel.show { transform: translateY(0); }
.cart-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cart-panel-title { font-weight: 600; font-size: 1rem; }
.cart-clear {
  background: none; border: none;
  color: var(--text-muted); font-size: 0.8rem;
  cursor: pointer;
}
.cart-panel-body {
  flex: 1; overflow-y: auto;
  padding: 8px 16px;
}
.cart-item {
  display: flex; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 0.85rem; font-weight: 500; }
.cart-item-price { color: var(--accent); font-size: 0.85rem; font-weight: 600; margin-top: 2px; }
.cart-item-price::before { content: '¥'; }

/* ===== Order Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all 0.3s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%; max-width: 340px;
  padding: 24px;
  text-align: center;
}
.modal-box h3 { margin-bottom: 16px; font-size: 1.1rem; }
.modal-box textarea {
  width: 100%; height: 60px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.85rem;
  resize: none;
  margin-bottom: 16px;
  font-family: inherit;
}
.modal-box textarea::placeholder { color: var(--text-muted); }
.modal-summary { margin-bottom: 16px; }
.modal-summary .total { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.modal-summary .total::before { content: '合计: ¥'; font-size: 0.9rem; color: var(--text); font-weight: 400; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button {
  flex: 1; padding: 10px;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
}
.modal-btn-confirm { background: var(--primary); color: #fff; }
.modal-btn-cancel { background: var(--bg-surface); color: var(--text-secondary); }

/* ===== Order Status ===== */
.order-status-page { padding: 16px; padding-bottom: 80px; }
.order-status-page h2 { margin-bottom: 16px; }
.order-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.order-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.order-id { font-size: 0.8rem; color: var(--text-muted); }
.order-status {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.order-status.pending { background: #FFB30033; color: #FFB300; }
.order-status.preparing { background: #2196F333; color: #64B5F6; }
.order-status.served { background: #4CAF5033; color: #81C784; }
.order-status.completed { background: #555; color: #aaa; }
.order-items { margin-bottom: 8px; }
.order-item { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 3px 0; }
.order-total { text-align: right; font-weight: 600; color: var(--accent); }
.order-total::before { content: '合计: ¥'; color: var(--text); font-weight: 400; }
.order-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; padding: 6px; background: var(--bg-surface); border-radius: var(--radius-sm); }

/* ===== Admin Panel ===== */
.admin-page { padding: 16px; padding-bottom: 80px; }
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.admin-login { text-align: center; padding: 40px 20px; }
.admin-login input {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 1rem;
  width: 200px;
}
.admin-login button {
  margin-top: 10px;
  padding: 10px 30px;
  background: var(--primary);
  border: none; border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.admin-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px; text-align: center;
  border: 1px solid var(--border);
}
.stat-num { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.admin-tabs {
  display: flex; gap: 0; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.admin-tab {
  padding: 8px 16px; cursor: pointer;
  font-size: 0.85rem; color: var(--text-secondary);
  border: none; background: none;
  position: relative;
}
.admin-tab.active { color: var(--primary); font-weight: 600; }
.admin-tab.active::after {
  content: ''; position: absolute;
  bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--primary);
}
.admin-order-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--border);
}
.admin-order-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.admin-order-actions { display: flex; gap: 6px; margin-top: 8px; }
.admin-order-actions button {
  padding: 6px 12px; border: none; border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.btn-approve { background: var(--success); color: #fff; }
.btn-prepare { background: #2196F3; color: #fff; }
.btn-serve { background: #FF9800; color: #fff; }
.btn-complete { background: var(--success); color: #fff; }
.btn-delete { background: var(--primary); color: #fff; }
.table-badge-sm {
  background: var(--bg-surface);
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.75rem; font-weight: 600;
}

/* ===== QR Codes Page ===== */
.qr-page { padding: 16px; }
.qr-page h2 { margin-bottom: 16px; }
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.qr-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}
.qr-card img { width: 140px; height: 140px; margin: 0 auto 8px; }
.qr-card .table-label { font-weight: 600; font-size: 0.9rem; }
.qr-card .table-url { font-size: 0.7rem; color: var(--text-muted); word-break: break-all; }

/* ===== Notifications ===== */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 999;
  background: var(--bg-card);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--primary); }

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .menu-grid { grid-template-columns: repeat(3, 1fr); max-width: 800px; margin: 0 auto; }
  .menu-section { max-width: 800px; margin: 0 auto; }
  .category-tabs { justify-content: center; }
}
