/* Shared report-table presentation. Structure, sticky offsets and data stay owned
   by each report. Load after page styles so legacy 7px captions and heavy grids
   cannot override the readable, compact baseline. */
:root {
    --ds-table-bg: #ffffff;
    --ds-table-head: #f4f5f7;
    --ds-table-hover: #f5f8fc;
    --ds-table-line: #e3e7ee;
    --ds-table-text: #253044;
    --ds-table-muted: #657287;
    --ds-table-link: #176ac6;
}

html[data-theme="dark"] {
    --ds-table-bg: #182231;
    --ds-table-head: #202c3d;
    --ds-table-hover: #223248;
    --ds-table-line: #344256;
    --ds-table-text: #e4ebf5;
    --ds-table-muted: #adbbce;
    --ds-table-link: #88bfff;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) {
    background-color: var(--ds-table-bg);
    color: var(--ds-table-text);
    font-size: 13px;
    font-weight: 400;
    font-variant-numeric: tabular-nums lining-nums;
    line-height: 1.45;
    border-spacing: 0;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) > thead > tr > th {
    padding: 8px 10px !important;
    background: var(--ds-table-head) !important;
    color: var(--ds-table-text) !important;
    border-bottom: 1px solid var(--ds-table-line) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    vertical-align: middle;
    text-align: left;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) > tbody > tr > :is(td, th) {
    padding: 7px 10px !important;
    color: var(--ds-table-text);
    border-bottom: 1px solid var(--ds-table-line) !important;
    font-size: 13px !important;
    font-weight: 400;
    line-height: 1.45 !important;
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Ordinary lists use horizontal separators. Matrix borders also identify metric
   groups, so those remain owned by the existing matrix styles. */
:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table):not(.rnp-table):not(.price-matrix-table) > :is(thead, tbody) > tr > :is(th, td) {
    border-inline: 0;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) > tfoot > tr > :is(th, td) {
    padding: 8px 10px;
    border-top: 1px solid var(--ds-table-line);
    background-color: var(--ds-table-head);
    color: var(--ds-table-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

/* One calm hover, not a new cell grid. Heatmaps keep their own semantic fills. */
:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table):not(.rnp-table):not(.price-matrix-table) > tbody > tr:hover > :is(td, th) {
    background-color: var(--ds-table-hover) !important;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) :is(td, th) > strong {
    font-size: inherit !important;
    font-weight: 600 !important;
    line-height: 1.45 !important;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) :is(td, th) > small {
    margin-top: 3px;
    color: var(--ds-table-muted) !important;
    font-size: 11px !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
    white-space: normal;
    overflow-wrap: anywhere;
}

:is(.workspace-page, .admin-portal-page) .data-table :is(.goods-product-cell, .advertising-product-cell, .ozon-ad-product, .rnp-matrix-product, .unit-product) strong {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.45 !important;
}

:is(.workspace-page, .admin-portal-page) .data-table :is(.goods-product-cell, .advertising-product-cell, .ozon-ad-product, .rnp-matrix-product, .unit-cell-stack, .unit-metric-cell) small,
:is(.workspace-page, .admin-portal-page) .data-table :is(.rnp-cell-trend, .rnp-product-shop) {
    font-size: 11px !important;
    line-height: 1.45 !important;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) :is(th.align-right, td.align-right, .cost-modal-value, .tax-rate-value, .tax-vat-value) {
    text-align: right !important;
    font-variant-numeric: tabular-nums lining-nums;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) td.align-right > strong {
    white-space: nowrap;
    overflow-wrap: normal;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) :is(th.align-center, td.align-center) {
    text-align: center !important;
}

:is(.workspace-page, .admin-portal-page) .data-table :is(td[data-label*="Дата"], td[data-label*="Статус"]):not(.align-center):not(.align-right) {
    text-align: left;
}

:is(.workspace-page, .admin-portal-page) .advertising-campaign-link-copy strong {
    white-space: normal;
    overflow-wrap: anywhere;
    overflow: visible;
    text-overflow: clip;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

/* The legacy generic 720px minimum squeezes Finance shops and captions into
   letter-wide strips. Retain the report's intended width and scroll it. */
.workspace-page .finance-table {
    min-width: 1740px;
}

.workspace-page .finance-article-table {
    min-width: 1980px;
}

.workspace-page .finance-day-table > :is(thead, tbody) > tr > :is(th, td):nth-child(2) {
    min-width: 180px;
}

.workspace-page .finance-table > :is(thead, tbody) > tr > .align-right {
    min-width: 104px;
}

@media (min-width: 761px) {
    /* Stable identifier/text lanes, not vertical columns of single letters.
       Existing phone cards continue to own their own widths below this point. */
    .workspace-page .data-table td[data-label="Магазин"] {
        min-width: 180px;
    }

    .workspace-page .data-table :is(td[data-label="SKU"], td[data-label="SKU / штрихкод"]) {
        min-width: 170px;
    }

    .workspace-page .data-table :is(td[data-label="Артикул МП"], td[data-label="Внутренний артикул"]) {
        min-width: 180px;
        max-width: 240px;
        white-space: normal;
    }

    .workspace-page .data-table td[data-label="Внутренний артикул"] > span {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) td > a:not(.button):not(.status) {
    color: var(--ds-table-link);
    text-underline-offset: 3px;
}

:is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) a:focus-visible {
    outline: 2px solid var(--primary, #6256f4);
    outline-offset: 3px;
    border-radius: 2px;
}

/* Titles and metadata are actual text, not ellipsis over the adjacent column. */
:is(.workspace-page, .admin-portal-page) :is(.goods-product-cell, .ozon-ad-product-cell, .advertising-product-cell) :is(strong, small),
:is(.workspace-page, .admin-portal-page) :is(.products-table, .finance-table, .ozon-ad-section-table, .ozon-ad-catalog-table) td > strong {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

:is(.workspace-page, .admin-portal-page) :is(.table-scroll, .rnp-table-scroll, .price-matrix-scroll) {
    scrollbar-color: #aab5c6 var(--ds-table-head);
    scrollbar-width: thin;
}

/* UNIT contains form grids, not one-line list rows. Do not collapse those grids,
   change column widths or detach the sticky product column. */
:is(.unit-wb-page, .unit-ozon-page) .unit-table > thead > tr > th {
    padding: 7px 10px !important;
}

:is(.unit-wb-page, .unit-ozon-page) .unit-table > tbody > tr > td {
    padding: 8px 10px !important;
    border-top-width: 0;
}

:is(.unit-wb-page, .unit-ozon-page) .unit-table :is(th, td):nth-child(5),
:is(.unit-wb-page, .unit-ozon-page) .unit-table :is(th, td):nth-child(10) {
    border-left: 1px solid var(--ds-table-line) !important;
}

/* Dense date matrices retain colgroups, frozen-column offsets, heatmaps and ABC
   states. Narrow day columns must not inherit ordinary-cell 12px side padding. */
:is(.workspace-page, .admin-portal-page) :is(.rnp-table, .price-matrix-table) > thead > tr > th,
:is(.workspace-page, .admin-portal-page) :is(.rnp-table, .price-matrix-table) > tbody > tr > :is(td, th) {
    padding: 7px 8px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
}

:is(.workspace-page, .admin-portal-page) .rnp-table > thead > tr > th {
    text-align: right;
}

:is(.workspace-page, .admin-portal-page) .rnp-table > thead > tr > :is(.rnp-product-column, .rnp-metric-column) {
    text-align: left;
}

:is(.workspace-page, .admin-portal-page) .rnp-table > tbody > tr > .rnp-product-column {
    vertical-align: top;
    text-align: left;
}

/* RNP is a dense matrix, not an ordinary report table. Keep both the value
   and its change readable without the shared table's 14px vertical padding.
   Natural height still grows for wrapped labels/amounts and the product card. */
body.finance-rnp-page.workspace-page .rnp-table > tbody > tr > :is(td, th) {
    padding: 2px 8px !important;
    line-height: 1.2 !important;
}

body.finance-rnp-page .rnp-table .rnp-metric-column > strong {
    line-height: 1.2 !important;
}

body.finance-rnp-page .rnp-table .rnp-cell-trend {
    display: flex;
    justify-content: flex-end;
    margin: 0;
    line-height: 1.1 !important;
}

/* A rowspan product card also sets the minimum total height when only a few
   metrics are selected. Compact its spacing without hiding any properties. */
body.finance-rnp-page .rnp-table .rnp-product-info {
    padding: 2px 1px;
    gap: 2px;
}

body.finance-rnp-page .rnp-table .rnp-matrix-product :is(strong, small, a),
body.finance-rnp-page .rnp-table .rnp-product-shop {
    line-height: 1.2 !important;
}

body.finance-rnp-page .rnp-table .rnp-product-side-fields > div {
    padding-block: 1px;
    line-height: 1.2;
}

body.finance-rnp-page .rnp-table .rnp-product-info > .button {
    min-height: 24px;
    height: 24px;
}

/* Exceptional amounts must wrap inside their fixed day cell, not paint over
   the next date. Ordinary-sized figures remain on one line naturally. */
:is(.workspace-page, .admin-portal-page) .rnp-table .rnp-value-cell > strong {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.15 !important;
}

:is(.workspace-page, .admin-portal-page) .price-matrix-table .matrix-sticky :is(strong, small) {
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 700px) {
    :is(.workspace-page, .admin-portal-page) .products-table {
        min-width: 0;
    }

    :is(.workspace-page, .admin-portal-page) .data-table td[data-label]::before {
        color: var(--ds-table-muted);
        font-size: 11px;
        font-weight: 600;
        line-height: 1.4;
        letter-spacing: 0;
        text-transform: none;
    }
}

@media (max-width: 600px) {
    /* Existing responsive cards remain cards; no global display/position reset. */
    :is(.workspace-page, .admin-portal-page) .data-table:is(.ui-responsive-table, .products-table, .orders-table, .companies-table, .stocks-table, .storage-table, .funnel-table, .cost-catalog-table, .cost-modal-periods, .tax-history-table, .tax-modal-periods, .advertising-table, .monthly-payments-table, .payment-purchases-table, .expansion-history-table) {
        min-width: 0;
    }

    :is(.workspace-page, .admin-portal-page) :is(.data-table, .ai-ratings-table, .monitoring-table) > tbody > tr > :is(td, th) {
        padding: 9px 10px !important;
    }

    :is(.workspace-page, .admin-portal-page) :is(.rnp-table, .price-matrix-table) > tbody > tr > :is(td, th) {
        padding: 7px 8px !important;
    }

}
