/* Tabelas preservam os dados, mas limitam o scroll à própria área. */
.history-table-desktop-viewport,
[data-history-table-shell],
.portal-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

table { max-width: 100%; }

th,
td { vertical-align: middle; }

@media (max-width: 767px) {
    .portal-table-scroll table,
    .history-table-desktop-viewport table { min-width: 42rem; }
}

/* Histórico: tabela, carregamento e estados por tema. */
.history-table-shell {
    background: rgba(2, 6, 23, 0.2);
}

@media (min-width: 1280px) {
    .history-table-desktop-viewport {
        min-height: 46rem;
    }
}

.history-table-loading {
    position: absolute;
    inset: 0;
    z-index: 45;
    display: flex;
    min-height: 12rem;
    align-items: center;
    justify-content: center;
    border-radius: 1.5rem;
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(8px);
}

.history-table-loading.hidden {
    display: none;
}

.history-table-loading-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.92);
    padding: 0.875rem 1rem;
    box-shadow: 0 18px 46px rgba(2, 6, 23, 0.34);
}

.history-table-loading-spinner {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 3px solid rgba(148, 163, 184, 0.28);
    border-top-color: #22d3ee;
    animation: history-loading-spin 0.8s linear infinite;
}

@keyframes history-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.history-table thead {
    box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.14);
}

.history-table thead th { white-space: nowrap; }

.history-table-row {
    background: rgba(2, 6, 23, 0.16);
    transition: background-color 140ms ease, box-shadow 140ms ease;
}

.history-table-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.025);
}

.history-table-row:hover {
    background: rgba(34, 211, 238, 0.07);
    box-shadow: inset 3px 0 0 rgba(34, 211, 238, 0.5);
}

.history-table-row-cancelled,
.history-table-row-cancelled:nth-child(even) {
    background: rgba(251, 191, 36, 0.055);
}

.history-sticky-actions-cell {
    background: rgb(2, 6, 23);
}

.history-table-row:nth-child(even) .history-sticky-actions-cell {
    background: rgb(5, 10, 26);
}

.history-table-row:hover .history-sticky-actions-cell {
    background: rgb(5, 25, 39);
}

.history-table-row-cancelled .history-sticky-actions-cell {
    background: rgb(20, 17, 16);
}

html[data-theme="light"] .history-toolbar-chip {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(126, 141, 163, 0.22) !important;
    color: #5d6c84 !important;
}

html[data-theme="light"] .history-toolbar-button-neutral,
html[data-theme="light"] .history-filter-reset {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(126, 141, 163, 0.22) !important;
    color: #24324a !important;
    box-shadow: 0 8px 18px rgba(24, 35, 56, 0.05);
}

html[data-theme="light"] .history-toolbar-button-refresh {
    box-shadow: 0 8px 18px rgba(208, 173, 78, 0.1);
}

html[data-theme="light"] .history-toolbar-button-selected {
    box-shadow: 0 8px 18px rgba(79, 170, 209, 0.12);
}

html[data-theme="light"] .history-toolbar-button-sienge {
    box-shadow: 0 8px 18px rgba(92, 173, 206, 0.12);
}

html[data-theme="light"] .history-toolbar-button-export {
    box-shadow: 0 8px 18px rgba(93, 176, 138, 0.1);
}

html[data-theme="light"] .history-toolbar-button-neutral:hover,
html[data-theme="light"] .history-filter-reset:hover {
    background: rgba(245, 249, 253, 0.96) !important;
}

html[data-theme="light"] .history-filter-submit {
    box-shadow: 0 12px 24px rgba(14, 165, 233, 0.16);
}

html[data-theme="light"] .history-filter-tip {
    background: rgba(255, 255, 255, 0.82) !important;
    border-color: rgba(126, 141, 163, 0.18) !important;
    color: #6f7d92 !important;
}

html[data-theme="light"] .history-sticky-actions-cell {
    background: #f8fbff !important;
    border-left-color: rgba(126, 141, 163, 0.18) !important;
    box-shadow: -10px 0 18px rgba(231, 237, 245, 0.88);
}

html[data-theme="light"] .history-table-shell {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(126, 141, 163, 0.22) !important;
}

html[data-theme="light"] .history-table-loading {
    background: rgba(241, 246, 251, 0.62);
}

html[data-theme="light"] .history-table-loading-card {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(126, 141, 163, 0.22);
    box-shadow: 0 18px 42px rgba(24, 35, 56, 0.12);
}

html[data-theme="light"] .history-table-loading-card .text-white {
    color: #182338 !important;
}

html[data-theme="light"] .history-table-loading-card .text-slate-400 {
    color: #61708a !important;
}

html[data-theme="light"] .history-table-row {
    background: rgba(255, 255, 255, 0.74);
}

html[data-theme="light"] .history-table-row:nth-child(even) {
    background: rgba(234, 241, 249, 0.58);
}

html[data-theme="light"] .history-table-row:hover {
    background: rgba(207, 234, 248, 0.72);
    box-shadow: inset 3px 0 0 #2298c5;
}

html[data-theme="light"] .history-table-row-cancelled,
html[data-theme="light"] .history-table-row-cancelled:nth-child(even) {
    background: rgba(250, 235, 197, 0.56);
}

html[data-theme="light"] .history-table-row:nth-child(even) .history-sticky-actions-cell {
    background: #f0f5fb !important;
}

html[data-theme="light"] .history-table-row:hover .history-sticky-actions-cell {
    background: #e0f1f8 !important;
}

html[data-theme="light"] .history-table-row-cancelled .history-sticky-actions-cell {
    background: #f8efd9 !important;
}

html[data-theme="light"] .history-table-row .history-sticky-actions-cell summary {
    background: rgba(255, 255, 255, 0.82) !important;
    border-color: rgba(126, 141, 163, 0.22) !important;
    color: var(--portal-text-primary) !important;
}

html[data-theme="light"] .history-table-row .history-sticky-actions-cell summary:hover {
    background: rgba(237, 243, 250, 0.96) !important;
}

html[data-theme="light"] .portal-main .rounded-\[1\.6rem\].border p.text-xs {
    color: rgba(24, 35, 56, 0.72) !important;
}

html[data-theme="light"] .portal-main .rounded-\[1\.6rem\].border p.text-\[11px\] {
    color: rgba(24, 35, 56, 0.68) !important;
}

html[data-theme="light"] .portal-main .rounded-\[1\.6rem\].border p.text-3xl {
    color: #182338 !important;
}

html[data-theme="light"] [data-history-sync-progress] {
    background: linear-gradient(180deg, rgba(255, 248, 229, 0.96), rgba(255, 252, 241, 0.98)) !important;
    border-color: rgba(230, 191, 87, 0.38) !important;
    box-shadow: 0 14px 30px rgba(186, 145, 33, 0.08), 0 24px 58px rgba(24, 35, 56, 0.05) !important;
}

html[data-theme="light"] [data-history-sync-title],
html[data-theme="light"] [data-history-sync-progress-step],
html[data-theme="light"] [data-history-sync-progress-time] {
    color: #47330a !important;
}

html[data-theme="light"] [data-history-sync-progress-label],
html[data-theme="light"] [data-history-sync-status-hint],
html[data-theme="light"] [data-history-sync-current-item],
html[data-theme="light"] [data-history-sync-selected-summary],
html[data-theme="light"] [data-history-sync-progress] .text-amber-50\/70,
html[data-theme="light"] [data-history-sync-progress] .text-amber-50\/75,
html[data-theme="light"] [data-history-sync-progress] .text-amber-50\/80,
html[data-theme="light"] [data-history-sync-progress] .text-amber-100\/70 {
    color: rgba(71, 51, 10, 0.74) !important;
}

html[data-theme="light"] [data-history-sync-status-badge] {
    background: rgba(193, 232, 247, 0.82) !important;
    border-color: rgba(79, 170, 209, 0.32) !important;
    color: #163a63 !important;
}

html[data-theme="light"] [data-history-sync-progress-bar] {
    background: linear-gradient(90deg, #d7a625, #f1c550, #e5ae2b) !important;
}

html[data-theme="light"] [data-history-sync-metric-label] {
    color: rgba(71, 51, 10, 0.66) !important;
}

html[data-theme="light"] [data-history-sync-metric] {
    color: #182338 !important;
}

html[data-theme="light"] [data-history-sync-progress] .bg-slate-950\/35,
html[data-theme="light"] [data-history-sync-progress] .bg-slate-950\/40 {
    background: rgba(255, 255, 255, 0.72) !important;
    border-color: rgba(126, 141, 163, 0.16) !important;
}

html[data-theme="light"] [data-history-sync-steps-list] li {
    color: rgba(71, 51, 10, 0.58) !important;
}

html[data-theme="light"] [data-history-sync-steps-list] li.text-amber-100,
html[data-theme="light"] [data-history-sync-steps-list] li.font-semibold {
    color: #3d2d0a !important;
}

html[data-theme="light"] [data-history-sync-progress] [data-history-sync-actions] button[data-history-sync-close] {
    background: rgba(255, 255, 255, 0.78) !important;
    border-color: rgba(126, 141, 163, 0.18) !important;
    color: #23314a !important;
}

html[data-theme="light"] [data-history-sync-progress] [data-history-sync-actions] button[data-history-sync-refresh] {
    background: linear-gradient(180deg, rgba(193, 232, 247, 0.9), rgba(224, 244, 251, 0.96)) !important;
    border-color: rgba(79, 170, 209, 0.3) !important;
    color: #163a63 !important;
}

html[data-theme="light"] .portal-main [class*="bg-cyan-400/10"],
html[data-theme="light"] .portal-main [class*="bg-emerald-400/10"],
html[data-theme="light"] .portal-main [class*="bg-amber-400/10"],
html[data-theme="light"] .portal-main [class*="bg-rose-400/10"],
html[data-theme="light"] .portal-main [class*="bg-violet-400/10"] {
    backdrop-filter: blur(10px);
}

/* Ações fixas do histórico em tema claro. */
html[data-theme="light"] .history-sticky-actions-header {
    background: linear-gradient(180deg, rgba(241, 246, 251, 0.98), rgba(236, 242, 248, 0.98)) !important;
    border-left-color: rgba(126, 141, 163, 0.18) !important;
    box-shadow: -10px 0 18px rgba(231, 237, 245, 0.85);
}
