/* ==========================================================================
   移动端适配（WAP）：≤820px 生效；功能与桌面完全一致，只改版式
   - 侧边栏 → 抽屉；表格 → 卡片；弹窗/抽屉 → 全屏；底部 5 项快捷栏
   ========================================================================== */

:root { --m-bbh: 58px; }

/* 底部快捷栏：默认隐藏。
   ⚠ 它的全部样式都写在下面 ≤820px 的媒体查询里，桌面端如果还留在 DOM 里，
   就会变成一个没有样式的 <nav> + 6 个"没有尺寸的 SVG"（SVG 会撑成 100% 宽高），
   把页面拉长一大截、底部露出一大块巨型图标（用户看到的"多出来的箭头"就是这个）。 */
.m-tabbar { display: none; }

@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-vf, .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-tabs { display: none !important; }
  .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: auto; margin-top: 0; display: flex; flex-wrap: wrap; gap: 6px; }
  .gz-crumb .sp .btn { flex: 0 0 auto; min-height: 30px; font-size: 12.5px; padding: 4px 10px; border-radius: 7px; }
  .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: fixed !important; left: 0; right: 0; bottom: 0; top: auto;
    width: auto !important; max-height: 62vh !important; z-index: 870;
    border-radius: 16px 16px 0 0 !important; border: 0;
    box-shadow: 0 -8px 28px rgba(16,24,40,.18);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.ct-side-on .ct-side { display: flex; }
  .ct-side .card-b { overflow: auto; }
  .ct-side .card-h { padding: 8px 12px; }
  .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: 68vh; -webkit-overflow-scrolling: touch; }
  .bd-grid { min-width: 620px; }              /* 保证横向滚动而不是被压扁 */
  .bd-cell { min-height: 40px; }
  .bd-legend { display: none; }               /* 手机上隐藏长说明，省空间 */
  .bd-dur { flex-wrap: wrap; }
  /* 手机端去掉「热销商品」条与看板顶部操作提示：把高度全留给网格
     （热销商品在手机上没法用：要先选场地方块，而点色块会弹详情，两者抢手势） */
  .ct-hot-strip, .ct-hot-btn { display: none !important; }
  .ct-colw { display: none !important; }   /* 手机上列宽固定，不给档位按钮占地方 */
  #ctBdMeta { display: none !important; }
  .ct-left .card-h { padding: 8px 12px; min-height: 0; }

  /* ---------- 订单操作按钮：手机端两列大按钮 ---------- */
  .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-mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--m-bbh) + 6px); z-index: 865;
    display: none; background: #fff; border-radius: 13px; border: 1px solid var(--bd);
    box-shadow: 0 8px 24px rgba(16,24,40,.22); padding: 8px 10px; }
  .ct-mini.on { display: block; }
  .ct-mini-top { display: flex; align-items: center; gap: 7px; }
  .ct-mini-nm { font-size: 14px; font-weight: 700; }
  .ct-mini-mt { flex: 1; min-width: 0; font-size: 11px; color: #8f98a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ct-mini-p { font-size: 16px; font-weight: 800; color: var(--err); letter-spacing: -.3px; }
  .ct-mini-p.ok { color: #12915c; }
  .ct-mini-ops { display: grid; grid-template-columns: 1.5fr 1fr 0.9fr; gap: 6px; margin-top: 7px; }
  .ct-mini-ops .btn { min-height: 34px; height: 34px; font-size: 12.5px; padding: 0 6px; border-radius: 8px; }

  .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 { padding: 14px !important; align-items: center !important; justify-content: center !important;
    background: rgba(15,23,42,.42); }
  .modal { width: 100% !important; max-width: 100% !important; height: auto !important; max-height: 86vh !important;
    border-radius: 16px !important; margin: 0 !important; display: flex !important; flex-direction: column;
    box-shadow: 0 20px 50px rgba(15,23,42,.28); }
  .modal > .m-h { flex: 0 0 auto; padding: 14px 16px 0; font-size: 15.5px; }
  .modal > .m-b { flex: 1 1 auto; overflow: auto; padding: 14px 16px; }
  .modal > .m-f { flex: 0 0 auto; margin-top: 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--bd-2); }
  .modal > .m-f .btn { flex: 1 1 0; min-height: 42px; }
  /* 全屏大抽屉（员工/商品这类长表单）保持整屏 */
  .drawer-mask { padding: 0 !important; align-items: stretch !important; }
  .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 {
    position: relative; flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: #8a93a3; font-size: 10px; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .m-tabbar a i { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px;
    line-height: 0; font-style: normal; transition: transform .15s; }
  .m-tabbar a i svg { width: 22px; height: 22px; display: block; }
  .m-tabbar a span { font-size: 10px; line-height: 1.15; white-space: nowrap; letter-spacing: -.2px; }
  .m-tabbar a.on { color: #e8a400; }
  .m-tabbar a.on span { font-weight: 700; }
  .m-tabbar a.on i { transform: translateY(-1px); }
  .m-tabbar a.on i svg { stroke-width: 2.2; }
  .m-tabbar a .dot { position: absolute; top: 7px; left: 50%; margin: 0 0 0 6px;
    width: 7px; height: 7px; border-radius: 50%; background: #ff4d4f; display: none; }
  .m-tabbar a.has-dot .dot { display: block; }

  /* 底部按钮对应多个页面时的选择卡片 */
  .m-pick { display: flex; flex-direction: column; gap: 8px; }
  .m-pick-i { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 14px;
    border: 1px solid var(--bd); border-radius: 11px; background: #fff; font-size: 15px; font-weight: 600;
    color: var(--txt); text-align: left; }
  .m-pick-i:active { background: var(--pri-a); border-color: var(--pri); }
  .m-pick-i em { margin-left: auto; font-style: normal; color: #b9c1d1; font-size: 17px; }

  /* 抽屉里的搜索框（移动端专用） */
  .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; }
}
