/* ===== AI 点单 SaaS · 抹茶绿主题 ===== */
:root {
  --green: #4CAF50;
  --green-dark: #2E7D32;
  --green-light: #A5D6A7;
  --green-pale: #E8F5E9;
  --green-bg: #F4FBF4;
  --text: #2b3a2e;
  --text-sub: #7a8a7d;
  --line: #e6efe7;
  --white: #fff;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(46,125,50,.10);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--green-bg); font-size: 15px; line-height: 1.5;
  /* 微信/移动端：禁止横竖屏自动放大字号（微信内经典问题） */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 移动端滚动更顺滑 */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
}
button, input, textarea { font-family: inherit; font-size: inherit; outline: none; border: none; background: none; }
input, textarea, select { -webkit-appearance: none; appearance: none; border-radius: 0; }
a { color: var(--green-dark); text-decoration: none; }

/* 高度变量：优先用 dvh（微信/移动端地址栏收起时不跳动），回退到 vh */
:root { --vh-full: 100vh; }
@supports (height: 100dvh) { :root { --vh-full: 100dvh; } }

/* ===== 移动端 / 微信安全区 ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  /* 刘海屏底部：输入条、底部功能条留出安全距离 */
  .inputbar, .bottombar { padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
  .cartfoot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@supports (padding: env(safe-area-inset-top)) {
  /* 微信内顶部可能贴状态栏，给顶部栏留白 */
  .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
}

/* ===== 微信内置浏览器专项 ===== */
/* 微信里 body 高度用 JS 兜底（见各页 inline script），同时禁止双击缩放造成的抖动 */
html { touch-action: manipulation; }
/* 微信里表单/按钮不做默认外观，避免安卓微信给 input 加灰底 */
input:-webkit-autofill { -webkit-text-fill-color: var(--text); transition: background-color 9999s; }

/* ===== 通用 ===== */
.btn { display: inline-block; padding: 10px 20px; border-radius: 999px; background: var(--green);
  color: #fff; font-weight: 600; cursor: pointer; transition: .15s; text-align: center; }
.btn:hover { background: var(--green-dark); }
.btn.ghost { background: var(--green-pale); color: var(--green-dark); }
.btn.line { background: #fff; border: 1px solid var(--green-light); color: var(--green-dark); }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px;
  background: var(--green-pale); color: var(--green-dark); margin-left: 6px; vertical-align: middle; }
.tag.hot { background: #ffebee; color: #c62828; }

/* ===== 顾客端布局 ===== */
.app { display: flex; flex-direction: column; height: var(--vh-full); max-width: 500px; margin: 0 auto;
  background: var(--green-bg); position: relative; box-shadow: 0 0 40px rgba(0,0,0,.06); }

.topbar { flex-shrink: 0; background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; padding: 14px 18px 16px; display: flex; align-items: center; gap: 12px;
  border-radius: 0 0 18px 18px; box-shadow: 0 4px 14px rgba(46,125,50,.22); }
.topbar .logo { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.topbar .info { flex: 1; min-width: 0; }
.topbar .name { font-size: 17px; font-weight: 700; }
.topbar .sub { font-size: 12px; opacity: .85; margin-top: 2px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.topbar .table { font-size: 12.5px; background: rgba(255,255,255,.2); padding: 5px 11px;
  border-radius: 999px; flex-shrink: 0; font-weight: 600; }

/* 对话区 */
.chat { flex: 1; overflow-y: auto; padding: 16px 14px 8px; }
.msg { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.avatar { width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 17px; }
.msg.ai .avatar { background: var(--green-pale); }
.msg.user .avatar { background: #fff; border: 1px solid var(--line); }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap;
  word-break: break-word; font-size: 14.5px; }
.msg.ai .bubble { background: #fff; border-top-left-radius: 4px; box-shadow: var(--shadow); }
.msg.user .bubble { background: var(--green); color: #fff; border-top-right-radius: 4px; }

/* 菜品卡片（对话内） */
.cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.card { background: var(--green-bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.card-img { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; flex-shrink: 0; }
.card .ci { flex: 1; min-width: 0; }
.card .cn { font-size: 14px; font-weight: 600; }
.card .cd { font-size: 11.5px; color: var(--text-sub); margin-top: 2px; }
.card .cp { color: var(--green-dark); font-weight: 700; font-size: 14px; margin-top: 3px; }
.card .cp::first-letter { font-size: 11px; }

/* 输入区 */
.inputbar { flex-shrink: 0; background: #fff; padding: 9px 12px; display: flex; align-items: center;
  gap: 8px; border-top: 1px solid var(--line); }
.inputbar input[type=text] { flex: 1; background: var(--green-bg); border-radius: 999px;
  padding: 10px 16px; font-size: 14.5px; border: 1px solid transparent; transition: .15s; }
.inputbar input[type=text]:focus { border-color: var(--green-light); background: #fff; }
.mic, .send { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 18px; cursor: pointer; flex-shrink: 0; transition: .15s; }
.mic { background: var(--green-pale); color: var(--green-dark); }
.mic.recording { background: #ffcdd2; color: #c62828; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.send { background: var(--green); color: #fff; }
.send:active { background: var(--green-dark); }

/* 底部功能条 */
.bottombar { flex-shrink: 0; background: #fff; display: flex; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.bbtn { flex: 1; padding: 11px 0 12px; text-align: center; font-size: 13px; color: var(--text-sub);
  cursor: pointer; position: relative; transition: .15s; }
.bbtn:active { background: var(--green-pale); }
.bbtn .ico { display: block; font-size: 19px; margin-bottom: 2px; }
.bbtn .badge { position: absolute; top: 4px; left: 50%; margin-left: 8px; background: var(--green);
  color: #fff; font-size: 10px; min-width: 17px; height: 17px; line-height: 17px; border-radius: 9px;
  padding: 0 4px; }
.bbtn.primary { color: var(--green-dark); font-weight: 700; }

/* ===== 点单弹层 ===== */
.sheet-mask { position: fixed; inset: 0; background: rgba(20,40,25,.42); z-index: 50; opacity: 0;
  pointer-events: none; transition: .22s; }
.sheet-mask.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 50%; transform: translateX(-50%) translateY(100%);
  bottom: 0; width: 100%; max-width: 500px; height: 74vh; background: #fff;
  border-radius: 20px 20px 0 0; z-index: 51; display: flex; flex-direction: column;
  transition: transform .26s cubic-bezier(.32,.72,0,1); }
.sheet.show { transform: translateX(-50%) translateY(0); }
.sheet-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); position: relative; flex-shrink: 0; }
.sheet-head .t { font-size: 16px; font-weight: 700; text-align: center; }
.sheet-head .x { position: absolute; right: 16px; top: 12px; font-size: 20px; color: var(--text-sub);
  cursor: pointer; line-height: 1; }
.sheet-body { flex: 1; display: flex; overflow: hidden; }
.sheet-cats { width: 96px; background: var(--green-bg); overflow-y: auto; flex-shrink: 0; }
.sheet-cat { padding: 15px 6px; text-align: center; font-size: 13px; color: var(--text-sub); cursor: pointer;
  position: relative; }
.sheet-cat.active { background: #fff; color: var(--green-dark); font-weight: 700; }
.sheet-cat.active::before { content:''; position:absolute; left:0; top:50%; transform:translateY(-50%);
  width: 3px; height: 17px; background: var(--green); border-radius: 0 2px 2px 0; }
.sheet-dishes { flex: 1; overflow-y: auto; padding-bottom: 76px; }
.sd { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid #f5f9f5; gap: 10px; }
.sd-img { width: 62px; height: 62px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.sd .si { flex: 1; min-width: 0; }
.sd .sn { font-size: 14.5px; font-weight: 600; }
.sd .sc { font-size: 11.5px; color: var(--text-sub); margin-top: 2px; }
.sd .sp { color: var(--green-dark); font-weight: 700; margin-top: 3px; font-size: 14.5px; }
.sd .sp::first-letter { font-size: 11px; }
.add { width: 27px; height: 27px; border-radius: 50%; background: var(--green); color: #fff;
  font-size: 20px; line-height: 25px; text-align: center; cursor: pointer; flex-shrink: 0; }
.add:active { transform: scale(.9); }
.qty { display: flex; align-items: center; }
.qbtn { width: 25px; height: 25px; border-radius: 50%; text-align: center; line-height: 23px;
  font-size: 17px; cursor: pointer; }
.qminus { border: 1px solid #cfe0d1; color: var(--text-sub); }
.qplus { background: var(--green); color: #fff; margin-left: 3px; }
.qnum { min-width: 26px; text-align: center; font-weight: 700; }

/* 购物车悬浮条 */
.cartbar { position: absolute; left: 12px; right: 12px; bottom: 12px; background: var(--green-dark);
  color: #fff; border-radius: 999px; padding: 11px 16px; display: flex; align-items: center;
  box-shadow: 0 8px 24px rgba(46,125,50,.35); cursor: pointer; }
.cartbar .ct { flex: 1; font-size: 15px; font-weight: 700; }
.cartbar .cc { background: rgba(255,255,255,.22); padding: 3px 11px; border-radius: 999px;
  font-size: 12.5px; margin-right: 10px; }
.cartbar .go { font-size: 13.5px; font-weight: 700; }

/* 购物车抽屉 */
.cartlist { padding: 8px 0 80px; overflow-y: auto; flex: 1; }
.crow { display: flex; align-items: center; padding: 11px 18px; gap: 10px; }
.crow .cname { flex: 1; font-size: 14px; }
.crow .cprice { color: var(--green-dark); font-weight: 600; width: 76px; }
.cartfoot { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 12px 18px; display: flex; align-items: center; gap: 12px; }
.cartfoot .sum { flex: 1; font-size: 15px; }
.cartfoot .sum b { color: var(--green-dark); font-size: 19px; }

/* Toast */
.toast { position: fixed; left: 50%; top: 42%; transform: translate(-50%,-50%); background: rgba(26,46,29,.9);
  color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 14px; z-index: 200; max-width: 78%;
  text-align: center; line-height: 1.55; white-space: pre-wrap; display: none; }
.toast.show { display: block; }

/* ===== 管理端 ===== */
.admin { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.admin-login { max-width: 380px; margin: 12vh auto; background: #fff; padding: 34px 30px;
  border-radius: 18px; box-shadow: var(--shadow); }
.admin-login h1 { font-size: 21px; margin-bottom: 6px; }
.admin-login p { color: var(--text-sub); font-size: 13.5px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--green-bg); transition: .15s; }
.field input:focus, .field select:focus { border-color: var(--green-light); background: #fff; }

.a-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
  flex-wrap: wrap; gap: 12px; }
.a-head h1 { font-size: 22px; }
.a-head h1 span { font-size: 13px; color: var(--text-sub); font-weight: 400; margin-left: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 25px; font-weight: 700; color: var(--green-dark); }
.stat .l { font-size: 12.5px; color: var(--text-sub); margin-top: 3px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 18px; border-radius: 999px; background: #fff; cursor: pointer; font-size: 13.5px;
  color: var(--text-sub); border: 1px solid var(--line); transition: .15s; }
.tab.active { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }

.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 12px 14px; background: var(--green-bg); color: var(--green-dark);
  font-weight: 600; font-size: 12.5px; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #fafdfa; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.pending { background: #fff3e0; color: #e65100; }
.pill.confirmed { background: #e3f2fd; color: #1565c0; }
.pill.done { background: var(--green-pale); color: var(--green-dark); }
.pill.canceled { background: #eceff1; color: #607d8b; }
.link { color: var(--green-dark); cursor: pointer; font-weight: 600; }
.link.danger { color: #c62828; }
.muted { color: var(--text-sub); font-size: 12.5px; }
.empty-tip { padding: 50px 20px; text-align: center; color: var(--text-sub); }

/* 模态 */
.modal-mask { position: fixed; inset: 0; background: rgba(20,40,25,.42); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 18px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 440px;
  max-height: 86vh; overflow-y: auto; }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ===== 双形态渲染：桌面 / 手机 ===== */
.mobile-only { display: none !important; }
.desktop-only { display: block; }

/* 手机端头部菜单按钮 */
.mob-menu-btn { display: none; width: 40px; height: 40px; border-radius: 11px; background: var(--green-pale);
  color: var(--green-dark); font-size: 19px; line-height: 1; cursor: pointer; flex-shrink: 0;
  align-items: center; justify-content: center; }
.mob-menu-btn:active { background: var(--green-light); }

/* ===== 订单卡片（手机端） ===== */
.o-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 15px; margin-bottom: 12px; }
.o-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.o-table { font-size: 16px; font-weight: 700; color: var(--green-dark); margin-right: 8px; }
.o-amount { font-size: 18px; font-weight: 700; color: var(--green-dark); white-space: nowrap; }
.o-meta { font-size: 11.5px; color: var(--text-sub); margin-top: 6px; word-break: break-all; }
.o-items { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.o-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 3px 0; }
.o-item span:last-child { color: var(--text-sub); white-space: nowrap; }
.o-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.o-actions .link { padding: 6px 14px; background: var(--green-pale); border-radius: 999px; font-size: 12.5px; }
.o-actions .link.danger { background: #ffebee; }

/* ===== 菜单卡片（手机端） ===== */
.m-dish { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.m-dish:last-child { border-bottom: none; }
.m-dish .mi { flex: 1; min-width: 0; }
.m-dish .mn { font-size: 15px; font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.m-dish .md { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.m-dish .mp { color: var(--green-dark); font-weight: 700; font-size: 15px; margin-top: 5px; }
.m-dish .ma { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.m-dish .ma .link { padding: 5px 13px; background: var(--green-pale); border-radius: 999px; font-size: 12.5px; }
.m-dish .ma .link.danger { background: #ffebee; }
.m-cat-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 15px;
  border-bottom: 1px solid var(--line); }

/* ===== 移动端断点 ===== */
@media (max-width: 768px) {
  .mobile-only { display: block !important; }
  .desktop-only { display: none !important; }

  .admin { padding: 14px 12px 46px; }
  .app { max-width: 100%; height: var(--vh-full); }
  .sheet { max-width: 100%; }

  /* 头部：标题 + ☰ 一行；操作区收进下拉面板 */
  .a-head { flex-wrap: nowrap; align-items: center; gap: 10px; margin-bottom: 14px; position: relative; }
  .a-head h1 { flex: 1; font-size: 17px; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
  .mob-menu-btn { display: flex; }

  .head-actions { display: none; position: absolute; right: 0; top: 48px; z-index: 60;
    background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.14);
    padding: 10px; flex-direction: column; align-items: stretch; gap: 8px; min-width: 190px; }
  .head-actions.show { display: flex; }
  .head-actions .btn { width: 100%; text-align: center; }
  .head-actions .poll-dot { text-align: center; }

  /* 统计：两列 */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat { padding: 12px 14px; }
  .stat .n { font-size: 20px; }
  .stat .l { font-size: 11.5px; }

  /* Tab 横向滚动，不换行 */
  .tabs { gap: 6px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 7px 15px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }

  /* 表格所在的 panel 允许横向滚动 */
  .panel { overflow-x: auto; }
  .panel table { min-width: 560px; }

  /* 对话面板：占满、避免被截断 */
  .chat-panel { height: calc(var(--vh-full) - 250px); min-height: 360px; }
  .chat-body { padding: 14px 12px; }
  .bubble { max-width: 84%; font-size: 14px; }
  .chat-quick { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .chat-quick::-webkit-scrollbar { display: none; }

  /* 新单横幅：两行布局 */
  .new-order-banner { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .new-order-banner .nob-text { flex-basis: calc(100% - 46px); }
  .new-order-banner .btn { flex: 1; }
  .new-order-banner .nob-close { position: absolute; right: 10px; top: 8px; }

  /* 弹窗底部按钮组：手机上铺满 */
  .modal { padding: 20px 16px; border-radius: 14px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; min-width: 90px; }

  /* 小票预览可横向滚动 */
  .ticket-pre { font-size: 11.5px; padding: 12px; }

  /* 导入行：手机上换行 */
  .imp-row { flex-wrap: wrap; }
  .imp-row input { flex: 1 1 100% !important; width: auto !important; }

  /* 超管菜单弹窗：加菜行手机上换行 */
  .mg-row { flex-wrap: wrap; }
  .mg-row input { flex: 1 1 40% !important; }
  .mg-row .btn { flex: 1 1 100%; }

  /* 菜品编辑弹窗的字段在手机上正常铺满 */
  .field input, .field select { padding: 10px 12px; }
}
