/*
 * Softway: giao diện điện thoại (< 640px) cho mọi trang quản trị / cổng khách.
 *
 * Bảng: mọi bảng Filament bật stackedOnMobile() (AdminPanelProvider / CustomerPanelProvider),
 * mỗi dòng thành một thẻ gọn: hàng đầu là ô chọn + cột định danh + trạng thái + nút thao tác,
 * các cột còn lại xếp 2 cột "nhãn trên – giá trị dưới". mobile.js đánh dấu cột tiêu đề
 * (sw-m-title), cột hẹp đầu bảng (sw-m-lead), trạng thái (sw-m-badge), ô trống (sw-m-empty),
 * ô dài (sw-m-wide); bảng HTML tự viết rộng hơn màn hình thành thẻ (sw-plain-cards).
 * Bảng dòng chi tiết trong biểu mẫu/trang xem: xem khối @container cuối tệp.
 * Không cần kéo ngang: mọi thứ nằm gọn trong bề ngang màn hình.
 */
@media (max-width: 639.98px) {
    /* ---------- Khung trang ---------- */
    /* Lưới an toàn: phần lỡ tràn không làm cả trang trượt ngang (clip giữ được thanh trên dính). */
    body {
        overflow-x: clip;
    }

    .fi-main {
        padding-inline: 0.75rem !important;
    }

    .fi-page-header-main-ctn {
        padding-block: 0.75rem !important;
        row-gap: 0.75rem !important;
    }

    .fi-header {
        row-gap: 0.75rem;
    }

    .fi-header-heading {
        font-size: 1.25rem !important;
        line-height: 1.75rem !important;
    }

    .fi-breadcrumbs {
        display: none;
    }

    /* Nút đầu trang: xếp gọn, không tràn khung. */
    .fi-header .fi-ac {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .fi-header .fi-ac > .fi-btn,
    .fi-header .fi-ac > * {
        max-width: 100%;
    }

    /* Thanh tab / bước: cuộn ngang trong chính nó thay vì đẩy cả trang. */
    .fi-tabs {
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .fi-tabs::-webkit-scrollbar {
        display: none;
    }

    /* ---------- Thanh công cụ bảng ---------- */
    /* Nút nhóm/hàng loạt + ô tìm kiếm + lọc + cột trên một hàng. */
    .fi-ta-header-toolbar {
        flex-direction: row !important;
        flex-wrap: nowrap;
        align-items: center !important;
        gap: 0.5rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    .fi-ta-header-toolbar > * {
        min-width: 0;
    }

    .fi-ta-header-toolbar > .fi-ta-actions {
        flex: 0 0 auto;
        flex-wrap: nowrap !important;
        gap: 0.25rem !important;
    }

    .fi-ta-header-toolbar > div:last-child {
        flex: 1 1 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .fi-ta-header-toolbar .fi-ta-search-field {
        flex: 1 1 auto;
        min-width: 0;
    }

    .fi-ta-header-ctn > .fi-ta-header {
        padding: 0.75rem !important;
    }

    .fi-ta-filters-above-content-ctn {
        padding: 0.5rem 0.75rem !important;
    }

    .fi-ta-filter-indicators {
        padding: 0.5rem 0.75rem !important;
    }

    .fi-pagination {
        padding: 0.5rem 0.75rem !important;
        row-gap: 0.5rem;
    }

    .fi-pagination .fi-pagination-overview {
        font-size: 0.75rem;
    }

    /* Dòng sắp xếp + chọn tất cả (thay cho tiêu đề cột trên điện thoại). */
    .fi-ta-table-stacked-header-row .fi-ta-table-stacked-header-cell {
        padding: 0.5rem 0.75rem !important;
        gap: 0.5rem !important;
    }

    .fi-ta-table-stacked-header-row .fi-ta-table-stacked-sorting {
        min-width: 0;
        gap: 0.5rem !important;
    }

    .fi-ta-table-stacked-header-row .fi-ta-table-stacked-sorting > label {
        min-width: 0;
        flex: 1 1 0;
    }

    .fi-ta-table-stacked-header-row .fi-ta-table-stacked-sorting > label:last-child:not(:first-child) {
        flex: 0 0 auto;
    }

    .fi-ta-table-stacked-header-row .fi-ta-page-checkbox {
        order: -1;
        margin-inline-start: 0 !important;
        margin-inline-end: 0.25rem;
    }

    /* Bảng không xếp thẻ được (bảng tuỳ biến trong trang): tự cuộn trong khung, không đẩy trang. */
    .fi-ta-content-ctn,
    .fi-in-table-repeater,
    .fi-fo-table-repeater {
        max-width: 100%;
    }

    /* ---------- Bảng HTML tự viết rộng hơn màn hình (mobile.js thêm sw-plain-cards) → thẻ ---------- */
    table.sw-plain-cards,
    table.sw-plain-cards > tbody,
    table.sw-plain-cards > tfoot {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    table.sw-plain-cards > thead {
        display: none !important;
    }

    table.sw-plain-cards > tbody > tr,
    table.sw-plain-cards > tfoot > tr {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.25rem 0.75rem;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid rgb(229 231 235);
    }

    .dark table.sw-plain-cards > tbody > tr,
    .dark table.sw-plain-cards > tfoot > tr {
        border-bottom-color: rgb(255 255 255 / 0.08);
    }

    table.sw-plain-cards > tbody > tr > :is(td, th),
    table.sw-plain-cards > tfoot > tr > :is(td, th) {
        display: block;
        min-width: 0;
        width: auto !important;
        padding-block: 0;
        padding-inline-end: 0;
        text-align: start !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        border: 0 !important;
    }

    table.sw-plain-cards > tbody > tr > :is(td, th):not([style*='padding']),
    table.sw-plain-cards > tfoot > tr > :is(td, th):not([style*='padding']) {
        padding-inline-start: 0;
    }

    table.sw-plain-cards :is(td, th)[data-sw-label]:not([data-sw-label=''])::before {
        content: attr(data-sw-label);
        display: block;
        font-size: 0.6875rem;
        line-height: 1rem;
        font-weight: 500;
        color: rgb(107 114 128);
        text-transform: none;
        letter-spacing: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Ô chỉ có biểu tượng (mũi tên mở rộng): nằm ở lề trái thẻ, ngang tiêu đề. */
    table.sw-plain-cards > :is(tbody, tfoot) > tr:has(> .sw-pc-icon) {
        position: relative;
        padding-inline-start: 2rem;
    }

    table.sw-plain-cards :is(td, th).sw-pc-icon {
        position: absolute;
        top: 0.5rem;
        inset-inline-start: 0.5rem;
        padding: 0 !important;
    }

    table.sw-plain-cards :is(td, th).sw-pc-title {
        grid-column: 1 / -1;
        font-weight: 600;
    }

    table.sw-plain-cards :is(td, th).sw-pc-title::before {
        display: none !important;
    }

    table.sw-plain-cards :is(td, th).sw-pc-empty {
        display: none !important;
    }

    table.sw-plain-cards tr.sw-pc-group > :is(td, th) {
        grid-column: 1 / -1;
    }

    table.sw-plain-cards tr.sw-pc-group > :is(td, th)::before {
        display: none !important;
    }

    table.sw-plain-cards tr.sw-pc-group > :is(td, th):empty {
        display: none !important;
    }

    /* ---------- Lưới thẻ (nhân viên, sản phẩm…): ảnh nhỏ bên trái, chữ bên phải ---------- */
    .fi-ta-content-grid {
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }

    .fi-ta-content-grid .fi-ta-split:has(> .fi-grid-col:first-child > .fi-ta-image) {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }

    .fi-ta-content-grid .fi-ta-split:has(> .fi-grid-col:first-child > .fi-ta-image) > .fi-grid-col:first-child {
        flex: 0 0 auto;
        width: auto !important;
    }

    .fi-ta-content-grid .fi-ta-split:has(> .fi-grid-col:first-child > .fi-ta-image) > .fi-grid-col:first-child .fi-ta-image {
        width: auto !important;
    }

    .fi-ta-content-grid .fi-ta-split:has(> .fi-grid-col:first-child > .fi-ta-image) > .fi-grid-col:first-child img {
        width: 3rem !important;
        height: 3rem !important;
    }

    .fi-ta-content-grid .fi-ta-split:has(> .fi-grid-col:first-child > .fi-ta-image) > .fi-grid-col:not(:first-child) {
        flex: 1 1 0;
        min-width: 0;
    }

    .fi-ta-content-grid .fi-ta-record .fi-ta-record-content {
        padding-block: 0.625rem !important;
    }

    /* ---------- Kanban: mỗi cột gần bằng màn hình, vuốt ngang dừng đúng từng cột ---------- */
    .crm-kanban-columns,
    .fi-kanban-board > .overflow-x-auto,
    .fi-kanban-board > div:has(> .fi-kanban-column) {
        scroll-snap-type: x proximity;
        scroll-padding-inline: 0.25rem;
        gap: 0.625rem !important;
        overscroll-behavior-x: contain;
    }

    .fi-kanban-column {
        width: 88% !important;
        max-width: 22rem;
        scroll-snap-align: start;
    }

    /* ---------- Biểu mẫu & trang xem ---------- */
    /* Trang xem: các mục chỉ đọc xếp 2 cột thay vì mỗi mục một hàng. */
    .fi-grid.lg\:fi-grid-cols:has(> .fi-grid-col > .fi-sc-component > .fi-in-entry):not(:has(> .fi-grid-col > .fi-sc-component > :is(.fi-fo-field, .fi-section, .fi-fo-repeater, .fi-fo-table-repeater))) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .fi-in-entry {
        row-gap: 0.125rem !important;
    }

    .fi-in-entry-label {
        font-size: 0.75rem !important;
        line-height: 1rem !important;
        color: rgb(107 114 128) !important;
    }

    .dark .fi-in-entry-label {
        color: rgb(156 163 175) !important;
    }

    .fi-section:not(.fi-section-not-contained) > .fi-section-content-ctn > .fi-section-content {
        padding: 0.75rem !important;
    }

    .fi-section-header {
        padding: 0.75rem !important;
    }

    /* Tiêu đề khối + nút bên phải: tiêu đề giữ đủ bề ngang, nút xuống hàng khi chật. */
    .fi-section-header:has(> .fi-section-header-after-ctn) {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .fi-section-header > .fi-section-header-text-ctn {
        flex: 1 1 12rem;
        min-width: 0;
    }

    .fi-section-header > .fi-section-header-after-ctn {
        flex: 0 1 auto;
        max-width: 100%;
        margin-inline-start: auto;
    }

    .fi-modal-content {
        padding: 1rem !important;
    }

    .fi-form-actions .fi-ac,
    .fi-sc-actions .fi-ac {
        flex-wrap: wrap;
    }

    /* ---------- Widget thống kê ---------- */
    .fi-wi-stats-overview-stats-ctn {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
    }

    .fi-wi-stats-overview-stat {
        padding: 0.625rem 0.75rem !important;
        min-width: 0;
    }

    .fi-wi-stats-overview-stat-value {
        font-size: 1.125rem !important;
        line-height: 1.5rem !important;
        overflow-wrap: anywhere;
    }

    .fi-wi-stats-overview-stat-label,
    .fi-wi-stats-overview-stat-description {
        font-size: 0.75rem !important;
    }
}

/*
 * Bảng dòng chi tiết trong biểu mẫu / trang xem (dòng đơn hàng, dòng hoá đơn…): khi khung hẹp
 * Filament đã xếp mỗi dòng thành khối nhưng mỗi trường chiếm một hàng (rất dài). Ở đây xếp 2 cột,
 * ô đầu (sản phẩm) cả bề ngang, nút xoá/nhân bản ở góc trên, dòng tổng gọn bên phải.
 * Theo bề ngang khung bảng (giống Filament: dưới 36rem), không theo màn hình.
 */
@container (width < 36rem) {
    .sw-repeater-cards > table > tbody > tr {
        position: relative;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.625rem 0.75rem !important;
        padding: 0.75rem !important;
    }

    .sw-repeater-cards > table > tbody > tr > td {
        min-width: 0 !important;
        width: auto !important;
        max-width: none !important;
        padding: 0 !important;
    }

    .sw-repeater-cards > table > tbody > tr > td > * {
        min-width: 0 !important;
    }

    .sw-repeater-cards > table > tbody > tr > td :is(.fi-fo-field, .fi-in-entry) {
        row-gap: 0.25rem !important;
    }

    .sw-repeater-cards > table > tbody > tr > td :is(.fi-fo-field-label-content, .fi-in-entry-label) {
        font-size: 0.75rem !important;
        line-height: 1rem !important;
        color: rgb(107 114 128);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sw-repeater-cards > table td[data-sw-role='empty'] {
        display: none !important;
    }

    /* Trang xem: dùng tên cột (đã dịch) thay cho nhãn riêng của từng ô. */
    .sw-repeater-cards > table > tbody > tr > td[data-sw-label]:not([data-sw-label='']):has(.fi-in-entry) .fi-in-entry-label-col {
        display: none !important;
    }

    .sw-repeater-cards > table > tbody > tr > td[data-sw-label]:not([data-sw-label='']):has(.fi-in-entry)::before {
        content: attr(data-sw-label);
        display: block;
        margin-bottom: 0.125rem;
        font-size: 0.75rem;
        line-height: 1rem;
        font-weight: 500;
        color: rgb(107 114 128);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Ô đầu (sản phẩm / mô tả): cả bề ngang, chừa chỗ cho nút ở góc. */
    .sw-repeater-cards > table > tbody > tr > td[data-sw-label]:first-child,
    .sw-repeater-cards > table > tbody > tr > td[data-sw-role='handle'] + td[data-sw-label] {
        grid-column: 1 / -1;
        padding-inline-end: 2.5rem !important;
    }

    .sw-repeater-cards > table > tbody > tr:has(> td[data-sw-role='handle']) > td[data-sw-role='handle'] + td[data-sw-label] {
        padding-inline-end: 5rem !important;
    }

    .sw-repeater-cards > table > tbody > tr > td[data-sw-role='actions'] {
        position: absolute;
        top: 0.5rem;
        inset-inline-end: 0.5rem;
    }

    .sw-repeater-cards > table > tbody > tr > td[data-sw-role='actions'] > div {
        padding: 0 !important;
        min-width: 0 !important;
        justify-content: flex-end !important;
        gap: 0.25rem !important;
    }

    .sw-repeater-cards > table > tbody > tr > td[data-sw-role='handle'] {
        position: absolute;
        top: 0.5rem;
        inset-inline-end: 2.75rem;
    }

    .sw-repeater-cards > table > tbody > tr > td[data-sw-role='handle'] > div {
        display: flex;
        gap: 0.125rem;
    }

    .sw-repeater-cards > table > tfoot,
    .sw-repeater-cards > table > tfoot > tr {
        display: block !important;
        width: 100%;
    }

    .sw-repeater-cards > table > tfoot > tr {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.25rem 1.25rem;
        padding: 0.5rem 0.75rem;
    }

    .sw-repeater-cards > table > tfoot > tr > td {
        display: block !important;
        padding: 0 !important;
        text-align: end !important;
    }

    .sw-repeater-cards > table > tfoot > tr > td[data-sw-role='empty'] {
        display: none !important;
    }

    .sw-repeater-cards > table > tfoot > tr > td[data-sw-label]:not([data-sw-label=''])::before {
        content: attr(data-sw-label) ': ';
        font-weight: 400;
        color: rgb(107 114 128);
    }
}

/*
 * Bảng → thẻ. mobile.js gắn sw-cards cho bảng stackedOnMobile khi: màn hình điện thoại (< 640px),
 * hoặc bảng rộng hơn khung chứa và khung hẹp hơn 768px (máy tính bảng có menu phụ, bảng con trong
 * cột hẹp…). Ở bề ngang >= 640px Filament vẫn vẽ bảng, nên khối dưới tự chuyển bảng thành khối.
 */
.fi-ta-table-stacked-on-mobile.sw-cards,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody,
.fi-ta-table-stacked-on-mobile.sw-cards > tfoot,
.fi-ta-table-stacked-on-mobile.sw-cards > tfoot > tr,
.fi-ta-table-stacked-on-mobile.sw-cards > tfoot > tr > td {
    display: block !important;
    width: 100%;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody {
    white-space: normal !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > thead {
    display: block !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > thead > tr:not(.fi-ta-table-stacked-header-row) {
    display: none !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > thead > tr.fi-ta-table-stacked-header-row {
    display: block !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > thead > tr.fi-ta-table-stacked-header-row > td {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
}

.fi-ta-table-stacked-on-mobile.sw-cards > thead > tr.fi-ta-table-stacked-header-row .fi-ta-table-stacked-sorting {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    max-width: 28rem;
    gap: 0.5rem;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr:not(.fi-ta-row),
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr:not(.fi-ta-row) > td {
    display: block !important;
    width: 100%;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td > .fi-ta-cell-content {
    display: block;
}

.fi-ta-content-ctn:has(> .fi-ta-table-stacked-on-mobile.sw-cards.sw-cards) {
    overflow-x: hidden !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: 0.75rem;
    row-gap: 0.375rem;
    padding: 0.625rem 0.75rem !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell {
    display: block;
    flex: 1 1 calc(50% - 0.375rem);
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    position: static;
}

/* Cột Filament ẩn ở bề ngang hiện tại (visibleFrom / hiddenFrom): mobile.js đánh dấu sw-m-off. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-off {
    display: none !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-empty {
    display: none !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-wide {
    flex-basis: 100%;
}

/* Nhãn nhỏ phía trên giá trị. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td > .fi-ta-cell-label {
    display: block;
    padding: 0 !important;
    font-size: 0.6875rem;
    line-height: 1rem;
    font-weight: 500;
    color: rgb(107 114 128);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td > .fi-ta-cell-label {
    color: rgb(156 163 175);
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td > .fi-ta-cell-content {
    min-width: 0;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* Nội dung cột: bỏ đệm của bảng, canh trái, cho xuống dòng. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-col {
    display: block;
    min-width: 0;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-cell-content > .fi-ta-col > *,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-cell-content > .fi-ta-col > * > :is(.fi-ta-text, .fi-ta-icon, .fi-ta-color, .fi-ta-image, .fi-ta-checkbox, .fi-ta-select, .fi-ta-toggle, .fi-ta-text-input) {
    padding: 0 !important;
    min-width: 0;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-cell-content :is(.fi-ta-text, .fi-ta-icon, .fi-ta-color, .fi-ta-image, .fi-ta-checkbox, .fi-ta-select, .fi-ta-toggle, .fi-ta-text-input) {
    padding: 0 !important;
    justify-content: flex-start !important;
    text-align: start !important;
    white-space: normal;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-cell-content :is(.fi-ta-text, .fi-ta-text-item) {
    max-width: 100% !important;
    overflow-wrap: anywhere;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-cell-content .fi-ta-text-input input,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td .fi-ta-cell-content .fi-ta-select select {
    width: 100%;
    min-width: 0 !important;
}

/* Dòng không chọn được: ô chọn trống không chiếm chỗ. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-selection-cell:not(:has(input)) {
    display: none !important;
}

/* Ô chọn: đầu thẻ, cùng hàng với tiêu đề. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-selection-cell {
    position: static !important;
    order: -3;
    flex: 0 0 auto;
    width: auto !important;
    padding: 0.125rem 0 0 !important;
}

/* Cột hẹp đầu bảng (ảnh đại diện, sao, ưu tiên…): đứng trước tiêu đề, không nhãn. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-lead {
    order: -2;
    flex: 0 0 auto;
    max-width: 40%;
}

/* Tiêu đề thẻ: cột định danh (mobile.js chọn); khi chưa có thì là ô dữ liệu đầu tiên. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-title,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:not(:has(> .sw-m-title)) > td.fi-ta-selection-cell + td.fi-ta-cell:not(:has(> .fi-ta-actions)),
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:not(:has(> .sw-m-title)) > td.fi-ta-cell:first-child:not(.fi-ta-selection-cell):not(:has(> .fi-ta-actions)) {
    order: -1;
    flex: 1 1 55%;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.sw-m-title > .fi-ta-cell-label,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.sw-m-lead > .fi-ta-cell-label,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:not(:has(> .sw-m-title)) > td.fi-ta-selection-cell + td.fi-ta-cell > .fi-ta-cell-label,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:not(:has(> .sw-m-title)) > td.fi-ta-cell:first-child > .fi-ta-cell-label {
    display: none;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.sw-m-title .fi-ta-cell-content,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:not(:has(> .sw-m-title)) > td.fi-ta-selection-cell + td.fi-ta-cell .fi-ta-cell-content,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:not(:has(> .sw-m-title)) > td.fi-ta-cell:first-child .fi-ta-cell-content {
    font-size: 0.9375rem;
    line-height: 1.375rem;
    font-weight: 600;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.sw-m-title :is(.fi-ta-text-item, .fi-ta-text-item-label) {
    font-weight: 600;
}

/* Trạng thái (một nhãn màu): cạnh tiêu đề, không nhãn cột. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-badge {
    order: 0 !important;
    flex: 0 1 auto;
    max-width: 42%;
    align-self: center;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-badge .fi-badge {
    max-width: 100%;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-badge .fi-badge > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Có nhãn trạng thái: tiêu đề co lại để tiêu đề + trạng thái + nút cùng một hàng. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row:has(> .sw-m-badge) > td.fi-ta-cell.sw-m-title {
    flex: 1 1 0;
    min-width: 40%;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell.sw-m-badge > .fi-ta-cell-label {
    display: none;
}

/* Nút thao tác: cùng hàng với tiêu đề, góc phải thẻ. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell:has(> .fi-ta-actions) {
    order: 0;
    flex: 0 0 auto;
    max-width: 45%;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell:has(> .fi-ta-actions) ~ td.fi-ta-cell,
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell:not(.sw-m-title):not(.sw-m-lead):not(.fi-ta-selection-cell):not(:has(> .fi-ta-actions)) {
    order: 1;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell > .fi-ta-actions {
    justify-content: flex-end !important;
    flex-wrap: wrap;
    gap: 0.25rem 0.625rem !important;
}

/* Nhiều nút có chữ: xuống hàng cuối thẻ. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell:has(> .fi-ta-actions > .fi-ac-action.fi-btn ~ .fi-ac-action.fi-btn) {
    order: 99;
    flex: 1 1 100%;
    max-width: none;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-row > td.fi-ta-cell:has(> .fi-ta-actions:empty) {
    display: none !important;
}

/* Dòng nhóm / tổng: gọn. */
.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-group-header-row > td {
    padding: 0.5rem 0.75rem !important;
}

.fi-ta-table-stacked-on-mobile.sw-cards > tbody > tr.fi-ta-summary-row > td {
    padding: 0.25rem 0.75rem !important;
}
