/* 茶语鲜饮 · 商家工作台 APP — 移动设计系统
   零依赖，仅本 APP 使用；与 PC 后台样式完全隔离。 */
:root {
  --brand: #16a06a;
  --brand-deep: #0f7a52;
  --brand-ink: #0c5e3e;
  --brand-soft: #e8f6ef;
  --brand-softer: #f1faf5;
  --bg: #f5f8f6;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --ink: #16241d;
  --ink-2: #5c6b63;
  --ink-3: #93a29a;
  --line: #e9f0ec;
  --line-strong: #d8e6df;
  --price: #fa5a3c;
  --warn: #b06a00;
  --warn-soft: #fff5e2;
  --danger: #d9483b;
  --danger-soft: #fdeceb;
  --ok: #16a06a;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --f-xs: 11px;
  --f-sm: 12px;
  --f-md: 14px;
  --f-lg: 16px;
  --f-xl: 20px;
  --f-2xl: 26px;

  --tap: 44px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --appbar-h: 52px;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--f-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--brand-deep); text-decoration: none; }
[hidden] { display: none !important; }

#app { min-height: 100%; }

/* ---------- 顶部栏 ---------- */
#appbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  height: calc(var(--appbar-h) + var(--safe-t));
  padding: var(--safe-t) var(--s4) 0;
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar-brand { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.appbar-logo {
  width: 28px; height: 28px; flex: none;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-deep) 100%);
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 800;
}
.appbar-title { font-size: var(--f-lg); font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.appbar-sub { font-size: var(--f-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-spacer { flex: 1; min-width: 0; }
.appbar-btn {
  min-width: var(--tap); height: 34px; padding: 0 var(--s3);
  border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand-deep);
  font-size: var(--f-sm); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.appbar-btn:active { opacity: .7; }

/* ---------- 内容区 ---------- */
#view {
  padding: calc(var(--appbar-h) + var(--safe-t) + var(--s4)) var(--s4)
           calc(var(--tabbar-h) + var(--safe-b) + var(--s6));
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
}
body.no-tabbar #view { padding-bottom: calc(var(--safe-b) + var(--s6)); }

.page-head { margin-bottom: var(--s4); }
.page-title { font-size: var(--f-xl); font-weight: 800; letter-spacing: -.2px; }
.page-sub { font-size: var(--f-sm); color: var(--ink-2); margin-top: 2px; }

.section { margin-bottom: var(--s5); }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); margin: 0 2px var(--s3);
}
.sec-title { font-size: var(--f-lg); font-weight: 700; }
.sec-extra { font-size: var(--f-sm); color: var(--ink-3); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s4);
  margin-bottom: var(--s3);
  box-shadow: 0 1px 2px rgba(16, 60, 42, .03);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s3);
}
.card-title { font-weight: 700; font-size: var(--f-md); }
.card-note { font-size: var(--f-xs); color: var(--ink-3); }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.stat-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s4);
}
.stat-label { font-size: var(--f-sm); color: var(--ink-2); }
.stat-value { font-size: var(--f-2xl); font-weight: 800; line-height: 1.25; margin-top: 2px; letter-spacing: -.5px; }
.stat-value.brand { color: var(--brand-deep); }
.stat-value.price { color: var(--price); }
.stat-value.warn { color: var(--warn); }
.stat-hint { font-size: var(--f-xs); color: var(--ink-3); margin-top: 2px; }

/* ---------- 列表行 / 卡片 ---------- */
.row { display: flex; align-items: center; gap: var(--s3); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 650; font-size: var(--f-md); }
.row-sub { font-size: var(--f-sm); color: var(--ink-2); margin-top: 2px; }
.row-meta { font-size: var(--f-xs); color: var(--ink-3); margin-top: 3px; }
.row-side { text-align: right; flex: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.thumb {
  width: 48px; height: 48px; flex: none;
  border-radius: var(--r-sm); object-fit: cover;
  background: var(--brand-soft);
  display: grid; place-items: center;
  color: var(--brand-deep); font-weight: 800; font-size: var(--f-lg);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.amount { font-size: var(--f-lg); font-weight: 800; color: var(--price); }
.amount.small { font-size: var(--f-md); }

.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px var(--s2); border-radius: var(--r-pill);
  font-size: var(--f-xs); font-weight: 600;
  background: var(--brand-soft); color: var(--brand-deep);
  white-space: nowrap;
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--brand-soft); color: var(--brand-deep); }
.bar { height: 8px; background: var(--line); border-radius: var(--r-pill); overflow: hidden; margin-top: var(--s2); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), #57c596); border-radius: var(--r-pill); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.muted { background: var(--surface-soft); color: var(--ink-2); border: 1px solid var(--line); }
.tag.plain { background: transparent; color: var(--ink-3); padding-left: 0; }

.divider { height: 1px; background: var(--line); margin: var(--s3) 0; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; font-size: var(--f-md); font-weight: 650;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn-main { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-ghost { background: var(--brand-soft); color: var(--brand-deep); border-color: transparent; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 var(--s3); font-size: var(--f-sm); border-radius: var(--r-pill); }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-off { opacity: .45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.btn-row .btn { flex: 1 1 auto; }

.fab {
  position: fixed; z-index: 25;
  right: max(var(--s4), calc((100vw - 720px) / 2 + var(--s4)));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s4));
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 28px; font-weight: 300;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(15, 122, 82, .3);
}
body.no-tabbar .fab { bottom: calc(var(--safe-b) + var(--s4)); }

/* ---------- 筛选 ---------- */
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 0 var(--s3); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 var(--s4);
  border-radius: var(--r-pill); background: var(--surface);
  border: 1px solid var(--line-strong); color: var(--ink-2);
  font-size: var(--f-sm); font-weight: 600;
  display: inline-flex; align-items: center;
}
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: var(--s4); }
.form-label { display: block; font-size: var(--f-sm); font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%; min-height: var(--tap);
  padding: 10px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--f-md);
  outline: none;
}
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.form-control { min-height: 96px; resize: vertical; line-height: 1.6; }
select.form-control { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s3); }
.form-hint { font-size: var(--f-xs); color: var(--ink-3); margin-top: 4px; }
.check-row { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); font-size: var(--f-md); }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); }

/* 套餐槽位：先选分类、再选菜品；隐藏分组里的勾选状态仍随表单提交 */
.slot-dish-group { padding: 2px 0 8px; }
.slot-dish-group[hidden] { display: none !important; }
.slot-cat-head { font-size: var(--f-xs); font-weight: 700; color: var(--brand-deep, var(--brand)); background: var(--brand-soft, #eef7f2); border-radius: var(--r-s, 8px); padding: 4px 8px; margin: 6px 0; }
.slot-cat-hint { padding: 4px 0 8px; }
.form-actions { display: flex; gap: var(--s3); margin-top: var(--s5); }
.form-actions .btn { flex: 1; }

/* ---------- 状态反馈 ---------- */
.state { text-align: center; padding: var(--s7) var(--s4); color: var(--ink-2); }
.state-title { font-size: var(--f-lg); font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.state-desc { font-size: var(--f-sm); }
.state .btn { margin-top: var(--s4); }
.spinner {
  width: 26px; height: 26px; margin: 0 auto var(--s3);
  border: 3px solid var(--brand-soft); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.notice {
  display: flex; gap: var(--s2); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--r-sm);
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: var(--f-sm); margin-bottom: var(--s3);
}
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
pre.preview {
  white-space: pre-wrap; word-break: break-all;
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--s3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--f-sm); line-height: 1.6;
  margin: 0; max-height: 46vh; overflow: auto;
}

/* ---------- 底部导航 ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-3); font-size: var(--f-xs);
}
.tab.on { color: var(--brand-deep); font-weight: 700; }
.tab-ic { width: 22px; height: 22px; display: grid; place-items: center; }
.tab-ic svg { width: 22px; height: 22px; }

/* ---------- 更多：九宫格 ---------- */
.grid-menu { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); }
.grid-cell {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--s4) var(--s2);
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  font-size: var(--f-sm); font-weight: 600; text-align: center;
}
.grid-cell:active { background: var(--brand-softer); }
.grid-ic {
  width: 40px; height: 40px; border-radius: 13px;
  background: var(--brand-soft); color: var(--brand-deep);
  display: grid; place-items: center; font-size: 18px; font-weight: 800;
}

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12, 32, 23, .42);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 720px;
  max-height: 88vh;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex; flex-direction: column;
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: var(--s4); border-bottom: 1px solid var(--line);
}
.sheet-title { font-size: var(--f-lg); font-weight: 700; }
.sheet-close { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-soft); color: var(--ink-2); font-size: 20px; line-height: 1; }
.sheet-body { padding: var(--s4); overflow-y: auto; padding-bottom: calc(var(--s4) + var(--safe-b)); }

.toast {
  position: fixed; z-index: 80;
  left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  transform: translateX(-50%);
  max-width: 84vw; padding: 10px var(--s4);
  border-radius: var(--r-pill);
  background: rgba(22, 36, 29, .92); color: #fff;
  font-size: var(--f-sm); text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .16);
}
.toast.ok { background: var(--brand-deep); }
.toast.err { background: var(--danger); }

/* ---------- 登录 ---------- */
.login-wrap { padding-top: var(--s7); }
.login-hero {
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-ink) 100%);
  color: #fff; border-radius: var(--r-lg);
  padding: var(--s6); margin-bottom: var(--s5);
}
.login-hero h1 { font-size: 22px; margin: 0 0 6px; font-weight: 800; }
.login-hero p { margin: 0; font-size: var(--f-sm); opacity: .85; }
.login-logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: rgba(255, 255, 255, .18); display: grid; place-items: center;
  font-size: 22px; font-weight: 800; margin-bottom: var(--s4);
}
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5); }
.login-tip { font-size: var(--f-xs); color: var(--ink-3); text-align: center; margin-top: var(--s4); }

/* ---------- 适配 ---------- */
@media (min-width: 560px) {
  .stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-menu { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 340px) {
  #view { padding-left: var(--s3); padding-right: var(--s3); }
  .stat-value { font-size: 21px; }
  .grid-menu { grid-template-columns: repeat(3, 1fr); }
  .btn-sm { padding: 0 var(--s2); }
}
