:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #221f1b;
  --ink-2: #6e675e;
  --ink-3: #a39a8d;
  --line: #ece4d9;
  --primary: #3c3489;
  --primary-soft: #f0eef9;
  --gold: #ef9f27;
  --gold-soft: #fdf1dc;
  --danger: #b4342a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(34, 31, 27, 0.04), 0 8px 24px rgba(34, 31, 27, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

input, textarea, select { font: inherit; color: inherit; }

a { color: var(--primary); text-decoration: none; }

.wrap { max-width: 620px; margin: 0 auto; padding: 0 16px; }

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 246, 240, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 16px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.topbar .sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.gold { background: var(--gold-soft); color: #9a6410; }

/* ---------------- 卡片 / 区块 ---------------- */
.section { margin: 18px 0 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.section-head .meta { font-size: 12.5px; color: var(--ink-3); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 明日餐单汇总 */
.sum-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.sum-row:last-child { border-bottom: 0; }
.sum-row .nm { font-weight: 600; font-size: 15px; }
.sum-row .pp {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sum-row .qt {
  margin-left: auto;
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 13px;
}
.empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
}

/* ---------------- 菜品网格 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.dish {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.dish.picked { border-color: var(--primary); }
.dish:active { transform: scale(0.99); }
.dish .ph {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #f6efe4, #efe6d8);
  overflow: hidden;
}
.dish .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dish .ph .noimg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  opacity: 0.35;
}
.dish .ph .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.dish .body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.dish .nm { font-weight: 650; font-size: 14.5px; line-height: 1.3; }
.dish .ds {
  font-size: 12.5px;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 20px;
}
.dish .foot { margin-top: auto; display: flex; justify-content: flex-end; }

/* 份数步进器 */
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fdfbf8;
  overflow: hidden;
}
.stepper button {
  width: 32px;
  height: 32px;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper button:disabled { opacity: 0.3; }
.stepper .q {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.stepper.on { border-color: var(--primary); background: var(--primary-soft); }
.stepper.on .q { color: var(--primary); }
.stepper.on button { color: var(--primary); }

/* ---------------- 底部提交条 ---------------- */
.submitbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  transform: translateY(120%);
  transition: transform 0.22s ease;
}
.submitbar.show { transform: translateY(0); }
.submitbar-in {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.submitbar .cnt { font-size: 13px; color: var(--ink-2); }
.submitbar .cnt b { color: var(--ink); font-size: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  transition: opacity 0.15s ease;
}
.btn:active { opacity: 0.85; }
.btn[disabled] { opacity: 0.45; }
.btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.gold { background: var(--gold); color: #3d2705; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f0d8d4; }
.btn.block { width: 100%; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.grow { flex: 1; }

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(24, 20, 16, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(14px);
  transition: transform 0.22s ease;
  max-height: 88vh;
  overflow-y: auto;
}
.mask.show .sheet { transform: translateY(0); }
.sheet h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.sheet .hint { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .req { color: var(--danger); margin-left: 2px; }
.input, .textarea, select.input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fdfbf8;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.textarea { height: auto; min-height: 68px; padding: 10px 12px; resize: vertical; }
.input:focus, .textarea:focus { border-color: var(--primary); background: #fff; }
.picked-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag {
  font-size: 12.5px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 9px;
  border-radius: 8px;
  font-weight: 600;
}
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.err { color: var(--danger); font-size: 13px; margin: -6px 0 12px; min-height: 18px; }

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translate(-50%, 12px);
  z-index: 60;
  background: #221f1b;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 30px 24px 24px;
}
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 700; letter-spacing: -0.2px; }
.login-card .lead { margin: 0 0 22px; font-size: 13.5px; color: var(--ink-2); }
.login-card .foot { margin: 16px 0 0; font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* ---------------- 未开放 ---------------- */
.locked {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}
.locked-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 32px 24px 24px;
  text-align: center;
}
.locked-ico {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--gold-soft);
  color: #9a6410;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 23px;
}
.locked-card h1 { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.locked-card p { margin: 0 0 6px; font-size: 13.5px; color: var(--ink-2); }
.locked-card .hrs {
  display: inline-block;
  margin: 12px 0 20px;
  padding: 6px 12px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 管理台 ---------------- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #f2ece2;
  border-radius: 12px;
  margin: 14px 0 0;
}
.tabs button {
  flex: 1;
  height: 36px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }

.a-row {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.a-row:last-child { border-bottom: 0; }
.a-row.off { opacity: 0.55; }
.a-thumb {
  width: 56px;
  height: 56px;
  border-radius: 11px;
  background: linear-gradient(135deg, #f6efe4, #efe6d8);
  flex: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ink-3);
}
.a-thumb img { width: 100%; height: 100%; object-fit: cover; }
.a-info { min-width: 0; flex: 1; }
.a-info .nm { font-weight: 650; font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.a-info .nm .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-info .ob {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #8a5a0d;
  font-size: 11px;
  font-weight: 600;
}
.a-info .ds { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-ops { display: flex; align-items: center; gap: 8px; flex: none; }

.switch {
  width: 42px;
  height: 25px;
  border-radius: 999px;
  background: #ded5c8;
  position: relative;
  transition: background 0.18s ease;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(17px); }

.stats {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fdfbf8;
}
.stat { flex: 1; }
.stat .k { font-size: 11.5px; color: var(--ink-3); }
.stat .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

.o-row { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.o-row:last-child { border-bottom: 0; }
.o-head { display: flex; align-items: center; gap: 8px; }
.o-head .who { font-weight: 650; font-size: 14.5px; }
.o-head .tm { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.o-head .del { margin-left: auto; font-size: 12.5px; color: var(--danger); }
.o-items { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.o-items .tag { background: var(--gold-soft); color: #8a5a0d; }
.o-note { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); background: #fdfbf8; border-radius: 8px; padding: 5px 9px; }

.form-row { padding: 14px; border-bottom: 1px solid var(--line); }
.form-row:last-child { border-bottom: 0; }
.form-row .lbl { font-size: 13px; font-weight: 650; margin-bottom: 8px; display: block; }
.form-row .tip { font-size: 12px; color: var(--ink-3); margin-top: 7px; }
.two-col { display: flex; align-items: center; gap: 10px; }
.two-col .sep { color: var(--ink-3); font-size: 13px; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: #fdfbf8;
}
.seg button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.5px; }

.upbox {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fdfbf8;
}
.upbox .pv {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: #f1e9dc;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 11.5px;
}
.upbox .pv img { width: 100%; height: 100%; object-fit: cover; }
.pad-bottom { padding-bottom: 90px; }
.hidden { display: none !important; }

@media (max-width: 360px) {
  .grid { gap: 10px; }
  .topbar h1 { font-size: 18px; }
}
