:root {
  --primary: #d93d3d;
  --primary-hover: #b82c2c;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --border-radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

/* 登录面板 */
.login-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  z-index: 100;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
}
.login-card {
  width: 380px;
  max-width: 100%;
  padding: 32px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
}
.brand-header {
  text-align: center;
  margin-bottom: 24px;
}
.brand-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.brand-header h2 { font-size: 20px; font-weight: 700; color: #0f172a; }
.brand-sub { font-size: 13px; color: var(--gray-600); margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}
.form-group input[type="checkbox"], .form-group input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
  cursor: pointer;
  flex-shrink: 0;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 61, 61, 0.1);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 按钮通用与 4 级操作层级规范 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  line-height: 1.25;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(217, 61, 61, 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-secondary {
  background: white;
  color: var(--gray-800);
  border-color: var(--gray-200);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}
.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
  background: #059669;
  border-color: #059669;
}
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 1px 2px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 12px; border-radius: 4px; }
.btn-outline { background: transparent; border: 1px solid currentColor; }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
}
.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--gray-800);
}

/* 顶部导航 */
.navbar {
  min-height: 56px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-right, 0px)) 8px calc(24px + env(safe-area-inset-left, 0px));
  gap: 12px;
  flex-wrap: wrap;
}
.nav-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.logo-emoji { font-size: 22px; }
.nav-title { font-weight: 700; font-size: 16px; }
.badge {
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-dev { background: #fee2e2; color: var(--primary); }
.nav-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.printer-controller {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-50);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}
.printer-label { font-size: 12px; color: var(--gray-600); }
.user-info { font-size: 13px; font-weight: 600; }

/* 二级导航 Tab 条 */
.sub-nav {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 calc(24px + env(safe-area-inset-right, 0px)) 0 calc(24px + env(safe-area-inset-left, 0px));
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.nav-tab {
  background: none;
  border: none;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.nav-tab:hover { color: var(--primary); }
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* 演示沙箱访客角色权限受限与横幅控制 (P0-5) */
.demo-banner-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #b45309;
  padding: 8px 24px;
  font-size: 13px;
  flex-wrap: wrap;
  gap: 8px;
}

body.role-demo #btn-open-category-modal,
body.role-demo #btn-open-dish-modal,
body.role-demo #btn-open-table-modal,
body.role-demo .btn-cat-action,
body.role-demo .btn-dish-action,
body.role-demo .btn-table-action,
body.role-demo #btn-save-store,
body.role-demo #btn-save-printer,
body.role-demo .logo-upload-btn-wrap {
  display: none !important;
}

/* 公开演示访客只读模式 (PUBLIC_DEMO_VIEWER) - 保持视觉完整但呈现只读锁定态 */
body.role-demo-viewer .btn-write-action,
body.role-demo-viewer #btn-save-store,
body.role-demo-viewer #btn-save-printer,
body.role-demo-viewer #btn-test-print,
body.role-demo-viewer #btn-export-csv,
body.role-demo-viewer #btn-open-category-modal,
body.role-demo-viewer #btn-open-dish-modal,
body.role-demo-viewer #btn-open-table-modal,
body.role-demo-viewer #btn-batch-generate-qr,
body.role-demo-viewer #btn-open-batch-download,
body.role-demo-viewer .btn-cat-action,
body.role-demo-viewer .btn-dish-action,
body.role-demo-viewer .btn-table-action,
body.role-demo-viewer .btn-order-kitchen,
body.role-demo-viewer .btn-order-reprint {
  opacity: 0.65;
  cursor: not-allowed !important;
}

body.role-demo-viewer .logo-upload-btn-wrap {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

.badge-public-demo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.btn-admin-login-entry {
  border-color: #cbd5e1;
  color: #475569;
  background: #ffffff;
  transition: all 0.2s;
}
.btn-admin-login-entry:hover {
  border-color: #94a3b8;
  color: #0f172a;
  background: #f8fafc;
}

.demo-readonly-badge {
  display: inline-block;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* 主体内容 */
.content-area {
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
  max-width: 1400px;
  margin: 0 auto;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-label { font-size: 13px; color: var(--gray-600); margin-bottom: 8px; }
.stat-val { font-size: 24px; font-weight: 700; color: #0f172a; }
.text-warning { color: #d97706; }
.text-success { color: var(--success); }

/* 操作与筛选条 */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  background: white;
  padding: 12px 18px;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
  flex-wrap: wrap;
  gap: 12px;
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-group label { font-size: 13px; color: var(--gray-600); }
.filter-group select, .filter-group input {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: white;
}
.filter-group input:focus, .filter-group select:focus {
  border-color: var(--primary);
}

/* 表格通用 */
.table-container {
  background: white;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.data-table th {
  background: var(--gray-50);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tr {
  transition: background-color 0.15s ease;
}
.data-table tr:hover { background: #f8fafc; }
.table-name { font-weight: 700; font-size: 14px; color: #0f172a; }
.people-tag { font-size: 12px; color: var(--gray-600); }
.order-no { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; color: var(--gray-600); font-variant-numeric: tabular-nums; }
.order-time { font-size: 12px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.item-summary { font-size: 13px; line-height: 1.4; }
.remark-tip { font-size: 12px; color: #ea580c; background: #fff7ed; padding: 2px 6px; border-radius: 4px; display: inline-block; margin-top: 4px; }
.price-tag { font-weight: 700; color: #0f172a; font-size: 14px; font-variant-numeric: tabular-nums; }

/* 菜品特有表格样式 */
.dish-cell { display: flex; align-items: center; gap: 12px; }
.dish-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--gray-100);
  flex-shrink: 0;
  border: 1px solid var(--gray-200);
}
.dish-title { font-weight: 600; font-size: 14px; color: #0f172a; }
.dish-desc { font-size: 12px; color: var(--gray-600); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-chip {
  display: inline-block;
  padding: 2px 6px;
  background: var(--gray-100);
  border-radius: 4px;
  font-size: 12px;
  color: var(--gray-600);
  margin-right: 4px;
}

/* 状态药丸 */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-unpaid { background: #f1f5f9; color: #64748b; }
.status-paid { background: #dcfce7; color: #15803d; }
.status-pending { background: #fef3c7; color: #b45309; }
.status-making { background: #fef08a; color: #854d0e; }
.status-served { background: #dbeafe; color: #1e40af; }
.status-completed { background: #f1f5f9; color: #334155; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-printed { background: #dcfce7; color: #166534; }
.status-print-fail { background: #fee2e2; color: #dc2626; cursor: pointer; }
.status-active { background: #dcfce7; color: #15803d; }
.status-disabled { background: #fee2e2; color: #991b1b; }
.status-onsale { background: #dbeafe; color: #1e40af; }
.status-soldout { background: #fee2e2; color: #b91c1c; }

/* 操作按钮列 */
.action-cell { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #94a3b8; }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* 弹窗打开时锁定背景滚动 */
body.modal-open {
  overflow: hidden !important;
}

/* 通用弹窗模态框 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
}
.modal-card {
  width: 580px;
  max-width: 95vw;
  background: white;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.modal-card-lg { width: 760px; }

/* 确保 modal-card 内部的表单继承弹性伸缩，绝不打断 flex 链路 */
.modal-card form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: #0f172a; }

.modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding-right: 6px;
  padding-bottom: 12px;
  overscroll-behavior: contain;
}

/* 粘性/固定底部按钮栏：保持在弹窗可见底部，操作触手可及 */
.modal-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  background: white;
  position: relative;
  z-index: 10;
}

/* 规格配置器 */
.spec-builder {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
}
.spec-group-box {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}
.spec-group-box:last-child {
  margin-bottom: 0;
}
.spec-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
}
.spec-group-header input.spec-group-name {
  flex: 1;
  min-width: 120px;
}
.spec-group-header select.spec-group-type {
  width: 100px;
  min-width: 90px;
  flex-shrink: 0;
  height: 38px;
  padding: 6px 8px;
  font-size: 13px;
  background: #ffffff;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-800);
}
.spec-group-header select.spec-group-type:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(217, 61, 61, 0.15);
}
.spec-group-header input[type="checkbox"].spec-group-req {
  width: 16px !important;
  height: 16px !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer;
  flex: none !important;
}
.spec-options-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 2px dashed var(--gray-200);
}
.spec-opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.spec-opt-row input[type="text"] {
  flex: 1;
  min-width: 100px;
}
.spec-opt-row input[type="number"] {
  width: 90px;
  flex-shrink: 0;
}

/* 预设图片快速选择器 */
.preset-images-box {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.preset-chip {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  position: relative;
}
.preset-chip img { width: 100%; height: 100%; object-fit: cover; }
.preset-chip:hover { border-color: var(--primary); }
.preset-chip.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(217, 61, 61, 0.4); }

/* 小票详情专用 */
.receipt-card {
  width: 440px;
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.receipt-mono {
  background: #fbfbfb;
  border: 1px dashed var(--gray-200);
  padding: 16px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1;
  border-radius: 6px;
  color: #333;
}
.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--gray-600);
}

/* 桌台与小程序码管理专有样式 (P1-C) */
.mode-alert-banner {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  transition: all 0.2s ease;
}
.mode-alert-banner.is-official {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.badge-official {
  background: #059669;
  color: white;
}
.badge-dev-alert {
  background: #d97706;
  color: white;
}

#qr-card-container svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 打印专有规则：仅输出桌牌卡片 */
@media print {
  body * {
    visibility: hidden;
  }
  #table-qr-modal,
  #table-qr-modal .modal-card,
  #qr-card-container,
  #qr-card-container * {
    visibility: visible !important;
  }
  #table-qr-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    padding: 0;
    display: block !important;
  }
  #table-qr-modal .modal-header,
  #table-qr-modal .modal-footer,
  #table-qr-modal .mode-alert-banner,
  #table-qr-modal .qr-tab-nav,
  #table-qr-modal .close-btn,
  #table-qr-modal .qr-preview-area + div {
    display: none !important;
  }
  #table-qr-modal .modal-card {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  #table-qr-modal .qr-preview-area {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }
  #qr-card-container {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto;
    width: 100% !important;
    max-width: 580px !important;
  }
}

/* 门店与打印设置卡片布局（兼容 390px 移动端视口，防止水平溢出） */
.card-grid-store {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 20px;
}

.panel-card {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  min-width: 0;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fdfdfd;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.panel-body {
  padding: 20px;
}

.text-xs {
  font-size: 12px;
}

/* P2 经营报表专有样式 */
.stat-sub {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 6px;
}

.btn-group {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--gray-200);
}

.btn-group .btn:last-child {
  border-right: none;
}

.btn-group .btn.active {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.rank-1 { background: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.rank-2 { background: #e2e8f0; color: #334155; border: 1px solid #cbd5e1; }
.rank-3 { background: #fed7aa; color: #9a3412; border: 1px solid #fdba74; }
.rank-other { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }

.ratio-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ratio-bar-bg {
  width: 60px;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.ratio-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

.spec-breakdown-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
}

.spec-breakdown-item {
  font-size: 12px;
  background: #f1f5f9;
  color: #475569;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* 响应式适配：Tablet (768px) 与 Mobile (390px) 零横向溢出与订单卡片流保障 */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .navbar {
    padding: calc(10px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) 10px calc(14px + env(safe-area-inset-left, 0px));
    gap: 8px;
  }
  .sub-nav {
    padding: 4px calc(12px + env(safe-area-inset-right, 0px)) 4px calc(12px + env(safe-area-inset-left, 0px));
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sub-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-tab {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    border-bottom-width: 2px;
    flex-shrink: 0;
  }
  .nav-tab.active {
    background: #fef2f2;
  }
  .content-area {
    padding: 16px calc(12px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .action-bar {
    padding: 12px;
  }
  .logo-upload-row {
    flex-direction: column;
    align-items: flex-start !important;
  }
}

@media (max-width: 640px) {
  /* 订单中心：深度卡片化改造（Order Card List） */
  #tab-orders .table-container {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  #tab-orders .data-table {
    display: block;
    width: 100%;
    border: none;
  }

  #tab-orders .data-table thead {
    display: none;
  }

  #tab-orders .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  #tab-orders .data-table tr.order-card-item {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }

  #tab-orders .data-table tr.order-card-item td {
    display: block;
    padding: 0;
    border: none;
    width: 100%;
  }

  /* 1. 桌号与就餐人数 */
  #tab-orders .td-order-table {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
  }

  #tab-orders .td-order-table .order-table-name {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
  }

  #tab-orders .td-order-table .order-people-count {
    font-size: 12px;
    color: #475569;
    background: #f1f5f9;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
  }

  /* 2. 订单号与下单时间 */
  #tab-orders .td-order-meta {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #64748b;
    padding-bottom: 6px !important;
    border-bottom: 1px dashed var(--gray-200) !important;
  }

  /* 3. 菜品清单与规格、备注 */
  #tab-orders .td-order-items {
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px 12px !important;
    border: 1px solid #f1f5f9 !important;
    margin: 2px 0;
  }

  #tab-orders .td-order-items .order-dish-list {
    font-weight: 600;
    font-size: 13px;
    color: #1e293b;
    line-height: 1.4;
  }

  #tab-orders .td-order-items .order-spec-list {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
  }

  #tab-orders .td-order-items .order-remark {
    margin-top: 6px;
    font-size: 12px;
  }

  /* 4. 实付金额（大号醒目排版） */
  #tab-orders .td-order-amount {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 !important;
  }

  #tab-orders .td-order-amount::before {
    content: "实付金额";
    font-size: 13px;
    font-weight: 600;
    color: #334155;
  }

  #tab-orders .td-order-amount .order-amount {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
  }

  /* 5. 业务状态标签 */
  #tab-orders .td-order-pay,
  #tab-orders .td-order-kitchen,
  #tab-orders .td-order-print {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #64748b;
  }

  #tab-orders .td-order-pay::before {
    content: "支付状态";
  }

  #tab-orders .td-order-kitchen::before {
    content: "出餐状态";
  }

  #tab-orders .td-order-print::before {
    content: "打印状态";
  }

  /* 6. 后厨操作按钮 */
  #tab-orders .td-order-actions {
    margin-top: 6px;
    padding-top: 10px !important;
    border-top: 1px solid var(--gray-100) !important;
  }

  #tab-orders .td-order-actions .order-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    width: 100%;
  }

  #tab-orders .td-order-actions .btn {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    font-size: 13px;
    text-align: center;
    justify-content: center;
  }

  /* 全局移动端操作栏与表格 */
  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .action-bar .filter-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .action-bar .filter-group select,
  .action-bar .filter-group input {
    width: 100%;
    box-sizing: border-box;
  }
  .action-bar > .btn {
    width: 100%;
  }
  .action-bar > div:last-child {
    display: flex;
    width: 100%;
  }
  .action-bar > div:last-child .btn {
    width: 100%;
  }
  .table-container {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .login-card {
    width: calc(100vw - 28px);
    padding: 24px 18px;
  }
  .panel-body {
    padding: 14px;
  }
}

