/* Final UX pass: contrast, tables, tabs, destructive actions, motion. Appearance only. */


/* Nested cards: one border per level, inner blocks use a tint instead of a second outline */
.entity-card .person-detail-card, .person-detail-card .extracted-box, .person-detail-card .dk-upload-card,
.ubo-card .ubo-upload-card, .ubo-card-body .fd-upload-card, .fatca-crs-card .declaration-box,
.entity-card .ubo-card, .success-section-card .success-side-card {
    border-color: transparent; box-shadow: none; background: #F4F7F1;
}

.rm-table-wrap { --sc-bg: #fff; --sh-bg: #EEF2EA; --sc-hover: #fafbf8; --sc-line: #d5dfcc; }
.rm-dark-mode .rm-table-wrap { --sc-bg: #343920; --sh-bg: #2A2E18; --sc-hover: #3b4126; --sc-line: #556040; }

/* Tables: scroll inside the card, sticky header, sticky Actions (and Company in compact view) */
.rm-table-wrap { overflow: auto; max-height: 68vh; }
.rm-table { min-width: 960px; }
.rm-table-wrap:not(.compact) .rm-table { min-width: 1320px; }
.rm-table thead th { position: sticky; top: 0; z-index: 3; }
.rm-table th:last-child, .rm-table td:last-child { position: sticky; right: 0; background: var(--sc-bg); box-shadow: -1px 0 0 var(--sc-line); }
.rm-table thead th:last-child { z-index: 4; background: var(--sh-bg); }
.rm-table tr:hover td:last-child { background: var(--sc-hover); }
.rm-table-wrap.compact #rmPipelineTable td:nth-child(4), .rm-table-wrap.compact #rmPipelineTable th:nth-child(4),
.rm-table-wrap.compact #underReviewTable td:nth-child(2), .rm-table-wrap.compact #underReviewTable th:nth-child(2),
.rm-table-wrap.compact #notCompletedTable td:nth-child(1), .rm-table-wrap.compact #notCompletedTable th:nth-child(1),
.rm-table-wrap.compact #completedTable td:nth-child(1), .rm-table-wrap.compact #completedTable th:nth-child(1) {
    position: sticky; left: 0; background: var(--sc-bg); box-shadow: 1px 0 0 var(--sc-line);
}
.rm-table-wrap.compact #rmPipelineTable th:nth-child(4), .rm-table-wrap.compact #underReviewTable th:nth-child(2),
.rm-table-wrap.compact #notCompletedTable th:nth-child(1), .rm-table-wrap.compact #completedTable th:nth-child(1) { z-index: 4; background: var(--sh-bg); }
.rm-table-wrap.compact #rmPipelineTable tr:hover td:nth-child(4), .rm-table-wrap.compact #underReviewTable tr:hover td:nth-child(2),
.rm-table-wrap.compact #notCompletedTable tr:hover td:nth-child(1), .rm-table-wrap.compact #completedTable tr:hover td:nth-child(1) { background: var(--sc-hover); }

/* Compact view hides secondary columns; "Show all columns" restores them */
.rm-table-wrap.compact #rmPipelineTable :is(th,td):is(:nth-child(1),:nth-child(3),:nth-child(8)),
.rm-table-wrap.compact #underReviewTable :is(th,td):is(:nth-child(1),:nth-child(4),:nth-child(5)),
.rm-table-wrap.compact #notCompletedTable :is(th,td):is(:nth-child(3),:nth-child(4)),
.rm-table-wrap.compact #completedTable :is(th,td):is(:nth-child(3),:nth-child(4),:nth-child(6)) { display: none; }
.density-toggle { margin: 0 0 8px auto; display: block; background: transparent; border: 1px solid #9CAF88; color: #4B5320;
    border-radius: 6px; padding: 6px 12px; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.density-toggle:hover { background: #EEF2EA; }

/* Destructive action sits apart from routine actions */
.rm-action-btns .rm-btn-action.delete { margin-left: 14px; position: relative; color: #b42318; border-color: #f3b4ae; }
.rm-action-btns .rm-btn-action.delete::before { content: ""; position: absolute; left: -9px; top: 4px; bottom: 4px; width: 1px; background: #d5dfcc; }

/* Back office tabs: clearer active state */
.bo-tab-btn.active { background: #EEF2EA; color: #32361f; border-bottom-color: #4B5320; box-shadow: inset 0 3px 0 #9CAF88; }

/* Dark mode for the new surfaces */
.rm-dark-mode .rm-table thead th { background: #2A2E18; }
.rm-dark-mode .density-toggle { border-color: #556040; color: #E8EDE5; }
.rm-dark-mode .bo-tab-btn.active { background: #343920; color: #E8EDE5; border-bottom-color: #9CAF88; box-shadow: inset 0 3px 0 #667254; }
.rm-dark-mode .rm-btn-action.delete { color: #f3b4ae; border-color: #7a3b36; }

/* Motion only where it explains a state change; none for people who ask for less */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Tablet and phone: only the Actions column stays pinned so the data keeps its width */
@media (max-width: 900px) {
    .rm-table-wrap.compact #rmPipelineTable :is(th,td):nth-child(4),
    .rm-table-wrap.compact #underReviewTable :is(th,td):nth-child(2),
    .rm-table-wrap.compact #notCompletedTable :is(th,td):nth-child(1),
    .rm-table-wrap.compact #completedTable :is(th,td):nth-child(1) { position: static; box-shadow: none; }
    .rm-table th:last-child, .rm-table td:last-child { position: static; box-shadow: none; }
}

/* Phones: each row becomes a card; primary actions stay visible at the foot of the card */
@media (max-width: 640px) {
    .rm-table-wrap { max-height: none; overflow: visible; }
    .rm-table, .rm-table-wrap:not(.compact) .rm-table { min-width: 0; display: block; }
    .rm-table thead { display: none; }
    .rm-table tbody { display: block; }
    .rm-table tbody tr { display: block; border: 1px solid #d5dfcc; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; background: var(--sc-bg); }
    .rm-table tbody td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 7px 0; border: 0; text-align: right; }
    .rm-table tbody td[data-label]::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #66705b; }
    .rm-table tbody td:last-child { display: block; padding-top: 10px; margin-top: 4px; border-top: 1px solid #d5dfcc; }
    .rm-table tbody td:last-child::before { display: none; }
    .rm-table tbody td .rm-action-btns { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
    .rm-table tbody td .rm-btn-action { min-height: 40px; }
    .rm-table-wrap.compact #rmPipelineTable td:nth-child(4), .rm-table-wrap.compact #underReviewTable td:nth-child(2),
    .rm-table-wrap.compact #notCompletedTable td:nth-child(1), .rm-table-wrap.compact #completedTable td:nth-child(1) { background: transparent; box-shadow: none; }
    .rm-dark-mode .rm-table tbody tr, .rm-dark-mode .rm-table tbody td:last-child { border-color: #556040; }
    .rm-dark-mode .rm-table tbody td[data-label]::before { color: #B5BDA8; }
}

/* Four-step flow: the screens of one step are stacked on one page */
.grp-hide { display: none !important; }
.grp-multi .screen.active + .screen.active { margin-top: 8px; border-top: 1px solid var(--border, #e3e8dc); }
