:root {
  --primary: #ff7eb3;
  --primary-light: #ffe0ef;
  --secondary: #7ec8e3;
  --accent: #ffb347;
  --bg: #fff9fb;
  --card-bg: #ffffff;
  --text: #3d2b3d;
  --text-light: #9b7fa0;
  --border: #f0d6e8;
  --success: #6bcb77;
  --danger: #ff6b6b;
  --shadow: 0 4px 20px rgba(255, 126, 179, 0.12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.top-nav {
  background: linear-gradient(135deg, #ff7eb3, #ff9cc2);
  padding: 16px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(255, 126, 179, 0.3);
}

.top-nav h1 {
  color: white;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
}

.top-nav .subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  text-align: center;
  margin-top: 2px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.nav-tab {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-tab.active {
  background: white;
  color: var(--primary);
  font-weight: 700;
}

.page {
  display: none;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.page.active {
  display: block;
}

.category-bar {
  display: flex;
  gap: 8px;
  top: 116px;
  overflow-x: auto;
  position: sticky;
  z-index: 90;
  background: var(--bg);
  padding: 8px 0 8px 0;
  margin: 0 0 8px 0;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  background: white;
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  color: var(--text-light);
  font-weight: 500;
}

.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 100px;
}

.menu-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s;
}

.menu-card:active {
  transform: scale(0.97);
}

.menu-card .img-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #ffe0ef, #ffd6f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
  overflow: hidden;
}

.menu-card .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

.menu-card .card-body {
  padding: 10px;
}

.menu-card .dish-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-card .dish-desc {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 6px;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  min-height: 30px;
}

.menu-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.menu-card .price {
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}

.menu-card .price span {
  font-size: 11px;
}

.add-btn {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.15s;
}

.add-btn:active {
  transform: scale(0.85);
}

.sold-out-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.cart-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  background: var(--text);
  border-radius: 50px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(61, 43, 61, 0.3);
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 200;
}

.cart-bar:active {
  transform: translateX(-50%) scale(0.98);
}

.cart-icon-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-info {
  flex: 1;
}

.cart-info .cart-total {
  color: white;
  font-size: 16px;
  font-weight: 700;
}

.cart-info .cart-hint {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
}

.checkout-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.cart-bar.empty {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  display: none;
  align-items: flex-end;
}

.modal-overlay.show {
  display: flex;
}

.modal-sheet {
  background: white;
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.close-btn {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cart-item .item-emoji {
  font-size: 28px;
}

.cart-item .item-info {
  flex: 1;
}

.cart-item .item-name {
  font-size: 14px;
  font-weight: 600;
}

.cart-item .item-price {
  font-size: 13px;
  color: var(--primary);
}

.qty-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: 700;
}

.qty-num {
  font-size: 15px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.cart-summary {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 12px;
}

.cart-summary .row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
}

.cart-summary .total-row {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.remark-input {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  resize: none;
  color: var(--text);
}

.remark-input:focus {
  border-color: var(--primary);
}

.submit-order-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: linear-gradient(135deg, #ff7eb3, #ff9cc2);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
}

.success-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
}

.success-modal.show {
  display: flex;
}

.success-card {
  background: white;
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  width: 280px;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.success-card .big-emoji {
  font-size: 56px;
  margin-bottom: 12px;
}

.success-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-card p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.success-card button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.order-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.order-card .order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.order-card .order-no {
  font-size: 12px;
  color: var(--text-light);
}

.order-card .order-time {
  font-size: 12px;
  color: var(--text-light);
}

.order-card .order-items {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}

.order-card .order-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-card .order-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.order-status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
}

.status-new {
  background: #fff3cd;
  color: #856404;
}

.status-done {
  background: #d1f7d6;
  color: #1a7a2a;
}

.mark-done-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid var(--success);
  background: white;
  color: var(--success);
  cursor: pointer;
}

.empty-hint {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

.empty-hint .big {
  font-size: 48px;
  margin-bottom: 12px;
}

.admin-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-dish-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary-light);
  color: var(--primary);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
}

.dish-manage-card {
  background: white;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: center;
}

.dish-manage-card .dish-emoji {
  font-size: 32px;
  flex-shrink: 0;
}

.dish-manage-card .dish-info {
  flex: 1;
  min-width: 0;
}

.dish-manage-card .dish-info .name {
  font-size: 14px;
  font-weight: 700;
}

.dish-manage-card .dish-info .meta {
  font-size: 12px;
  color: var(--text-light);
}

.dish-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.edit-btn,
.del-btn,
.toggle-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.edit-btn {
  background: #e8f4fd;
  color: #1a73e8;
}

.del-btn {
  background: #fde8e8;
  color: var(--danger);
}

.toggle-btn {
  background: #e8fde8;
  color: var(--success);
}

.toggle-btn.off {
  background: #f5f5f5;
  color: #999;
}

.form-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  display: none;
  align-items: flex-end;
}

.form-modal.show {
  display: flex;
}

.form-sheet {
  background: white;
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.3s ease;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  color: var(--text);
  background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group textarea {
  resize: none;
  height: 80px;
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.emoji-opt {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: white;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-opt.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.img-upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.img-upload-area:hover {
  border-color: var(--primary);
}

.img-upload-area .preview-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 8px;
}

.img-upload-area p {
  font-size: 13px;
  color: var(--text-light);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-cancel {
  flex: 1;
  padding: 12px;
  background: var(--bg);
  color: var(--text-light);
  border: none;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-save {
  flex: 2;
  padding: 12px;
  background: linear-gradient(135deg, #ff7eb3, #ff9cc2);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.cat-manage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.cat-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}

.cat-tag .del-cat {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}

.add-cat-row {
  display: flex;
  gap: 8px;
}

.add-cat-row input {
  flex: 1;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.add-cat-row input:focus {
  border-color: var(--primary);
}

.add-cat-row button {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  z-index: 500;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.new-order-badge {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
}

.admin-lock {
  text-align: center;
  padding: 40px 20px;
}

.admin-lock .lock-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.admin-lock h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.admin-lock p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.pin-input {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.pin-input input {
  width: 48px;
  height: 48px;
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  outline: none;
  color: var(--text);
}

.pin-input input:focus {
  border-color: var(--primary);
}

.pin-submit {
  padding: 12px 32px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.pin-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 249, 251, 0.85);
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.loading-overlay.hide {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay p {
  font-size: 14px;
  color: var(--text-light);
}
