:root {
  --bg: #f5f7f4;
  --paper: #ffffff;
  --ink: #20231f;
  --muted: #73796e;
  --line: #e3e7dd;
  --brand: #0d8b72;
  --brand-dark: #08614f;
  --gold: #b37a2b;
  --danger: #bf3b34;
  --shadow: 0 16px 40px rgba(25, 40, 31, .12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(13, 139, 114, .14), transparent 28rem),
    linear-gradient(180deg, #edf7f3 0%, var(--bg) 22rem);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 104px;
  position: relative;
}

.topbar, .admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 4px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 30px; }
h2 { margin-bottom: 0; font-size: 22px; }
h3 { margin-bottom: 6px; font-size: 17px; }
.subline { margin: 0; color: var(--muted); font-size: 14px; }

.admin-entry, .ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 12px;
}

.notice {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(179, 122, 43, .28);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(234, 248, 244, .86));
}

.notice span { color: var(--muted); font-size: 13px; }

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scrollbar-width: none;
}

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

.category-tabs button, .admin-tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 13px;
  white-space: nowrap;
}

.category-tabs button.active, .admin-tabs button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.dish-list {
  display: grid;
  gap: 10px;
}

.dish-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
}

.dish-img {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(135deg, #d7eee4, #f4d8a9);
  object-fit: cover;
}

.dish-info { min-width: 0; }
.dish-info p { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.price-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { color: var(--danger); font-weight: 800; }

.qty-control {
  display: grid;
  grid-template-columns: 32px 34px 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.qty-control button {
  height: 32px;
  border: 0;
  background: #fff;
  color: var(--brand-dark);
  font-size: 20px;
}

.qty-control span { text-align: center; font-weight: 700; }
.sold { opacity: .54; }
.sold-tag { color: var(--danger); font-weight: 700; }

.cart-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  transform: translateX(-50%);
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  pointer-events: none;
  z-index: 10;
}

.cart-footer {
  width: 100%;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.cart-panel.drawer-open .cart-footer {
  display: none;
}

.cart-summary {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(8, 97, 79, .14);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.cart-summary strong {
  color: var(--danger);
}

.submit-order-btn {
  flex: 0 0 132px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand-dark);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.submit-order-btn.disabled {
  background: #7b8580;
  color: rgba(255, 255, 255, .84);
}

.cart-drawer {
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  pointer-events: auto;
  max-height: 74vh;
  overflow: auto;
}

.drawer-head, .cart-row, .order-card-head, .manage-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.cart-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.cart-row small, .order-meta, .empty {
  color: var(--muted);
}

.order-form, .manage-form {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

.primary-btn {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  padding: 12px 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%) translateY(16px);
  width: min(calc(100% - 32px), 460px);
  border-radius: 8px;
  background: rgba(32, 35, 31, .94);
  color: #fff;
  padding: 11px 14px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 20;
}

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

.admin-view {
  position: relative;
  z-index: 12;
  min-height: calc(100vh - 28px);
  margin: -18px -14px -104px;
  padding: 18px 14px 32px;
  background: var(--bg);
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.admin-tabs button { width: 100%; }
.admin-panel { display: grid; gap: 10px; }

.order-card, .manage-form, .manage-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 12px;
}

.order-card-head h3 { margin: 0; }
.order-meta { margin: 4px 0 10px; font-size: 12px; }
.group-title { margin: 10px 0 4px; color: var(--brand-dark); font-weight: 800; }
.order-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.order-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.manage-form.compact { grid-template-columns: 1fr auto; align-items: end; }
.check-line { display: flex; grid-template-columns: auto 1fr; align-items: center; color: var(--ink); }
.check-line input { width: auto; }
.manage-list { display: grid; gap: 10px; margin-top: 10px; }
.manage-row { align-items: flex-start; }
.manage-row p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.row-actions { display: grid; gap: 6px; min-width: 76px; }
.danger-btn { border-color: rgba(191, 59, 52, .28); color: var(--danger); }

.upload-field {
  display: grid;
  gap: 8px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-dropzone {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed rgba(13, 139, 114, .45);
  border-radius: 8px;
  background: rgba(13, 139, 114, .05);
  color: var(--brand-dark);
  text-align: center;
  padding: 16px;
}

.upload-dropzone span {
  font-weight: 800;
}

.upload-dropzone small {
  color: var(--muted);
}

.upload-dropzone.dragover {
  border-color: var(--brand);
  background: rgba(13, 139, 114, .12);
}

.image-preview {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.image-preview img {
  width: 112px;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg);
}

@media (min-width: 760px) {
  .app-shell {
    width: min(100%, 980px);
    padding-inline: 24px;
  }

  .dish-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cart-panel { width: min(100%, 980px); padding-inline: 24px; }
  .admin-view { margin-inline: -24px; padding-inline: 24px; }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px 10px 96px;
  }

  .topbar {
    padding-inline: 2px;
  }

  h1 {
    font-size: 26px;
  }

  .dish-card {
    grid-template-columns: 86px 1fr;
    gap: 10px;
  }

  .dish-img {
    width: 86px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .cart-panel {
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }

  .cart-drawer {
    max-height: 82vh;
    padding: 12px;
  }

  .cart-summary {
    padding: 12px;
  }

  .submit-order-btn {
    flex-basis: 112px;
    padding-inline: 10px;
  }
}
