/* ==================== 手机 / 折叠屏（触屏紧凑布局） ====================
 *
 * 只在 <html> 带 layout-compact 时生效（由 js/utils/layout.js 判定）：
 *   layout-phone    窄于 700px 的手机：顶部标题栏 + 底部常用栏，整页跟着手指滚动
 *   layout-compact  触屏且窄于 1100px（折叠屏展开、平板竖屏）：左侧窄图标栏 + 顶部标题栏
 *   layout-pane     紧凑布局里宽 ≥ 880px 且高 ≥ 560px：订单页左列表右详情
 * 电脑（鼠标）布局完全不受这个文件影响，表格仍是表格。
 *
 * 表格转卡片：js/utils/mobile-ui.js 会给每个 <td> 补上 data-label（列名）和
 * data-m（角色，来自 <th data-m="...">）；这里按角色把一行排成一张卡片。
 */

:root {
    --m-brand: #4B5CFB;
    --m-brand-soft: #E8EBFF;
    --m-bg: #F5F6FF;
    --m-surface: #FFFFFF;
    --m-ink: #2E3A59;
    --m-muted: #6D7688;
    --m-faint: #98A1B5;
    --m-line: #E2E6F5;
    --m-ok: #14885A;
    --m-ok-bg: #E1F4EB;
    --m-bad: #CC3A50;
    --m-bad-bg: #FCE8EC;
    --m-warn: #A8610A;
    --m-warn-bg: #FFEFD6;
    --m-radius: 16px;
    --m-shadow: 0 1px 2px rgba(46, 58, 89, 0.05), 0 8px 22px rgba(75, 92, 251, 0.07);
    --m-bar-h: 54px;
    --m-nav-h: 58px;
    --m-rail-w: 76px;
    --m-sat: env(safe-area-inset-top, 0px);
    --m-sab: env(safe-area-inset-bottom, 0px);
    --m-sal: env(safe-area-inset-left, 0px);
    --m-sar: env(safe-area-inset-right, 0px);
}

/* 手机专用元素，电脑上一律隐藏 */
.m-appbar,
.m-nav,
.m-backdrop,
.m-sheet {
    display: none;
}

html.m-lock,
html.m-lock body,
html.layout-compact.m-lock-modal,
html.layout-compact.m-lock-modal body {
    overflow: hidden;
}

/* ==================== 通用：触屏手感 ==================== */
html.layout-compact {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--m-bar-h) + var(--m-sat) + 8px);
}

html.layout-compact body {
    -webkit-tap-highlight-color: transparent;
}

html.layout-compact button,
html.layout-compact a,
html.layout-compact select,
html.layout-compact label,
html.layout-compact summary {
    touch-action: manipulation;
}

/* 触屏没有悬停：去掉悬停上浮，避免点一下后按钮一直“飘”着 */
html.layout-compact .btn:hover,
html.layout-compact .btn-primary:hover,
html.layout-compact .btn-success:hover,
html.layout-compact .btn-danger:hover,
html.layout-compact .btn-secondary:hover,
html.layout-compact .help-icon:hover,
html.layout-compact .btn-logout:hover,
html.layout-compact .table-container:hover {
    transform: none;
}

html.layout-compact .table-container:hover {
    box-shadow: none;
}

html.layout-compact tbody tr:hover {
    background: transparent;
}

/* ==================== 外壳：手机 ==================== */
html.layout-phone body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    background: var(--m-bg);
}

html.layout-phone .app-container {
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
}

html.layout-phone .sidebar {
    display: none;
}

html.layout-phone .main-area {
    display: block;
    overflow: visible;
}

html.layout-phone .tab-bar {
    display: none;
}

html.layout-phone .tab-content-area {
    overflow: visible;
    padding: 4px calc(12px + var(--m-sar)) calc(var(--m-nav-h) + var(--m-sab) + 28px) calc(12px + var(--m-sal));
}

html.layout-phone .m-appbar {
    position: sticky;
    top: 0;
    z-index: 30;
}

/* 顶部标题栏（手机和折叠屏内屏都有） */
html.layout-compact .m-appbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    min-height: calc(var(--m-bar-h) + var(--m-sat));
    padding: var(--m-sat) calc(16px + var(--m-sar)) 0 calc(18px + var(--m-sal));
    background: var(--m-bg);
    border-bottom: 1px solid transparent;
}

html.layout-compact .m-appbar-title {
    min-width: 0;
    flex: 1;
}

html.layout-compact .m-appbar-title h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--m-ink);
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 底部常用栏（只有手机） */
html.layout-phone .m-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 0 calc(4px + var(--m-sar)) var(--m-sab) calc(4px + var(--m-sal));
    background: #FFFFFF;
    border-top: 1px solid var(--m-line);
    box-shadow: 0 -4px 18px rgba(46, 58, 89, 0.06);
}

html.layout-phone .m-nav-item {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: var(--m-nav-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: none;
    color: var(--m-muted);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

html.layout-phone .m-nav-item svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

html.layout-phone .m-nav-item.is-active {
    color: var(--m-brand);
}

html.layout-phone .m-nav-item.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--m-brand);
}

/* ==================== 外壳：折叠屏内屏 / 平板（左侧窄图标栏） ==================== */
html.layout-compact:not(.layout-phone) body {
    overflow: hidden;
}

html.layout-compact:not(.layout-phone) .app-container {
    height: 100vh;
    height: 100dvh;
}

html.layout-compact:not(.layout-phone) .tab-bar {
    display: none;
}

html.layout-compact:not(.layout-phone) .tab-content-area {
    padding: 4px calc(14px + var(--m-sar)) 24px 14px;
}

html.layout-compact:not(.layout-phone) .sidebar,
html.layout-compact:not(.layout-phone) .sidebar.collapsed {
    width: var(--m-rail-w);
    min-width: var(--m-rail-w);
    padding-left: var(--m-sal);
    background: #FFFFFF;
    border-right: 1px solid var(--m-line);
    box-shadow: none;
}

html.layout-compact:not(.layout-phone) .sidebar-header {
    justify-content: center;
    padding: calc(12px + var(--m-sat)) 0 12px;
    background: transparent;
    border: 0;
}

html.layout-compact:not(.layout-phone) .sidebar-header::before {
    display: none;
}

html.layout-compact:not(.layout-phone) .sidebar-toggle {
    display: none;
}

html.layout-compact:not(.layout-phone) .sidebar-title {
    opacity: 1;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4B5CFB, #818CF8);
    color: transparent;
    font-size: 0;
    text-shadow: none;
    display: grid;
    place-items: center;
}

html.layout-compact:not(.layout-phone) .sidebar-title::before {
    content: 'HUB';
    color: #FFFFFF;
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.5px;
}

html.layout-compact:not(.layout-phone) .sidebar-nav {
    padding: 4px 6px;
}

html.layout-compact:not(.layout-phone) .nav-group {
    border-top: 0;
    padding-top: 0;
    margin: 0;
}

html.layout-compact:not(.layout-phone) .nav-group-title {
    display: none;
}

html.layout-compact:not(.layout-phone) .nav-group-items,
html.layout-compact:not(.layout-phone) .nav-group.collapsed .nav-group-items {
    max-height: none !important;
    overflow: visible;
}

html.layout-compact:not(.layout-phone) .nav-menu {
    margin: 0;
}

html.layout-compact:not(.layout-phone) .nav-menu li a,
html.layout-compact:not(.layout-phone) .nav-group-items li a,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .nav-menu li a,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .nav-group-items li a {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 60px;
    padding: 8px 2px;
    border-left: 0;
    border-radius: 16px;
    text-align: center;
}

html.layout-compact:not(.layout-phone) .menu-icon,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .menu-icon {
    width: auto;
    margin: 0;
    font-size: 1.25rem;
    line-height: 1;
}

html.layout-compact:not(.layout-phone) .menu-text,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .menu-text {
    display: block;
    flex: none;
    max-width: 100%;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
    overflow: visible;
}

html.layout-compact:not(.layout-phone) .nav-menu li a.active,
html.layout-compact:not(.layout-phone) .nav-group-items li a.active {
    background: var(--m-brand-soft);
    color: var(--m-brand);
}

html.layout-compact:not(.layout-phone) .sidebar.collapsed .nav-menu li a:hover::after,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .nav-group-items li a:hover::after {
    display: none;
}

html.layout-compact:not(.layout-phone) .user-menu,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .user-menu {
    flex-direction: column;
    gap: 6px;
    padding: 10px 4px calc(10px + var(--m-sab));
    background: transparent;
}

html.layout-compact:not(.layout-phone) .user-details {
    display: none;
}

html.layout-compact:not(.layout-phone) .btn-logout,
html.layout-compact:not(.layout-phone) .sidebar.collapsed .btn-logout {
    min-height: 36px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

/* ==================== 底部面板（更多菜单、操作菜单、确认框） ==================== */
html.layout-compact .m-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(28, 36, 66, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

html.layout-compact .m-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

html.layout-compact .m-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    max-height: 90vh;
    max-height: 90dvh;
    background: #FFFFFF;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px rgba(20, 28, 58, 0.2);
    transform: translateY(102%);
    visibility: hidden;
    transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.26s;
}

html.layout-compact .m-sheet.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.layout-compact .m-sheet-grab {
    width: 40px;
    height: 5px;
    margin: 9px auto 0;
    border-radius: 99px;
    background: #D3D8E8;
    flex: none;
}

html.layout-compact .m-sheet-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    min-height: 54px;
    padding: 6px 8px 4px 20px;
}

html.layout-compact .m-sheet-head h2 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--m-ink);
}

html.layout-compact .m-sheet-close {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--m-muted);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

html.layout-compact .m-sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 20px 18px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

html.layout-compact .m-sheet-foot {
    display: flex;
    flex: none;
    gap: 10px;
    padding: 12px 20px calc(12px + var(--m-sab));
    border-top: 1px solid var(--m-line);
    background: #FFFFFF;
}

html.layout-compact .m-sheet-foot[hidden] {
    display: none;
}

html.layout-compact .m-sheet-foot .btn {
    flex: 1;
}

html.layout-compact .m-sheet-foot .btn-primary,
html.layout-compact .m-sheet-foot .btn-danger {
    flex: 1.4;
}

/* 菜单行（操作菜单） */
html.layout-compact .m-menu {
    display: flex;
    flex-direction: column;
}

html.layout-compact .m-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    min-height: 56px;
    padding: 10px 4px;
    border: 0;
    border-bottom: 1px solid var(--m-line);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

html.layout-compact .m-row:last-child {
    border-bottom: 0;
}

html.layout-compact .m-row:active {
    background: var(--m-brand-soft);
}

html.layout-compact .m-row:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

html.layout-compact .m-row-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--m-ink);
}

html.layout-compact .m-row-hint {
    font-size: 0.82rem;
    color: var(--m-muted);
    line-height: 1.4;
}

html.layout-compact .m-row.is-danger .m-row-label {
    color: var(--m-bad);
}

/* 确认框 */
html.layout-compact .m-confirm-text {
    margin: 4px 0 10px;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--m-ink);
    white-space: pre-line;
}

html.layout-compact .m-confirm-list {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--m-muted);
}

/* “更多页面”菜单 */
html.layout-compact .m-more-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

html.layout-compact .m-more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    padding: 0 14px;
    border: 1px solid var(--m-line);
    border-radius: 15px;
    background: #FFFFFF;
    color: var(--m-ink);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

html.layout-compact .m-more-item.is-active {
    border-color: var(--m-brand);
    background: var(--m-brand-soft);
    color: var(--m-brand);
}

html.layout-compact .m-more-icon {
    font-size: 1.3rem;
    line-height: 1;
}

html.layout-compact .m-account {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--m-line);
}

html.layout-compact .m-account-avatar {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #4B5CFB, #818CF8);
    color: #FFFFFF;
    font-weight: 800;
}

html.layout-compact .m-account-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

html.layout-compact .m-account-text span {
    font-size: 0.8rem;
    color: var(--m-muted);
}

/* ==================== 通用组件：搜索栏、状态标签、筛选按钮 ==================== */
html.layout-compact .m-chips {
    display: flex;
    gap: 8px;
    margin: 0 -12px;
    padding: 2px 12px 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

html.layout-compact .m-chips::-webkit-scrollbar {
    display: none;
}

html.layout-compact .m-chip {
    flex: none;
    min-height: 44px;
    padding: 0 17px;
    border: 1.5px solid var(--m-line);
    border-radius: 99px;
    background: #FFFFFF;
    color: var(--m-muted);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

html.layout-compact .m-chip.is-active {
    background: var(--m-ink);
    border-color: var(--m-ink);
    color: #FFFFFF;
}

html.layout-compact .m-badge {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--m-brand);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
}

html.layout-compact .m-badge:empty {
    display: none;
}

/* ==================== 页面头部：标题栏已显示页面名，这里只留操作 ==================== */
html.layout-compact .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 8px;
    padding: 2px 0 4px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

html.layout-compact .page-header::before {
    display: none;
}

html.layout-compact .page-header > h2 {
    display: none;
}

html.layout-compact .page-header > div {
    flex-wrap: wrap;
    width: 100%;
}

html.layout-compact .page-header select,
html.layout-compact .page-header input[type="text"],
html.layout-compact .page-header input[type="search"],
html.layout-compact .page-header input[type="date"],
html.layout-compact .page-header input[type="number"] {
    min-width: 0 !important;
    max-width: 100%;
    width: 100% !important;
}

html.layout-compact .page-header label {
    white-space: normal !important;
}

/* ==================== 按钮、输入框：放大到手指好点 ==================== */
html.layout-compact .btn,
html.layout-compact .btn-small,
html.layout-compact .btn-sm,
html.layout-compact button.btn {
    min-height: 44px;
    padding: 0.5rem 1rem !important;
    font-size: 0.95rem !important;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    line-height: 1.25;
}

html.layout-compact td .btn {
    margin: 0 !important;
}

/* 16px 以上，iPhone 点进输入框时页面不会被自动放大 */
html.layout-compact input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html.layout-compact select,
html.layout-compact textarea {
    font-size: 16px !important;
}

html.layout-compact input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
html.layout-compact select {
    min-height: 46px;
}

html.layout-compact input[type="checkbox"],
html.layout-compact input[type="radio"] {
    width: 22px;
    height: 22px;
}

html.layout-compact .form-container {
    padding: 1rem;
    max-width: 100%;
}

html.layout-compact .form-group {
    margin-bottom: 1.1rem;
}

html.layout-compact .form-group input,
html.layout-compact .form-group select,
html.layout-compact .form-group textarea {
    padding: 0.7rem 0.85rem;
}

html.layout-compact .switch {
    width: 54px;
    height: 32px;
}

html.layout-compact .slider:before {
    height: 26px;
    width: 26px;
}

html.layout-compact input:checked + .slider:before {
    transform: translateX(22px);
}

/* ==================== 弹窗：从底部升起，保存按钮固定在底部 ==================== */
html.layout-compact .modal.show {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

html.layout-compact .modal-content {
    width: 100% !important;
    max-width: none !important;
    max-height: 92vh;
    max-height: 92dvh;
    margin: 0;
    padding: 0 16px calc(16px + var(--m-sab));
    border-radius: 22px 22px 0 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* 点输入框时浏览器会把它滚进视野：别让它被吸顶的标题栏或吸底的按钮栏盖住 */
    scroll-padding-top: 76px;
    scroll-padding-bottom: 110px;
}

/* 带吸底按钮栏的弹窗：按钮栏自己负责底部内边距和安全区，否则按钮栏下面会露出一条正在滚动的内容 */
html.layout-compact .modal-content:has(.form-actions) {
    padding-bottom: 0;
}

html.layout-compact .modal-header {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 -16px 12px;
    padding: 14px 8px 10px 16px;
    background: #FFFFFF;
}

html.layout-compact .modal-header h3 {
    font-size: 1.15rem;
}

html.layout-compact .modal .close,
html.layout-compact .modal .modal-close {
    width: 44px;
    height: 44px;
    flex: none;
    font-size: 1.8rem;
}

html.layout-compact .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    gap: 0.75rem;
    margin: 14px -16px 0;
    padding: 12px 16px calc(12px + var(--m-sab));
    background: #FFFFFF;
    border-top: 1px solid var(--m-line);
}

html.layout-compact .form-actions .btn {
    flex: 1;
}

/* 提示条：避开顶部标题栏 */
html.layout-compact #alert-container {
    top: calc(var(--m-sat) + var(--m-bar-h) + 6px) !important;
    width: calc(100% - 24px) !important;
    max-width: 560px !important;
}

html.layout-compact .alert {
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

/* ==================== 表格 → 卡片 ==================== */
html.layout-compact .table-container {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

html.layout-compact .table-container table,
html.layout-compact table.rt {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 0.95rem;
}

html.layout-compact .table-container thead,
html.layout-compact table.rt thead {
    display: none;
}

html.layout-compact .table-container tbody,
html.layout-compact table.rt tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

html.layout-compact .table-container tbody tr,
html.layout-compact table.rt tbody tr {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 14px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius);
    box-shadow: var(--m-shadow);
}

html.layout-compact .table-container td,
html.layout-compact .rt td {
    display: block;
    flex: 1 1 100%;
    min-width: 0;
    padding: 0;
    border: 0 !important;
    text-align: left;
    font-size: 0.92rem;
    white-space: normal !important;
    overflow: visible;
    text-overflow: clip;
    max-width: none !important;
    overflow-wrap: anywhere;
    order: 4;
}

/* 普通列和折叠列（点开后）：“列名 值”，换行时对齐到值的位置。
   列名宽 6.4em（按 0.82rem 算 ≈ 5.25rem），换行缩进 5.7em（按 0.92rem 算 ≈ 5.24rem），两边对齐 */
html.layout-compact td[data-label]:is(:not([data-m]), [data-m="hide"]) {
    padding-left: 5.7em;
    text-indent: -5.7em;
}

html.layout-compact td[data-label]:is(:not([data-m]), [data-m="hide"])::before {
    content: attr(data-label);
    display: inline-block;
    width: 6.4em;
    text-indent: 0;
    color: var(--m-faint);
    font-size: 0.82rem;
}

html.layout-compact td[data-label]:is(:not([data-m]), [data-m="hide"]) > * {
    text-indent: 0;
}

html.layout-compact td[data-m="select"] {
    order: 0;
    flex: 0 0 auto;
}

html.layout-compact td[data-m="status"] {
    order: 1;
    flex: 1 1 0;
    font-weight: 700;
}

html.layout-compact td[data-m="title"] {
    order: 2;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.4;
}

html.layout-compact td[data-m="sub"] {
    order: 3;
    flex: 0 1 auto;
    color: var(--m-muted);
    font-size: 0.88rem;
}

html.layout-compact td[data-m="sub"] + td[data-m="sub"]::before {
    content: '·';
    margin-right: 0.5em;
    color: var(--m-faint);
}

html.layout-compact td[data-m="hide"] {
    display: none;
    order: 5;
}

html.layout-compact tr.rt-open td[data-m="hide"] {
    display: block;
}

html.layout-compact td[data-m="actions"] {
    order: 9;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--m-line) !important;
    margin-top: 2px;
}

html.layout-compact td[data-m="actions"] .btn {
    flex: 1 1 auto;
}

html.layout-compact td[data-m="actions"] .btn-primary {
    order: -1;
}

/* 有折叠内容的卡片：底部给一个展开提示 */
html.layout-compact tr.rt-card::after {
    content: '展开更多 ▾';
    order: 8;
    flex: 1 1 100%;
    text-align: center;
    font-size: 0.78rem;
    color: var(--m-faint);
}

html.layout-compact tr.rt-card.rt-open::after {
    content: '收起 ▴';
}

/* 加载中、暂无数据这类占位行：不要做成卡片 */
html.layout-compact table tbody tr.rt-note {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

html.layout-compact table tbody tr.rt-note td {
    padding: 28px 8px;
    text-align: center;
    text-indent: 0;
}

html.layout-compact table tbody tr.rt-note td::before {
    display: none;
}

/* ==================== 空状态、加载中 ==================== */
html.layout-compact .empty-state {
    padding: 2.5rem 1rem;
}

html.layout-compact .empty-tabs-hint {
    font-size: 1rem;
}

/* ==================== 折叠屏内屏：面板变成居中窗口 ==================== */
html.layout-compact:not(.layout-phone) .m-sheet {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(580px, calc(100% - 48px));
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 22px;
    overflow: hidden;
    transform: translate(-50%, -46%) scale(0.97);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0s linear 0.2s;
}

html.layout-compact:not(.layout-phone) .m-sheet.is-open {
    transform: translate(-50%, -50%);
    opacity: 1;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

html.layout-compact:not(.layout-phone) .m-sheet-grab {
    display: none;
}

html.layout-compact:not(.layout-phone) .modal.show {
    align-items: center;
    padding: 1rem;
}

html.layout-compact:not(.layout-phone) .modal-content {
    width: min(720px, 100%) !important;
    border-radius: 22px;
}

@media (prefers-reduced-motion: reduce) {
    html.layout-compact .m-sheet,
    html.layout-compact .m-backdrop {
        transition: none !important;
    }
}
