/* ==========================================================================
   wk-mobile-20261118.css —— 工作台「真正干活」页面的移动端适配层
   --------------------------------------------------------------------------
   只做窄屏（≤820px）。PC 端一个像素都不受影响：所有规则都在 @media 里。
   依据：2026-11-18 用 390px 宽 iframe 跑遍 112 条路由，量出 14 条横向溢出，
        并把被 overflow:hidden 裁掉的假阳性剔掉后的真实溢出点：
        · /library /images /products      右上工具条 .btn-primary 溢 17px
        · /mall/orders                    统计卡 .stat-cards 溢 28px
        · /engineering                    hero-left / hero-title 定宽 393 → 545px
        · /engineering/report              .src 区块 397px
        · /engineering/finance             .sec / .sec-head 533px
        · /engineering/ai/*（6 个）        .btn-p 定宽按钮 396px
   ========================================================================== */

@media (max-width: 820px) {

  /* ---------- 0. 通用安全网 ----------
     overflow-x:clip 而不是 hidden：clip 不产生滚动容器，
     页面里的 position:sticky 顶栏 / 吸底按钮不会被废掉 */
  html, body { overflow-x: clip; }
  img, video, canvas { max-width: 100%; }
  table { max-width: 100%; }

  /* ---------- 1. 工程模块落地页 hero（定宽 393 撑破） ---------- */
  .hero, .eng-hero { flex-wrap: wrap; }
  .hero-left, .hero-right, .hero-title, .hero-sub, .hero-actions {
    max-width: 100% !important; width: auto !important; min-width: 0 !important;
  }

  /* ---------- 2. 工程模块内页区块（report / finance / quality …） ---------- */
  .sec, .sec-head, .sec-body, .sec-foot,
  .src, .src-list, .stat-cards, .stat-card {
    max-width: 100% !important; min-width: 0 !important;
  }
  .stat-cards { flex-wrap: wrap; }
  .stat-cards > *, .stats > *, .kpi-row > * { flex: 1 1 46%; min-width: 0; }

  /* ---------- 3. 资料库 / 图片库 / 产品库 工具条 ---------- */
  .page-head, .list-head, .tool-head, .bar-head { flex-wrap: wrap; gap: 8px; }
  .page-head .btn-primary, .list-head .btn-primary, .tool-head .btn-primary { flex: 0 0 auto; }
  .btn-primary, .btn-ghost, .btn-p { max-width: 100%; }

  /* ---------- 4. 弹窗 / 抽屉不要超出视口 ---------- */
  .modal-panel, .modal-card, .drawer, .panel { max-width: calc(100vw - 20px) !important; }
  .modal-body { overflow-x: auto; }

  /* ---------- 5. 卡片标题行：标题 + 右侧按钮挤成一行时允许换行 ----------
     实测 /library /images /products 的 .card-title 里那个 flex 子项定宽 277，
     从 130 排到 407，把 390 的视口撑出 17px。 */
  .card-title { flex-wrap: wrap; min-width: 0; }
  .card-title > span { min-width: 0; flex-wrap: wrap; }
  .card-title .btn-primary { flex: 0 0 auto; }

  /* ---------- 6. 工程报告页 src 网格：两列定宽撑到 397 ---------- */
  .src-grid { grid-template-columns: 1fr !important; }
  .src { min-width: 0 !important; max-width: 100% !important; }

  /* ---------- 7. 工程首页统计卡 ---------- */
  .stat-card, .stat-sub { min-width: 0 !important; max-width: 100% !important; }

  /* ---------- 8. 宽表进横向滚动，别压成一列字 ---------- */
  .pb-table, .cmp-table, .tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---------- 9. 工程 AI 数字员工（6 个）输入行 ----------
     实测：.ask-row 只有 157 宽，里面的「发送」按钮被顶到 345..398。
     输入框让它自己收缩，按钮不够位置就换行。 */
  .ask-row { flex-wrap: wrap !important; gap: 8px; }
  .ask-row > * { min-width: 0 !important; max-width: 100% !important; }
  .ask-row input, .ask-row textarea { flex: 1 1 140px !important; width: auto !important; min-width: 0 !important; }
  .ask-row .btn-p, .ask-row button { flex: 0 0 auto !important; }

  /* ---------- 10. 造价引擎首页的宽按钮 ----------
     实测：.btn-main 里一行中文 nowrap，撑到 299.8 宽，从 108 排到 408。 */
  .btn-main { max-width: 100% !important; white-space: normal !important; height: auto !important; }

  /* ---------- 11. 工程模块落地页 hero 在窄屏直接单列 ----------
     .eng-hero 里 .hero-row 是 grid，127 宽里塞 .stats-grid 两列 57.5，
     子项 .stat-sub 从 222..279 的卡片里跑到 384..395。 */
  .hero-row { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; width: 100% !important; }
  .stat-card { width: auto !important; }
  .stat-sub { position: static !important; }
}

/* ==========================================================================
   12. 更窄（≤560px）时把外壳让出来：左图标条收窄、内容内距压小
   ========================================================================== */
@media (max-width: 560px) {
  .content { padding-left: 10px !important; padding-right: 10px !important; }
  .eng-root, .rp-root, .ai-root, .cost-page { padding-left: 0 !important; padding-right: 0 !important; }
  .sidebar { flex: 0 0 52px !important; width: 52px !important; }
}

/* ==========================================================================
   13. 外壳（左图标条 / 顶栏 / 公告条）在手机上的收口
   --------------------------------------------------------------------------
   实测 /engineering/ai/cost 390px：
     · .sidebar-brand .name 169 宽，从 -41 排到 127，压在公告条上（"标网"鬼影）
     · .page-title 只剩 37 宽，标题被截成「工…」
   ========================================================================== */
@media (max-width: 820px) {
  .sidebar-brand .name { display: none !important; }
  .sidebar-brand { justify-content: center; overflow: hidden; }
  .topbar .page-title {
    flex: 0 1 auto !important;
    max-width: 46vw !important;
    overflow: hidden !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .topbar .search { display: none !important; }     /* 顶栏搜索让位给标题；全局搜索在下面的导航行里 */
  .topbar { padding-left: 8px !important; padding-right: 8px !important; }
  .nb { font-size: 12px !important; }               /* 公告条别占太高 */
}

/* ==========================================================================
   14. 发布提示浮层（publish-hint.js）在手机上贴底，不要浮在页面中间
   ========================================================================== */
@media (max-width: 820px) {
  .wk-ph {
    left: 10px !important;
    right: 10px !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
  }
  .wk-ph ~ .wk-ph { display: none !important; }      /* 万一被重复挂载，只留一个 */
}

/* ==========================================================================
   15. 卡片「设置头」：标题 + 右上折叠按钮 + 一段说明，说明被挤成竖排
   --------------------------------------------------------------------------
   实测 /construction：「标书设置 | 配置将作为…（挤到 47px 宽，每行 4 个字）| 收起」
   ========================================================================== */
@media (max-width: 820px) {
  .settings-head { flex-wrap: wrap !important; gap: 6px 8px; }
  .settings-sub { flex: 1 1 100% !important; width: auto !important; min-width: 0 !important; }
}

/* ==========================================================================
   16. 分类 Tab：外层够放但每个 Tab 内距太大 → 「全部」被压成「全 / 部」
   实测 /library：.tab-nav 272 宽放 4 个 68 宽的 span.tab
   ========================================================================== */
@media (max-width: 820px) {
  .tab-nav { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-nav::-webkit-scrollbar { height: 0; }
  .tab-nav .tab { flex: 0 0 auto !important; white-space: nowrap !important; padding-left: 10px !important; padding-right: 10px !important; }
}

/* ==========================================================================
   17. 右下角浮层打架：AI 助手 pill 压在「发布 / 我的 / 客服」上面
   ========================================================================== */
@media (max-width: 560px) {
  .ai-fab {
    bottom: calc(104px + env(safe-area-inset-bottom)) !important;
    right: 10px !important;
    left: auto !important;
    padding: 0 12px !important;
    height: 36px !important;
    border-radius: 18px !important;
    font-size: 12px !important;
  }
  .ai-fab-label { display: none !important; }
  .ai-fab-icon { margin: 0 !important; }
}

/* ==========================================================================
   18. 工程内页 hero 右上角的小按钮被压成竖排
   --------------------------------------------------------------------------
   实测 /engineering/report：button.hero-reset 只有 42 宽，「刷新数据」竖着一列；
        /engineering/cost：同款「恢复初始数据」。
   ========================================================================== */
@media (max-width: 820px) {
  [class$="-hero"] { flex-wrap: wrap !important; }
  .hero-reset {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
    line-height: 1.3 !important;
    align-self: flex-start;
  }
}

/* ==========================================================================
   19. 手机上别露出灰色横向滚动条
   --------------------------------------------------------------------------
   实测 /biz：标签行 / 分类行是 overflow-x:auto 的横向滚动区，桌面不显滚动条，
   手机 Windows Edge 会画一条 8px 的灰条压在内容上，很难看。
   ========================================================================== */
@media (max-width: 820px) {
  html, body { scrollbar-width: none; }
  ::-webkit-scrollbar { width: 0 !important; height: 0 !important; }
  .top-nav, .subnav, .subnav-inner, .tn-inner, .tab-nav, .nb-win {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
}
