/* 火灵CRM 手机端 APP 外壳：仅 <=820px 且 body.is-mobile 生效 */
@media (max-width: 820px) {
  body.is-mobile {
    padding-top: 0 !important;
    background: #eef2f7;
    overscroll-behavior-y: none;
  }
  body.is-mobile .sidebar,
  body.is-mobile .sidebar-collapse,
  body.is-mobile .top-tabbar,
  body.is-mobile .mid-zone,
  body.is-mobile .topbar-search,
  body.is-mobile #quick-add,
  body.is-mobile .classic-top-action,
  body.is-mobile #theme-btn,
  body.is-mobile #view-mode-btn,
  body.is-mobile #notice-btn,
  body.is-mobile #cl-toolbar { display: none !important; }

  body.is-mobile .main { margin-left: 0 !important; width: 100%; }
  body.is-mobile .topbar {
    position: sticky; top: 0; z-index: 900;
    height: 58px; min-height: 58px; padding: 0 14px;
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(15,23,42,.04);
  }
  body.is-mobile .topbar-title {
    flex: 1; min-width: 0; font-size: 17px; font-weight: 700; color: #0f172a;
    display: flex; align-items: center; gap: 9px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  body.is-mobile .topbar-title::before {
    content: '火'; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px; font-weight: 700;
    background: linear-gradient(145deg, #0f172a, #0891b2);
    box-shadow: 0 3px 10px rgba(8,145,178,.28);
  }
  body.is-mobile .topbar-title small { display: none !important; }
  body.is-mobile .topbar-right { gap: 4px; }
  body.is-mobile .topbar-right .icon-btn { display: none !important; }
  body.is-mobile .user-chip { padding: 3px; border: 0; background: transparent; }
  body.is-mobile .user-chip .avatar { width: 34px; height: 34px; font-size: 13px; }
  body.is-mobile .user-meta { display: none; }
  body.is-mobile .content { padding: 12px 12px calc(86px + env(safe-area-inset-bottom, 0px)) !important; }
  body.is-mobile .content-inner { max-width: none; }

  body.is-mobile .breadcrumb { display: none; }
  body.is-mobile .page-head { display: block; margin: 2px 0 12px; }
  body.is-mobile .page-head h1 { font-size: 21px; line-height: 1.35; margin: 0 0 4px; }
  body.is-mobile .page-sub { font-size: 11.5px; line-height: 1.55; color: #64748b; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  body.is-mobile .page-actions { margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; }
  body.is-mobile .page-actions .btn { flex: 1 1 auto; justify-content: center; }

  body.is-mobile .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  body.is-mobile .kpi { min-height: 86px !important; padding: 12px !important; border-radius: 13px !important; }
  body.is-mobile .kpi-label { font-size: 11.5px !important; }
  body.is-mobile .kpi-value { font-size: 21px !important; }
  body.is-mobile .kpi-foot { font-size: 10.5px !important; }
  body.is-mobile .kpi-ico { width: 28px !important; height: 28px !important; font-size: 13px !important; }

  body.is-mobile .split-2,
  body.is-mobile .split-3,
  body.is-mobile .split-23,
  body.is-mobile .quick-grid,
  body.is-mobile .mini-kpi-row,
  body.is-mobile .detail-grid,
  body.is-mobile .wb-wrap,
  body.is-mobile .form-grid,
  body.is-mobile .form-grid-3 { grid-template-columns: 1fr !important; }
  body.is-mobile .stack { gap: 0 !important; }
  body.is-mobile .card { margin-bottom: 10px !important; border-radius: 13px !important; }
  body.is-mobile .card-head, body.is-mobile .card-title { padding: 11px 13px !important; }
  body.is-mobile .card-body { padding: 11px 13px !important; }
  body.is-mobile .section-title { margin-top: 12px; }

  body.is-mobile .toolbar { flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 3px; scrollbar-width: none; }
  body.is-mobile .toolbar::-webkit-scrollbar { display: none; }
  body.is-mobile .toolbar .search-box { min-width: 175px; flex: 0 0 auto; }
  body.is-mobile .filter-select { flex: 0 0 auto; height: 36px; }
  body.is-mobile .toolbar .btn { flex: 0 0 auto; }

  body.is-mobile .table-wrap { border-radius: 12px; overflow-x: auto; }
  body.is-mobile table.table { min-width: 760px; }
  body.is-mobile .table th, body.is-mobile .table td { padding: 9px 10px; font-size: 11.5px; }
  body.is-mobile .table th { font-size: 10.5px; }
  body.is-mobile .pager { padding: 8px 10px; }

  body.is-mobile .drawer {
    width: 100vw !important; max-width: 100vw !important; border-radius: 0 !important;
    height: 100dvh; top: 0; bottom: 0;
  }
  body.is-mobile .drawer-head { padding: 13px 14px !important; position: sticky; top: 0; z-index: 5; background: #fff; }
  body.is-mobile .drawer-head h2 { font-size: 16px !important; }
  body.is-mobile .drawer-body { padding: 12px 13px 90px !important; }
  body.is-mobile .drawer .tabs { overflow-x: auto; white-space: nowrap; }
  body.is-mobile .drawer .tab { flex: 0 0 auto; }

  body.is-mobile .modal-mask { align-items: flex-end; padding: 0; }
  body.is-mobile .modal {
    width: 100% !important; max-width: 100% !important; max-height: 92dvh;
    margin: 0 !important; border-radius: 18px 18px 0 0 !important;
    display: flex; flex-direction: column;
  }
  body.is-mobile .modal-head { padding: 13px 16px; }
  body.is-mobile .modal-body { padding: 14px 16px; overflow-y: auto; }
  body.is-mobile .modal-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
  body.is-mobile .modal-foot .btn { flex: 1; }

  body.is-mobile .cust-hero { flex-direction: column; align-items: flex-start; gap: 10px; padding: 15px !important; }
  body.is-mobile .cust-hero-stats { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  body.is-mobile .cust-stat { padding: 8px 0; }
  body.is-mobile .cust-hero-main h2 { font-size: 18px; }
  body.is-mobile .mini-kpi-row { grid-template-columns: 1fr 1fr !important; }
  body.is-mobile .desc-grid { grid-template-columns: 1fr !important; }
  body.is-mobile .wb-tree-card { position: static; max-height: 235px; overflow-y: auto; padding: 8px !important; }
  body.is-mobile .wb-main { padding: 10px 12px !important; }

  body.is-mobile .report-hero, body.is-mobile .fin-hero { flex-direction: column; }
  body.is-mobile .chart-box { height: 210px; }
  body.is-mobile .c360-proto .proto-inner { padding: 12px !important; }
  body.is-mobile #c360-proto .detail-grid { grid-template-columns: 1fr !important; }
  body.is-mobile #c360-proto .proto-top { padding: 10px 12px; }
}

/* 底部 APP 导航 */
.m-app-tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding: 5px 4px env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.97);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -6px 20px rgba(15,23,42,.06);
  backdrop-filter: blur(16px);
}
body.is-mobile .m-app-tabbar { display: flex; }
.m-app-tab { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #94a3b8; font-size: 10px; font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.m-app-tab .ico { font-size: 20px; line-height: 1; filter: grayscale(.15); }
.m-app-tab.active { color: #0891b2; font-weight: 700; }
.m-app-tab.active .ico { filter: none; transform: translateY(-1px); }
.m-app-tab.active::after { content: ''; width: 16px; height: 3px; border-radius: 3px; background: #0891b2; margin-top: 1px; }

/* 全部功能 / 我的 面板 */
.m-sheet-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1300; opacity: 0; pointer-events: none; transition: opacity .2s; }
.m-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1301; max-height: 88dvh; background: #f8fafc; border-radius: 22px 22px 0 0; transform: translateY(105%); transition: transform .25s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; overflow: hidden; }
body.m-sheet-open .m-sheet-mask { opacity: 1; pointer-events: auto; }
body.m-sheet-open .m-sheet { transform: translateY(0); }
.m-sheet-head { display: flex; align-items: center; gap: 10px; padding: 15px 17px 12px; background: #fff; border-bottom: 1px solid #eef2f7; }
.m-sheet-head .m-avatar { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(145deg,#0f172a,#0891b2); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.m-sheet-head .m-user { flex: 1; min-width: 0; }
.m-sheet-head .m-user b { display: block; font-size: 15px; }
.m-sheet-head .m-user span { display: block; font-size: 11px; color: #94a3b8; }
.m-sheet-head .m-close { border: 0; background: #f1f5f9; width: 30px; height: 30px; border-radius: 50%; font-size: 18px; color: #64748b; }
.m-sheet-body { padding: 12px 14px 22px; overflow-y: auto; }
.m-sheet-title { font-size: 12px; font-weight: 700; color: #64748b; margin: 6px 2px 8px; }
.m-nav-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; }
.m-nav-item { border: 0; background: #fff; border-radius: 12px; padding: 11px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; color: #334155; font-family: inherit; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.m-nav-item .ico { font-size: 22px; line-height: 1; }
.m-nav-item.active { background: #ecfeff; color: #0891b2; box-shadow: 0 0 0 1px #a5f3fc inset; }
.m-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.m-sheet-actions button { border: 1px solid #e2e8f0; background: #fff; border-radius: 11px; padding: 11px 8px; font-size: 12.5px; color: #334155; font-family: inherit; text-align: center; }
.m-sheet-actions button.danger { color: #dc2626; border-color: #fecaca; }
.m-sheet-ver { text-align: center; font-size: 10.5px; color: #94a3b8; margin-top: 14px; }

/* 登录页手机适配 */
@media (max-width: 640px) {
  .login-wrap { padding: 12px !important; }
  .login-card { padding: 28px 20px 22px !important; border-radius: 18px !important; max-width: 100%; }
  .login-logo { width: 56px; height: 56px; font-size: 24px; }
  .login-title { font-size: 24px; }
  .login-theme-switch { top: 10px !important; right: 12px !important; font-size: 11px !important; padding: 5px 9px !important; }
  .login-demo { font-size: 11px; }
  .login-shell { grid-template-columns: 1fr !important; }
  .login-hero { display: none !important; }
  .login-panel { padding: 26px 20px !important; }
}

body.m-sheet-open { overflow: hidden; }
.m-sheet-mask { pointer-events: none; }
body.m-sheet-open .m-sheet-mask { pointer-events: auto; }

/* 移动端层级：抽屉盖住顶栏与底栏，弹窗在抽屉之上 */
body.is-mobile .drawer { z-index: 1250 !important; }
body.is-mobile .drawer-mask { z-index: 1200 !important; }
body.is-mobile .modal-mask { z-index: 1400 !important; }
body.is-mobile .m-app-tabbar { z-index: 1000; }
body.is-mobile .m-sheet-mask { z-index: 1500; }
body.is-mobile .m-sheet { z-index: 1501; }
body.is-mobile .filter-select { min-width: 106px; }

/* 客户列表：手机端卡片 */
.m-cust-list { display: flex; flex-direction: column; gap: 9px; }
.m-cust-card { background: #fff; border: 1px solid #e8eef5; border-radius: 14px; padding: 12px 13px 10px; box-shadow: 0 2px 8px rgba(15,23,42,.05); cursor: pointer; }
.m-cust-card:active { transform: scale(.995); }
.m-cust-head { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.m-cust-name { font-size: 14.5px; font-weight: 700; color: #0f172a; line-height: 1.45; flex: 1; min-width: 0; word-break: break-all; }
.m-cust-sub { margin-top: 3px; font-size: 11px; color: #94a3b8; }
.m-cust-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.m-cust-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; background: #f8fafc; color: #64748b; font-size: 10.5px; border: 1px solid #eef2f7; }
.m-cust-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 9px; padding-top: 8px; border-top: 1px dashed #eef2f7; font-size: 11px; color: #64748b; }
.m-cust-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.m-cust-count { font-size: 11px; color: #94a3b8; }
.m-cust-actions { display: flex; gap: 6px; }
.m-cust-actions .btn { border: 1px solid rgba(34,211,238,.45); color: #0891b2; background: #fff; border-radius: 7px; padding: 4px 10px; font-size: 11px; }
.m-cust-actions .btn:hover { background: #ecfeff; }

/* 手机端筛选栏换行：搜索占一行，筛选/按钮在下一行 */
body.is-mobile .toolbar { flex-wrap: wrap !important; overflow: visible !important; gap: 8px; }
body.is-mobile .toolbar .search-box { flex: 1 0 100%; width: 100%; min-width: 0; }
body.is-mobile .toolbar .spacer { display: none; }
body.is-mobile .toolbar .filter-select { flex: 1 1 calc(50% - 4px); min-width: 0; width: auto; }
body.is-mobile .toolbar .btn { flex: 1 1 calc(50% - 4px); }

/* 顶栏已显示页面标题时，隐藏重复的页内 h1 */
body.is-mobile .page-head h1.m-dup-title { display: none; }

/* 覆盖原工程 style.mobile.css 的 select 100% 宽规则，手机端 2 列筛选 */
body.is-mobile .toolbar select.filter-select {
  flex: 1 1 calc(50% - 4px) !important;
  width: auto !important;
  min-width: 0 !important;
}
body.is-mobile .toolbar .btn { flex: 1 1 calc(50% - 4px) !important; }

/* 刘海屏安全区（PWA 独立窗口） */
body.is-mobile .topbar {
  height: calc(58px + env(safe-area-inset-top, 0px)) !important;
  min-height: calc(58px + env(safe-area-inset-top, 0px)) !important;
  padding-top: env(safe-area-inset-top, 0px) !important;
}
body.is-mobile .drawer-head { padding-top: calc(13px + env(safe-area-inset-top, 0px)) !important; }
body.is-mobile .m-sheet-head { padding-top: calc(15px + env(safe-area-inset-top, 0px)); }

/* 覆盖原版移动端 100vh 全屏弹窗，改为真正的底部弹层 */
body.is-mobile .modal {
  min-height: 0 !important;
  height: auto !important;
  max-height: 92dvh !important;
}
body.is-mobile .modal-body { flex: 1 1 auto; max-height: none; }
