:root {
  --bg: #f3efe6;
  --ink: #1a3a2f;
  --accent: #c45c26;
  --accent-2: #2f6f5e;
  --card: #fffdf8;
  --line: #d9d0c0;
  --muted: #5c6b64;
  --ok: #2f6f5e;
  --warn: #b7791f;
  --bad: #a33b2b;
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #e7f0ea 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f7e6d8 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  padding-bottom: 40px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(26, 58, 47, 0.96);
  color: #f7f3ea;
  backdrop-filter: blur(8px);
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.role-switch {
  display: flex;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 3px;
}

.role-btn {
  border: 0;
  background: transparent;
  color: #d9e5df;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.role-btn.active {
  background: #f7f3ea;
  color: var(--ink);
  font-weight: 600;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px 12px 0;
}

.tab {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 0.95rem;
}

.tab.active {
  border-color: var(--accent-2);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent-2);
}

main { padding: 8px 16px 24px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: rise 280ms ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h1 { font-size: 1.45rem; margin: 16px 0 6px; }
h2.sub { font-size: 1.05rem; margin: 28px 0 10px; color: var(--muted); }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

.list { display: flex; flex-direction: column; gap: 10px; }

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.item-title { font-weight: 650; font-size: 1.05rem; }
.item-price { color: var(--accent); font-weight: 700; white-space: nowrap; }
.item-desc { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

.qty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.qty-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.2rem;
  line-height: 1;
}

.qty-val { min-width: 1.5rem; text-align: center; font-weight: 600; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  font-size: 0.92rem;
}

.field input, .field textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  background: #fff;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
}

.row { display: flex; gap: 10px; }

.primary, .ghost, .danger {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 8px;
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  flex: 1;
}

.danger {
  background: #f8e8e4;
  color: var(--bad);
  padding: 8px 12px;
  font-size: 0.88rem;
}

.summary {
  margin-top: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
}

.card-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
}
.badge.draft { background: #ece7dc; color: #5a5448; }
.badge.submitted { background: #f6e7c8; color: var(--warn); }
.badge.confirmed { background: #d9ebe3; color: var(--ok); }
.badge.rejected { background: #f3d8d3; color: var(--bad); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.actions .primary { width: auto; margin: 0; padding: 10px 14px; }
.actions .ghost { flex: 0 0 auto; }

.meta { margin-top: 8px; color: var(--muted); font-size: 0.85rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(26, 58, 47, 0.95);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  z-index: 50;
  max-width: 90vw;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.item-with-img {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dish-media {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #efe8dc;
  line-height: 0;
}

.dish-thumb {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  object-position: center;
  vertical-align: middle;
}

.item-body { flex: 1; min-width: 0; width: 100%; }

.img-preview {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #efe8dc;
  margin-top: 4px;
}

.img-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  object-position: center;
}

.tabs .tab[hidden] { display: none !important; }
.view[hidden] { display: none !important; }

body[data-role="orderer"] #navTabs {
  grid-template-columns: 1fr;
}
body[data-role="confirmer"] #navTabs {
  grid-template-columns: 1fr 1fr;
}

.landing-main {
  max-width: 420px;
  margin: 0 auto;
  padding: 64px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-hero {
  font-size: 2rem;
  margin: 0 0 4px;
  color: var(--ink);
}

.entry-link {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1.05rem;
}

.entry-link.orderer {
  background: var(--accent);
  color: #fff;
}

.entry-link.confirmer {
  background: var(--accent-2);
  color: #fff;
}

.stars { letter-spacing: 1px; }
.stars .on { color: #d4a017; }
.stars .off { color: #cfc6b6; }

.meta-row {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.cat-title {
  margin: 18px 0 8px;
  font-size: 1.05rem;
  color: var(--accent-2);
}

.empty-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
}

body[data-page="confirmer"] #navTabs {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ===== 外卖式菜单：左分类 + 右列表 ===== */
body[data-page="orderer"] {
  padding-bottom: 0;
  height: 100vh;
  overflow: hidden;
}
body[data-page="orderer"] .top {
  flex-shrink: 0;
}
.order-page.view.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  animation: none;
  max-width: none;
  margin: 0;
  padding: 0;
}
.menu-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  background: #f6f3ec;
}
.cat-nav {
  width: 84px;
  flex-shrink: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #ebe6dc;
  overscroll-behavior: contain;
}
.cat-nav-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 16px 8px;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
  position: relative;
}
.cat-nav-item.active {
  background: #fffdf8;
  color: var(--ink);
  font-weight: 700;
}
.cat-nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}
.menu-scroll {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fffdf8;
  overscroll-behavior: contain;
}
.menu-panel {
  padding: 0 10px 16px;
}
.menu-sec-title {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -10px 8px;
  padding: 10px 12px 8px;
  background: #fffdf8;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.food-item {
  padding: 12px 4px 14px;
  border-bottom: 1px solid #eee7da;
}
.food-name {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0 0 10px;
  line-height: 1.3;
}
.food-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.food-pic {
  width: 92px;
  height: 92px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #efe8dc;
  position: relative;
}
.food-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  /* 防止滚动时闪：禁止指针事件与拖拽，固定尺寸盒 */
  pointer-events: none;
  -webkit-user-drag: none;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.food-pic .ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
}
.food-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.food-price {
  color: var(--accent);
  font-weight: 800;
  font-size: 1.05rem;
}
.food-meta .meta-row {
  margin: 0;
  font-size: 0.8rem;
}
.food-meta .qty-row {
  margin-top: auto;
  justify-content: flex-end;
}
.order-footer {
  flex-shrink: 0;
  background: rgba(255,253,248,0.97);
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.field.compact { margin: 0 0 8px; }
.footer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.footer-bar .summary {
  flex: 1;
  margin: 0;
  text-align: left;
  font-size: 1.1rem;
}
.primary.compact {
  width: auto;
  margin: 0;
  padding: 12px 20px;
  white-space: nowrap;
}

/* 确认方菜品列表也用左右排布 */
.food-item.manage .actions {
  margin-top: 6px;
}

/* 通用确认/提示弹窗 */
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.app-dialog[hidden] { display: none !important; }
.app-dialog-mask {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 26, 0.45);
}
.app-dialog-card {
  position: relative;
  width: min(92vw, 360px);
  background: #fffdf8;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 20px 18px 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.app-dialog-msg {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.app-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.app-dialog-actions .primary,
.app-dialog-actions .ghost {
  width: auto;
  margin: 0;
  min-width: 88px;
}
