/* Сводка РНП: матрица показатель × день + динамика */

:root {
    --rnp-good: #067647;
    --rnp-good-bg: rgba(6, 118, 71, 0.10);
    --rnp-bad: #b42318;
    --rnp-bad-bg: rgba(180, 35, 24, 0.10);
    --rnp-accent-soft: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
}

.rnp-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
    margin: 0 0 14px;
}

.rnp-stat {
    background: linear-gradient(165deg, #fff 0%, var(--panel-muted, #f4f5f7) 100%);
    border: 1px solid var(--border, #e2e5ea);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    animation: rnp-stat-in 0.35s ease both;
}

.rnp-stat:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.rnp-stat-key {
    border-color: color-mix(in srgb, var(--accent, #2563eb) 28%, var(--border, #e2e5ea));
}

.rnp-stat-hero {
    background: linear-gradient(165deg, #fff 0%, var(--rnp-accent-soft) 100%);
    border-color: color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border, #e2e5ea));
}

.rnp-stat span {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
}

.rnp-stat strong {
    font-size: 16px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.rnp-stat.is-neg strong { color: var(--rnp-bad); }
.rnp-stat.is-pos strong { color: var(--rnp-good); }

.rnp-stat-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 22px;
    margin-top: 2px;
}

.rnp-stat-tone-good { box-shadow: inset 3px 0 0 var(--rnp-good); }
.rnp-stat-tone-bad { box-shadow: inset 3px 0 0 var(--rnp-bad); }

.rnp-table-wrap {
    /* Высота по содержимому, скролл страницы; горизонтальный скролл — внутри */
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
    border: 1px solid var(--border, #e2e5ea);
    border-radius: 10px;
    background: var(--panel, #fff);
}

.rnp-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.rnp-table th,
.rnp-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border, #eef0f3);
    border-right: 1px solid var(--border, #eef0f3);
    white-space: nowrap;
    text-align: right;
    vertical-align: middle;
    height: 36px;
    box-sizing: border-box;
    transition: background-color 0.15s ease;
}

.rnp-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel-muted, #f7f8fa);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted, #4b5563);
}

.rnp-table .rnp-sticky {
    position: sticky;
    left: 0;
    z-index: 3;
    text-align: left;
    background: var(--panel, #fff);
    font-weight: 550;
    min-width: 220px;
    max-width: 300px;
    border-right: 1px solid var(--border, #d8dce3);
}

.rnp-table thead .rnp-sticky {
    z-index: 4;
    background: var(--panel-muted, #f7f8fa);
}

.rnp-table .rnp-day {
    min-width: 96px;
}

.rnp-table .rnp-day-clickable {
    cursor: pointer;
}

.rnp-table .rnp-day-clickable:hover {
    background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--panel-muted, #f7f8fa));
}

.rnp-table .rnp-day-label {
    display: block;
}

.rnp-day-events {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: flex-end;
    margin-top: 3px;
    max-width: 110px;
    margin-left: auto;
}

.rnp-ev {
    display: inline-block;
    font-size: 10px;
    font-weight: 650;
    line-height: 1.2;
    padding: 1px 4px;
    border-radius: 4px;
    background: #eef2f7;
    color: #334155;
}

.rnp-ev-note { background: #fef3c7; color: #92400e; }
.rnp-ev-price { background: #dbeafe; color: #1d4ed8; }
.rnp-ev-rule { background: #ede9fe; color: #5b21b6; }
.rnp-ev-stock { background: #fee2e2; color: #b91c1c; }

.rnp-metric-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.02em;
    background: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
    color: var(--accent, #2563eb);
    vertical-align: middle;
}

.rnp-table .rnp-day-latest,
.rnp-table td.rnp-day-latest {
    background: color-mix(in srgb, var(--accent, #2563eb) 6%, transparent);
    box-shadow: inset 0 -2px 0 var(--accent, #2563eb);
}

.rnp-table thead .rnp-day-latest {
    color: var(--accent, #2563eb);
    font-weight: 700;
}

.rnp-table .rnp-total-col {
    font-weight: 650;
    background: #fafbfc;
    border-left: 1px solid var(--border, #d8dce3);
}

.rnp-table tbody tr:hover td,
.rnp-table tbody tr:hover .rnp-sticky {
    background: #f3f6fb;
}

.rnp-table .rnp-row-income .rnp-sticky {
    font-weight: 650;
}

.rnp-table .rnp-row-total {
    background: #f8fafc;
}

.rnp-table .rnp-row-total .rnp-sticky,
.rnp-table .rnp-row-total .rnp-total-col {
    background: #f1f5f9;
    font-weight: 700;
}

.rnp-table .rnp-row-key .rnp-sticky {
    box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent, #2563eb) 55%, transparent);
}

.rnp-table .rnp-row-hero td,
.rnp-table .rnp-row-hero .rnp-sticky {
    background: color-mix(in srgb, var(--accent, #2563eb) 5%, var(--panel, #fff));
}

.rnp-table .rnp-row-hero .rnp-sticky {
    box-shadow: inset 3px 0 0 var(--accent, #2563eb);
    font-weight: 700;
}

.rnp-table .rnp-row-ads .rnp-sticky {
    box-shadow: inset 3px 0 0 #d97706;
}

.rnp-table tbody tr.rnp-row-hero:hover td,
.rnp-table tbody tr.rnp-row-hero:hover .rnp-sticky {
    background: color-mix(in srgb, var(--accent, #2563eb) 9%, #f3f6fb);
}

.rnp-table .rnp-neg { color: var(--rnp-bad); }
.rnp-table .rnp-pos { color: var(--rnp-good); }

.rnp-cell-val {
    display: inline;
}

.rnp-delta {
    display: inline;
    font-size: 10px;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0.01em;
    margin-left: 4px;
    white-space: nowrap;
}

.rnp-delta-good { color: var(--rnp-good); }
.rnp-delta-bad { color: var(--rnp-bad); }
.rnp-delta-up { color: #2563eb; }
.rnp-delta-down { color: #9333ea; }
.rnp-delta-flat { color: #9ca3af; }

.rnp-heat-good-1 { background: rgba(6, 118, 71, 0.08); }
.rnp-heat-good-2 { background: rgba(6, 118, 71, 0.16); }
.rnp-heat-good-3 { background: rgba(6, 118, 71, 0.26); font-weight: 650; }
.rnp-heat-bad-1 { background: rgba(180, 35, 24, 0.08); }
.rnp-heat-bad-2 { background: rgba(180, 35, 24, 0.16); }
.rnp-heat-bad-3 { background: rgba(180, 35, 24, 0.26); font-weight: 650; }
.rnp-heat-up-1 { background: rgba(37, 99, 235, 0.08); }
.rnp-heat-up-2 { background: rgba(37, 99, 235, 0.14); }
.rnp-heat-down-1 { background: rgba(147, 51, 234, 0.08); }
.rnp-heat-down-2 { background: rgba(147, 51, 234, 0.14); }

.rnp-spark {
    flex: 0 0 auto;
    opacity: 0.85;
}

.rnp-spark-good { color: var(--rnp-good); }
.rnp-spark-bad { color: var(--rnp-bad); }

@keyframes rnp-stat-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.rnp-formula,
.rnp-alloc-hint {
    display: none !important;
}

#rnpPeriodPresets .rnp-period-btn.active {
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
}

.rnp-mode-tabs {
    display: inline-flex;
    gap: 4px;
    margin-right: 4px;
}

.rnp-mode-tabs .rnp-mode-btn.active {
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 10%, transparent);
}

.rnp-year-wrap,
.rnp-month-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rnp-year-wrap[hidden],
.rnp-month-wrap[hidden] {
    display: none !important;
}

.rnp-year-label {
    font-size: 13px;
    color: var(--ozon-gray, #667085);
}

#rnpYearSelect {
    min-width: 88px;
}

#rnpMonthSelect {
    min-width: 118px;
}

/* Тулбар не должен обрезать выпадающий список артикулов */
#rnpContent.panel,
#rnpContent .catalog-toolbar,
#rnpContent .catalog-controls {
    overflow: visible;
}

#rnpContent .catalog-toolbar {
    position: relative;
    z-index: 8;
}

.rnp-sku-search-wrap {
    position: relative;
    z-index: 9;
    min-width: 260px;
    max-width: 380px;
    flex: 1 1 280px;
}

.rnp-sku-combo {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.rnp-sku-combo .catalog-search-input {
    flex: 1 1 auto;
    min-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.rnp-sku-dropdown-btn {
    flex: 0 0 36px;
    border: 1px solid var(--border, #e2e5ea);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--panel-muted, #f4f5f7);
    color: var(--text-muted, #4b5563);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.rnp-sku-dropdown-btn:hover {
    background: #eef2f7;
    color: var(--text, #111827);
}

.rnp-sku-suggest {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 80;
    max-height: min(320px, 50vh);
    overflow: auto;
    background: var(--panel, #fff);
    border: 1px solid var(--border, #e2e5ea);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.rnp-sku-suggest-head {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    border-bottom: 1px solid var(--border, #eef0f3);
    background: var(--panel-muted, #f7f8fa);
    position: sticky;
    top: 0;
}

.rnp-sku-suggest button {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 8px 12px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    align-items: center;
}

.rnp-sku-suggest button:hover,
.rnp-sku-suggest button:focus,
.rnp-sku-suggest button.is-active {
    background: #f3f6fb;
    outline: none;
}

.rnp-sku-suggest strong {
    display: block;
    font-size: 13px;
    grid-column: 1;
}

.rnp-sku-suggest .rnp-sku-suggest-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    grid-column: 1;
}

.rnp-sku-suggest .rnp-sku-suggest-sale {
    grid-column: 2;
    grid-row: 1 / span 2;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #4b5563);
    white-space: nowrap;
}

.rnp-alloc-hint {
    margin: -6px 0 12px;
}

.rnp-table .rnp-cum-up {
    background: rgba(6, 118, 71, 0.12);
    color: var(--rnp-good);
    font-weight: 600;
}

.rnp-table .rnp-cum-down {
    background: rgba(180, 35, 24, 0.12);
    color: var(--rnp-bad);
    font-weight: 600;
}

.rnp-sku-link {
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 650;
    color: var(--accent, #2563eb);
    cursor: pointer;
    text-align: left;
}

.rnp-sku-link:hover {
    text-decoration: underline;
}

.rnp-sku-name {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted, #6b7280);
    white-space: normal;
    max-width: 240px;
    line-height: 1.3;
    margin-top: 2px;
}

.rnp-table .rnp-cumsum-total .rnp-sticky {
    font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
    .rnp-stat {
        animation: none;
    }
    .rnp-stat:hover {
        transform: none;
    }
}
