:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #1f2937; --muted: #6b7280;
  --line: #e5e7eb; --primary: #2563eb; --primary-dark: #1d4ed8;
  --ok: #059669; --warn: #d97706; --danger: #dc2626;
  --radius: 12px; --shadow: 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--primary); text-decoration: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  height: 54px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; color: var(--text); white-space: nowrap; }
.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topnav a { padding: 7px 11px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.topnav a:hover { background: #f3f4f6; color: var(--primary); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.linkbtn { color: var(--danger); }
.wrap { max-width: 980px; margin: 0 auto; padding: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.center-box { padding-top: 12vh; }
.big-code { font-size: 56px; font-weight: 800; color: var(--primary); }
.flashes { position: fixed; top: 62px; left: 0; right: 0; z-index: 50; pointer-events: none; }
.flash { max-width: 520px; margin: 0 auto 6px; padding: 10px 14px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.12); text-align: center; }
.flash.error, .alert.error { border-color: #fecaca; color: var(--danger); background: #fef2f2; }
.flash.ok, .alert.ok { border-color: #a7f3d0; color: var(--ok); background: #ecfdf5; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--line); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; font: inherit; font-size: 15px;
  border: 1px solid #d1d5db; border-radius: 9px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { resize: vertical; min-height: 62px; }
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 14px; min-height: 40px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.btn:hover, button:hover { border-color: #9ca3af; }
.btn.primary, button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn.sm, button.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row.tight { gap: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: #f3f4f6; color: var(--muted); white-space: nowrap; }
.badge.done, .badge.ok { background: #d1fae5; color: #065f46; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.info { background: #dbeafe; color: #1e40af; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.hidden { display: none !important; }

/* 话务员下单 */
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 8px; }
.dish { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px;
  background: #fff; cursor: pointer; text-align: center; min-height: 68px; }
.dish:active { background: #eff6ff; }
.dish .name { font-size: 14px; font-weight: 600; }
.dish .price { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cart-item { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.cart-item:last-child { border-bottom: 0; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .title { font-weight: 600; }
.cart-item .meta { font-size: 12px; color: var(--muted); }
.cart-item .fields { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.cart-item .fields input { width: 58px; padding: 5px; font-size: 13px; }
.cart-item .fields input.note-input { width: 100%; }
.cart-item .fields select { width: 76px; padding: 5px; font-size: 13px; }
.cart-item .del { color: var(--danger); border: 0; background: transparent; min-height: 30px; padding: 0 6px; }
.total-bar { display: flex; justify-content: space-between; align-items: center;
  position: sticky; bottom: 0; background: #fff; padding: 10px 0 2px; }
.total-bar .amount { font-size: 22px; font-weight: 800; color: var(--danger); }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 14px; }
.tag.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.voice { border-color: #bfdbfe; color: var(--primary); }
.voice.recording { background: #fee2e2; border-color: #fca5a5; color: var(--danger); }

/* 后厨 */
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; text-align: center; }
.stat b { display: block; font-size: 26px; color: var(--primary); }
.stat span { font-size: 12px; color: var(--muted); }
.order-card { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.order-card .head { display: flex; justify-content: space-between; align-items: center;
  padding: 9px 11px; background: #f9fafb; border-bottom: 1px solid var(--line); }
.order-card .body { padding: 4px 11px 9px; }
.prep-line { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.prep-line:last-child { border-bottom: 0; }
.prep-line .txt { flex: 1; min-width: 0; }
.prep-line.done .txt { color: var(--muted); text-decoration: line-through; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs a { flex: 1; text-align: center; padding: 9px; border-radius: 9px; background: #fff;
  border: 1px solid var(--line); color: var(--muted); }
.tabs a.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.expr { font-family: ui-monospace, Menlo, Consolas, monospace; background: #eff6ff;
  padding: 3px 7px; border-radius: 6px; color: #1e40af; }

/* PC 后台 */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar { width: 210px; flex: 0 0 210px; background: #fff; border-right: 1px solid var(--line); padding: 14px 10px; }
.sidebar a { display: block; padding: 10px 12px; border-radius: 9px; color: var(--muted); margin-bottom: 3px; }
.sidebar a:hover, .sidebar a.on { background: #eff6ff; color: var(--primary); font-weight: 600; }
.admin-main { flex: 1; min-width: 0; padding: 18px 22px; max-width: calc(100vw - 210px); }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 14px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fafcff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.filter-bar { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar .fld { width: 150px; }
.filter-bar label { margin-top: 0; }
.bar-track { height: 9px; background: #f3f4f6; border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar-fill { height: 100%; background: var(--primary); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); gap: 12px; }
.inline-form { display: inline; }

/* 登录 */
.login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 26px; }
.login-card h1 { margin: 0; font-size: 24px; text-align: center; }
.login-card > p.muted { text-align: center; margin: 4px 0 18px; }
.login-card .btn { margin-top: 18px; }

@media (max-width: 640px) {
  .stat-row { flex-wrap: wrap; } .stat { min-width: 45%; }
  .admin-shell { display: block; }
  .sidebar { width: auto; flex: none; display: flex; gap: 4px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sidebar a { white-space: nowrap; margin: 0; padding: 8px 10px; }
  .admin-main { padding: 12px; max-width: 100%; }
}
