/* ============ 点菜啦 · 样式 ============ */
:root {
  --bg: #fff7ef;
  --card: #ffffff;
  --primary: #ff6b35;
  --primary-2: #ff8f5e;
  --green: #2e9e4f;
  --text: #2d2a26;
  --muted: #9a9287;
  --border: #f0e6da;
  --shadow: 0 2px 10px rgba(255, 107, 53, 0.08);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ff7a3d, #ff5f2e);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 95, 46, 0.25);
}
.brand { font-size: 19px; font-weight: 700; letter-spacing: 1px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.22); color: #fff;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255,255,255,0.4); }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,0.25); }
.badge.ok { background: #2e9e4f; }
.badge.warn { background: #c9a227; }
.badge.demo { background: rgba(255,255,255,0.25); }

/* ---------- 角色标签页 ---------- */
.tabs {
  position: sticky; top: 60px; z-index: 15;
  display: flex; gap: 8px; padding: 10px 16px;
  background: var(--bg);
}
.tab {
  flex: 1; padding: 11px 0; border-radius: 14px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--muted);
  transition: all .15s;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow); }

/* ---------- 视图 ---------- */
main { padding: 4px 16px 90px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 分类 chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 12px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 14px; color: var(--text);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 菜品网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dish {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 15px 12px; border-radius: 14px; background: var(--card);
  border: 1.5px solid var(--border); box-shadow: var(--shadow);
  text-align: left; transition: all .12s;
}
.dish:active { transform: scale(0.97); }
.dish-emoji { font-size: 22px; }
.dish-name { font-size: 15px; font-weight: 500; flex: 1; }
.dish-check {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--green); color: #fff; font-size: 13px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.dish.on { border-color: var(--primary-2); background: #fff2ea; }

/* ---------- 买菜清单 ---------- */
.summary-card {
  background: linear-gradient(135deg, #ff7a3d, #ff5f2e); color: #fff;
  border-radius: 16px; padding: 18px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.summary-top { display: flex; align-items: center; gap: 14px; }
.summary-num { font-size: 42px; font-weight: 800; line-height: 1; }
.summary-txt { font-size: 16px; font-weight: 600; }
.summary-txt span { font-size: 13px; font-weight: 400; opacity: .9; }
.summary-hint { margin-top: 10px; font-size: 13px; opacity: .95; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty span { font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 14px; padding: 13px 14px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.row-check { font-size: 22px; width: 30px; flex: 0 0 auto; color: var(--muted); }
.row-check:active { transform: scale(0.9); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; font-weight: 600; }
.row-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row.bought { opacity: .6; }
.row.bought .row-title { text-decoration: line-through; }
.row-del { font-size: 18px; color: #c9c0b6; padding: 6px; }
.row-del:active { color: #e5484d; }

.bought-wrap { margin-top: 16px; }
.bought-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: #f1eadf; font-size: 14px; color: var(--text);
}
.bought-toggle .chev { color: var(--muted); }
.bought-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; width: 100%; }
.btn.primary:active { background: #e85a29; }
.btn.ghost { background: #f1eadf; color: var(--text); width: 100%; }

/* ---------- 底部已选栏 ---------- */
.selected-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.96); backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
}
.selected-bar-btn {
  width: 100%; padding: 13px; border-radius: 14px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 700;
}
.selected-bar-btn:active { background: #e85a29; }

/* ---------- 抽屉 / 弹窗 ---------- */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg); border-radius: 20px 20px 0 0; max-height: 75vh;
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-head .icon-btn { background: var(--border); color: var(--text); }
.sheet-body { overflow-y: auto; padding: 4px 16px; }
.sheet-item { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--border); }
.sheet-item.bought { opacity: .6; }
.sheet-item-top { display: flex; align-items: center; gap: 8px; }
.sheet-item-name { font-size: 16px; font-weight: 600; flex: 1; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #e2f4e6; color: var(--green); }
.note-input {
  width: 100%; margin-top: 10px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; font-size: 14px; outline: none;
}
.note-input:focus { border-color: var(--primary-2); }
.sheet-foot { text-align: center; font-size: 12px; color: var(--muted); padding: 12px 16px 14px; }

.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 41;
  width: calc(100% - 40px); max-width: 420px; background: #fff; border-radius: 18px;
  overflow: hidden; animation: fade .15s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-head .icon-btn { background: var(--bg); color: var(--text); }
.modal-body { padding: 8px 18px 4px; }
.modal-foot { padding: 12px 18px 18px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 14px; outline: none;
}
.field input:focus { border-color: var(--primary-2); }
.hint { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 10px 12px; }

.hidden { display: none !important; }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(10px);
  background: rgba(45,42,38,0.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
  max-width: 85vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 菜单管理 ---------- */
.add-form {
  background: var(--card); border-radius: 16px; padding: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.add-form .row2 { display: flex; gap: 10px; }
.add-form input, .add-form select {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 15px; outline: none; background: #fff;
}
.add-form input:focus, .add-form select:focus { border-color: var(--primary-2); }
.import-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.import-hint { font-size: 13px; color: var(--muted); }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; background: #f1eadf; color: var(--text); flex: 0 0 auto; }
.btn.small:active { background: #e7ddd0; }
.mrow {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--border);
}
.mrow-emoji { font-size: 20px; }
.mrow-name { flex: 1; font-size: 15px; font-weight: 600; }
.mrow-cat { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 9px; border-radius: 999px; }
.mrow-count { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
