/* Reports page/table helpers.
   Scoped by .reports-sticky-first-col to avoid affecting other tables globally. */

.reports-page .table {
    font-size: 0.82rem;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto !important;
    width: 100%;
    min-width: max-content;
    margin-bottom: 0;
    background-color: transparent;
}

/* Стили заголовков отчета с поддержкой sticky */
.reports-page thead th {
    position: sticky;
    top: 0;
    z-index: 15;
    background-color: #1a1d20 !important;
    color: var(--accent-amber) !important;
    font-family: var(--header);
    font-weight: 600;
    padding: 12px 10px;
    border-bottom: 2px solid var(--accent-amber-border) !important;
    white-space: nowrap;
    box-shadow: 0 2px 2px rgba(0,0,0,0.2);
}

.reports-page tbody td {
    padding: 8px 10px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Базово не даем первой колонке схлопываться во всех отчетных таблицах. */
.reports-page .table th:first-child,
.reports-page .table td:first-child {
    min-width: 220px !important;
    width: 24% !important;
    max-width: none !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.reports-page tr:hover td {
    background-color: rgba(251, 191, 36, 0.03) !important;
}

/* Bootstrap status rows are light by default; keep report tables dark. */
.reports-page .table tbody tr.table-danger td,
.reports-page .table tbody tr.table-danger th {
    background-color: rgba(220, 53, 69, 0.16) !important;
    color: var(--foreground) !important;
}

.reports-page .table tbody tr.table-warning td,
.reports-page .table tbody tr.table-warning th {
    background-color: rgba(251, 191, 36, 0.16) !important;
    color: var(--foreground) !important;
}

.reports-page .table tbody tr.table-success td,
.reports-page .table tbody tr.table-success th {
    background-color: rgba(25, 135, 84, 0.16) !important;
    color: var(--foreground) !important;
}

.reports-sticky-first-col {
    table-layout: auto;
}

/* закрепляем первую колонку */
.reports-sticky-first-col th:first-child,
.reports-sticky-first-col td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #1a1d20 !important;
    box-shadow: 4px 0 8px rgba(0, 0, 0, 0.4);
    vertical-align: middle;

    min-width: clamp(220px, 24vw, 420px) !important;
    max-width: none !important;
    width: auto !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

.reports-sticky-first-col th:first-child {
    white-space: nowrap;
}

table.reports-cashboxes-table {
    table-layout: auto !important;
}

table.reports-cashboxes-table th:first-child,
table.reports-cashboxes-table td:first-child {
    width: 220px !important;
    min-width: 220px !important;
    max-width: 220px !important;
    white-space: nowrap !important;
}

table.reports-cashboxes-table th:not(:first-child),
table.reports-cashboxes-table td:not(:first-child) {
    width: 1% !important;
    white-space: nowrap !important;
}

@media (min-width: 992px) {
    .reports-page .table th:first-child,
    .reports-page .table td:first-child {
        min-width: 240px;
    }

    .reports-sticky-first-col th:first-child,
    .reports-sticky-first-col td:first-child {
        min-width: 360px !important;
    }
}

/* Улучшение скролла только для страницы reports */
.reports-page .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    background: var(--card);
    max-height: 80vh; /* Ограничение высоты для работы sticky header */
}

/* Вспомогательные классы для колонок с числами */
.reports-page .text-numeric {
    text-align: right;
    font-family: var(--money);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Итоговые строки */
.reports-page .report-summary-row td {
    background-color: rgba(255, 255, 255, 0.04) !important;
    font-weight: 700;
    color: var(--foreground);
    border-top: 1px solid var(--accent-amber-border);
    border-bottom: 2px solid var(--accent-amber-border);
}
