/* ============================================================
   移动端 H5 全局底座 mobile.css
   【铁律】全部规则包在 @media (max-width: 768px) 内 —— >768px 零注入，PC 端布局/样式物理不变。
   目标：≤768px 时页面由「缩小版 PC」重排为 APP 质感界面。
   页面特有规则（列隐藏、弹窗特调）放各页面内 <style> 的 media 段，本文件只放通用底座。
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --m-safe-bottom: env(safe-area-inset-bottom, 0px);
    --m-nav-h: 58px;
  }

  /* ---------- 基础 ---------- */
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { font-size: 14px; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
  * { -webkit-tap-highlight-color: transparent; }

  /* 轻量点击反馈 */
  .btn, button, .menu-item, .report-tab, .m-tab, .es-menu-item, a {
    transition: transform .08s ease, opacity .08s ease;
  }
  .btn:active, button:active, .m-tab:active, .es-menu-item:active {
    opacity: .72; transform: scale(.97);
  }

  /* 输入控件 16px：防 iOS 聚焦自动放大 + 手机可读性 */
  input, select, textarea { font-size: 16px !important; }

  /* ---------- 头部 / 布局骨架 ---------- */
  .header { padding: 10px 14px; }
  .header h1 { font-size: 17px; }
  .container { flex-direction: column !important; }
  #sidebar-container { display: none !important; }  /* PC 侧栏退场，底部 Tab 顶上 */
  .main { flex: 1 1 auto; min-width: 0; padding: 10px 12px !important; }
  .card { border-radius: 14px !important; box-shadow: 0 1px 8px rgba(31,45,61,.07) !important; }
  .card-header { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }

  /* ---------- 按钮 APP 化（大圆角 / 大点击区） ---------- */
  .btn {
    min-height: 42px; padding: 0 16px; border-radius: 12px;
    font-size: 14px; font-weight: 600; box-sizing: border-box;
  }
  .btn-primary, .btn-success, .btn-warning, .btn-danger { box-shadow: 0 2px 6px rgba(31,45,61,.12); }

  /* ---------- 通用表格 → 卡片（data-label 方案） ----------
     页面渲染 JS 给 <td> 加 data-label="字段名"，移动端自动变「字段名: 值」两列卡片行；
     不需要 label 的 td（操作列等）加 class="no-label"。
     【豁免】合并表头（rowspan/colspan）等不适合卡片化的表格加 class="data-table no-card"，
     保持原表格形态走横向滚动（页面内自行给 min-width）。 */
  .data-table:not(.no-card) { width: 100% !important; border-collapse: separate !important; border-spacing: 0 !important; }
  .data-table:not(.no-card) thead { display: none !important; }
  .data-table:not(.no-card), .data-table:not(.no-card) tbody { display: block !important; width: 100%; }
  .data-table:not(.no-card) tr {
    display: block; background: #fff; border: none;
    border-radius: 14px; padding: 6px 14px 10px; margin: 0 0 12px;
    box-shadow: 0 1px 6px rgba(31,45,61,.08);
  }
  .data-table:not(.no-card) td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none !important; padding: 7px 0 !important;
    font-size: 14px; line-height: 1.5; text-align: left !important;
    background: transparent !important;
    word-break: break-all;
  }
  .data-table:not(.no-card) td::before {
    content: attr(data-label);
    flex-shrink: 0; max-width: 38%;
    color: #8a94a6; font-size: 13px;
  }
  .data-table:not(.no-card) td.no-label::before { content: none !important; }
  .data-table:not(.no-card) td[colspan] { display: block !important; text-align: center !important; }

  /* 卡片内操作按钮：全宽易点 */
  .data-table td .btn { min-height: 36px; padding: 0 14px; margin: 2px 4px 2px 0; }

  /* ---------- 底部 Tab 导航（mobile-nav.js 注入） ---------- */
  body.m-nav-active { padding-bottom: calc(var(--m-nav-h) + var(--m-safe-bottom) + 8px); }
  .m-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9500;
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
    border-top: 1px solid #eef0f4;
    box-shadow: 0 -2px 12px rgba(31,45,61,.06);
    padding-bottom: var(--m-safe-bottom);
  }
  .m-nav-tabs { display: flex; height: var(--m-nav-h); }
  .m-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; text-decoration: none; color: #8a94a6; font-size: 11px;
    max-width: 25%; min-width: 0; cursor: pointer; -webkit-user-select: none; user-select: none;
  }
  .m-tab .m-tab-icon { font-size: 20px; line-height: 1; }
  .m-tab .m-tab-label { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-tab.active { color: #2385bb; font-weight: 600; }

  /* 「更多」全屏抽屉 */
  .m-drawer { position: fixed; inset: 0; z-index: 9600; display: none; }
  .m-drawer.open { display: block; }
  .m-drawer-mask { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
  .m-drawer-panel {
    position: absolute; left: 0; right: 0; bottom: 0; top: 12vh;
    background: #f7f8fa; border-radius: 18px 18px 0 0;
    display: flex; flex-direction: column;
    padding-bottom: calc(var(--m-safe-bottom) + 8px);
    animation: m-drawer-up .22s ease;
  }
  @keyframes m-drawer-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
  .m-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; font-size: 16px; font-weight: 700; color: #1f2d3d;
    background: #fff; border-radius: 18px 18px 0 0;
  }
  .m-drawer-close { font-size: 24px; color: #8a94a6; padding: 0 8px; line-height: 1; }
  .m-drawer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 16px; }
  .m-drawer-group { margin-bottom: 12px; }
  .m-drawer-group-title { font-size: 12px; color: #98a2b3; padding: 6px 6px 4px; }
  .m-drawer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .m-drawer-item {
    background: #fff; border-radius: 10px; padding: 11px 6px; text-align: center;
    font-size: 13px; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    box-shadow: 0 1px 3px rgba(31,45,61,.06);
  }
  .m-drawer-item.active { background: #e8f4fc; color: #2385bb; font-weight: 600; }
  .m-drawer-loading { padding: 34px 0; text-align: center; color: #98a2b3; font-size: 13px; }

  /* ---------- 顶部快捷按钮收纳条（mobile-nav.js 把 5 个胶囊入口从 .header 移入） ---------- */
  .m-quickbar {
    display: flex; align-items: center; gap: 8px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 8px 12px; background: #fff; border-bottom: 1px solid #f0f0f4;
    scrollbar-width: none;
  }
  .m-quickbar::-webkit-scrollbar { display: none; }
  .m-quickbar a {
    flex: 0 0 auto !important; height: 32px !important; padding: 0 10px !important;
    font-size: 12px !important; margin-right: 0 !important;
    box-shadow: 0 1px 4px rgba(31,45,61,.12) !important;
  }
  .m-quickbar a span:first-child { font-size: 14px !important; }

  /* ---------- 通用弹窗 sheet 化辅助类（页面可选挂载） ---------- */
  .m-sheet-mask { align-items: flex-end !important; justify-content: stretch !important; }
  .m-sheet-panel {
    min-width: 0 !important; width: 100% !important; max-width: 100% !important;
    max-height: 92vh !important; border-radius: 18px 18px 0 0 !important;
    margin: 0 !important;
    padding-bottom: calc(var(--m-safe-bottom) + 12px) !important;
    animation: m-drawer-up .2s ease;
  }

  /* ---------- 通用横滚辅助 ---------- */
  .m-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---------- 控制台嵌入页通用骨架（page-layout/filter-sidebar 家族，第三批 2026-09-10） ----------
     嵌入页（iframe embed=1）统一骨架 .page-layout > .filter-sidebar + .main-container：
     手机端侧栏退场、主容器全宽；弹窗统一底部全屏 sheet 化（含内联 min-width 的 !important 覆盖）。 */
  .page-layout { display: block !important; }
  .page-layout > .filter-sidebar { display: none !important; }
  .page-layout > .main-container {
    width: 100% !important; max-width: 100vw !important;
    padding: 10px 12px !important; box-sizing: border-box; overflow-x: hidden;
  }
  .page-header { flex-wrap: wrap; gap: 8px; }

  /* 弹窗底部全屏化（覆盖各页 .modal-box 的 min-width:360~480px 与 JS 内联 min-width） */
  .modal-overlay, .modal-mask { align-items: flex-end !important; padding: 0 !important; }
  .modal-overlay .modal-box, .modal-overlay .modal-content,
  .modal-mask .modal-box, .modal-mask .modal-content, .modal-mask > .modal {
    min-width: 0 !important; max-width: 100% !important; width: 100% !important;
    max-height: 92vh !important; overflow-y: auto !important;
    border-radius: 18px 18px 0 0 !important; margin: 0 !important;
    animation: m-drawer-up .2s ease;
  }
  /* 弹窗内多列表单网格降单列 */
  .modal-box .form-row, .modal-box .form-row-3, .modal-box .form-row-4,
  .modal-content .form-row, .modal-content .form-row-3, .modal-content .form-row-4 { display: block !important; }
  .modal-box .form-row > *, .modal-box .form-row-3 > *, .modal-box .form-row-4 > *,
  .modal-content .form-row > *, .modal-content .form-row-3 > *, .modal-content .form-row-4 > * { width: 100% !important; margin: 0 0 8px; }

  /* 表单弹窗防键盘遮挡：visualViewport 由 mobile-nav.js 处理，这里兜底内边距 */
  body.m-keyboard-open .m-sheet-panel, body.m-keyboard-open .m-drawer-panel { max-height: 70vh !important; }
}
