/* =====================================================================
   LiveGig /user 控制台 —— 移动端专用适配样式（2026-11-22）
   ---------------------------------------------------------------------
   适用范围：仅 @media (max-width: 768px)，对 PC 端（≥769px）零影响。
   设计原则：
     1. 不修改任何既有 DOM 结构、不改动 PC 端既有类名与规则；
     2. 只在移动端断点内新增/覆盖规则，可随时整文件下线回滚；
     3. 修复依据来自 2026-11-22 Playwright 真机尺寸实测（375×812 / 414×896），
        数据来源：/tmp/mobile_audit.js、/tmp/overflow_probe.js、/tmp/sticky_probe.js。

   实测发现的问题与对应修复：
     P1 触控目标过小：表单控件高 32px、表格内按钮 24px、复选框 13px
        → 修复 1（表单控件）、修复 2（按钮）、修复 3（复选框）
     P2 列冻结偏移错位：design-system 对所有 .mimo-table 硬编码
        left:36px/72px，仅当「首列=复选框(35~40px)+第2列=序号(48~50px)」
        时才成立；meal_allowance 等首列为文本列的表会出现文字相互压盖
        → 修复 4（按表结构分流的冻结策略）
     P3 卡片头部按钮宽度硬编码 414px（design-system 第 1920 行附近），
        在 375/414 屏上必然溢出卡片
        → 修复 5
     P4 筛选表单 d-flex 不换行，控件被挤出可视区
        → 修复 6
     P5 表格横向滚动缺少可见提示
        → 修复 7
   ===================================================================== */

/* ---------------------------------------------------------------
   修复 1：表单控件触达面积（iOS 建议 ≥44px，Android ≥40px）
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    .mimo-form__input,
    .mimo-form__select,
    select.mimo-form__select,
    input.mimo-form__input {
        min-height: 40px !important;
        height: 40px !important;
    }

    /* 文件上传控件：原生 file input 不能被压成固定高度
       （否则文件名显示不全、点击区域变窄），只保底最小高度。 */
    input[type="file"].mimo-form__input {
        height: auto !important;
        min-height: 40px !important;
    }

    .mimo-form__textarea {
        min-height: 88px !important;
    }

    /* 表格列内的紧凑下拉（--sm）：保持紧凑但保证可点。
       选择器必须带上元素名，否则特异性低于上面的 select.mimo-form__select
       （同为 !important 时特异性高者胜），会被误提升到 40px。 */
    select.mimo-form__select--sm,
    input.mimo-form__select--sm,
    .mimo-form__select.mimo-form__select--sm {
        height: 34px !important;
        min-height: 34px !important;
    }
}

/* ---------------------------------------------------------------
   修复 2：按钮触达面积
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    /* 与 design-system 移动端基线保持一致（min-height:44px），不降级 */
    .mimo-btn {
        min-height: 44px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* 紧凑按钮与纯图标按钮例外：
       .mimo-btn--sm 本就是表格内小按钮（高 28px），
       .mimo-alert__close 为 Toast 关闭图标按钮，
       统一加 16px 横向 padding 会使其变形。 */
    .mimo-btn--sm {
        min-height: 32px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .mimo-alert__close {
        min-height: 32px !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    /* 表格内操作按钮：原 0.25rem padding 触达面积约 24px，移动端放大到 32px。
       只放大尺寸，不强制改写 display：部分页面在表格内用的是块级/图标按钮，
       一刀切 inline-flex 会让按钮变形或撑高行。 */
    .mimo-table tbody td .mimo-btn,
    .mimo-table tbody td button,
    .mimo-table tbody td a.mimo-btn {
        min-height: 32px !important;
        padding: 4px 10px !important;
        font-size: 0.8125rem !important;
    }

    .mimo-table tbody td .mimo-btn,
    .mimo-table tbody td a.mimo-btn {
        display: inline-flex !important;
        align-items: center !important;
    }

    /* 侧边栏抽屉内的折叠按钮（原约 30px）放大到可点尺寸 */
    .mimo-sidebar__toggle {
        width: 44px !important;
        height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* ---------------------------------------------------------------
   修复 3：复选框 / 单选框触达面积
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    /* 尺寸统一由「修复 8」以 20×20 落地（此处不再重复声明尺寸：
       同特异性且同带 !important 时后写者胜，重复声明会让本段变成死代码），
       这里只补充对齐与外边距。 */
    input[type="checkbox"].mimo-form__check-input,
    input[type="radio"].mimo-form__check-input {
        margin: 0 !important;
        vertical-align: middle !important;
    }

    /* 复选框所在单元格的点击热区放大（点击单元格空白处也能命中） */
    .mimo-table tbody td:has(> input.mimo-form__check-input) {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
}

/* ---------------------------------------------------------------
   修复 4：表格列冻结策略（按表语义分流，避免文字压盖）
   ---------------------------------------------------------------
   问题：design-system 移动端统一对第 1/2/3 列做 sticky left
   （0 / 36px / 72px），该偏移仅适用于「复选框列(40px) + 序号列(48px)」
   的标准人员表。实际各表首列/第 2 列宽度并不相同：
     #personnelTable          复选框列 42px、第 2 列「序号」48px
     .badge-management-table  复选框列 40px、第 2 列「序号」50px
     #mealOrderTable         复选框列 42px、第 2 列「序号」48px
     #hotelArrangementTable   复选框列 38px、第 2 列「#」35px
     其余表首列多为文本（人员姓名 233px、套餐名称 212px 等），
     统一用 36/72 会直接压在首列文字上。

   移动端策略（按表 id 精确分流冻结偏移，:has() 只用于识别首列是否为复选框）：
     · 标准人员表（#personnelTable / #mealOrderTable / #hotelArrangementTable
       以及 badge_management 的 #personnelTable.badge-management-table）
       → 保留三列冻结，偏移按各表实测列宽取（42/90、42/90、38/73、40/90）；
     · 其余所有表 → 第 2/3 列一律解冻，并清除冻结列专属的右边框；
     · 首列为复选框（窄列）→ 首列继续冻结在 left:0；
       首列为文本（人员姓名 233px、套餐名称 212px 等）→ 首列也解冻，
       避免冻结的宽文本列遮住大半屏幕的数据列；
     · .badge-stats-table 的冻结/解冻由 design-system 与页面内联样式负责，
       本文件不介入（用 :not(:is(.badge-stats-table *)) 排除）。
   旧浏览器不支持 :has() 时只是「首列按 design-system 原样冻结」，不会更差。
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    /* 4.1 通用解冻：非标准表的第 2/3 列一律解冻，
       消除 design-system 硬编码 left:36px/72px 造成的文字互相压盖。
       排除项：
         · #personnelTable / #mealOrderTable / #hotelArrangementTable → 见 4.3
         · .badge-stats-table → design-system 与页面内联样式已专门处理（冻结部门列） */
    .mimo-table:not(.badge-stats-table):not(:is(.badge-stats-table *)):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) th:nth-child(2),
    .mimo-table:not(.badge-stats-table):not(:is(.badge-stats-table *)):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) td:nth-child(2),
    .mimo-table:not(.badge-stats-table):not(:is(.badge-stats-table *)):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) th:nth-child(3),
    .mimo-table:not(.badge-stats-table):not(:is(.badge-stats-table *)):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) td:nth-child(3) {
        position: static !important;
        left: auto !important;
        /* 冻结列专属的右边框在解冻后会变成莫名竖线 */
        border-right: none !important;
    }

    /* 4.2 首列：复选框列窄，保留冻结在 left:0；
       文本首列（人员姓名 233px、套餐名称 212px 等）过宽，
       冻结会遮住大半屏幕的数据列 → 移动端解冻，随表格一起横向滚动。
       .badge-stats-table 的首列（部门）由页面内联样式冻结，故排除。 */
    .mimo-table:has(thead th:first-child input[type="checkbox"]):not(.mimo-tbl-cards) th:first-child,
    .mimo-table:has(thead th:first-child input[type="checkbox"]):not(.mimo-tbl-cards) td:first-child {
        position: sticky !important;
        left: 0 !important;
    }

    .mimo-table:not(.badge-stats-table):not(:is(.badge-stats-table *)):not(:has(thead th:first-child input[type="checkbox"])) th:first-child,
    .mimo-table:not(.badge-stats-table):not(:is(.badge-stats-table *)):not(:has(thead th:first-child input[type="checkbox"])) td:first-child {
        position: static !important;
        left: auto !important;
        box-shadow: none !important;
    }

    /* 4.3 标准人员表：恢复第 2/3 列冻结，偏移按各表实测列宽取值。
       偏移仅在未横向滚动时生效：滚动后由 .mimo-table-scrolled 接管
       （隐藏前两列、第 3 列归位），此时不应再强制偏移。
       :not(.mimo-tbl-cards) —— 卡片化后无冻结列，且本页规则带 ID（特异性 1,3,1），
       会压过卡片化段的类选择器 (0,2,3)，必须显式排除。 */
    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable:not(.mimo-tbl-cards) th:nth-child(2),
    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable:not(.mimo-tbl-cards) td:nth-child(2) {
        position: sticky !important;
        left: 42px !important;
    }

    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable:not(.mimo-tbl-cards) th:nth-child(3),
    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable:not(.mimo-tbl-cards) td:nth-child(3) {
        position: sticky !important;
        left: 90px !important;
    }

    .mimo-table-responsive:not(.mimo-table-scrolled) #mealOrderTable:not(.mimo-tbl-cards) th:nth-child(2),
    .mimo-table-responsive:not(.mimo-table-scrolled) #mealOrderTable:not(.mimo-tbl-cards) td:nth-child(2) {
        position: sticky !important;
        left: 42px !important;
    }

    .mimo-table-responsive:not(.mimo-table-scrolled) #mealOrderTable:not(.mimo-tbl-cards) th:nth-child(3),
    .mimo-table-responsive:not(.mimo-table-scrolled) #mealOrderTable:not(.mimo-tbl-cards) td:nth-child(3) {
        position: sticky !important;
        left: 90px !important;
    }

    .mimo-table-responsive:not(.mimo-table-scrolled) #hotelArrangementTable:not(.mimo-tbl-cards) th:nth-child(2),
    .mimo-table-responsive:not(.mimo-table-scrolled) #hotelArrangementTable:not(.mimo-tbl-cards) td:nth-child(2) {
        position: sticky !important;
        left: 38px !important;
    }

    .mimo-table-responsive:not(.mimo-table-scrolled) #hotelArrangementTable:not(.mimo-tbl-cards) th:nth-child(3),
    .mimo-table-responsive:not(.mimo-table-scrolled) #hotelArrangementTable:not(.mimo-tbl-cards) td:nth-child(3) {
        position: sticky !important;
        left: 73px !important;
    }

    /* badge_management.php 的工作证人员表与 personnel.php 共用 #personnelTable，
       但列宽不同（复选框 40px / 序号 50px），偏移按 40 / 90 单独指定
       （特异性高于上面的 #personnelTable 通用规则）。 */
    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable.badge-management-table:not(.mimo-tbl-cards) th:nth-child(2),
    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable.badge-management-table:not(.mimo-tbl-cards) td:nth-child(2) {
        left: 40px !important;
    }

    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable.badge-management-table:not(.mimo-tbl-cards) th:nth-child(3),
    .mimo-table-responsive:not(.mimo-table-scrolled) #personnelTable.badge-management-table:not(.mimo-tbl-cards) td:nth-child(3) {
        left: 90px !important;
    }

    /* badge_management.php 的页面内联样式把第 3 列固定在 left:90px 且带 !important，
       横向滚动后（design-system 隐藏了前两列）该偏移会造成左侧空洞，
       因此滚动态下把姓名列归位到 left:0。 */
    .mimo-table-responsive.mimo-table-scrolled #personnelTable.badge-management-table th:nth-child(3),
    .mimo-table-responsive.mimo-table-scrolled #personnelTable.badge-management-table td:nth-child(3) {
        left: 0 !important;
    }

    /* 4.4 横向滚动后的兜底：通用表禁止 design-system 平移/隐藏前两列。
       design-system 的 translateX(-100%) 是为「前两列冻结」设计的；
       通用表的前两列已解冻，若继续平移会与相邻列重叠、出现错位。
       标准人员表保留 design-system 的行为（隐藏复选框/序号、姓名列归位），
       由滑入按钮随时找回。 */
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) .mimo-table:not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) th:nth-child(1),
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) .mimo-table:not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) td:nth-child(1),
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) .mimo-table:not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) th:nth-child(2),
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) .mimo-table:not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) td:nth-child(2) {
        transform: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* 4.4b 非 .mimo-table 的表格（material-table / data-table / mini-table 等，
       分布在 stock_in、stock_out、rooms_management、meals_new、
       sync_hotel_rooms、project_settings 等页）：它们同样会被
       design-system 的 .mimo-table-scrolled 规则平移/隐藏前两列，
       但不受 4.1/4.2 管控，这里统一禁止平移，避免内容不可达。 */
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) table:not(.mimo-table):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) th:nth-child(1),
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) table:not(.mimo-table):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) td:nth-child(1),
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) table:not(.mimo-table):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) th:nth-child(2),
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) table:not(.mimo-table):not(#personnelTable):not(#mealOrderTable):not(#hotelArrangementTable) td:nth-child(2) {
        transform: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* 4.5 恢复移动端被 design-system 隐藏的「显示选择列」滑入按钮：
       ≤768px 时 design-system（mimo-design-system.css 第 2242 行）用
       display:none!important 隐藏该按钮，却又用 .mimo-table-scrolled 隐藏首两列
       并置 pointer-events:none —— 横向滑动后复选框列不可点且无法找回（死路）。
       本规则靠特异性 (0,3,1) > design-system 的 (0,1,1) 覆盖它；
       按钮点击行为为「滚回表格起点」（header.php 注入的 JS），
       对通用表相当于「一键回到表首」，对标准表则是找回被隐藏的选择列。 */
    .mimo-table-responsive.mimo-table-scrolled:not(.badge-stats-table) .mimo-table-slidein-btn {
        display: flex !important;
        width: 32px !important;
        height: 56px !important;
    }
}

/* ---------------------------------------------------------------
   修复 5：卡片头部按钮组宽度（原硬编码 414px，移动端溢出）
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    .mimo-card__header > .mimo-flex.mimo-flex-wrap > .mimo-btn {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ---------------------------------------------------------------
   修复 6：筛选表单在窄屏换行堆叠，控件全宽
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    /* 选择器覆盖三种实际写法：
       ① form#filterForm.d-flex（Bootstrap d-flex）
       ② form.d-flex.align-items-center.gap-3（酒店房间列表）
       ③ form#filterForm / form.filter-form（direct_meal_order、
          direct_hotel_arrangement、hotel_statistics 等语义化分组表单） */
    form#filterForm,
    form.d-flex.align-items-center.gap-3,
    .filter-form.d-flex {
        flex-wrap: wrap !important;
        row-gap: 10px !important;
    }

    form#filterForm > *,
    form.d-flex.align-items-center.gap-3 > *,
    .filter-form.d-flex > * {
        max-width: 100% !important;
    }

    /* 语义化分组表单的字段组在窄屏整行堆叠 */
    form#filterForm > .col-md-6,
    form#filterForm > .hotel-filter-form__field,
    form#filterForm > .hotel-statistics-filter__field {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    form#filterForm > select,
    form.d-flex.align-items-center.gap-3 > select,
    .filter-form.d-flex > select,
    form#filterForm .filter-buttons,
    form.d-flex.align-items-center.gap-3 .filter-buttons,
    .filter-form.d-flex .filter-buttons,
    form#filterForm .filter-actions,
    form.d-flex.align-items-center.gap-3 .filter-actions,
    .filter-form.d-flex .filter-actions {
        width: 100% !important;
    }

    .filter-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .filter-buttons > * {
        flex: 1 1 120px !important;
    }
}

/* ---------------------------------------------------------------
   修复 7：表格横向滚动提示（滚动条可见 + 惯性滚动）
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    .mimo-table-responsive,
    .table-responsive,
    .table-container {
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin;
    }

    .mimo-table-responsive::-webkit-scrollbar,
    .table-responsive::-webkit-scrollbar,
    .table-container::-webkit-scrollbar {
        height: 5px;
    }

    .mimo-table-responsive::-webkit-scrollbar-thumb,
    .table-responsive::-webkit-scrollbar-thumb,
    .table-container::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.28);
        border-radius: 3px;
    }

    .mimo-table-responsive::-webkit-scrollbar-track,
    .table-responsive::-webkit-scrollbar-track,
    .table-container::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
    }
}

/* ---------------------------------------------------------------
   修复 8：第二轮复测遗留的细粒度控件
   ---------------------------------------------------------------
   2026-11-22 复测（375/414）发现以下控件仍低于可点尺寸：
     · 无 class 的原生 checkbox/radio（16×16）→ 统一 20×20
     · 表格内复选框 18×18 → 统一 20×20（配合行高放大）
     · .st-step 步骤条按钮（84×24）→ 高度 34
     · .fi 系列输入框（高 31）→ 高度 36
     · .espire-reminder-close-btn（28×28）→ 36×36
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        vertical-align: middle !important;
    }

    input[type="checkbox"].mimo-form__check-input,
    input[type="radio"].mimo-form__check-input {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
    }

    .st-step {
        min-height: 34px !important;
        padding-top: 6px !important;
        padding-bottom: 6px !important;
    }

    input.fi,
    select.fi {
        min-height: 36px !important;
        height: 36px !important;
    }

    .espire-reminder-close-btn {
        width: 36px !important;
        height: 36px !important;
    }
}

/* ---------------------------------------------------------------
   修复 9：通用窄屏细节（长文本、栅格间距、顶部留白）
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    .mimo-grid {
        gap: 10px !important;
    }
    .mimo-card {
        padding: var(--mimo-space-3) !important;
    }

    .mimo-page {
        padding-bottom: 24px !important;
    }

    /* 统计/信息类文本允许换行，避免撑破卡片 */
    .mimo-stat__value,
    .mimo-stat__label {
        overflow-wrap: anywhere;
    }
}

/* ---------------------------------------------------------------
   修复 10：移动端表格卡片化（2026-11-23）
   ---------------------------------------------------------------
   实测（375px）：/user 61 张表在手机上的可见列仅 1.9~4.0，
   一行数据需横滑 400~760px 才能看完 —— 这是「表格不适配」的根因，
   单纯调宽度/加滚动条无法解决。

   方案：≤768px 时把表渲染成「一串记录卡片」
     · 每条记录一张卡片：勾选 + 标题 + 关键字段 + 操作列
     · 默认只显示「标题 + 2 个关键字段 + 操作列」，其余字段折叠
     · 卡片右上角图标按钮展开/收起该条记录的全部字段
     · 表头保留但仅显示含复选框的表头 → 批量「全选」不丢
     · 交叉表/矩阵表/DataTables 管理的表不参与卡片化（结构性限制）

   配套脚本：/user/assets/js/mobile-table.js
     · 只在移动端执行，PC 端 DOM 与样式零改动
     · 只增加 data-label 属性与 class，不删除/重排任何单元格，
       textContent / innerText 完全不变
     · 展开按钮为「无文字节点」的图标按钮（文案由 ::before 渲染），
       不会污染 personnel.php 依赖的 row.cells[2].textContent
   --------------------------------------------------------------- */
@media (max-width: 768px) {
    /* 卡片化容器（mimo-tbl-cards 由脚本添加） */
    .mimo-tbl-cards {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        table-layout: auto !important;
    }

    /* 表头：仅保留含复选框的表头（批量全选），其余隐藏 */
    .mimo-tbl-cards > thead {
        display: block !important;
    }

    .mimo-tbl-cards > thead > tr {
        display: block !important;
    }

    .mimo-tbl-cards > thead > tr > th {
        display: none !important;
        position: static !important;
    }

    .mimo-tbl-cards > thead > tr > th.mimo-tbl-hascheck {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 2px 2px 10px !important;
        font-size: 0.8125rem !important;
        font-weight: 500;
        color: var(--mimo-text-secondary, #6b7280);
    }

    .mimo-tbl-cards > thead > tr > th.mimo-tbl-hascheck::before {
        content: '全选';
    }

    /* 表体：每行一张卡片 */
    .mimo-tbl-cards > tbody {
        display: block !important;
    }

    /* 卡片：字段按「两列网格」排布。
       改造前每个字段独占一整行（标签 34% + 值左对齐），
       短值（如「性别 男」）右侧留下 200px+ 空白 →
       改为两列网格，标签在上、值在下，卡片右侧不再有大片留白。 */
    .mimo-tbl-cards > tbody > tr {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 12px;
        row-gap: 8px;
        align-items: start;
        /* 不能用 !important：SortableJS 拖拽时会给 ghost 行写内联 position:fixed，
           author !important 会压掉内联样式，导致触摸拖拽指示块不跟手。 */
        position: relative;
        margin: 0 0 10px !important;
        padding: 10px 12px !important;
        border: 1px solid var(--mimo-border-warm, #e5e7eb) !important;
        border-radius: 10px !important;
        background: var(--mimo-bg-container, #fff) !important;
        box-shadow: none !important;
    }

    /* SortableJS 触摸 fallback 克隆行：必须保持 fixed 定位 */
    .mimo-tbl-cards > tbody > tr.sortable-fallback {
        position: fixed !important;
        z-index: 1000 !important;
        opacity: 0.9;
        pointer-events: none;
    }

    .mimo-tbl-cards > tbody > tr:hover {
        background: var(--mimo-bg-container, #fff) !important;
    }

    /* 单元格：网格单元。标签(::before)在上、值在下。
       选择器重复写两次 .mimo-tbl-cards 以把特异性提到 (0,2,3)，
       压过 design-system 的 .mimo-table td:nth-child(n) 冻结列规则 (0,2,1)，
       否则 td 仍为 sticky + z-index:2，会压住左上角绝对定位的勾选框。 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td {
        display: block !important;
        /* 卡片模式无冻结列：取消 design-system / 冻结列规则带来的 sticky。 */
        position: static !important;
        left: auto !important;
        z-index: auto !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        border-right: none !important;
        background: transparent !important;
        box-shadow: none !important;
        text-align: left !important;
        vertical-align: top !important;
        font-size: 0.875rem !important;
        line-height: 1.45;
        min-height: 26px;
        overflow-wrap: anywhere;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        color: var(--mimo-text-secondary, #6b7280);
        font-size: 0.8125rem !important;
        font-weight: 500;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    /* 标题单元格（记录主标识）：独占整行 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-title {
        grid-column: 1 / -1;
        display: block !important;
        /* sticky 在卡片模式下无意义；且 sticky 会成为展开按钮的定位基准，
           导致按钮漂离卡片右缘 → 强制 static，按钮以卡片(tr)为基准。 */
        position: static !important;
        padding: 0 68px 6px 0 !important;
        font-weight: 600;
        font-size: 0.9375rem !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-title::before {
        content: none !important;
    }

    /* 含勾选框的行：标题左侧为绝对定位的勾选框让位（2026-11-23） */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr.mimo-tbl-rowcheck > td.mimo-tbl-title {
        padding-left: 40px !important;
    }

    /* 勾选单元格：绝对定位到卡片左上角，与标题同行。
       改造前为独占一行的 flex 格，窄屏下表现为一个突兀的空方块。 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-check {
        grid-column: auto;
        display: flex !important;
        position: absolute !important;
        top: 8px;
        left: 12px;
        width: 40px !important;
        height: 40px !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        z-index: 3 !important;
    }

    /* 勾选框视觉尺寸维持 18px；触控热区由下方 label 提供 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-check input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
        flex: 0 0 auto;
    }

    /* label 命中区：40×40 触控热区（原生 checkbox 忽略 padding，
       实测 computed padding 恒为 0，只能用 label 扩大点击区）。
       热区向右下扩展，input 仍靠左上角，不遮挡标题文字。 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-check label.mimo-tbl-checkhit {
        display: inline-flex !important;
        align-items: flex-start;
        justify-content: flex-start;
        width: 40px !important;
        height: 40px !important;
        margin: 0 !important;
        cursor: pointer;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-check::before {
        content: none !important;
    }

    /* 操作单元格：独占整行，按钮换行排列，不再挤成一排 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-action {
        grid-column: 1 / -1;
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 4px !important;
        border-bottom: none !important;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-action::before {
        content: none !important;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-action .mimo-btn {
        min-height: 34px !important;
    }

    /* 跨列行（空状态 / 提示行 / 部门分隔行） */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-span {
        grid-column: 1 / -1;
        display: block !important;
        text-align: center !important;
        padding: 14px 0 !important;
        border-bottom: none !important;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-span::before {
        content: none !important;
    }

    /* 序号列：卡片模式下永久隐藏（与展开状态无关）。
       若改为折叠，展开后序号会独占一格，把标题挤到下一行并与勾选框错位。 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td.mimo-tbl-index {
        display: none !important;
    }

    /* 折叠：默认隐藏非关键字段 */
    .mimo-tbl-cards > tbody > tr:not(.mimo-tbl-open) > td.mimo-tbl-fold {
        display: none !important;
    }

    /* 表尾（合计行）：单行横排，不拆行、不留空标签槽 */
    .mimo-tbl-cards > tfoot {
        display: block !important;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tfoot > tr {
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 14px;
        padding: 8px 12px !important;
        border: 1px solid var(--mimo-border-warm, #e5e7eb) !important;
        border-radius: 10px !important;
        background: var(--mimo-bg-page, #f8f9fa) !important;
        font-weight: 600;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tfoot > tr > td {
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
        position: static !important;
        left: auto !important;
        width: auto !important;
        padding: 2px 0 !important;
        border: none !important;
        border-right: none !important;
        background: transparent !important;
        box-shadow: none !important;
        font-size: 0.8125rem !important;
    }

    .mimo-tbl-cards.mimo-tbl-cards > tfoot > tr > td::before {
        content: attr(data-label);
        color: var(--mimo-text-secondary, #6b7280);
        font-size: 0.8125rem !important;
        font-weight: 500;
    }

    /* 展开/收起按钮：绝对定位于卡片右上角。
       按钮本身无文字节点（文案由 ::before 渲染），不影响单元格 textContent。 */
    .mimo-tbl-expand {
        position: absolute !important;
        top: 6px;
        right: 10px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        height: 40px;
        padding: 0 10px;
        border: 1px solid var(--mimo-border-warm, #e5e7eb) !important;
        border-radius: 20px;
        background: var(--mimo-bg-page, #f8f9fa) !important;
        color: var(--mimo-text-secondary, #6b7280) !important;
        font-size: 0.75rem !important;
        line-height: 1;
        z-index: 3;
    }

    .mimo-tbl-expand::before {
        content: '展开';
    }

    .mimo-tbl-open .mimo-tbl-expand::before {
        content: '收起';
    }

    /* design-system 的 .mimo-table td 默认 white-space:nowrap，
       卡片模式下长文本（如套餐内容）会横向溢出卡片 300~400px，
       实测导致容器 scrollWidth 从 325px 涨到 722px → 恢复自动换行。 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td,
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td *,
    .mimo-tbl-cards.mimo-tbl-cards > tfoot > tr > td,
    .mimo-tbl-cards.mimo-tbl-cards > tfoot > tr > td * {
        white-space: normal !important;
    }

    /* 弹性子项默认 min-width:auto，会以 min-content 撑宽卡片（实测溢出 40px）
       → 允许收缩，配合上面的 overflow-wrap:anywhere 正常换行。 */
    .mimo-tbl-cards.mimo-tbl-cards > tbody > tr > td > *,
    .mimo-tbl-cards.mimo-tbl-cards > tfoot > tr > td > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* 卡片化表格所在的外层容器：container-fluid.px-4 的 24px 左右内边距
       与 .mimo-card 自身的 12px 内边距叠加，实测在 375px 屏上
       卡片右侧到视口空白 49px（约 13%）→ 移动端收窄为 12px。 */
    .container-fluid:has(.mimo-tbl-cards) {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* 分组标题行（按日期 / 分类分组的跨列行） */
    .mimo-tbl-cards > tbody > tr.mimo-tbl-group {
        background: var(--mimo-bg-page, #f8f9fa) !important;
        padding: 8px 12px !important;
        margin: 4px 0 10px !important;
    }

    .mimo-tbl-cards > tbody > tr.mimo-tbl-group > td {
        font-weight: 600;
        font-size: 0.8125rem !important;
        color: var(--mimo-text-secondary, #6b7280);
    }

    /* 卡片内的图片（物资缩略图）限制尺寸，避免撑破卡片 */
    .mimo-tbl-cards img {
        max-width: 120px !important;
        height: auto !important;
    }
}

/* ---------------------------------------------------------------
   修复 11：移动端深度适配（2026-11-23）
   ---------------------------------------------------------------
   依据：320px / 375px 两轮全量 60 页 Playwright 实测结果
     ① 可点元素普遍低于 iOS 建议的 44×44
        （主表单控件 40px、紧凑按钮 32px、表格展开按钮 40px、
          关闭/交换图标按钮 32~36px、物资小按钮 33~37px）
     ② 全站 0 处 safe-area-inset：刘海屏底部横条会遮住底栏与末行按钮
     ③ ≤576px 共享 .mimo-grid--4 被固定为 3 列（适配“3 子元素”场景），
        4 张统计卡排成 3+1 孤儿卡
     ④ 320px 下 badge_management 顶栏溢出 11px；
        materials_* 页日期条（d-flex gap-2 + 写死 140px 日期框）溢出
     本段全部限定在 ≤768px 内，桌面端（≥769px）零影响。
   --------------------------------------------------------------- */
@media (max-width: 768px) {

    /* ---------- 1. 触控热区：抬到 44 / 40 / 36 三档 ---------- */

    /* 主表单控件 40 → 44（iOS 建议）；
       选择器需带元素名，否则低于「修复 1」段的 input.mimo-form__input（0,1,1） */
    input.mimo-form__input,
    select.mimo-form__select,
    .mimo-form__select {
        min-height: 44px !important;
        height: 44px !important;
    }

    /* 表格内紧凑下拉：34 → 36（表格行高有限，不强行 44） */
    select.mimo-form__select--sm,
    input.mimo-form__select--sm,
    .mimo-form__select.mimo-form__select--sm {
        height: 36px !important;
        min-height: 36px !important;
    }

    /* 紧凑按钮 32 → 36 */
    .mimo-btn--sm {
        min-height: 36px !important;
    }

    /* 表格内操作按钮 32 → 36 */
    .mimo-table tbody td .mimo-btn,
    .mimo-table tbody td button,
    .mimo-table tbody td a.mimo-btn {
        min-height: 36px !important;
        padding: 6px 12px !important;
    }

    /* 卡片展开/收起按钮 40 → 44 */
    .mimo-tbl-expand {
        min-width: 44px !important;
        width: 44px !important;
        height: 44px !important;
    }

    /* 关闭/交换等图标按钮 → 44 */
    .espire-reminder-close-btn {
        width: 44px !important;
        height: 44px !important;
    }

    .st-swap-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
    }

    /* 步骤条/类型按钮 34~36 → 40 */
    .st-step,
    .st-type-btn {
        min-height: 40px !important;
    }

    /* 日期选择/复制按钮 38 → 44 */
    .date-picker-btn,
    .date-copy-btn {
        min-height: 44px !important;
    }

    /* 物资页小按钮 33~37 → 44 */
    .btn-material-primary.btn-material-sm,
    .btn-material-secondary.btn-material-sm {
        min-height: 44px !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    /* 行内删除类小按钮 32 → 40 */
    .remove-transport-row,
    .remove-date-btn,
    .remove-badge-type {
        min-height: 40px !important;
    }

    /* fi 系列输入 36 → 40 */
    input.fi,
    select.fi {
        min-height: 40px !important;
        height: 40px !important;
    }

    /* 空内容按钮（只有图标）补最小可点宽度 */
    .mimo-btn--default {
        min-width: 44px !important;
    }

    /* ---------- 2. 刘海屏安全区（safe-area） ---------- */
    .mimo-page {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* 固定在底部的悬浮操作区（如 badge_management 右下角打印按钮） */
    .position-fixed.bottom-0 {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* 移动端顶栏：贴顶时避开刘海，并允许标题省略而非撑破 */
    .mimo-mobile-topbar {
        padding-top: env(safe-area-inset-top, 0px) !important;
        /* 320px 下顶栏内容（项目名徽标）会把包含块撑到 331px，
           导致 fixed 定位的顶栏与右下角悬浮按钮一并溢出 → 限宽 + 裁切 */
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .mimo-mobile-topbar > *,
    .mimo-mobile-topbar .mimo-flex {
        min-width: 0 !important;
        flex-shrink: 1 !important;
    }

    .mimo-mobile-topbar-title {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* ---------- 3. 顶部统计卡阵列：自适应列数，消除孤儿卡 ----------
       不用共享 .mimo-grid--N（≤576px 固定 3 列，4 张卡必然 3+1），
       改用 flex：2 张为基准一行，末行不足时自动拉伸填满，不产生孤儿卡。 */
    .mimo-grid--2:has(> .mimo-stat),
    .mimo-grid--3:has(> .mimo-stat),
    .mimo-grid--4:has(> .mimo-stat),
    .material-stats-row:has(> .mimo-stat) {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .mimo-grid--2:has(> .mimo-stat) > .mimo-stat,
    .mimo-grid--3:has(> .mimo-stat) > .mimo-stat,
    .mimo-grid--4:has(> .mimo-stat) > .mimo-stat,
    .material-stats-row:has(> .mimo-stat) > .mimo-stat {
        flex: 1 1 calc(50% - 5px) !important;
        min-width: 0 !important;
    }

    /* 卡片内文字块允许收缩（图标 + 文字并排时防撑破） */
    .mimo-stat__info {
        min-width: 0 !important;
    }

    /* ---------- 3-b. A 型统计卡（图标 + 信息区）改水平并列 ----------
       A 型 = .mimo-stat 内含 .mimo-stat__icon + .mimo-stat__info（hotels / hotel_add /
       materials_* / stock_in / sync_hotel_rooms / rooms_management / room_stock_dashboard /
       meals_new 等）。原图标是右上角绝对定位（design-system 默认），文字区整行独享，
       在窄屏显得松散且卡片过高。

       这里采用基准页（user/mobile_material_register.php + assets/css/
       mobile-material-register-pc.css）的形态：左侧 44px 圆形色块 + 右侧文字
       （value 在上、label 在下），仅在移动端生效，桌面端保持原样。 */
    .mimo-stat:has(> .mimo-stat__info) {
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 14px 16px !important;
    }

    .mimo-stat:has(> .mimo-stat__info) > .mimo-stat__icon {
        position: static !important;
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        font-size: 20px !important;
        opacity: 1 !important;
        background: var(--mimo-bg-page, #f8f9fa) !important;
        color: var(--mimo-text-primary, #111827) !important;
    }

    .mimo-stat:has(> .mimo-stat__info) > .mimo-stat__info {
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    /* 水平布局后可用宽度变窄，数值按视口收缩（避免日期类长值折行） */
    .mimo-stat:has(> .mimo-stat__info) .mimo-stat__value {
        font-size: clamp(18px, 5vw, 32px) !important;
        line-height: 1.2 !important;
    }

    /* B 型统计卡（label/value + 右上角绝对定位图标）：标签给图标留安全距离 */
    .mimo-stat:has(> .mimo-stat__icon) > .mimo-stat__label {
        padding-right: 28px !important;
    }

    /* ---------- 4. 局部溢出修复 ---------- */

    /* 物资页日期条：容器允许换行，日期框不再写死 140px */
    div.d-flex.gap-2:has(> input[type="date"]) {
        flex-wrap: wrap !important;
    }

    div.d-flex.gap-2 > input[type="date"].mimo-form__input {
        width: auto !important;
        max-width: 100% !important;
        flex: 1 1 140px !important;
        min-width: 0 !important;
    }

    /* direct_meal_order 日期导航：两侧按钮不压缩，中间内容可收缩 */
    .date-nav-btn {
        flex: 0 0 auto !important;
    }

    .date-hero-body {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    /* 卡片内「标题 + 操作」两栏行：窄屏允许换行。
       实测（badge_management@320）：该行内容宽 294px > 卡片内容区 246px，
       逐级传导后把 body 撑到 331px → 页面出现 11px 横向滚动。 */
    .mimo-card__body .mimo-flex.mimo-justify-between,
    .mimo-card__header .mimo-flex.mimo-justify-between {
        flex-wrap: wrap !important;
        row-gap: 8px !important;
    }

    .mimo-card__body .mimo-flex.mimo-justify-between > *,
    .mimo-card__header .mimo-flex.mimo-justify-between > * {
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

/* ---------------------------------------------------------------
   修复 11-b：极窄屏（≤360px）补充
   --------------------------------------------------------------- */
@media (max-width: 360px) {
    /* 统计卡在极窄屏回到单列：两列时卡片内容区不足 130px，数字与标签会挤 */
    .mimo-grid--2:has(> .mimo-stat),
    .mimo-grid--3:has(> .mimo-stat),
    .mimo-grid--4:has(> .mimo-stat),
    .material-stats-row:has(> .mimo-stat) > .mimo-stat {
        flex-basis: 100% !important;
    }

    /* 顶栏在极窄屏允许换行，避免溢出 */
    .mimo-mobile-topbar {
        height: auto !important;
        min-height: 56px;
        flex-wrap: wrap !important;
        row-gap: 4px;
    }
}
