/* 亿帆共享工作台 —— 手机端增强样式（2026-11-02）
 * 结构：先写桌面端默认（隐藏手机专用元素），再用 (max-width:880px) 覆盖。
 * 顺序不能反 —— 媒体查询不增加特异性，后写的赢。
 */

/* ---------- 桌面端默认：这些只有手机上才出现 ---------- */
.m-swipe{display:none}
.msel{display:none}
#wfInstallBtn{
  flex:0 0 auto; border:1px solid var(--brand); background:var(--brand);
  color:#fff; border-radius:16px; padding:4px 10px; font-size:12px;
  line-height:1.3; white-space:nowrap; cursor:pointer;
}
#wfInstallBtn:hover{color:#fff; opacity:.92}

@media (max-width: 880px){

  /* ================= 1. 列表表格 → 卡片 ================= */
  table[data-mcard="1"]{
    display:block; width:100%; min-width:0!important; border:0; font-size:13px;
    border-collapse:separate;
  }
  table[data-mcard="1"] thead{display:none}
  table[data-mcard="1"] tbody{display:block}
  table[data-mcard="1"] tbody tr{
    display:block; position:relative; background:var(--panel);
    border:1px solid var(--line); border-radius:var(--radius);
    padding:10px 12px; margin-bottom:9px;
  }
  table[data-mcard="1"] tbody tr:hover{background:var(--panel)}
  table[data-mcard="1"] tbody tr.m-ck{padding-right:46px}

  table[data-mcard="1"] tbody td{
    display:flex; align-items:baseline; justify-content:space-between; gap:12px;
    border:0; padding:3px 0; text-align:left;
    white-space:normal!important; width:auto!important; min-width:0!important; max-width:none!important;
  }
  table[data-mcard="1"] tbody td::before{
    content:attr(data-l); flex:0 0 auto; color:var(--muted); font-size:12px; line-height:1.6;
  }
  table[data-mcard="1"] tbody td:not([data-l])::before{display:none}

  /* 标题格：客户名 / 单号，占满整行 */
  table[data-mcard="1"] tbody td.m-title{
    display:block; font-weight:600; font-size:15px; line-height:1.45;
    padding:0 0 7px; margin-bottom:6px; border-bottom:1px solid var(--line);
  }
  table[data-mcard="1"] tbody td.m-title::before{display:none}

  /* 勾选格浮到右上角，不占一行 */
  table[data-mcard="1"] tbody td.ck{
    position:absolute; right:10px; top:9px; padding:0!important;
    width:auto!important; min-width:0!important; margin:0!important;
  }
  table[data-mcard="1"] tbody td.ck::before{display:none}
  table[data-mcard="1"] tbody td.ck input{width:20px; height:20px; margin:0}

  /* 操作按钮通栏 */
  table[data-mcard="1"] tbody td.m-act{
    display:block; padding:8px 0 0; margin-top:7px; border-top:1px dashed var(--line);
  }
  table[data-mcard="1"] tbody td.m-act::before{display:none}
  table[data-mcard="1"] tbody td.m-act button{width:100%; margin:0; padding:9px 12px; font-size:14px}

  /* 空状态 / 跨列占位行 */
  table[data-mcard="1"] tbody tr.m-span{border:0; background:none; padding:0; margin:0}
  table[data-mcard="1"] tbody tr.m-span td{
    display:block; text-align:center; padding:26px 0; color:var(--muted); border:0;
  }
  table[data-mcard="1"] tbody tr.m-span td::before{display:none}

  /* 卡片化后不需要横向滚动条 */
  .scroll-x::-webkit-scrollbar{height:0}

  /* 卡片里放输入框/下拉（花名册那种可编辑表）时，它们默认 width:100%，
     在 flex 行里会把左边的列名挤成 0 宽 —— 实际表现是「只剩一个下拉框，不知道在改哪一项」。
     留 62% 给控件，列名才有地方站。 */
  table[data-mcard="1"] tbody td > input:not([type="checkbox"]):not([type="radio"]),
  table[data-mcard="1"] tbody td > select,
  table[data-mcard="1"] tbody td > textarea{
    flex:1 1 auto; width:auto!important; min-width:0; max-width:62%;
  }
  /* 末尾那格没有列名（「我」标签、行内小按钮）：靠右收尾，别孤零零顶在左边 */
  table[data-mcard="1"] tbody td:last-child:not([data-l]):not(.ck):not(.m-act){
    justify-content:flex-end; padding-top:7px;
  }

  /* ================= 2. 按页收敛列（手机上只留能快速判断的） =================
     注意：必须挂在 [data-mcard="1"] 上。万一 JS 没跑起来（弱网或老浏览器），
     表格会退回横滚而不是「少了三列还滚不动」——降级也要能用。 */
  /* 客户列表：订单数 / 最近下单 / 客户类型 收进档案页。
     注意保留 c-contact —— 业务员在手机上最常做的就是找客户打电话，
     把电话收起来等于把最主要的功能收起来。一级分类（重要/一般）也留着，判价值要看它。 */
  table.ctbl[data-mcard="1"] td.c-ord,
  table.ctbl[data-mcard="1"] td.c-date,
  table.ctbl[data-mcard="1"] td.c-type{display:none}
  table.ctbl[data-mcard="1"] td.c-region,
  table.ctbl[data-mcard="1"] td.c-owner,
  table.ctbl[data-mcard="1"] td.c-grade,
  table.ctbl[data-mcard="1"] td.c-contact{white-space:normal!important; width:auto!important}

  /* 后台花名册：岗位 / 直属主管 / 上级经理 手机上放不下，进详情看 */
  #staffTb[data-mcard="1"] td:nth-child(6),
  #staffTb[data-mcard="1"] td:nth-child(7),
  #staffTb[data-mcard="1"] td:nth-child(8){display:none}

  /* ================= 3. 录入表格（.lines）：保持横排，给个滑动提示 ================= */
  .m-swipe{
    display:flex; align-items:center; gap:6px; margin:2px 0 6px;
    font-size:11.5px; color:var(--muted);
  }
  .m-swipe::before{content:"↔"; font-size:13px; color:var(--brand)}

  /* thead 隐藏后补的「全选本页」：客户页批量分配、改类型都靠它 */
  .msel{
    display:block; margin:0 0 8px; padding:7px 10px;
    background:var(--brand-soft); border:1px solid var(--brand-line);
    border-radius:var(--radius);
  }
  .msel label{
    display:flex; align-items:center; gap:9px; margin:0;
    font-size:13px; color:var(--text); width:100%;
  }
  .msel input{width:18px; height:18px; margin:0; flex:0 0 auto}

  /* ================= 4. 抽屉 / 弹层 ================= */
  /* 客户档案抽屉：手机上占满整屏，4 列指标压成 2 列 */
  .drawer .panel{width:100%!important}
  .metric{grid-template-columns:repeat(2,1fr)!important}
  .drawer .dbody{padding:12px 12px calc(var(--tab-h) + 16px)}
  .drawer .dhead{padding:12px}

  /* 通用弹层：贴底弹出，拇指够得着 */
  .modal-mask{align-items:flex-end!important; padding:0!important}
  .modal{
    max-width:100%!important; max-height:88vh!important;
    border-radius:14px 14px 0 0!important;
    padding:16px 14px calc(16px + env(safe-area-inset-bottom))!important;
  }
  .modal .fields, .modal .grid, .modal .grid.c2, .modal .grid.c3{grid-template-columns:1fr!important}
  .modal .fields .w2{grid-column:span 1!important}

  /* ================= 5. 页头 / 工具栏 ================= */
  .acts{margin-top:12px}
  .page-head{margin-bottom:10px}
  .page-head h2{font-size:16px}

  /* 顶栏防挤压：装了「安装」按钮之后，长名字 + logo 会把按钮顶出屏幕 */
  .appbar .logo{flex:0 0 auto}
  .appbar .who{flex:0 1 auto; min-width:0; overflow:hidden}
  .appbar .who b{display:inline-block; max-width:5.5em; overflow:hidden;
    text-overflow:ellipsis; white-space:nowrap; vertical-align:bottom}

  /* ================= 6. 安装引导 ================= */
  #wfInstallBtn{padding:5px 11px; font-size:12px}

  #wfInstallTip{
    position:fixed; left:10px; right:10px; bottom:calc(var(--tab-h) + 12px);
    z-index:200; background:var(--panel); border:1px solid var(--line);
    border-radius:12px; padding:14px 16px; box-shadow:0 10px 30px rgba(15,23,42,.18);
  }
  #wfInstallTip b{font-size:15px}
  #wfInstallTip ol{margin:8px 0 0; padding-left:20px; font-size:13px; line-height:1.9; color:var(--text)}
  #wfInstallTip .n{margin:8px 0 10px; font-size:12px; color:var(--muted)}
  #wfInstallTip button{width:100%}

  /* ================= 7. iOS 不做整页缩放 =================
     Safari 在输入框字号 <16px 时，一点输入框就把整页放大，退不回去，很难受。
     下面这些控件在各自页面的 <style> 里写死了 12.5~13px，而且那条规则比
     shell.css 的 `input{font-size:16px}` 特异性高、又在 mobile.css 之后加载，改基础规则没用。
     这里用 html body 前缀把特异性抬到 0,1,3~0,1,4 硬压回去，比逐个页面改更不容易漏。 */
  html body .move-box input, html body .move-box select,
  html body .flw-form input, html body .flw-form select,
  html body .fields input, html body .fields select, html body .fields textarea,
  html body .lines td input, html body .lines td select{font-size:16px}
  /* 字号提到 16px 之后「ppr管件仓库」更宽了，下拉的最小宽度要跟着放开，否则显示成 ppr管件… */
  html body .lines td.wh select{min-width:122px}
}

/* 超窄屏（iPhone SE 320~375）：logo 只留「亿帆」，把宽度让给名字和按钮 */
@media (max-width: 400px){
  .appbar .logo em{display:none}
  .appbar .who b{max-width:4.2em}
}

/* 合并备注格里的「拆」：手机上手指点，给足触控面积（2026-11-13） */
@media (max-width: 880px){
  html body .nsp{padding:10px 7px; font-size:12px}
}

/* 备注多行框：手机上字号 16px，避免 iOS 聚焦放大（2026-11-13 第二轮） */
@media (max-width: 880px){
  html body #lines textarea.noteTa{font-size:16px}
}
