/* 手机端通用适配：只在窄屏生效，电脑端完全不受影响。由 Common\Behavior\MobileAdaptBehavior 自动引入 */
@media screen and (max-width: 768px) {
    html, body { min-width: 0 !important; max-width: 100vw; -webkit-text-size-adjust: 100%; }
    body { overflow-x: hidden; }
    /* H+ 的入场动画会从屏幕右侧滑入，手机上会把页面撑宽、出现横向滚动 */
    .animated { -webkit-animation: none !important; animation: none !important; }
    img, video, canvas { max-width: 100%; height: auto; }

    /* ---------- 布局容器 ---------- */
    .wrapper, .wrapper-content { padding: 8px !important; }
    .ibox-title { padding: 10px 12px 6px !important; min-height: 0 !important; }
    .ibox-title h5 { float: none !important; display: block; margin-bottom: 6px; }
    .ibox-tools { position: static !important; float: none !important; }
    .ibox-content { padding: 10px !important; }
    .container, .container-fluid { padding-left: 8px !important; padding-right: 8px !important; }
    .row { margin-left: -6px !important; margin-right: -6px !important; }
    [class*="col-sm-"], [class*="col-md-"], [class*="col-lg-"] { width: 100% !important; float: none !important; padding-left: 6px !important; padding-right: 6px !important; }
    .layui-fluid { padding: 8px !important; }
    .layui-card-body { padding: 10px !important; }
    .layui-col-space15 > *, .layui-col-space10 > * { padding: 4px !important; }

    /* ---------- 表格：横向滑动，不挤压文字 ---------- */
    .m-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 8px; }
    .m-scroll > table { min-width: 640px; margin-bottom: 0 !important; }
    .m-scroll > table td, .m-scroll > table th { white-space: normal; }
    .m-scroll.m-can-scroll::before { content: '← 左右滑动查看更多 →'; display: block; position: -webkit-sticky; position: sticky; left: 0; padding: 2px 0 4px; color: #aaa; font-size: 12px; text-align: center; }
    .table-responsive { border: 0 !important; }
    .layui-table-view, .layui-table-box { max-width: 100% !important; }
    .layui-table-body { -webkit-overflow-scrolling: touch; }
    .layui-table-page { white-space: normal !important; height: auto !important; }
    .layui-table-tool { height: auto !important; min-height: 50px; }
    .layui-table-tool-temp { padding-right: 0 !important; }

    /* ---------- 列多的表格：一条记录一张卡片（m.js 给每个单元格加 data-label） ---------- */
    .m-cards-bar { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 6px; font-size: 13px; color: #666; }
    .m-cards-bar .m-cards-all { margin: 0; font-weight: normal; }
    .m-cards-bar .m-cards-all input { width: 18px; height: 18px; vertical-align: -4px; }
    .m-cards-switch { margin-left: auto; padding: 4px 10px; border: 1px solid #ddd; border-radius: 3px; background: #fff; color: #666; font-size: 12px; }
    .m-scroll.m-cards-box { overflow-x: visible; }
    table.m-cards:not(.m-cards-off) { display: block; width: 100% !important; min-width: 0 !important; table-layout: auto !important; border: 0 !important; background: transparent !important; }
    table.m-cards:not(.m-cards-off) > thead { display: none; }
    table.m-cards:not(.m-cards-off) > tbody { display: block; }
    table.m-cards:not(.m-cards-off) > tbody > tr { display: block; position: relative; margin: 0 0 10px; padding: 6px 10px; border: 1px solid #e3e6ea; border-radius: 6px; background: #fff !important; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
    table.m-cards:not(.m-cards-off) > tbody > tr > td { display: block; position: relative; width: auto !important; max-width: none !important; min-height: 30px; padding: 5px 0 5px 5.6em !important; border: 0 !important; border-bottom: 1px dashed #f0f0f0 !important; white-space: normal !important; overflow: visible !important; word-break: break-all; text-align: left !important; line-height: 1.5; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td:last-child { border-bottom: 0 !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 5.2em; color: #999; font-size: 12px; line-height: 1.7; word-break: keep-all; white-space: normal; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td[data-label=""] { padding-left: 0 !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td[data-label=""]::before { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-empty { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-check { position: absolute; top: 4px; right: 8px; z-index: 1; min-height: 0; padding: 0 !important; border: 0 !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-check::before { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-check input { width: 20px; height: 20px; }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-plain > td { padding-left: 0 !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td .btn, table.m-cards:not(.m-cards-off) > tbody > tr > td .layui-btn { margin: 0 6px 4px 0; }

    /* 卡片里的操作按钮：一行排开、等宽、触控区域够大 */
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-ops { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; padding: 8px 0 4px !important; border-top: 1px solid #eee !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-ops::before { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-ops br { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-ops .btn, table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-ops .layui-btn { flex: 1 1 0; min-width: 76px; height: 38px; margin: 0 !important; padding: 0 6px; line-height: 36px; font-size: 15px; text-align: center; white-space: nowrap; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td br.m-card-br, table.m-cards:not(.m-cards-off) > tbody > tr > td .m-card-blank { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td br.m-card-br + .btn { margin-left: 8px; }

    /* ---------- 卡片布局（按列名分配位置，见 m.js CARD_PROFILES） ---------- */
    /* 标题整行加粗；标题下面一行是 店铺/客户 等小字、状态小标签、时间，金额靠右；普通字段两列排；长内容整行；按钮在最底部 */
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles { display: flex; flex-wrap: wrap; align-items: center; padding: 10px 12px 8px; border-radius: 8px; border-color: #e6e8eb; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td { flex: 0 0 100%; box-sizing: border-box; min-height: 0; }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td.m-card-check { position: absolute; top: 9px; right: 10px; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-title { order: 1; padding: 0 30px 4px 0 !important; border: 0 !important; font-size: 15px; font-weight: 600; color: #222; line-height: 1.45; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-title::before { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-title .btn, table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-title .layui-btn { font-weight: normal; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-sub,
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-meta,
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-badge,
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-amount { order: 2; flex: 0 1 auto; width: auto !important; padding: 2px 10px 6px 0 !important; border: 0 !important; font-size: 12px; color: #888; line-height: 1.6; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-sub::before,
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-meta::before { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-sub { color: #555; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-badge { order: 3; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-badge::before { position: static; display: inline; width: auto; margin-right: 3px; font-size: 11px; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-badge { color: #1e88e5; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-meta { order: 3; }
    /* 标题下的这一行信息结束后换行，普通字段从新的一行开始 */
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles::after { content: ''; order: 5; flex: 0 0 100%; height: 0; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-amount { order: 4; margin-left: auto; padding-right: 0 !important; font-size: 16px; font-weight: 600; color: #e64a19; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-amount::before { position: static; display: inline; width: auto; margin-right: 4px; font-size: 11px; font-weight: normal; }
    /* 普通字段：两列，字段名在上、值在下 */
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-grid { order: 6; flex: 0 0 50%; padding: 6px 8px 6px 0 !important; border: 0 !important; border-top: 1px solid #f3f4f6 !important; font-size: 13px; color: #333; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-grid::before { position: static; display: block; width: auto; line-height: 1.4; font-size: 11px; }
    /* 整行字段：字段名在左 */
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-full { order: 7; padding: 6px 0 6px 4.6em !important; border: 0 !important; border-top: 1px solid #f3f4f6 !important; font-size: 13px; color: #333; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-full::before { width: 4.3em; top: 7px; font-size: 11px; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-full[data-label=""] { padding-left: 0 !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops { order: 9; flex: 0 0 100%; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops:not(.m-card-ops) { padding: 8px 0 2px !important; border: 0 !important; border-top: 1px solid #eee !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops:not(.m-card-ops)::before { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td .btn-xs, table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td .layui-btn-xs { padding: 1px 7px; font-size: 12px; }
    /* 操作列：按钮外面包着 div（bootstrap 栅格）的，也平铺成一排 */
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops { display: flex; flex-wrap: wrap; gap: 6px; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops .form-group, table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops [class*="col-"] { display: contents; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops br { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops .btn, table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops .layui-btn { flex: 1 1 28%; min-width: 72px; height: 36px; margin: 0 !important; padding: 0 6px; line-height: 34px; font-size: 14px; text-align: center; white-space: nowrap; }
    /* 卡片里的小图标（编辑、旗帜、电话等）不要撑大 */
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td:not(.m-r-full) img { max-height: 18px; width: auto; vertical-align: -3px; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-card-check { font-size: 11px; color: #999; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-grid, table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-full { align-self: stretch; }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td > br.m-card-lead { display: none; }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-checktext > td.m-r-title { padding-right: 72px !important; }
    /* 按钮超过 3 个：默认只显示前 2 个和“更多” */
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops:not(.m-ops-open) .m-more-item { display: none !important; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops .m-more-btn { order: 99; color: #555; background: #f5f6f7; border-color: #ddd; }
    table.m-cards:not(.m-cards-off) > tbody > tr > td.m-r-ops.m-ops-open .m-more-btn { flex-basis: 100%; }

    /* ---------- 弹窗 ---------- */
    .m-layer .layui-layer-title { height: 46px; padding: 0 52px 0 14px; line-height: 46px; font-size: 16px; font-weight: 600; color: #222; background: #fff; border-bottom: 1px solid #eee; }
    /* 关闭按钮放大一点，方便点 */
    .m-layer .layui-layer-setwin { top: 16px; right: 16px; transform: scale(1.35); transform-origin: right top; }
    .m-layer .layui-layer-btn { display: flex; gap: 10px; padding: 10px 12px 12px; text-align: center; }
    .m-layer .layui-layer-btn a { flex: 1 1 0; height: 40px; margin: 0; line-height: 40px; font-size: 15px; border-radius: 4px; }
    .m-layer-full { border-radius: 0 !important; }
    .m-layer-full .layui-layer-content { -webkit-overflow-scrolling: touch; }
    .layui-layer-dialog { max-width: 92vw; }
    .layui-layer-dialog .layui-layer-content { font-size: 15px; line-height: 1.6; }
    table.m-cards:not(.m-cards-off) > tbody > tr.m-card-roles > td.m-card-check input { margin: 0 0 0 4px; vertical-align: middle; }

    /* ---------- 表单：一行一个，输入框不再触发 iOS 自动放大 ---------- */
    input[type="text"], input[type="search"], input[type="number"], input[type="tel"], input[type="password"],
    input[type="date"], input[type="datetime-local"], select, textarea, .form-control, .layui-input, .layui-textarea, .layui-select {
        font-size: 16px !important;
    }
    .form-inline .form-group, .form-inline .input-group, .form-inline .form-control,
    .form-inline select, .form-inline input[type="text"], .form-inline input[type="search"] {
        display: block !important; width: 100% !important; margin: 0 0 8px 0 !important;
    }
    .form-inline .input-group { display: table !important; }
    .form-inline .input-group .form-control { display: table-cell !important; margin: 0 !important; }
    .form-horizontal .control-label { text-align: left !important; padding-top: 0 !important; margin-bottom: 4px; }
    .layui-form-item { margin-bottom: 10px !important; }
    .layui-form-item .layui-inline { display: block !important; margin-right: 0 !important; margin-bottom: 8px !important; }
    .layui-form-label { float: none !important; display: block !important; width: auto !important; padding: 4px 0 !important; text-align: left !important; }
    .layui-input-block { margin-left: 0 !important; }
    .layui-input-inline { float: none !important; display: block !important; width: 100% !important; margin: 0 0 8px 0 !important; }
    .layui-form-mid { float: none !important; display: block !important; padding: 0 0 4px !important; }

    /* ---------- 按钮：加大触控区域 ---------- */
    .btn, .layui-btn { min-height: 32px; line-height: 1.6; touch-action: manipulation; }
    .btn-xs, .layui-btn-xs { min-height: 26px; padding: 2px 8px; }
    .btn-group, .layui-btn-group { white-space: normal; }
    .pagination, .layui-laypage { white-space: normal; }
    .pagination > li > a, .pagination > li > span { padding: 6px 10px; margin-bottom: 4px; }

    /* ---------- 弹窗 ---------- */
    .layui-layer { max-width: 100vw !important; }
    /* 铺满屏幕的弹窗由 m.js 按页面缩放算好宽度，不受 100vw 限制（页面缩小后 100vw 只有半屏） */
    .layui-layer.m-layer-full { max-width: none !important; }
    .layui-layer-content { -webkit-overflow-scrolling: touch; }
    .modal-dialog { width: auto !important; margin: 8px !important; }

    /* ---------- 登录页：固定 500px 的登录框改为自适应 ---------- */
    .login, .signinpanel, .signuppanel, .middle-box, .loginscreen { width: auto !important; max-width: 420px; margin: 16px auto !important; padding: 20px 16px !important; float: none !important; }
    .logtitle { font-size: 22px !important; line-height: 1.4 !important; margin: 24px 12px 8px !important; height: auto !important; }
    .login .form-input, .login .vertify-input, .login input[type="text"], .login input[type="password"] { width: 100% !important; height: 42px; box-sizing: border-box; }
    .login input.vertify-input, .login input[type="text"].vertify-input { width: 55% !important; float: left; }
    .login .imgvertify { float: right; width: 42%; margin: 0 !important; }
    .login .imgvertify img { width: 100%; height: 42px; }
    .login .btn, .login #logbtn { width: 100% !important; height: 44px; font-size: 16px; }
    .login [class*="col-sm-offset-"] { margin-left: 0 !important; }

    /* ---------- 表格内的图标按钮、图片 ---------- */
    .m-scroll td img { max-width: 120px; }
    td a.glyphicon, td a.fa, td .layui-icon { display: inline-block; min-width: 28px; min-height: 28px; line-height: 28px; text-align: center; }
    .m-top-btn { display: none; position: fixed; right: 12px; bottom: 20px; z-index: 1500; width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(26,179,148,.9); color: #fff; font-size: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }

    /* ---------- 筛选区折叠（m.js 自动添加切换按钮） ---------- */
    .m-filter-toggle { display: block; width: 100%; margin: 0 0 8px; padding: 8px 12px; border: 1px solid #1ab394; border-radius: 4px; background: #fff; color: #1ab394; font-size: 14px; text-align: center; }
    .m-filter-collapsed { display: none !important; }

    /* ---------- H+ 后台主框架：左侧菜单改成抽屉 ---------- */
    body.m-shell .navbar-static-side { position: fixed !important; top: 0; bottom: 0; left: -240px !important; width: 220px !important; z-index: 2001; overflow-y: auto; transition: left .2s; display: block !important; }
    body.m-shell.m-nav-open .navbar-static-side { left: 0 !important; box-shadow: 2px 0 12px rgba(0,0,0,.25); }
    body.m-shell #page-wrapper { margin-left: 0 !important; }
    body.m-shell .nav-close { display: block !important; }
    body.m-shell .m-nav-mask { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 2000; background: rgba(0,0,0,.35); }
    body.m-shell.m-nav-open .m-nav-mask { display: block; }
    body.m-shell .m-nav-btn { position: fixed; left: 8px; bottom: 16px; z-index: 1999; width: 46px; height: 46px; border: 0; border-radius: 50%; background: #1ab394; color: #fff; font-size: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
    body.m-shell .content-tabs .btn-group.roll-right { display: none !important; }
    body.m-shell .content-tabs .J_tabExit { right: 0 !important; width: 56px !important; padding: 0 !important; text-align: center; font-size: 12px; }
    body.m-shell .content-tabs .roll-nav.roll-right.J_tabRight { right: 0 !important; }
    body.m-shell nav.page-tabs { margin-left: 40px !important; margin-right: 56px !important; width: auto !important; }
    body.m-shell .content-tabs .navbar-minimalize { display: block !important; }
    /* H+ 在小屏默认把顶部页签栏整个隐藏，这里恢复：左侧菜单按钮 + 页签 + 退出 */
    body.m-shell .content-tabs { display: block !important; margin: 0 !important; height: 42px; }
    body.m-shell #page-wrapper { padding: 0 !important; height: 100%; min-height: 0 !important; }
    body.m-shell .content-tabs { position: fixed !important; top: 0; left: 0; right: 0; z-index: 1000; }
    body.m-shell .J_mainContent { position: fixed !important; top: 42px; left: 0; right: 0; bottom: 0; margin: 0 !important; height: auto !important; overflow: hidden; }
    body.m-shell .J_iframe { display: block; width: 100% !important; height: 100% !important; }
    html.m-shell-html, body.m-shell, body.m-shell #wrapper { height: 100%; overflow: hidden; }
    body.m-shell .border-bottom .navbar-header { float: none; }
    body.m-shell .navbar-top-links { display: none; }
    body.m-shell .J_mainContent, body.m-shell .J_iframe { -webkit-overflow-scrolling: touch; }
}

/* 小屏电脑：列太多的表格横向滚动（m.js 只在列被挤到不足 64px 时才启用） */
.m-wide-scroll { width: 100%; overflow-x: auto; margin-bottom: 8px; }
.m-wide-scroll > table { margin-bottom: 0 !important; }
.m-wide-scroll > table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 页面大小 / 电脑版切换（只在手机上出现：m.js 只在小屏幕上创建这些元素） */
.m-zoom-btn { position: fixed; left: 10px; bottom: 74px; z-index: 99998; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 14px; line-height: 40px; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.m-zoom-panel { display: none; position: fixed; left: 10px; bottom: 122px; z-index: 99999; padding: 10px 12px; border-radius: 6px; background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-size: 14px; color: #333; }
.m-zoom-panel.m-zoom-open { display: block; }
.m-zoom-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; white-space: nowrap; }
.m-zoom-row button { min-width: 36px; height: 34px; padding: 0 10px; border: 1px solid #ddd; border-radius: 4px; background: #f7f7f7; font-size: 15px; }
.m-zoom-row .m-zoom-wide { font-size: 13px; }
.m-zoom-val { min-width: 46px; text-align: center; }
/* 电脑版下页面按 1280 宽缩小显示，切回按钮相应放大，保证手指点得到 */
.m-zoom-btn.m-zoom-pc { left: 20px; bottom: 40px; width: 150px; height: 96px; border-radius: 16px; font-size: 34px; line-height: 96px; background: rgba(26,179,148,.92); }

/* 打印时隐藏手机端附加元素 */
@media print {
    .m-filter-toggle, .m-nav-btn, .m-nav-mask, .m-top-btn, .m-zoom-btn, .m-zoom-panel { display: none !important; }
}
