/* ==========================================================================
   移动端适配（WAP）：≤820px 生效；功能与桌面完全一致，只改版式
   - 侧边栏 → 抽屉；表格 → 卡片；弹窗/抽屉 → 全屏；底部 5 项快捷栏
   ========================================================================== */

:root { --m-bbh: 58px; }

@media (max-width: 820px) {
  html, body { -webkit-text-size-adjust: 100%; max-width: 100%; overflow-x: hidden; }
  body { overscroll-behavior-y: contain; }

  /* 顶栏与底部栏严格贴边（避免被内容最小宽度撑出屏幕） */
  .gz-header { width: 100%; max-width: 100vw; box-sizing: border-box; }
  .m-tabbar { width: 100%; max-width: 100vw; box-sizing: border-box; }

  /* 看板 KPI：两列；双栏布局在手机上一列 */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .grid2 { grid-template-columns: 1fr !important; gap: 10px !important; }
  .kpi { padding: 10px 12px; }
  .kpi .n { font-size: 18px !important; }
  .kpi .l { font-size: 11.5px !important; }

  /* ---------- 顶部栏：只留 ☰、店名、切店、头像 ---------- */
  .gz-header { height: 50px; padding: 0 8px; gap: 6px; }
  .gz-logo { display: none; }
  .gz-collapse { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; font-size: 20px; border-radius: 8px; }
  .gz-collapse:active { background: #f0f3f8; }
  .gz-hd-store { flex: 1; min-width: 0; gap: 0; }
  .gz-hd-store select { width: 100%; max-width: 100%; height: 36px; font-size: 15px; border-radius: 8px; }
  .gz-hd-store .gz-hd-search, .gz-hd-store .btn { display: none; }        /* 搜索移到抽屉里 */
  .gz-hd-right { gap: 4px; }
  .gz-hd-right .lnk, .gz-hd-right .gz-bell, .gz-hd-right .gz-who span, .gz-hd-right .btn { display: none; }
  .gz-hd-right .hd-review { display: none; }                              /* 底部栏已有入口 */
  .gz-hd-right .gz-who { display: flex; }
  .gz-hd-right .gz-who .av { width: 30px; height: 30px; line-height: 30px; font-size: 13px; }

  /* ---------- 侧边栏 → 抽屉 ---------- */
  .gz-sider {
    width: 260px; transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 6px 0 24px rgba(0, 0, 0, .25); z-index: 300; padding-bottom: 80px;
  }
  body.m-open .gz-sider { transform: none; }
  body.collapsed .gz-sider { width: 260px; }
  body.collapsed .gz-sider .m-txt, body.collapsed .gz-sider .m-arrow, body.collapsed .gz-sider .sub { display: inline; }
  .gz-sider .m-item { padding-top: 14px; padding-bottom: 14px; font-size: 15px; }
  body.m-open::after {
    content: ""; position: fixed; inset: 50px 0 0 0; background: rgba(0, 0, 0, .35); z-index: 250;
  }

  /* ---------- 主区 ---------- */
  .gz-main { margin-left: 0 !important; padding-top: 50px; padding-bottom: calc(var(--m-bbh) + 16px); }
  .gz-crumb { height: auto !important; min-height: 42px; padding: 8px 12px; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; position: static; background: #fff; border-bottom: 1px solid var(--bd-2); }
  .gz-crumb .c2 { font-size: 15px; font-weight: 600; color: var(--txt); }
  .gz-crumb .sp { width: 100%; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
  .gz-crumb .sp .btn { flex: 1 1 auto; }
  .gz-body { padding: 10px; }

  /* 卡片/KPI 栅格 → 两列 */
  .card { border-radius: 10px; margin-bottom: 10px; }
  .card-hd { padding: 10px 12px; font-size: 14px; }
  .grid, .kpis, .cards, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .kpi, .stat { padding: 10px; }
  .kpi-v { font-size: 19px !important; }

  /* 按钮/输入：手指友好 */
  .btn, button.btn, a.btn { min-height: 40px; font-size: 15px; padding: 9px 14px; border-radius: 9px; }
  .btn.sm { min-height: 34px; font-size: 13.5px; }
  input, select, textarea { min-height: 40px; font-size: 16px !important; border-radius: 9px; }  /* 16px 防 iOS 自动放大 */
  .filters, .toolbar, .bar { flex-wrap: wrap; gap: 8px; }

  /* ---------- 表格 → 卡片列表 ---------- */
  .table-wrap { overflow: visible !important; }
  table.tb { display: block; width: 100%; font-size: 14px; }
  table.tb thead { display: none; }
  table.tb tbody { display: block; }
  table.tb tr { display: block; background: #fff; border: 1px solid var(--bd); border-radius: 10px; margin: 0 0 8px; padding: 4px 12px; }
  table.tb tr:active { background: #f7faff; }
  table.tb td {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    border: none !important; padding: 7px 0; text-align: right; line-height: 1.5;
  }
  table.tb td::before {
    content: attr(data-label); color: #8a93a3; font-size: 12.5px; font-weight: 400;
    flex: 0 0 auto; text-align: left; padding-top: 1px; white-space: nowrap;
  }
  table.tb td:empty, table.tb td[data-label=""] { display: none; }
  table.tb td.num { text-align: right; }
  table.tb td .btn { min-height: 30px; font-size: 13px; padding: 4px 10px; }
  table.tb tr.empty-row, table.tb td.empty { display: block; text-align: center; padding: 28px 0; }
  table.tb td.empty::before { content: none; }

  /* ---------- 场地看板：纵向堆叠（看板在上、结算栏在下） ---------- */
  .ct-flex { flex-direction: column; gap: 10px; }
  .ct-left { width: 100%; }
  .ct-side {
    position: static !important; width: 100% !important; flex: none !important;
    max-height: none !important; order: 2;
  }
  .bd-days { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 8px; gap: 6px; }
  .bd-days > * { flex: 0 0 auto; }
  .bd-scroll { max-height: 56vh; -webkit-overflow-scrolling: touch; }
  .bd-grid { min-width: 620px; }              /* 保证横向滚动而不是被压扁 */
  .bd-cell { min-height: 40px; }
  .bd-legend { display: none; }               /* 手机上隐藏长说明，省空间 */
  .bd-dur { flex-wrap: wrap; }

  /* ---------- 订单操作按钮：手机端两列大按钮 ---------- */
  .ct-side .od-ops { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ct-side .od-ops .btn { width: 100%; min-height: 40px; }
  .ct-side .sd-total .row b { font-size: 15px; }
  @keyframes ctSideFlash { 0% { box-shadow: 0 0 0 3px rgba(43, 111, 254, .55); } 100% { box-shadow: 0 0 0 0 rgba(43, 111, 254, 0); } }
  .ct-side-flash { animation: ctSideFlash 1.2s ease-out; border-radius: 10px; }

  /* ---------- 弹窗 / 抽屉 → 全屏 ---------- */
  .modal-mask, .drawer-mask { padding: 0 !important; align-items: stretch !important; }
  .modal, .drawer { width: 100% !important; max-width: 100% !important; max-height: 100% !important; height: 100%; border-radius: 0 !important; margin: 0 !important; }
  .modal-hd, .drawer-hd { position: sticky; top: 0; background: #fff; z-index: 5; }
  .modal-bd, .drawer-bd { padding-bottom: 24px; }
  .modal-ft, .drawer-ft { position: sticky; bottom: 0; background: #fff; padding-bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
  .modal-ft .btn, .drawer-ft .btn { flex: 1 1 0; min-height: 44px; }

  /* ---------- 场地看板：横向可滑、格子加大 ---------- */
  .ct-grid-wrap, .board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ct-cell { min-height: 40px; }

  /* ---------- 底部快捷栏 ---------- */
  .m-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--m-bbh);
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .98); border-top: 1px solid var(--bd);
    display: none; z-index: 200; backdrop-filter: saturate(180%) blur(12px);
  }
  body.m-device:not(.m-login) .m-tabbar { display: flex; }
  .m-tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: #7d8797; font-size: 11px; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .m-tabbar a i { font-size: 19px; font-style: normal; line-height: 1; }
  .m-tabbar a.on { color: var(--pri); }
  .m-tabbar a.on i { transform: translateY(-1px); }
  .m-tabbar a .dot { position: absolute; margin-left: 18px; margin-top: -14px; width: 7px; height: 7px; border-radius: 50%; background: #ff4d4f; display: none; }
  .m-tabbar a.has-dot .dot { display: block; }

  /* 抽屉里的搜索框（移动端专用） */
  .m-drawer-search { padding: 10px 12px 4px; }
  .m-drawer-search input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--bd); border-radius: 10px; }

  /* 登录页 */
  .login-card { width: calc(100% - 32px) !important; padding: 22px 18px !important; margin: 0 auto; }
  .login-card h1 { font-size: 20px; }
  .login-card input, .login-card .btn { height: 46px; font-size: 16px !important; }
}

/* 超小屏 */
@media (max-width: 360px) {
  .grid, .kpis, .cards { grid-template-columns: 1fr !important; }
  .m-tabbar a { font-size: 10px; }
}
