/* ============================================================
   关澜 ERP · 手机端全局适配层   2026-12-04
   ------------------------------------------------------------
   原则：
   1) 全部规则包在 @media (max-width: 1100px) 里，电脑宽屏零影响；
   2) 只做布局与触控可用性，不改任何业务样式/颜色体系；
   3) 本文件最后加载（index.html 末尾），同特异性时按源序压住旧层。
   配套：js/mobile.js（抽屉遮罩点击关闭、宽表格横向滚动包裹）。
   ============================================================ */

/* ============ ① 侧栏抽屉 ============ */
@media (max-width: 1100px) {

  /* ①a 菜单按钮：style.css 的 .hidden{display:none!important} 把它压死了，
     手机上永远打不开抽屉——这里按同权 + 源序重新放行 */
  .app #menuBtn.menu-btn.hidden {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 38px; height: 38px;
    font-size: 20px; line-height: 1;
    flex-shrink: 0;
  }

  /* ①b 抽屉本体：脱离文档流 + 定宽。断点扩到 1100px 后，861~1100 平板带
     不能再依赖 side-nav5.css 的 ≤860 规则，这里自带完整抽屉定位。
     ⚠ transition 必须为 none：本机合成器会冻结 transform 动画（画在半路不重绘，
     抽屉留下一条 40px 的边永远挂在屏上——2026-12-04 老板截图实锤），瞬开瞬关最稳 */
  .side-nav {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: none !important;
    box-shadow: 6px 0 24px rgba(23, 61, 53, .35);
  }
  body.side-open .side-nav { transform: translateX(0) !important; }
  .side-nav {
    width: min(36vw, 140px) !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .side-nav .side-brand { padding: 10px 9px 8px; gap: 6px; }
  .side-nav .side-brand .brand-mark { width: 20px; height: 20px; font-size: 11.5px; border-radius: 5px; }
  .side-nav .side-brand-t { font-size: 11.5px; }
  .side-nav .side-grp-t { padding: 5px 8px 4px; margin: 0 4px; }
  .side-nav .side-grp-abbr { font-size: 12.5px; letter-spacing: .5px; }
  .side-nav .side-grp-sub { display: none; }
  .side-nav .side-grp-t .arr { font-size: 8px; }
  .side-nav .side-item { padding: 6px 7px 6px 10px; margin: 0 4px; font-size: 12px; gap: 6px; }
  .side-nav .side-item .ic { width: 14px; font-size: 11.5px; }
  .side-nav .side-foot { display: none; }

  /* ①c 遮罩：抽屉打开时压暗页面；点击关闭在 js/mobile.js 里 */
  body.side-open::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(10, 16, 24, .48);
    z-index: 55;                       /* 抽屉 z=60 之下、正文之上 */
    -webkit-tap-highlight-color: transparent;
  }

  /* ============ ② 顶栏 ============ */
  /* 顶栏单行不折行（theme.css 的 wrap 会让快捷导航折到第二行） */
  html body .app .gnav {
    padding: 0 10px; gap: 8px;
    height: 50px; min-height: 50px;
    flex-wrap: nowrap;
  }
  /* #flowNav 的父层 .gnav-right 不许把内容宽度顶出去 */
  html body .app .gnav .gnav-right {
    flex: 1 1 auto; min-width: 0;
    overflow: hidden;
  }

  /* 快捷导航胶囊：一行横滑，不换行不挤爆
     （带 #flowNav 提权——theme.css 的 .app .gnav .flow-nav 会顶掉普通类选择器的 min-width:0） */
  html body .app .gnav #flowNav {
    flex: 1 1 auto; min-width: 0; width: auto;
    display: flex; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .flow-nav::-webkit-scrollbar { display: none; }
  .flow-nav .fnav-link { flex: 0 0 auto; white-space: nowrap; padding: 5px 11px; }

  /* 账号胶囊：手机上只留头像+箭头，名字职位让位给导航 */
  .gnav .uchip { padding: 4px 6px; gap: 0; flex-shrink: 0; }
  .gnav .uchip .uchip-meta { display: none; }
  .gnav .uchip .uchip-caret { margin-left: 2px; }
  .gnav .icon-btn { width: 34px; height: 34px; font-size: 15px; flex-shrink: 0; }

  /* ============ ③ 面包屑行 ============
     工作台等无页头的屏会把「新建客户/新建订单」塞进 .cright，
     手机上窄行挤成竖排字。处理：标题一行省略，「数据实时同步」
     用 font-size:0 藏掉裸文本（按钮在 #qcCrumb 里恢复字号保留）。 */
  .crumb {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    overflow: hidden;
    white-space: nowrap;
  }
  .crumb #pageTitle,
  .crumb b {
    flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
  }
  .crumb .cright { font-size: 0; flex-shrink: 0; }
  .crumb .cright .live { display: none; }
  .crumb #qcCrumb { font-size: 12px; display: inline-flex; gap: 6px; }
  .crumb #qcCrumb .qc-link {
    padding: 5px 10px; white-space: nowrap;
    font-size: 12.5px;
  }

  /* ============ ④ 内容区与卡片 ============ */
  html body .app .main-col .content {
    padding: 10px 10px 18px;
    overflow-x: hidden;          /* 页面级横向溢出一律禁止（宽内容交给滚动壳） */
  }
  /* 页头（标题+操作按钮/筛选框）手机上折行：标题一行，筛选控件整行铺满
     （.page-act 桌面是绝对定位钉右上角，手机必须回文档流，否则盖住标题） */
  .page-head { flex-wrap: wrap; row-gap: 10px; }
  .page-head > div:first-child { flex: 1 1 100%; min-width: 0; }
  .page-head .page-act {
    position: static !important;
    flex-wrap: wrap; gap: 8px;
  }
  .page-head .page-act .input,
  .page-head .page-act input,
  .page-head .page-act select {
    width: 100% !important;      /* 压过元素上的 style="width:180px" */
    max-width: none !important;
    flex: 1 1 auto;
  }
  .page-head .page-act input[type="date"] { width: auto !important; flex: 1 1 40%; }
  .page-head .page-act .btn { flex: 0 0 auto; }
  .page-head .page-title-lg { font-size: 19px; }
  .content .card,
  .content .panel { padding: 12px; border-radius: 12px; }

  /* ★ 2026-12-04 二批（m10）：761~1100 平板带防撑爆。
     style.css 的 ≤1180 断点把 .grid-2-32/.grid-3 收成裸 1fr 单列，但没有
     minmax(0,1fr) + 子项 min-width:0 保护（theme.css 那套只到 ≤760）——
     财务看板等屏的宽表把列轨 min-content 撑到 1000px+，再被上面 .content 的
     overflow-x:hidden 裁死：823/950 实测右侧 ~157px 内容不可达。
     这里把 2026-11-17 的防撑爆三件套扩到整个 ≤1100 带：
     .grid-2 保持双列不收（只加子项可收缩），.grid-2-32/.grid-3 与
     style.css ≤1180 的单列意图一致（仅补 minmax(0)），列数不变。 */
  .grid-2 > *, .grid-2-32 > *, .grid-3 > *, .kpi-grid > * { min-width: 0; max-width: 100%; }
  .grid-2-32, .grid-3 { grid-template-columns: minmax(0, 1fr) !important; }
  .card { min-width: 0; max-width: 100%; }
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 左侧窄标签列（「跟进中心」「工作汇报」这类）在极窄处会被挤成一字一行，
     统一改为整行横排小标题 */
  .content h3, .content h4 { line-height: 1.4; }

  /* 卡片头（标题+选择器+操作链接）手机上允许折行，标题保持横排；
     「生产状态通栏」的工单选择器整行占满 */
  .card-head { flex-wrap: wrap; row-gap: 8px; }
  .card-head .card-title { white-space: nowrap; }
  .pflow-picker { flex-wrap: wrap; gap: 6px; width: 100%; }
  .pflow-picker label { white-space: nowrap; }
  .pflow-picker select {
    min-width: 0 !important; max-width: none !important; width: 100%;
  }

  /* 「全新定制下单」页头：标题让到第二行占满（否则被三个按钮挤成 0 宽竖排字） */
  .oco-head { flex-wrap: wrap; row-gap: 8px; }
  .oco-title { flex: 1 1 100%; min-width: 0; order: 9; }
  .oco-actions { margin-left: auto; }

  /* 「AI识图报价」三张类型卡：窄屏一列铺开（列宽被脚本内联写死，须 !important 压内联） */
  @media (max-width: 640px) {
    .aq-pick-cards { grid-template-columns: 1fr !important; gap: 10px; }
  }

  /* 弹出层里的下拉/日期等原生控件尺寸（iPhone 聚焦缩放防护：字号≥16px） */
  .content input, .content select, .content textarea,
  .modal-body input, .modal-body select, .modal-body textarea,
  .login-input, .input, select.input, input.input {
    font-size: 16px;
  }

  /* ============ ⑤ 五步工序条（flow-strip）============
     桌面是 flex:1 平分五列，390px 下每列 70px、文字一字一行。
     手机改为一行横滑，每列保持内容宽度。 */
  .flow-strip {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    gap: 4px;
  }
  .flow-strip::-webkit-scrollbar { display: none; }
  .flow-strip .flow-step { flex: 0 0 auto; min-width: max-content; padding-right: 14px; }
  .flow-strip .flow-label { white-space: nowrap; }

  /* ============ ⑥ 弹窗 ============ */
  .modal-box {
    width: min(96vw, 620px);
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 14px;
  }
  .modal-box.modal-sm { width: min(92vw, 420px); }
  .modal-body {
    max-height: calc(94vh - 132px);
    max-height: calc(94dvh - 132px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-foot {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .modal-foot button, .modal-foot .btn-ghost, .modal-foot .btn-primary, .modal-foot .btn-danger {
    min-height: 42px;
  }
  /* 弹窗拖拽是鼠标逻辑，触屏禁用避免误拖 */
  .modal-head { cursor: default !important; touch-action: pan-y; }

  /* 消息中心批量操作条：允许折行（原 flex 不换行，窄屏挤成竖条） */
  .nt-batchbar { flex-wrap: wrap; row-gap: 8px; }
  .nt-batchbar .nt-chk { white-space: nowrap; }

  /* 报价器门户（端口下单管理）页头：标题/副标题竖排堆叠，不许互挤 */
  .op-title { flex-direction: column; align-items: flex-start; gap: 4px; }
  .op-title h1 { white-space: normal; }

  /* 工作台底部三面板（在途订单/生产工序/收入结构）：JS 里内联写死的三列网格，
     手机堆成一列（选择器匹配 style 属性文本，!important 压内联；全站仅工作台这一处该写法） */
  .content div[style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* 工作台趋势面板顶部四小格（总订单/总金额/日均/峰值日）：内联四列 → 两列 */
  .content div[style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ============ ⑦ 轻提示 ============ */
  #toast {
    left: 12px; right: 12px;
    transform: none;
    text-align: center;
    max-width: none;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    word-break: break-all;
  }

  /* ============ ⑧ A4 打印预览层 ============ */
  .ql-pv-bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .ql-pv-hint { display: none; }
  .ql-pv-acts { flex-wrap: wrap; }
}

/* ============ ⑨ 登录页（≤700px 才叠）============ */
@media (max-width: 700px) {
  /* 右侧登录面板占满全宽（CNC 动画底图 theme.css 已在窄屏隐藏） */
  .login-wrap { flex-direction: column; overflow-y: auto; }
  .login-wrap .lg-right { width: 100%; min-height: 100vh; }
  .login-wrap .lg-box { width: 100%; max-width: 420px; margin: 0 auto; }
  /* 左上角 logo/数据条在小屏被裁半，登录框里已有关 logo，直接藏 */
  .login-wrap .lg-logo-corner,
  .login-wrap .lg-status-bar { display: none; }
}

/* ============ ⑩ 造型报价器暗色主题补齐（2026-12-04 老板拍板：跟随右上角◐）============
   quote.css 里 .q-native/.q-topbar/.q-type-tab/.glbk-* 写死了浅色底，
   深色主题下整页白一块黑一块、标题白字落白底成「幽灵字」。
   本段仅在 html[data-theme="dark"] 时压成暗色，浅色主题与桌面宽屏完全不受影响；
   .active 橙色选中态用 :not(.active) 排除。 */
/* .q-native 的白底是 JS 拼页时的内联 style，必须 !important 才压得过 */
html[data-theme="dark"] .q-native { background: transparent !important; }

/* 深色主题下顶栏/面包屑统一深色（跟随◐；kb-dark 看板页本就如此，这里补齐其余页面） */
html[data-theme="dark"] body .app .gnav,
html[data-theme="dark"] .gnav {
  background: transparent !important;
  border-bottom-color: rgba(255, 255, 255, .10) !important;
}
html[data-theme="dark"] .gnav .icon-btn,
html[data-theme="dark"] .gnav .menu-btn { color: rgba(255, 255, 255, .85); }
html[data-theme="dark"] .gnav .uchip {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .18);
}
html[data-theme="dark"] .gnav .uchip .user-name { color: rgba(255, 255, 255, .88); }
html[data-theme="dark"] .gnav .uchip .user-role { color: rgba(255, 255, 255, .45); }
html[data-theme="dark"] .q-topbar {
  background: linear-gradient(135deg, #0E1A24, #101C2B);
  border-color: rgba(255, 255, 255, .08);
}
html[data-theme="dark"] .q-scene-btn:not(.active),
html[data-theme="dark"] .q-type-tab:not(.active) {
  background: rgba(255, 255, 255, .06);
  color: #cfd8e0;
  border-color: rgba(255, 255, 255, .14);
}
html[data-theme="dark"] .glbk-dock {
  background: linear-gradient(135deg, #0E1A24, #101C2B);
  border-color: rgba(255, 255, 255, .08);
}
html[data-theme="dark"] .glbk-dtpl,
html[data-theme="dark"] .glbk-tplbtn,
html[data-theme="dark"] .glbk-dfoot,
html[data-theme="dark"] .glbk-doffer {
  background: rgba(255, 255, 255, .05);
  border-color: rgba(255, 255, 255, .10);
}
html[data-theme="dark"] .glbk-clear { background: rgba(226, 82, 82, .14); }
html[data-theme="dark"] .glbk-preview { color: #9B85FF; }
html[data-theme="dark"] .glbk-pdf { color: #ff9d8f; }
html[data-theme="dark"] .glbk-excel { color: #34d399; }
html[data-theme="dark"] .glbk-ofmode { color: #6ee7b7; }
