/**
 * Reports UI Stabilization — shared compact layout, grid contrast, dropdown safety.
 * UI only; scoped to report/operational/financial list pages (not dashboard KPI home).
 */

:root {
    --z-action-menu: 1500;
    --report-header-title-size: 1.125rem;
    --report-region-gap: 0.4rem;
}

/* ── Compact page header (reports / operational / financial lists) ─────────── */
.collections-reports-page .ar-dashboard-header,
.collections-op-report-page .ar-dashboard-header,
.collections-operational-page:not(.collections-dashboard-page) .ar-dashboard-header,
.financial-customer-balances-page .ar-dashboard-header,
.financial-soa-page .ar-dashboard-header,
.financial-aging-page .ar-dashboard-header,
.collections-worklist-shell .ar-dashboard-header,
.collections-worklist-workspace-shell .ar-dashboard-header,
.collections-plans-shell .ar-dashboard-header,
.collections-plan-shell .ar-dashboard-header,
.collections-followups-shell .ar-dashboard-header,
.collections-promises-shell .ar-dashboard-header,
.collections-monthly-due-shell .ar-dashboard-header,
.collections-items-shell .ar-dashboard-header,
.collections-critical-shell .ar-dashboard-header,
.collections-confirmed-payments-shell .ar-dashboard-header,
.collections-payment-detection-shell .ar-dashboard-header,
.collections-performance-report-shell .ar-dashboard-header,
.users-page-shell .ar-dashboard-header,
.audit-email-delivery-log-shell .ar-dashboard-header {
    margin-block-end: 0.35rem;
    padding-block-end: 0;
}

.collections-reports-page .ar-dashboard-section__eyebrow,
.collections-op-report-page .ar-dashboard-section__eyebrow,
.collections-operational-page:not(.collections-dashboard-page) .ar-dashboard-section__eyebrow,
.financial-customer-balances-page .ar-dashboard-section__eyebrow,
.financial-soa-page .ar-dashboard-section__eyebrow,
.financial-aging-page .ar-dashboard-section__eyebrow {
    display: none;
}

.collections-reports-page .ar-dashboard-header__title,
.collections-op-report-page .ar-dashboard-header__title,
.collections-operational-page:not(.collections-dashboard-page) .ar-dashboard-header__title,
.financial-customer-balances-page .ar-dashboard-header__title,
.financial-soa-page .ar-dashboard-header__title,
.financial-aging-page .ar-dashboard-header__title {
    font-size: var(--report-header-title-size);
    line-height: 1.2;
    margin: 0;
}

/* Subtitle moved to tooltip/meta — keep grid high on 1080p */
.collections-reports-page .ar-dashboard-header__subtitle,
.collections-op-report-page .ar-dashboard-header__subtitle,
.collections-operational-page:not(.collections-dashboard-page) .ar-dashboard-header__subtitle,
.financial-customer-balances-page .ar-dashboard-header__subtitle,
.financial-soa-page .ar-dashboard-header__subtitle,
.financial-aging-page .ar-dashboard-header__subtitle,
.collections-worklist-shell .ar-dashboard-header__subtitle,
.collections-worklist-workspace-shell .ar-dashboard-header__subtitle,
.collections-plans-shell .ar-dashboard-header__subtitle,
.collections-plan-shell .ar-dashboard-header__subtitle,
.collections-followups-shell .ar-dashboard-header__subtitle,
.collections-promises-shell .ar-dashboard-header__subtitle,
.collections-monthly-due-shell .ar-dashboard-header__subtitle,
.collections-items-shell .ar-dashboard-header__subtitle,
.collections-critical-shell .ar-dashboard-header__subtitle,
.collections-confirmed-payments-shell .ar-dashboard-header__subtitle,
.collections-payment-detection-shell .ar-dashboard-header__subtitle,
.collections-performance-report-shell .ar-dashboard-header__subtitle,
.audit-email-delivery-log-shell .ar-dashboard-header__subtitle {
    display: none;
}

/* Duplicate title in toolbar when page header exists */
.collections-op-report-page .collections-reports-toolbar__title,
.collections-reports-page .collections-reports-toolbar__title {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.collections-op-report-page .collections-reports-toolbar__desc,
.collections-reports-page .collections-reports-toolbar__desc {
    display: none;
}

/* ── Workspace region density ─────────────────────────────────────────────── */
.collections-reports-page .ar-workspace,
.collections-op-report-page .ar-workspace,
.collections-report-workspace .ar-workspace,
.collections-operational-page .ar-workspace,
.financial-customer-balances-page .ar-workspace,
.financial-soa-page .ar-workspace,
.financial-aging-page .ar-workspace {
    display: grid;
    gap: var(--report-region-gap);
}

.collections-reports-page .ar-workspace__region--toolbar,
.collections-op-report-page .ar-workspace__region--toolbar,
.collections-operational-page .ar-workspace__region--filters,
.collections-reports-page .ar-workspace__region--filters {
    margin: 0;
}

/* ── Remove instructional clutter above grids ─────────────────────────────── */
.collections-reports-page .collections-performance-data-callout,
.collections-op-report-page .collections-performance-data-callout,
.collections-reports-page aside.collections-performance-data-callout,
.collections-monthly-due-page .collections-monthly-due-filter-note,
.collections-open-items-report .collections-reports-export-note,
.collections-critical-report .collections-reports-export-note,
.collections-reports-page .collections-reports-export-note {
    display: none !important;
}

.collections-reports-stale-notice[hidden],
.collections-reports-stale-notice:not(.is-visible) {
    display: none !important;
}

.collections-reports-stale-notice.is-visible {
    margin-block: 0.35rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
}

/* ── Compact filters ──────────────────────────────────────────────────────── */
.collections-reports-page .collections-filter-shell,
.collections-op-report-page .collections-filter-shell,
.collections-operational-page .collections-filter-shell,
.collections-reports-filters,
.financial-balances-filters,
.financial-soa-filters,
.financial-aging-filters {
    padding: 0.55rem 0.75rem;
    gap: 0.4rem;
}

.collections-quick-filters {
    gap: 0.45rem;
    align-items: end;
}

.collections-quick-filters .app-label,
.collections-reports-filters .app-label,
.financial-balances-filters .app-label {
    font-size: 0.72rem;
    margin-block-end: 0.2rem;
}

.collections-quick-filters .app-input,
.collections-quick-filters .app-select,
.collections-reports-filters .app-input {
    min-height: 2.125rem;
    font-size: 0.84rem;
}

.collections-report-nav {
    padding-block: 0.2rem 0;
    margin-block-start: 0.2rem;
    border-top: 0;
}

/* ── Compact summary strip (when present) ─────────────────────────────────── */
.collections-op-summary-strip:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 1rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--color-border-subtle, #e5e7eb);
    border-radius: var(--radius-md, 0.5rem);
    background: var(--color-surface-muted, #f8fafc);
    font-size: 0.78rem;
    line-height: 1.3;
    max-height: 2.75rem;
    overflow: hidden;
}

.collections-report-grid__meta {
    min-height: 1.1rem;
    font-size: 0.76rem;
}

/* ── Strong ERP grid (not faded) ────────────────────────────────────────── */
.collections-reports-page .collections-reports-table tbody td,
.collections-op-report-page .collections-reports-table tbody td,
.collections-monthly-due-report .collections-reports-table tbody td,
.collections-performance-report .collections-reports-table tbody td,
.collections-open-items-report .collections-reports-table tbody td,
.collections-critical-report .collections-reports-table tbody td,
.collections-worklist-shell .app-table tbody td,
.collections-worklist-workspace-shell .app-table tbody td,
.collections-plans-shell .app-table tbody td,
.collections-followups-shell .app-table tbody td,
.collections-monthly-due-shell .app-table tbody td,
.collections-items-shell .app-table tbody td,
.collections-critical-shell .app-table tbody td,
.collections-operational-page:not(.collections-dashboard-page) .app-table tbody td {
    color: var(--color-text, #111827);
    font-weight: 500;
    opacity: 1;
}
.financial-customer-balances-page .app-table tbody td,
.financial-soa-page .app-table tbody td,
.financial-aging-page .app-table tbody td {
    color: var(--color-text, #111827);
    font-weight: 500;
    opacity: 1;
}

.collections-reports-page .collections-reports-table thead th,
.collections-op-report-page .collections-reports-table thead th,
.collections-operational-page:not(.collections-dashboard-page) .app-table thead th,
.financial-customer-balances-page .app-table thead th,
.financial-soa-page .app-table thead th,
.financial-aging-page .app-table thead th {
    background: var(--color-table-head, #eef2f6);
    color: var(--tbl-head-text, #ffffff);
    font-weight: 800;
    border-bottom: 2px solid var(--tbl-head-rule, #003f6e);
}

.collections-reports-page .collections-reports-table tbody tr:hover td,
.collections-op-report-page .collections-reports-table tbody tr:hover td,
.collections-operational-page:not(.collections-dashboard-page) .app-table tbody tr:hover td,
.financial-customer-balances-page .app-table tbody tr:hover td,
.financial-soa-page .app-table tbody tr:hover td,
.financial-aging-page .app-table tbody tr:hover td {
    background: var(--color-surface-muted, #f3f6f9);
}

.collections-reports-table td.text-end,
.collections-reports-table th.text-end,
.app-table .num,
.app-table .amount,
.app-table td.text-end,
.app-table th.text-end {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.amount-negative,
.text-negative,
td.is-negative,
.collections-grid-counter strong.amount-negative {
    color: var(--color-danger, #b42318);
    font-weight: 700;
}

.collections-erp-customer strong {
    font-weight: 600;
    color: var(--color-text, #111827);
}

/* ── Action dropdown — no clipping inside table wrappers ──────────────────── */
.collections-report-grid__table-shell,
.collections-report-grid__table-wrap,
.collections-reports-page .app-table-wrap,
.collections-op-report-page .app-table-wrap,
.collections-operational-page .app-table-wrap,
.collections-worklist-page .app-table-wrap,
.financial-customer-balances-page .app-table-wrap,
.financial-soa-page .app-table-wrap,
.financial-aging-page .app-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
}

.app-actions-col,
.collections-plan-actions,
.ar-data-grid__td-actions {
    overflow: visible;
    position: relative;
}

.app-action-menu {
    z-index: var(--z-action-menu);
}

/* Stable grid height during load */
.collections-report-grid__table-shell {
    min-height: 12rem;
}

.collections-report-grid .app-state,
.collections-report-grid .app-state-loading,
.collections-report-grid .app-state-empty,
.collections-report-grid .app-state-error {
    min-height: 7rem;
    margin: 0;
    color: var(--color-text-muted, #6b7280);
    opacity: 1;
}

/* ── Compact toolbar ─────────────────────────────────────────────────────── */
.ar-toolbar.collections-reports-toolbar,
.ar-toolbar.financial-balances-toolbar,
.ar-toolbar.financial-soa-toolbar,
.ar-toolbar.financial-aging-toolbar {
    padding-block: 0.25rem;
    gap: 0.4rem;
}

.ar-toolbar .btn {
    min-height: 2rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.82rem;
}

.collections-freshness--inline {
    font-size: 0.74rem;
    color: var(--color-text-muted, #6b7280);
}

/* ── RTL numeric alignment ────────────────────────────────────────────────── */
[dir="rtl"] .collections-reports-table th.text-end,
[dir="rtl"] .collections-reports-table td.text-end,
[dir="rtl"] .app-table .num,
[dir="rtl"] .app-table .amount {
    text-align: end;
}

/* ── Settings / apps (supporting routes) ──────────────────────────────────── */
.settings-users-page .ar-dashboard-header__subtitle,
.users-page-shell .ar-dashboard-header__subtitle {
    display: none;
}

.settings-users-page .ar-dashboard-section__eyebrow {
    display: none;
}

.settings-users-page .ar-dashboard-header__title {
    font-size: var(--report-header-title-size);
}

.settings-users-page .app-table tbody td {
    color: var(--color-text, #111827);
    font-weight: 500;
}

@media (max-width: 48rem) {
    .collections-quick-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── Moved here from pages/collections/reports/workspace-compliance.css ───────
   That stylesheet was linked by no page, so none of these rules reached a
   browser -- yet report-nav.php still renders every one of these classes, and
   this file already owns the .collections-report-nav container, so the children
   belong beside it. Without them the report links painted as run-together plain
   text: index.css defines only the --more variant, and a substring search makes
   that look like the base rule exists. Verified by computed style after the
   move, not by the file being present. */

.collections-report-nav__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-muted, #6b7280);
    white-space: nowrap;
}

.collections-report-nav__list {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.collections-report-nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md, 0.5rem);
    color: var(--color-text-muted, #6b7280);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.collections-report-nav__link:hover {
    color: var(--color-primary, #2563eb);
    background: var(--color-surface-muted, #f8fafc);
}

.collections-report-nav__link.is-active {
    color: var(--color-text, #111827);
    background: var(--color-surface, #fff);
    border-color: var(--color-border, #d0d7de);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

[dir="rtl"] .collections-report-nav {
    direction: rtl;
}
