/* One modal shell and one table frame throughout the application. */
:root {
    --sf-modal-surface: #fff;
    --sf-modal-body: #fff;
    --sf-modal-text: #344054;
    --sf-modal-muted: #667085;
    --sf-modal-border: #d9e2ee;
    --sf-modal-heading: #f7f9fc;
    --sf-modal-info-label-bg: #f8fafc;
    --sf-modal-info-label: #687588;
    --sf-modal-info-value: #27364d;
    --sf-modal-row-border: #edf0f4;
    --sf-modal-table-gap: 1rem;
    --sf-modal-gutter: 1.5rem;
    --sf-modal-frame-radius: 12px;
}
html.dark-style,
html[data-tenant-theme="dark"] {
    --sf-modal-surface: #2f3349;
    --sf-modal-body: #292d42;
    --sf-modal-text: #e1e5f0;
    --sf-modal-muted: #b6bee3;
    --sf-modal-border: #4b5068;
    --sf-modal-heading: #383d56;
    --sf-modal-info-label-bg: #292d42;
    --sf-modal-info-label: #aeb7cc;
    --sf-modal-info-value: #f0f3fa;
    --sf-modal-row-border: #4b5068;
}
html[data-saas-theme="dark"] {
    --sf-modal-surface: #182230;
    --sf-modal-body: #182230;
    --sf-modal-text: #e5e7eb;
    --sf-modal-muted: #aab6c6;
    --sf-modal-border: #344255;
    --sf-modal-heading: #24364d;
    --sf-modal-info-label-bg: #111827;
    --sf-modal-info-label: #aab6c6;
    --sf-modal-info-value: #e5e7eb;
    --sf-modal-row-border: #344255;
}
/* Include the legacy tenant dialog whose page uses ID-level !important rules. */
html body .modal .modal-content,
html body #tenantActionModal .modal-content {
    border: 1px solid var(--sf-modal-border) !important;
    border-radius: 16px !important;
    box-shadow: none !important;
    overflow: hidden;
    color: var(--sf-modal-text) !important;
    background: var(--sf-modal-surface) !important;
}
html body .modal .modal-content .modal-header {
    padding: 1.25rem var(--sf-modal-gutter) !important;
    border-bottom: 1px solid var(--sf-modal-border) !important;
    background: var(--sf-modal-surface) !important;
    color: var(--sf-modal-text) !important;
}
html body .modal .modal-content .modal-header .modal-title {
    margin: 0 !important;
    color: var(--sf-modal-text) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
}
html body .modal .modal-content .modal-body {
    padding: var(--sf-modal-table-gap) var(--sf-modal-gutter) var(--sf-modal-gutter) !important;
    background: var(--sf-modal-body) !important;
    color: var(--sf-modal-text) !important;
}
html body .modal .modal-content .modal-footer {
    padding: 1rem var(--sf-modal-gutter) !important;
    border-top: 1px solid var(--sf-modal-border) !important;
    background: var(--sf-modal-surface) !important;
}
html body .modal .dataTables_wrapper {
    min-width: 0;
    max-width: 100%;
    padding: 1rem !important;
    border: 1px solid var(--sf-modal-border) !important;
    border-radius: var(--sf-modal-frame-radius) !important;
    box-shadow: none !important;
    background: var(--sf-modal-surface) !important;
    color: var(--sf-modal-text) !important;
}
/* The DataTables wrapper owns the frame, not its responsive ancestor. */
html body .modal .table-responsive:has(.dataTables_wrapper) {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
}
html body .modal .dataTables_wrapper .tenant-datatable-scroll {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    border: 0 !important;
    box-shadow: none !important;
}
/* A deliberately grouped card keeps its frame instead of adding a second one. */
html body .modal .card:has(.dataTables_wrapper) {
    border: 1px solid var(--sf-modal-border) !important;
    border-radius: var(--sf-modal-frame-radius) !important;
    box-shadow: none !important;
    background: var(--sf-modal-surface) !important;
}
html body .modal .card .dataTables_wrapper {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
/* Plain information tables also get just one frame. */
html body .modal .table-responsive:has(> table:not(.dataTable)) {
    border: 1px solid var(--sf-modal-border) !important;
    border-radius: var(--sf-modal-frame-radius) !important;
    box-shadow: none !important;
    overflow-x: auto !important;
}
html body .modal .table-responsive > table {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
/* Modal-body padding supplies the gap; direct table hosts get the same spacing. */
html body .modal .modal-content > .table-responsive {
    margin: var(--sf-modal-table-gap) var(--sf-modal-gutter) var(--sf-modal-gutter) !important;
}
html body .modal .modal-content .modal-body > .table-responsive {
    margin: 0 !important;
}
html body .modal .modal-content .complaint-thread {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: var(--sf-modal-table-gap) !important;
    margin-bottom: var(--sf-modal-table-gap) !important;
}
html body .modal .complaint-thread .dataTables_wrapper {
    width: 100% !important;
    box-sizing: border-box;
    border-radius: var(--sf-modal-frame-radius) !important;
    overflow: hidden !important;
}
html body .modal .modal-content .complaint-thread .dataTables_wrapper table.dataTable {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed !important;
}
html body .modal .complaint-thread table.dataTable td {
    white-space: normal !important;
    overflow-wrap: anywhere;
}
html body .modal .complaint-thread .col { min-width: 0; }
html body .modal .complaint-thread td .row { margin-left: 0; margin-right: 0; }
html body .modal .complaint-thread td :is(.row, .col, small) {
    white-space: normal !important;
    overflow-wrap: anywhere;
}
html body .modal .complaint-thread :is(img, video) { max-width: 100%; }
html body .modal .complaint-thread pre { white-space: pre-wrap; overflow-wrap: anywhere; }
html body .modal .modal-content table thead th {
    background: var(--sf-modal-heading) !important;
    color: var(--sf-modal-text) !important;
    font-size: .75rem !important;
    font-weight: 600 !important;
}
html:is(.dark-style, [data-tenant-theme="dark"], [data-saas-theme="dark"]) body .modal .modal-content table thead th {
    background: var(--sf-modal-heading) !important;
    color: var(--sf-modal-text) !important;
}
@media (max-width: 575.98px) {
    :root { --sf-modal-gutter: 1rem; }
    html body .modal .modal-content .modal-header,
    html body .modal .modal-content .modal-body,
    html body .modal .modal-content .modal-footer { padding: 1rem !important; }
    html body .modal .dataTables_wrapper { padding: .75rem !important; }
}

/* Info Type is the reference for static label/value detail tables. */
html body .modal .modal-content table:not(.dataTable):not(:has(thead, tr > :nth-child(3))):has(tr > td:nth-child(2)) {
    width: 100%;
    margin: 0 !important;
    background: var(--sf-modal-surface) !important;
}
html body .modal .modal-content table:not(.dataTable):not(:has(thead, tr > :nth-child(3))):has(tr > td:nth-child(2)) td {
    padding: 13px 16px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--sf-modal-row-border) !important;
    vertical-align: middle !important;
    white-space: normal !important;
    background: var(--sf-modal-surface) !important;
    box-shadow: none !important;
}
html body .modal .modal-content table:not(.dataTable):not(:has(thead, tr > :nth-child(3))):has(tr > td:nth-child(2)) tr:last-child td { border-bottom: 0 !important; }
html body .modal .modal-content table:not(.dataTable):not(:has(thead, tr > :nth-child(3))):has(tr > td:nth-child(2)) td:first-child {
    width: 40% !important;
    color: var(--sf-modal-info-label) !important;
    background: var(--sf-modal-info-label-bg) !important;
    font-size: .78rem !important;
    font-weight: 600 !important;
}
html body .modal .modal-content table:not(.dataTable):not(:has(thead, tr > :nth-child(3))):has(tr > td:nth-child(2)) td:last-child {
    color: var(--sf-modal-info-value) !important;
    font-size: .84rem !important;
    font-weight: 600 !important;
}
html body .modal .modal-content table:not(.dataTable):not(:has(thead, tr > :nth-child(3))):has(tr > td:nth-child(2)) td:last-child > span.text-muted:not(.badge) {
    color: var(--sf-modal-info-value) !important;
}
@media (min-width: 576px) {
    html body .modal .modal-dialog:not(.modal-xl):not([class*="modal-fullscreen"]):has(table:not(.dataTable) tr > td:nth-child(2)):not(:has(table thead, table tr > :nth-child(3))) {
        max-width: min(620px, calc(100vw - 2rem)) !important;
    }
}
