/* Opt-in: the older Backstage lists keep their existing controls and data. */
table[data-responsive-cards] { width: 100% !important; }
table[data-responsive-cards] td { overflow-wrap: anywhere; }
table[data-responsive-cards].tv-table-empty { table-layout: fixed; min-width: 0 !important; }
table[data-responsive-cards].tv-table-empty th { min-width: 0 !important; width: auto !important; overflow: hidden; }
table[data-responsive-cards].tv-table-empty td { padding: 32px 16px !important; text-align: center; white-space: normal; }
#users_table th:last-child, #users_table td:last-child { white-space: nowrap; }
.tv-export-steps [data-stepper-item] > :first-child { flex-shrink: 0; }

@media (max-width: 767px) {
    table[data-responsive-cards] { display: block; min-width: 0 !important; border: 0 !important; }
    table[data-responsive-cards] thead { display: block; max-width: 100%; overflow-x: auto; }
    table[data-responsive-cards] thead tr { display: flex; align-items: center; }
    table[data-responsive-cards] thead th {
        flex: 0 0 auto; min-width: 0 !important; width: auto !important;
        padding: 12px 14px !important; font-size: 11px; white-space: nowrap;
    }
    table[data-responsive-cards] thead th:empty { display: none; }
    table[data-responsive-cards] tbody { display: grid; gap: 12px; padding: 12px; }
    table[data-responsive-cards] tbody > tr {
        position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 14px 12px; padding: 16px; border: 1px solid var(--tw-gray-200, #e5e7eb);
        border-radius: 12px; background: var(--tw-light, #fff);
    }
    table[data-responsive-cards] tbody > tr > td {
        display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
        min-width: 0 !important; width: auto !important; padding: 0 !important;
        border: 0 !important; box-shadow: none !important; white-space: normal;
    }
    table[data-responsive-cards] tbody > tr > td::before {
        content: attr(data-column-label); font-size: 11px; font-weight: 500;
        color: var(--tw-gray-600, #64748b); line-height: 1.4;
    }
    table[data-responsive-cards] tbody > tr > td.tv-cell-primary { grid-column: 1 / -1; padding-right: 26px !important; }
    table[data-responsive-cards] tbody > tr > td.tv-cell-wide { grid-column: 1 / -1; }
    table[data-responsive-cards] tbody > tr > td.tv-cell-select { position: absolute; top: 16px; right: 16px; }
    table[data-responsive-cards] tbody > tr > td.tv-cell-actions {
        grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center;
        padding-top: 12px !important; border-top: 1px solid var(--tw-gray-200, #e5e7eb) !important;
    }
    table[data-responsive-cards] td.tv-cell-primary::before,
    table[data-responsive-cards] td.tv-cell-select::before,
    table[data-responsive-cards] td.tv-cell-actions::before { display: none; }
    table[data-responsive-cards] td > *, table[data-responsive-cards] td .flex-col { min-width: 0; max-width: 100%; }
    table[data-responsive-cards] tbody > tr > td.tv-cell-blank { display: none; }
    table[data-responsive-cards] td .btn { min-height: 36px; }
    table[data-responsive-cards].tv-table-empty tbody > tr { display: block; border: 0; padding: 20px 0; }
    table[data-responsive-cards].tv-table-empty tbody > tr > td { display: block; text-align: center; }
    table[data-responsive-cards].tv-table-empty td::before { display: none; }
    .card:has(table[data-responsive-cards]) .card-footer > .flex:last-child { flex-wrap: wrap; justify-content: center; gap: 10px; }
    .card:has(table[data-responsive-cards]) [data-datatable-pagination] { display: flex; flex-wrap: nowrap; align-items: center; }

    .tv-export-steps.card-header { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; gap: 8px; padding: 18px 16px; }
    .tv-export-steps [data-stepper-item] { flex-direction: column; gap: 7px; min-width: 0; text-align: center; }
    .tv-export-steps [data-stepper-item] > :first-child { width: 32px; height: 32px; font-size: 13px; }
    .tv-export-steps [data-stepper-item] h4 { display: none; }
    .tv-export-steps [data-stepper-item] > :last-child { min-width: 0; }
    .tv-export-steps [data-stepper-item] > :last-child span { font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; }
}
