/* ==========================================================
   События по карте: матрица домов и тем (С.В. Шестопалов)
   Слой поверх Bootstrap 5: цвета, ступенчатая таблица, шкала 1–6
   ========================================================== */

.shp-section {
    position: relative;
    z-index: 1;
    scroll-margin-top: 96px;
}

/* ---------- Карточка ---------- */

.shp-card {
    --shp-line: rgba(140, 170, 210, 0.22);
    --shp-muted: #91a2b8;
    background-color: #0b1220;
    background-image: linear-gradient(180deg, rgba(17, 26, 46, 0.92) 0%, rgba(8, 13, 26, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: #e9eff8;
    text-align: left;
    font-family: 'Segoe UI', Roboto, sans-serif;
}

.shp-badge {
    background-color: rgba(77, 173, 255, 0.12);
    border: 1px solid rgba(77, 173, 255, 0.25);
    color: #4dadff;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 11px;
    padding: 0.45em 1em;
}

.shp-sub {
    color: var(--shp-muted);
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 620px;
}

.shp-head-text {
    min-width: 0;
    max-width: 640px;
}

.shp-hint {
    color: var(--shp-muted);
    font-size: 12px;
    line-height: 1.5;
    margin-top: 10px;
}

/* ---------- Вкладки ---------- */

.shp-tabs {
    --bs-nav-link-color: #91a2b8;
    --bs-nav-link-hover-color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 4px;
}

.shp-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    background: transparent;
}

.shp-tabs .nav-link:hover {
    border-bottom-color: rgba(77, 173, 255, 0.35);
}

.shp-tabs .nav-link.active {
    color: #ffffff;
    background: transparent;
    border-bottom-color: #4dadff;
}

.shp-switch {
    font-size: 13px;
    color: var(--shp-muted);
}

.shp-switch .form-check-input {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
}

.shp-switch .form-check-input:checked {
    background-color: #4dadff;
    border-color: #4dadff;
}

/* Кнопки внутри карточки — в тон тёмной панели, без белой фокусной заливки */
.shp-card .btn-outline-light {
    --bs-btn-color: #cfe0f5;
    --bs-btn-border-color: rgba(255, 255, 255, 0.22);
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: rgba(77, 173, 255, 0.16);
    --bs-btn-hover-border-color: rgba(77, 173, 255, 0.5);
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: rgba(77, 173, 255, 0.22);
    --bs-btn-active-border-color: rgba(77, 173, 255, 0.55);
    --bs-btn-focus-shadow-rgb: 77, 173, 255;
}

.shp-card .btn:focus,
.shp-card .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(77, 173, 255, 0.22);
}

/* ---------- Таблица (общая база поверх .table) ---------- */

.shp-table {
    --bs-table-color: inherit;
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(140, 170, 210, 0.22);
    --bs-table-accent-bg: transparent;
    color: inherit;
    table-layout: fixed;
    font-size: 13px;
    margin-bottom: 0;
}

.shp-table > :not(caption) > * > * {
    padding: 0;
}

/* Ступенчатая таблица: рамки только у реальных ячеек, без линий в пустоте */
.shp-table > :not(caption) > * {
    border-width: 0;
}

.shp-table > :not(caption) > * > * {
    border-width: 1px;
}

.shp-table th,
.shp-table td {
    vertical-align: middle;
    text-align: center;
}

/* Шкала оценок */

.shp-table td[data-score],
.shp-table .shp-mx-avg[data-score] {
    background-color: rgba(var(--sc), 0.13);
    color: rgb(var(--sc));
    font-weight: 700;
    box-shadow: none;
}

.shp-table td[data-score="1"] { --sc: 88, 226, 164; }
.shp-table td[data-score="2"] { --sc: 150, 214, 110; }
.shp-table td[data-score="3"] { --sc: 232, 204, 96; }
.shp-table td[data-score="4"] { --sc: 236, 154, 84; }
.shp-table td[data-score="5"] { --sc: 236, 106, 92; }
.shp-table td[data-score="6"] { --sc: 214, 68, 68; }

.shp-table .shp-mx-avg[data-score="1"] { --sc: 88, 226, 164; }
.shp-table .shp-mx-avg[data-score="2"] { --sc: 150, 214, 110; }
.shp-table .shp-mx-avg[data-score="3"] { --sc: 232, 204, 96; }
.shp-table .shp-mx-avg[data-score="4"] { --sc: 236, 154, 84; }
.shp-table .shp-mx-avg[data-score="5"] { --sc: 236, 106, 92; }
.shp-table .shp-mx-avg[data-score="6"] { --sc: 214, 68, 68; }

.shp-cell {
    height: 34px;
    font-size: 13.5px;
    font-weight: 700;
    color: rgb(var(--sc));
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.shp-cell:hover,
.shp-cell:focus-visible {
    background-color: rgba(var(--sc), 0.32);
    outline: none;
}

.shp-cell:focus-visible {
    box-shadow: inset 0 0 0 2px #4dadff;
}

.shp-table td.shp-cell.is-picked {
    background-color: rgba(var(--sc), 0.45);
    color: #ffffff;
    box-shadow: inset 0 0 0 2px #4dadff;
}

.shp-cell[data-score]:hover,
.shp-cell[data-score]:focus-visible {
    background-color: rgba(var(--sc), 0.34);
}

.shp-cell-empty {
    color: rgba(255, 255, 255, 0.22);
    cursor: default;
    background-color: rgba(255, 255, 255, 0.015);
}

/* ---------- Матрица «дома × темы» ---------- */

.shp-matrix {
    min-width: 660px;
}

.shp-matrix col.shp-mx-col-house {
    width: 172px;
}

.shp-matrix col.shp-mx-col-avg {
    width: 74px;
}

.shp-mx-head th {
    height: 52px;
    padding: 6px 4px !important;
    background-color: rgba(255, 255, 255, 0.045);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: #dbe6f5;
}

.shp-mx-corner {
    text-align: left !important;
    padding-left: 12px !important;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--shp-muted);
}

.shp-mx-theme-name {
    display: block;
}

.shp-mx-theme-sub {
    display: block;
    font-size: 10.5px;
    font-weight: 400;
    color: var(--shp-muted);
    margin-top: 2px;
}

.shp-mx-avg-head {
    color: var(--shp-muted) !important;
    font-size: 11px !important;
}

.shp-mx-house {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    column-gap: 3px;
    align-content: center;
    padding: 6px 10px !important;
    text-align: left !important;
    background-color: rgba(255, 255, 255, 0.03);
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
}

.shp-mx-num {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
    color: #4dadff;
    font-weight: 700;
    font-size: 12px;
}

.shp-mx-sign {
    grid-column: 2;
    grid-row: 1;
    font-size: 12.5px;
    color: #e9eff8;
}

.shp-mx-ruler {
    grid-column: 2;
    grid-row: 2;
    font-size: 10.5px;
    color: var(--shp-muted);
}

.shp-mx-avg {
    font-size: 12.5px;
    font-weight: 700;
    color: #c9d6e8;
    background-color: rgba(255, 255, 255, 0.03);
}

.shp-mx-foot .shp-mx-avg {
    border-top-width: 2px;
}

.shp-mx-foot-label {
    font-size: 11px;
    color: var(--shp-muted);
}

.shp-mx-avg-total {
    background-color: rgba(77, 173, 255, 0.08);
}

/* ---------- Справочная таблица 12×12 ---------- */

.shp-table col.shp-col-label {
    width: 148px;
}

.shp-corner {
    height: 54px;
    padding: 6px 10px !important;
    text-align: left !important;
    vertical-align: top !important;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.25;
    background-color: rgba(255, 255, 255, 0.03);
}

.shp-rowhead {
    height: 32px;
    padding: 0 10px !important;
    text-align: left !important;
    font-size: 13px;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.03);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shp-glyph {
    display: inline-block;
    width: 18px;
    margin-right: 6px;
    font-size: 13px;
    color: #8c7bf0;
    font-family: 'Segoe UI Symbol', 'DejaVu Sans', Arial, serif;
}

.shp-colhead {
    height: 122px;
    padding: 8px 0 !important;
    font-size: 13px;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.03);
    vertical-align: bottom !important;
}

.shp-colhead span {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.shp-axis-corner {
    padding: 8px 10px !important;
    font-size: 12px;
    font-weight: 600;
    color: var(--shp-muted);
    text-align: left !important;
    vertical-align: bottom !important;
    background-color: rgba(255, 255, 255, 0.03);
}

.shp-axis-corner span {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* ---------- Панели, легенда, детали ---------- */

.shp-panel {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(140, 170, 210, 0.18);
    border-radius: 12px;
    color: inherit;
    text-align: left;
}

.shp-legend-title {
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--shp-muted);
    margin-bottom: 6px;
}

.shp-legend {
    --bs-list-group-bg: transparent;
    --bs-list-group-color: inherit;
    --bs-list-group-border-color: transparent;
    margin-bottom: 0;
}

.shp-legend .list-group-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 3px 0;
    border: 0;
    font-size: 12.5px;
    background-color: transparent;
}

.shp-legend .list-group-item[data-score="1"] { --sc: 88, 226, 164; }
.shp-legend .list-group-item[data-score="2"] { --sc: 150, 214, 110; }
.shp-legend .list-group-item[data-score="3"] { --sc: 232, 204, 96; }
.shp-legend .list-group-item[data-score="4"] { --sc: 236, 154, 84; }
.shp-legend .list-group-item[data-score="5"] { --sc: 236, 106, 92; }
.shp-legend .list-group-item[data-score="6"] { --sc: 214, 68, 68; }

.shp-legend-num {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: rgb(var(--sc));
    background-color: rgba(var(--sc), 0.18);
    box-shadow: inset 0 0 0 1px rgba(var(--sc), 0.35);
}

/* Карточка деталей */

.shp-detail-title {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--shp-muted);
    margin-bottom: 10px;
}

.shp-detail-pair {
    font-size: 13px;
    color: #dbe6f5;
}

.shp-detail-score {
    font-size: 13px;
    color: #ffffff;
    margin: 4px 0 12px;
}

.shp-detail-score b {
    font-size: 20px;
    font-weight: 800;
    color: rgb(var(--sc, 120 140 170));
    margin-right: 4px;
}

.shp-detail[data-score] {
    --sc: 88, 226, 164;
}

.shp-detail[data-score="1"] { --sc: 88, 226, 164; }
.shp-detail[data-score="2"] { --sc: 150, 214, 110; }
.shp-detail[data-score="3"] { --sc: 232, 204, 96; }
.shp-detail[data-score="4"] { --sc: 236, 154, 84; }
.shp-detail[data-score="5"] { --sc: 236, 106, 92; }
.shp-detail[data-score="6"] { --sc: 214, 68, 68; }

.shp-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
    color: var(--shp-muted);
    min-width: 0;
}

.shp-detail-row b {
    color: #e9eff8;
    font-weight: 600;
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
}

.shp-section .row > * {
    min-width: 0;
}

.shp-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.shp-stat {
    padding: 8px 6px;
    border-radius: 9px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.04);
    min-width: 0;
}

.shp-stat b {
    display: block;
    font-size: 18px;
    line-height: 1.1;
}

.shp-stat span {
    display: block;
    font-size: 10.5px;
    line-height: 1.25;
    color: var(--shp-muted);
    overflow-wrap: anywhere;
}

.shp-stat-good b { color: #58e2a4; }
.shp-stat-mid b { color: #e8cc60; }
.shp-stat-bad b { color: #ec6a5c; }

.shp-pill {
    display: inline-block;
    padding: 1px 7px;
    margin: 1px 0;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.06);
    color: #dbe6f5;
    font-size: 11.5px;
}

.shp-muted {
    color: var(--shp-muted);
}

.shp-detail-note {
    font-size: 12.5px;
    color: var(--shp-muted);
    margin-bottom: 10px;
}

/* Пустое состояние */

.shp-empty {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 26px;
    border: 1px dashed rgba(140, 170, 210, 0.3);
    border-radius: 12px;
    color: var(--shp-muted);
}

.shp-empty::before {
    content: '\25C8';
    font-size: 26px;
    line-height: 1;
    color: rgba(77, 173, 255, 0.6);
}

.shp-empty b {
    display: block;
    color: #e9eff8;
    font-size: 14px;
    margin-bottom: 4px;
}

.shp-empty p {
    font-size: 12.5px;
    line-height: 1.5;
}

/* ---------- Печатный вид ---------- */

.shp-card.shp-paper {
    background-color: #f3ece3;
    background-image: none;
    border-color: #cbbfae;
    color: #1b1b1b;
    --shp-line: #b3a795;
    --shp-muted: #5f5546;
    font-family: Georgia, 'Times New Roman', serif;
}

.shp-paper .shp-table {
    --bs-table-color: #1b1b1b;
    --bs-table-border-color: #b3a795;
}

.shp-paper .shp-mx-head th,
.shp-paper .shp-mx-house,
.shp-paper .shp-mx-avg,
.shp-paper .shp-corner,
.shp-paper .shp-rowhead,
.shp-paper .shp-colhead,
.shp-paper .shp-axis-corner {
    background-color: #f7f2ea;
    color: #1b1b1b;
}

.shp-paper .shp-table td[data-score] {
    background-color: #f7f2ea;
    color: #1b1b1b;
    font-weight: 400;
}

.shp-paper .shp-table td[data-score]:hover {
    background-color: #efe6d8;
}

.shp-paper .shp-table td.shp-cell.is-picked {
    background-color: #e4d8c4;
    color: #000000;
    box-shadow: inset 0 0 0 2px #7a2f2f;
}

.shp-paper .shp-mx-num,
.shp-paper .shp-mx-sign,
.shp-paper .shp-mx-ruler,
.shp-paper .shp-mx-theme-name,
.shp-paper .shp-mx-theme-sub {
    color: #1b1b1b;
}

.shp-paper .shp-tabs .nav-link {
    color: #5f5546;
}

.shp-paper .shp-tabs .nav-link.active {
    color: #1b1b1b;
    border-bottom-color: #7a2f2f;
}

.shp-paper .shp-panel {
    background-color: #fbf7f0;
    border-color: #c3b6a3;
    color: #1b1b1b;
}

.shp-paper .shp-legend-num {
    color: #1b1b1b;
    background-color: #efe6d8;
    box-shadow: inset 0 0 0 1px #c3b6a3;
}

.shp-paper .shp-detail-row b,
.shp-paper .shp-detail-score,
.shp-paper .shp-detail-pair,
.shp-paper .shp-empty b {
    color: #1b1b1b;
}

.shp-paper .shp-empty {
    border-color: #c3b6a3;
    color: #5f5546;
}

.shp-paper .shp-pill {
    background-color: #efe6d8;
    color: #1b1b1b;
}

/* ---------- Адаптив ---------- */

@media (max-width: 575.98px) {
    .shp-card {
        --bs-card-border-radius: 16px;
    }

    .shp-matrix {
        min-width: 600px;
    }

    .shp-matrix col.shp-mx-col-house {
        width: 140px;
    }

    .shp-mx-house {
        grid-template-columns: 30px minmax(0, 1fr);
        padding: 4px 6px !important;
    }
}

/* ---------- «Как считается» ---------- */

.shp-how summary {
    cursor: pointer;
    padding: 12px 14px;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--shp-muted);
    list-style: none;
}

.shp-how summary::-webkit-details-marker {
    display: none;
}

.shp-how summary::after {
    content: '+';
    float: right;
    font-size: 14px;
    line-height: 1;
}

.shp-how[open] summary::after {
    content: '−';
}

.shp-how-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    font-size: 12px;
}

.shp-how-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--shp-muted);
}

.shp-how-list b {
    color: #e9eff8;
    font-weight: 600;
}

.shp-paper .shp-how-list b {
    color: #1b1b1b;
}

.shp-paper .shp-how-list li {
    border-top-color: #ddd0bd;
}

/* ---------- Печать: только таблица ---------- */

@media print {
    @page {
        margin: 12mm;
    }

    header.header,
    footer.footer,
    .stars,
    .stars2,
    .stars3,
    .toast,
    main > *:not(.shp-section),
    .shp-tools,
    .shp-tabs {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #111111 !important;
    }

    .shp-section {
        padding: 0 !important;
    }

    .shp-card {
        background: #ffffff !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        color: #111111 !important;
        font-family: Georgia, 'Times New Roman', serif;
        break-inside: avoid;
    }

    .shp-card .p-4 {
        padding: 0 !important;
    }

    .shp-badge {
        background: #f2f2f2 !important;
        border-color: #999999 !important;
        color: #333333 !important;
    }

    .shp-title,
    .shp-card h2 {
        color: #111111 !important;
    }

    .shp-sub,
    .shp-hint {
        color: #444444 !important;
    }

    .shp-table {
        --bs-table-color: #111111;
        --bs-table-border-color: #999999;
        min-width: 0 !important;
    }

    .shp-table td[data-score] {
        background: #ffffff !important;
        color: #111111 !important;
        font-weight: 400;
    }

    .shp-cell.is-picked {
        box-shadow: inset 0 0 0 2px #7a2f2f !important;
    }

    .shp-mx-head th,
    .shp-mx-house,
    .shp-mx-avg,
    .shp-corner,
    .shp-rowhead,
    .shp-colhead,
    .shp-axis-corner,
    .shp-mx-foot-label {
        background: #f4f4f4 !important;
        color: #111111 !important;
    }

    .shp-mx-num,
    .shp-mx-sign,
    .shp-mx-ruler,
    .shp-mx-theme-name,
    .shp-mx-theme-sub,
    .shp-mx-corner,
    .shp-mx-avg-head {
        color: #111111 !important;
    }

    .shp-panel {
        background: #ffffff !important;
        border-color: #cccccc !important;
        color: #111111 !important;
        break-inside: avoid;
    }

    .shp-legend-title,
    .shp-how summary,
    .shp-detail-title,
    .shp-detail-row {
        color: #444444 !important;
    }

    .shp-legend .list-group-item,
    .shp-detail-row b,
    .shp-detail-pair,
    .shp-detail-score,
    .shp-how-list b {
        color: #111111 !important;
    }

    .shp-legend-num {
        color: #111111 !important;
        background: #eeeeee !important;
        box-shadow: none !important;
    }

    .shp-stat {
        background: #f4f4f4 !important;
    }

    .shp-stat b,
    .shp-stat span {
        color: #111111 !important;
    }

    .shp-empty {
        border-color: #bbbbbb !important;
        color: #444444 !important;
    }

    .table-responsive {
        overflow: visible !important;
    }
}
