/* ============================================================
   mobile.css —— 手机 / 平板自适应（2026-11-10 威哥要求）
   引入位置：workspace.html / embed_base.html / base.html / login.html / crm/login.html
   ★ 全部规则只在窄屏生效，PC 端（>820px）样式一行都不改。
   ★ 手机端主入口是 /w（workspace.html）+ iframe 内的 embed_base.html 页面，
     所以本文件既管外壳（抽屉菜单），也管 iframe 内容（表格 / 弹窗 / 表单）。
   ============================================================ */

/* ---------- 所有屏幕：触控与缩放基础（不影响 PC 视觉） ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video { max-width: 100%; }
/* 由 mobile.js 自动套在「没有横向滚动容器的表格」外，避免宽表把页面撑破 */
.m-xscroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.m-xscroll > table { margin: 0; }
/* 表格可横滑时的一行提示（宽度够时由 mobile.js 自动隐藏） */
.m-swipe-tip { display: none; font-size: 11.5px; color: #64748b; padding: 2px 2px 4px;
  letter-spacing: .3px; }

@media (max-width: 820px) {

  /* ========== ① 通用：排版 / 间距 / 输入框 ========== */
  body { font-size: 14px; overflow-x: clip; }
  .wrap, .embed-wrap { padding: 8px !important; }
  .card { padding: 10px 12px; margin-bottom: 10px; border-radius: 10px; }
  .card h2 { font-size: 15px; }
  .card-sub { font-size: 12px; }
  .home-hero { height: 88px; border-radius: 10px; }
  .home-hero-txt { padding: 0 14px; }
  .home-hero-txt .t1 { font-size: 17px; }
  .home-hero-txt .t2 { font-size: 12px; }

  /* iOS 下小于 16px 的输入框会自动放大整页，统一放大；按钮加大触控区
     ★ 模板里很多筛选框写了内联 style="min-width:240px"，手机上必须 !important 清零，
       否则一行排不下就会把整页撑宽（客户池 / A / C 工作台都踩过这个坑）。 */
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
  select, textarea {
    font-size: 16px !important; min-height: 38px;
    min-width: 0 !important; max-width: 100%; width: 100%; }
  /* 筛选 / 工具栏一律单列，避免多个输入框在 375px 里横向挤爆 */
  .row, .row.gap14, .toolbar, .toolbar .left, .imp-tools, .dash-custom, .cal-bar {
    flex-direction: column; align-items: stretch; }
  .row > *, .toolbar > *, .toolbar .left > *, .imp-tools > * { max-width: 100%; }
  .btn, .btn.sm, .page-btn, .rg, .view-tab, .ws-tab, .ws-kid, .ws-sys-head {
    min-height: 36px; }
  .btn { padding: 8px 14px; font-size: 14px; }
  .btn.sm { padding: 6px 10px; font-size: 13px; }
  .btn.w-full, .login-card .btn { min-height: 44px; }

  /* 多栏一律改单栏，保证输入框内容完整可见、不被挤压 */
  .grid, .b-form, .pf-grid, .crm-grid, .two-col, .inv-wrap,
  .dash-2col, .dash-3col { grid-template-columns: 1fr !important; }
  .stat-summary, .dash-entry, .dg-body, .um-pages {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  /* 纯 C 角首页只有「面访工作台」一张卡，独占整行更好点 */
  .dash-entry.de-solo { grid-template-columns: 1fr !important; }
  .sys-grid { grid-template-columns: 1fr !important; }
  .row, .toolbar { gap: 8px; }
  .row > *, .toolbar .left { min-width: 0; }
  .grow, .grid .field, .imp-tools .grow, .pf-form .field { width: 100%; min-width: 0; }
  .pf-form .field.grow { flex: 1 1 100%; }
  .field input, .field select, .field textarea { width: 100%; }
  input[type=month] { width: 100%; max-width: 200px; }
  .view-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 3px; }
  .view-tab { white-space: nowrap; flex: none; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .toast { max-width: 92vw; bottom: 18px; text-align: center; }

  /* ========== ② 表格：横向滑动，表头保持可见 ========== */
  .table-wrap { max-height: none; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: 8px; }
  .tbl th, .tbl td { padding: 8px 10px; }
  .tbl th { font-size: 12.5px; }
  .cal-wrap, .imp-list, .sync-prev { -webkit-overflow-scrolling: touch; }
  .cols-panel { width: calc(100vw - 24px); max-width: none; right: 0; }
  .cols-panel label { width: 50%; }
  .ms-panel { max-width: calc(100vw - 24px); }
  .ms { min-width: 0; max-width: 100%; }

  /* ========== ③ 弹窗：不再固定 520/760/900px，整屏可用 ==========
     页面里大量写了 style="width:760px"，必须 !important 覆盖。 */
  .crm-modal { padding: 3vh 8px; align-items: flex-start; }
  .crm-modal-box, .crm-modal-box.wide, .um-box {
    width: 100% !important; max-width: 100% !important; max-height: 90vh;
    padding: 14px 14px 18px; border-radius: 12px; }
  .prof-modal { padding: 2vh 0 0; align-items: center; }
  .prof-modal .prof-box {
    width: 100% !important; max-width: 100% !important; height: 94vh;
    border-radius: 12px 12px 0 0; }
  .imp-num { gap: 6px; }
  .imp-num .n { padding: 8px 4px; }
  .imp-list { max-height: 40vh; }
  .crm-modal .b-form, .crm-modal .pf-form { grid-template-columns: 1fr; }
  .crm-modal .crm-modal-box input,
  .crm-modal .crm-modal-box select { max-width: 100%; }

  /* ========== ④ CRM 首页 / 看板 / 横幅 ========== */
  .dash-hello { padding: 14px; border-radius: 12px; }
  .dh-hi { font-size: 18px; }
  .dh-right { width: 100%; flex-wrap: wrap; gap: 8px; }
  .dh-todo { min-width: 84px; padding: 6px 10px; }
  .dash-entry .de { padding: 11px 12px; }
  .dash-entry .de b { font-size: 13.5px; }
  .dash-bar { padding: 9px 10px; gap: 8px; }
  .dash-label { margin-left: 0; }
  .dash-custom { flex-wrap: wrap; }
  .dash-dt { font-size: 16px !important; }
  .dc { padding: 10px 12px; }
  .dc .dc-v { font-size: 20px; }
  .dash-chart { height: 220px; }
  .dash-chart.lg { height: 250px; }
  .chart-box { height: 280px; }
  .kpi-it { flex: 1 1 45%; min-width: 0; padding: 9px 11px; }
  .kpibar-score { margin-left: 0; }
  .flow-row { flex-direction: column; gap: 4px; }
  .flow-row .fk { flex: none; width: 100%; padding-top: 0; }
  .flow-acts { flex-wrap: wrap; }
  /* 蓝色横幅里的项目组切换器 */
  .cts { flex-wrap: wrap; gap: 6px; padding: 6px 9px; }
  .cts-sel { min-width: 0; width: 100%; font-size: 16px !important; }
  .cts-tip { display: none; }
  .sem-stats { flex-wrap: wrap; gap: 12px; }
  .sem-ops { flex-wrap: wrap; }

  /* ========== ⑤ 非嵌入页顶栏（base.html） ========== */
  .topbar { height: auto; min-height: 48px; padding: 6px 10px; gap: 8px; flex-wrap: wrap; }
  .brand { font-size: 15px; }
  .nav { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .nav-drop { position: fixed; left: 10px; right: 10px; top: 54px; min-width: 0; }
  .nav-group.open .nav-drop { display: block; }
  .nav-group.open .nav-toggle { color: #fff; background: rgba(255,255,255,.08); }
  .topbar-info { display: none; }
  .plat-user .crm-tag, .plat-user .hint, .crm-user .crm-tag { display: none; }
  .team-switch-wrap { width: 100%; }
  .team-switch { max-width: none; flex: 1; }

  /* ========== ⑥ 登录页（两张登录卡片都写死了宽度） ========== */
  .login-wrap { padding: 14px !important; min-height: 100dvh; }
  .login-card {
    width: 100% !important; max-width: 400px !important;
    padding: 22px 18px !important; border-radius: 14px !important; }
  .login-card h1 { font-size: 17px; }
  .login-card .field { margin-bottom: 14px; }
  .login-card input { min-height: 44px; }

  /* ========== ⑦ SPA 外壳：左侧菜单改抽屉，内容区全宽 ==========
     手机端 ☰ = 开/关抽屉（不再用 PC 的 folded 折叠逻辑），点菜单项自动收起。 */
  body.ws-body { overflow: hidden; }
  .ws { height: 100vh; height: 100dvh; }
  .ws-side {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 150;
    width: 78vw; max-width: 290px;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.28); }
  body.folded .ws-side { width: 78vw; max-width: 290px; }
  body.m-nav-open .ws-side { transform: translateX(0); }
  .ws-mask { display: none; position: fixed; inset: 0; z-index: 140;
    background: rgba(15,23,42,.5); }
  body.m-nav-open .ws-mask { display: block; }

  /* 抽屉里始终显示完整文字（忽略 PC 端 remembered folded 状态） */
  body.folded .ws-name, body.folded .ws-ver, body.folded .ws-home .nm,
  body.folded .ws-sys-head .nm, body.folded .ws-sys-head .ar { display: block; }
  body.folded .ws-brand { justify-content: flex-start; padding: 0 14px; }
  body.folded .ws-home, body.folded .ws-sys-head { justify-content: flex-start; padding: 10px; }
  body.folded .ws-sys.open .ws-kids {
    position: static; left: auto; margin-top: 0; min-width: 0;
    background: transparent; border: 0; box-shadow: none; padding: 2px 0 6px 30px; }
  .ws-kid { padding: 10px 12px; font-size: 14px; }
  .ws-sys-head { padding: 11px 10px; }
  .ws-brand { height: 52px; }
  .ws-side-foot { padding: 10px 14px; }

  .ws-main { width: 100%; }
  .ws-top { height: 48px; padding: 0 8px; gap: 8px; }
  .ws-fold { width: 38px; height: 34px; font-size: 17px; flex: none; }
  .ws-crumb { font-size: 12.5px; }
  .ws-user { gap: 6px; }
  .ws-user .crm-tag { display: none; }
  .ws-uname { max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ws-pwd, .ws-logout { padding: 7px 9px; white-space: nowrap; }
  .ws-tabs { height: 44px; padding: 0 8px; gap: 6px; -webkit-overflow-scrolling: touch; }
  .ws-tab { padding: 8px 12px; font-size: 13px; }
  .ws-tab .x { padding: 4px 2px; }
  .ws-tab-close-other { display: none; }
  .pwd-dlg { width: 100%; max-width: none; margin: 0 10px; }
}

/* 超窄屏（≤380px，如 iPhone SE）：统计卡仍保持两列，否则首页要滑很久 */
@media (max-width: 380px) {
  .ws-user .ws-uname { display: none; }
  .ws-top { gap: 6px; }
  .dash-entry .de { padding: 10px 11px; }
  .dash-entry .de b { font-size: 13px; }
  .stat-summary .sum-card { padding: 9px 10px; }
}
