/* ===== Diagnostic viewer: unified topbar / navigation / notes ===== */

.diagnostic-viewer-shell,
.page-shell,
.card {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.diagnostic-viewer-header-card.diagnostic-viewer-topbar {
    margin-bottom: 16px;
    padding: 0;
    overflow: hidden;
    border-radius: 22px;

    background:
        radial-gradient(circle at 18% 0%, rgba(55, 110, 179, 0.32), transparent 34%),
        radial-gradient(circle at 86% 12%, rgba(168, 85, 247, 0.16), transparent 34%),
        linear-gradient(
            135deg,
            rgba(35, 49, 64, 0.82),
            rgba(39, 45, 72, 0.82) 52%,
            rgba(47, 42, 82, 0.80)
        );

    border: 1px solid rgba(165, 180, 252, 0.20);

    box-shadow:
        0 16px 38px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(129, 140, 248, 0.08) inset,
        inset 0 1px 0 rgba(255, 255, 255, 0.09),
        inset 0 -1px 0 rgba(15, 23, 42, 0.28);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}



.diagnostic-viewer-topbar__head {
    --diagnostic-viewer-tools-width: 200px;

    display: grid;
    grid-template-columns:
        minmax(320px, 0.86fr)
        minmax(430px, 1.34fr)
        var(--diagnostic-viewer-tools-width);
    grid-template-areas: "client nav tools";
    gap: 18px;
    align-items: center;
    padding: 20px;
}

.diagnostic-viewer-topbar__client {
    grid-area: client;
    min-width: 0;
}

.diagnostic-viewer-topbar__client .page-header__title {
    margin: 0;
    color: #f8fafc;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.diagnostic-viewer-topbar__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 0;
    margin-top: 8px;

    color: rgba(226, 232, 240, 0.86);
    font-size: 16px;
    line-height: 1.3;
}

.diagnostic-viewer-topbar__meta span {
    display: inline-flex;
    align-items: center;
}

.diagnostic-viewer-topbar__meta span + span::before {
    content: "•";
    margin: 0 12px;
    color: rgba(74, 222, 128, 0.82);
}


.diagnostic-viewer-topbar__empty {
    grid-area: tools;
    justify-self: end;
    padding: 10px 12px;
    border-radius: 12px;

    background: rgba(15, 23, 42, 0.32);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.diagnostic-viewer-topbar__tools {
    grid-area: tools;

    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    justify-self: end;
    width: var(--diagnostic-viewer-tools-width);
    max-width: 100%;
    min-width: 0;
}

.diagnostic-viewer-topbar__picker {
    width: 100%;
    max-width: none;
    margin: 0;
}

.diagnostic-viewer-topbar__picker select {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 40px;
    margin: 0;
    padding: 0 30px 0 12px;

    border-radius: 12px;
    background: rgba(15, 23, 42, 0.78);
    border-color: rgba(148, 163, 184, 0.22);

    color: #f8fafc;
    font-size: 14px;
    line-height: 1;
}

.diagnostic-viewer-topbar__tools .consultation-control {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
}

.diagnostic-viewer-topbar__tools .consultation-control__form {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.diagnostic-viewer-topbar__tools .consultation-control__form .btn,
.diagnostic-viewer-topbar__tools .diagnostic-viewer-tool-btn {
    width: 100%;
    min-width: 0;
    height: 40px;
    min-height: 40px;
    padding: 4px 12px 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;

    border-radius: 12px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.15;
    white-space: nowrap;
}

.diagnostic-viewer-tool-btn {
    appearance: none;
    border: 1px solid transparent;
    font: inherit;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.diagnostic-viewer-tool-btn--primary {
    color: #ffffff;
    background: linear-gradient(135deg, #6b28bd, #79286d);
    border-color: rgba(191, 219, 254, 0.34);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.diagnostic-viewer-tool-btn--primary:hover {
    color: #ffffff;
    background: linear-gradient(135deg, #8642d8, #913383);
    border-color: rgba(191, 219, 254, 0.48);
    transform: translateY(-1px);
}

.diagnostic-viewer-tool-btn--secondary {
    color: #e2e8f0;
    background: #402879;
    border-color: rgba(148, 163, 184, 0.18);
}

.diagnostic-viewer-tool-btn--secondary:hover {
    color: #ffffff;
    background: #523496;
    border-color: rgba(148, 163, 184, 0.28);
    transform: translateY(-1px);
}

.diagnostic-viewer-nav {
    display: flex;
    justify-content: stretch;
    margin: 0;
}

.diagnostic-viewer-topbar__nav {
    grid-area: nav;
    align-self: center;
    min-width: 0;
}

.diagnostic-viewer-nav__panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
}

.diagnostic-viewer-nav__link {
    flex: 1 1 170px;
    max-width: 230px;
    min-width: 160px;
    min-height: 40px;
    padding: 11px 12px 7px;
    border-radius: 13px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;

    font-size: 14px;
    font-weight: 400;
    line-height: 1.2;

    color: #e8fff3;
    background: rgba(15, 23, 42, 0.34);
    border: 1px solid rgba(187, 247, 208, 0.18);

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 8px 18px rgba(0, 0, 0, 0.12);

    transition:
        transform 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.diagnostic-viewer-topbar__nav--count-4 .diagnostic-viewer-nav__panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    max-width: 460px;
    margin: 0 auto;
}

.diagnostic-viewer-topbar__nav--count-4 .diagnostic-viewer-nav__link {
    width: 100%;
    max-width: none;
    min-width: 0;
}

.diagnostic-viewer-nav__link:hover {
    color: #ffffff;
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(187, 247, 208, 0.34);
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 22px rgba(37, 99, 235, 0.18);
}

.diagnostic-viewer-nav__link.is-active {
    color: #ffffff;
    background: rgba(34, 197, 94, 0.52);
    border-color: rgba(187, 247, 208, 0.36);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        0 10px 26px rgba(34, 197, 94, 0.24);
    transform: none;
}

.diagnostic-viewer-notes-card {
    width: 100%;
    max-width: none;
    margin: 0 0 16px;
    padding: 0;
    border-radius: 18px;

    background: rgba(30, 41, 59, 0.58);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.diagnostic-viewer-notes-card .expert-notes-card__summary {
    min-height: 44px;
    padding: 10px 16px;
}

.diagnostic-viewer-notes-card .expert-eyebrow {
    font-size: 11px;
    letter-spacing: 0.08em;
}

.diagnostic-viewer-notes-card .expert-notes-card__summary strong {
    font-size: 14px;
    font-weight: 600;
}

.diagnostic-viewer-notes-card .expert-notes-card__hint {
    font-size: 12px;
    font-weight: 500;
}

.diagnostic-viewer-notes-card .expert-notes-form--compact {
    padding: 12px 16px 14px;
}

.diagnostic-viewer-notes-card textarea {
    min-height: 96px;
}

@media (max-width: 1180px) {
    .diagnostic-viewer-topbar__head {
        grid-template-columns: minmax(0, 1fr) var(--diagnostic-viewer-tools-width);
        grid-template-areas:
            "client tools"
            "nav nav";
        gap: 16px 18px;
    }

    .diagnostic-viewer-topbar__nav {
        padding-top: 16px;
        border-top: 1px solid rgba(148, 163, 184, 0.14);
    }

    .diagnostic-viewer-nav__link {
        flex: 1 1 170px;
        max-width: 240px;
    }
}

@media (max-width: 760px) {
    .diagnostic-viewer-header-card.diagnostic-viewer-topbar {
        border-radius: 18px;
    }

    .diagnostic-viewer-topbar__head {
        --diagnostic-viewer-tools-width: 100%;

        grid-template-columns: 1fr;
        grid-template-areas:
            "client"
            "tools"
            "nav";
        gap: 14px;
        padding: 18px 16px;
    }

    .diagnostic-viewer-topbar__client .page-header__title {
        font-size: 24px;
    }

    .diagnostic-viewer-topbar__meta {
        font-size: 14px;
    }

    .diagnostic-viewer-topbar__tools {
        width: 100%;
        justify-self: stretch;
        grid-template-columns: 1fr;
    }

    .diagnostic-viewer-topbar__nav {
        padding-top: 14px;
    }

    .diagnostic-viewer-nav__panel {
        gap: 8px;
    }

    .diagnostic-viewer-nav__link {
        flex: 1 1 calc(50% - 8px);
        max-width: none;
        min-width: 0;
        min-height: 40px;
        white-space: normal;
        padding: 11px 10px 7px;
        font-size: 13px;
    }

    .diagnostic-viewer-notes-card {
        margin-bottom: 16px;
    }
}

@media (max-width: 460px) {
    .diagnostic-viewer-topbar__nav--count-4 .diagnostic-viewer-nav__panel {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .diagnostic-viewer-nav__link {
        flex-basis: 100%;
    }
}

/* ===== Diagnostic viewer: resource age period ===== */

.resource-age-period {
    --resource-age-accent: rgba(148, 163, 184, 0.86);
    --resource-age-accent-soft: rgba(148, 163, 184, 0.16);
    --resource-age-accent-border: rgba(148, 163, 184, 0.28);

    margin-top: 12px;
    padding: 12px 14px 13px;
    border-radius: 16px;
    background:
        linear-gradient(135deg, var(--resource-age-accent-soft), rgba(255,255,255,0.025));
    border: 1px solid var(--resource-age-accent-border);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.025) inset,
        0 8px 18px rgba(0,0,0,0.10);
}

.resource-age-period--reserve,
.resource-age-period--good {
    --resource-age-accent: rgba(34, 197, 94, 0.92);
    --resource-age-accent-soft: rgba(34, 197, 94, 0.13);
    --resource-age-accent-border: rgba(34, 197, 94, 0.30);
}

.resource-age-period--warn {
    --resource-age-accent: rgba(245, 158, 11, 0.95);
    --resource-age-accent-soft: rgba(245, 158, 11, 0.13);
    --resource-age-accent-border: rgba(245, 158, 11, 0.32);
}

.resource-age-period--danger {
    --resource-age-accent: rgba(239, 68, 68, 0.92);
    --resource-age-accent-soft: rgba(239, 68, 68, 0.13);
    --resource-age-accent-border: rgba(239, 68, 68, 0.32);
}

.resource-age-period__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 11px;
}

.resource-age-period__main {
    min-width: 0;
}

.resource-age-period__eyebrow {
    margin-bottom: 4px;
    color: rgba(203, 213, 225, 0.78);
    font-size: 12px;
    line-height: 1.2;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.resource-age-period__title {
    color: #f8fafc;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 700;
}

.resource-age-period__delta {
    flex: 0 0 auto;
    min-width: 42px;
    padding: 7px 10px;
    border-radius: 999px;
    text-align: center;
    color: #ffffff;
    background: var(--resource-age-accent-soft);
    border: 1px solid var(--resource-age-accent-border);
    font-size: 16px;
    line-height: 1;
    font-weight: 700;
}

.resource-age-scale {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
    border-radius: 13px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(15, 23, 42, 0.28);
}

.resource-age-scale__cell {
    min-width: 0;
    min-height: 54px;
    padding: 7px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.035);
    border-right: 1px solid rgba(255,255,255,0.06);
    box-sizing: border-box;
}

.resource-age-scale__cell:last-child {
    border-right: 0;
}

.resource-age-scale__cell.is-calendar {
    background:
        linear-gradient(180deg, rgba(59, 130, 246, 0.22), rgba(255,255,255,0.04));
}

.resource-age-scale__cell.is-bio {
    background:
        linear-gradient(180deg, var(--resource-age-accent-soft), rgba(255,255,255,0.04));
    box-shadow: inset 0 0 0 1px var(--resource-age-accent-border);
}

.resource-age-scale__cell.is-calendar.is-bio {
    background:
        linear-gradient(135deg, rgba(59, 130, 246, 0.20), var(--resource-age-accent-soft));
}

.resource-age-scale__markers {
    display: flex;
    justify-content: center;
    gap: 4px;
    min-height: 18px;
}

.resource-age-scale__marker {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 10px;
    line-height: 1;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0,0,0,0.18);
}

.resource-age-scale__marker--calendar {
    background: rgba(59, 130, 246, 0.92);
}

.resource-age-scale__marker--bio {
    background: var(--resource-age-accent);
}

.resource-age-scale__label {
    color: rgba(203, 213, 225, 0.42);
    font-size: 11px;
    line-height: 1;
    font-weight: 600;
    white-space: nowrap;
}

.resource-age-scale__cell.is-calendar .resource-age-scale__label,
.resource-age-scale__cell.is-bio .resource-age-scale__label {
    color: rgba(248, 250, 252, 0.92);
}

.resource-age-period__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 8px;
    color: rgba(203, 213, 225, 0.75);
    font-size: 12px;
    line-height: 1.25;
}

.resource-age-period__legend strong {
    color: #f8fafc;
}

.resource-age-period__details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.resource-age-period__detail {
    min-width: 0;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.25);
    border: 1px solid rgba(255,255,255,0.07);
}

.resource-age-period__detail span,
.resource-age-period__detail small {
    display: block;
    color: rgba(203, 213, 225, 0.72);
    font-size: 12px;
    line-height: 1.25;
}

.resource-age-period__detail strong {
    display: block;
    margin: 4px 0 3px;
    color: #f8fafc;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 700;
}

.resource-age-period__detail--muted strong {
    color: rgba(226, 232, 240, 0.82);
}

.resource-age-period__note {
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: rgba(203, 213, 225, 0.74);
    font-size: 12px;
    line-height: 1.45;
}

@media (max-width: 640px) {
    .resource-age-period__head,
    .resource-age-period__details {
        grid-template-columns: 1fr;
    }

    .resource-age-period__head {
        display: grid;
    }

    .resource-age-period__delta {
        justify-self: start;
    }

    .resource-age-scale {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


/* ===== Diagnostic viewer: shared resource overview ===== */

.brain-functions-top__left--resource {
    display: block !important;
    min-width: 0;
}

.brain-functions-top__left--full {
    grid-column: 1 / -1;
}

.brain-functions-top__left--with-metrics {
    grid-column: 1 / -1;
}

.brain-resource-overview {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
    gap: 14px;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.brain-resource-overview--consultation {
    margin: 14px 0 16px;
}

.age-compare-card--resource-period,
.age-compare-card--resource-state {
    margin: 0;
    height: 100%;
    box-sizing: border-box;
}

.age-compare-card--resource-period {
    padding: 0;
    overflow: hidden;
}

.resource-age-period--standalone {
    margin-top: 0;
    height: 100%;
    box-sizing: border-box;
    border-radius: 18px;
}

.age-compare-card--resource-state {
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: flex-start;
}

.resource-battery__description {
    margin-top: 9px;
    color: rgba(203, 213, 225, 0.72);
    font-size: 12px;
    line-height: 1.45;
}

/* Внутри общего resource overview карточки не должны наследовать
   раскладку старого верхнего блока brain-functions-top. */
.brain-functions-top__left .brain-resource-overview .age-compare-card--resource-period,
.brain-functions-top__left .brain-resource-overview .age-compare-card--resource-state {
    grid-column: auto;
}

.resource-state-note {
    margin-top: 2px;
    padding-top: 13px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.resource-state-note__title {
    margin-bottom: 8px;
    color: #f8fafc;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 700;
}

.resource-state-note__text {
    display: grid;
    gap: 5px;
    color: rgba(226, 232, 240, 0.86);
    font-size: 14px;
    line-height: 1.45;
}

.brain-functions-top__left--with-metrics .brain-resource-overview {
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
}

@media (max-width: 900px) {
    .brain-functions-top__left--with-metrics {
        grid-column: 1 / -1;
    }

    .brain-functions-top__left--with-metrics .brain-resource-overview {
        grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
    }
}

@media (max-width: 760px) {
    .brain-resource-overview,
    .brain-functions-top__left--with-metrics .brain-resource-overview {
        grid-template-columns: 1fr;
    }

    .resource-state-note__title {
        font-size: 21px;
    }
}

/* ===== Brain functions ===== */

.brain-functions-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.brain-metric--reserve {
    border-color: rgba(246, 211, 101, 0.46);
    box-shadow:
        0 0 0 1px rgba(246, 211, 101, 0.10) inset,
        0 0 22px rgba(246, 211, 101, 0.12);
}

.brain-metric {
    background: rgba(15, 23, 42, 0.32);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px;
}

.brain-metric__label {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.brain-metric__value {
    font-size: 24px;
    font-weight: 700;
}

.brain-chart-wrap {
    position: relative;
    height: 420px;
    background: rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 16px;
}

.brain-metric--red {
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(127, 29, 29, 0.14);
}

.brain-metric--red .brain-metric__label,
.brain-metric--red .brain-metric__value {
    color: #fecaca;
}

.brain-metric--blue {
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(30, 64, 175, 0.14);
}

.brain-metric--blue .brain-metric__label,
.brain-metric--blue .brain-metric__value {
    color: #bfdbfe;
}

.brain-metric--green {
    border-color: rgba(34, 197, 94, 0.28);
    background: rgba(20, 83, 45, 0.14);
}

.brain-metric--green .brain-metric__label,
.brain-metric--green .brain-metric__value {
    color: #bbf7d0;
}

.brain-metric__label::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.brain-metric--red .brain-metric__label::before { background: #ef4444; }
.brain-metric--blue .brain-metric__label::before { background: #3b82f6; }
.brain-metric--green .brain-metric__label::before { background: #22c55e; }

.brain-metric__norm {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 9px;
}

.brain-metric__norm-label {
    color: rgba(203, 213, 225, 0.68);
    font-size: 12px;
    line-height: 1;
}

@media (max-width: 900px) {
    .brain-functions-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .brain-chart-wrap {
        height: 320px;
    }
}

@media (max-width: 640px) {
    .brain-functions-metrics {
        grid-template-columns: 1fr;
    }
}

.brain-functions-top {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
    margin-bottom: 20px;
}

/* Убираем промежуточные обёртки из раскладки,
   чтобы все карточки легли в общую сетку */
.brain-functions-top__left,
.brain-functions-top__right,
.brain-functions-top__left .brain-functions-metrics--age,
.brain-functions-top .brain-functions-side-metrics {
    display: contents;
}

.brain-functions-top__left .age-compare-card,
.brain-functions-top__left .brain-metric {
    margin-top: 0;
    margin-bottom: 0;
    height: 100%;
    box-sizing: border-box;
}

/* Первая строка: шкала + пояснение */
.brain-functions-top__left .age-compare-card {
    grid-column: span 2;
}

.brain-functions-top__left .brain-metric {
    grid-column: span 2;
}

/* Вторая строка: четыре плашки функций */
.brain-functions-side-metrics--below {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
    margin-top: 16px;
    margin-bottom: 22px;
}

.brain-functions-side-metrics--below .brain-metric {
    min-height: 78px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 1100px) {
    .brain-functions-side-metrics--below {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .brain-functions-side-metrics--below {
        grid-template-columns: 1fr;
    }
}

.brain-functions-side-metrics .brain-metric {
    grid-column: span 1;
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brain-functions-side-metrics .brain-metric__value {
    font-size: 22px;
}

.brain-functions-side-metrics .brain-metric__label {
    margin-bottom: 8px;
}

.brain-metric[data-series] {
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    cursor: default;
}

.brain-metric[data-series]:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.brain-metric__value-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.brain-metric__value-row .brain-metric__value {
    flex: 0 0 auto;
    margin: 0;
}

.brain-metric__value-row .brain-metric__status {
    margin-left: 0;
}

.brain-metric__status {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 999px;

    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.34);
    color: #fde68a;

    font-size: 11px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
}

.brain-metric--attention {
    box-shadow:
        inset 0 0 0 1px rgba(245, 158, 11, 0.12),
        0 0 20px rgba(245, 158, 11, 0.10);
}

.brain-metric--attention[data-series]:hover {
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.18),
        inset 0 0 0 1px rgba(245, 158, 11, 0.12),
        0 0 20px rgba(245, 158, 11, 0.12);
}

@media (max-width: 1100px) {
    .brain-functions-top {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .brain-functions-top__left .age-compare-card,
    .brain-functions-top__left .brain-metric,
    .brain-functions-side-metrics .brain-metric {
        grid-column: span 1;
    }
}

@media (max-width: 640px) {
    .brain-functions-top {
        grid-template-columns: 1fr;
    }

    .brain-functions-top__left .age-compare-card,
    .brain-functions-top__left .brain-metric,
    .brain-functions-side-metrics .brain-metric {
        grid-column: span 1;
    }
}

/* =========================================
   Diagnostic viewer: consultation mode
   ========================================= */

.consultation-viewer-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.30);
    background:
        linear-gradient(
            135deg,
            rgba(103, 52, 151, 0.84),
            rgba(59, 61, 219, 0.815) 52%,
            rgba(103, 52, 151, 0.84)
        );
    box-shadow:
        0 0 0 1px rgba(168, 85, 247, 0.04) inset,
        0 8px 20px rgba(0,0,0,0.08);
}

.consultation-viewer-notice__main {
    min-width: 0;
}

.consultation-viewer-notice__title {
    margin-bottom: 3px;
    color: #ddd6fe;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.consultation-viewer-notice__text {
    color: rgba(237, 233, 254, 0.78);
    font-size: 13px;
    line-height: 1.4;
}

.consultation-viewer-notice__state {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.34);
    border: 1px solid rgba(221, 214, 254, 0.14);
    color: rgba(237, 233, 254, 0.80);
    font-size: 12px;
    line-height: 1.2;
}

.consultation-viewer-notice__state strong {
    color: #ffffff;
}

.consultation-viewer-notice__state--empty {
    color: rgba(237, 233, 254, 0.68);
}

.consultation-viewer-notice__clear-form {
    margin: 0;
}

.consultation-viewer-notice__clear-btn {
    appearance: none;
    border: 1px solid rgba(248, 113, 113, 0.28);
    border-radius: 999px;
    padding: 5px 8px;
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    font: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.consultation-viewer-notice__clear-btn:hover {
    background: rgba(239, 68, 68, 0.20);
    color: #ffffff;
}

.consultation-section-share {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.22);
    background:
        linear-gradient(
            135deg,
            rgba(168, 85, 247, 0.10),
            rgba(255,255,255,0.025)
        );
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.consultation-section-share--inline {
    margin-top: -4px;
}

.consultation-section-share__label {
    color: rgba(237, 233, 254, 0.78);
    font-size: 13px;
    line-height: 1.35;
    font-weight: 700;
}

.consultation-section-share__form {
    margin: 0;
    flex: 0 0 auto;
}

.consultation-section-share__button {
    appearance: none;
    border: 1px solid rgba(168, 85, 247, 0.60);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(107, 48, 163, 0.54);
    color: #ede9fe;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    font-weight: 400;
    cursor: pointer;
    transition: 0.18s ease;
}

.consultation-section-share__button:hover {
    background: rgba(126, 62, 185, 0.65);
    border-color: rgba(168, 85, 247, 0.40);
    color: #ffffff;
}

.consultation-section-share__button.is-active {
    background: rgba(241, 45, 241, 0.58);
    border-color: rgba(255, 255, 255, 0.8);
    color: #bbf7d0;
}

@media (max-width: 760px) {
    .consultation-viewer-notice,
    .consultation-section-share {
        align-items: stretch;
        flex-direction: column;
    }

    .consultation-viewer-notice__state {
        width: 100%;
        box-sizing: border-box;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .consultation-section-share__form,
    .consultation-section-share__button {
        width: 100%;
    }

    .consultation-section-share__button {
        text-align: center;
    }
}

.diagnostic-section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.diagnostic-section-head h2 {
    margin: 0;
    min-width: 0;
}

.consultation-section-share__form--head {
    margin: 0;
    flex: 0 0 auto;
}

.consultation-section-share__button--head {
    white-space: nowrap;
}

.organs-system-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.organs-system-head .organs-system-title {
    flex: 1 1 auto;
    margin-bottom: 0;
}

.organ-share-form {
    margin: 0;
    flex: 0 0 auto;
}

.organ-share-form--group {
    margin-left: auto;
}

.organ-side-card__title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: nowrap;
}

.organ-side-card__title-row .organ-side-card__title {
    min-width: 0;
    flex: 1 1 0;
    margin: 0;
    overflow-wrap: normal;
}

.consultation-section-share__button--small {
    padding: 7px 10px;
    font-size: 12px;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .organs-system-head,
    .organ-side-card__title-row {
        align-items: stretch;
        flex-direction: column;
    }

    .organ-share-form,
    .organ-share-form--group,
    .organ-share-form .consultation-section-share__button {
        width: 100%;
    }
}

/* ===== Therapy blocks picker ===== */

.therapy-block-picker {
    margin: 18px 0 22px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(34, 62, 94, 0.6);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(14px)
}

.therapy-block-picker__head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.therapy-block-picker__head h3 {
    margin-bottom: 6px;
}

.therapy-block-picker__select-wrap {
    min-width: 320px;
}

.therapy-block-picker__select-wrap label {
    margin-bottom: 6px;
}

.therapy-block-picker__select-wrap select {
    margin-bottom: 0;
}

.therapy-block-detail {
    display: grid;
    gap: 14px;
}

.therapy-block-detail__top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.therapy-block-detail__title {
    font-size: 18px;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 8px;
}

.therapy-block-detail__meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: #cbd5e1;
    font-size: 14px;
}

.therapy-block-detail__badge {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.34);
    color: #bbf7d0;
    font-size: 13px;
    font-weight: 700;
}

.therapy-block-detail__bulk {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.06);
}

.therapy-block-detail__bulk label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

.therapy-block-detail__bulk input {
    width: 110px;
    margin-bottom: 0;
}

.therapy-block-items,
.therapy-item-children {
    display: grid;
    gap: 10px;
}

.therapy-block-child,
.therapy-item-child-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
}

.therapy-block-child__name,
.therapy-item-child-row__title {
    font-weight: 600;
    color: #f3f4f6;
    line-height: 1.35;
}

.therapy-block-child__radio {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    font-weight: 700;
}

.therapy-block-child__radio input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #22c55e;
}

.therapy-block-child__sessions,
.therapy-item-child-row__sessions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    white-space: nowrap;
    font-size: 14px;
}

.therapy-block-child__sessions input,
.therapy-item-child-row__sessions input {
    width: 82px;
    margin-bottom: 0;
    padding: 8px 10px;
}

.therapy-block-detail__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.therapy-item-children-form {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.therapy-item-children-form__submit {
    justify-self: start;
}

@media (max-width: 760px) {
    .therapy-block-picker__select-wrap {
        width: 100%;
        min-width: 0;
    }

    .therapy-block-child,
    .therapy-item-child-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .therapy-block-child__sessions,
    .therapy-item-child-row__sessions {
        justify-content: space-between;
    }

    .therapy-block-child__sessions input,
    .therapy-item-child-row__sessions input {
        width: 120px;
    }
}

/* ===== Therapy order history ===== */

.therapy-order-card-head,
.therapy-history-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.therapy-order-card-head h2,
.therapy-history-head h2 {
    margin-bottom: 6px;
}

.therapy-order-card-head .btn {
    flex: 0 0 auto;
}

.therapy-history-list {
    display: grid;
    gap: 12px;
}

.therapy-history-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.therapy-history-row__top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.therapy-history-row__title {
    font-size: 18px;
    font-weight: 400;
    color: #f8fafc;
}

.therapy-history-row__meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #cbd5e1;
}

.therapy-history-row__courses {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.therapy-history-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.14);
    border: 1px solid rgba(59, 130, 246, 0.22);
    color: #dbeafe;
    font-size: 13px;
    line-height: 1.2;
}

.therapy-history-status {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
}

.therapy-history-status--draft {
    background: rgba(148, 163, 184, 0.16);
    color: #cbd5e1;
}

.therapy-history-status--waiting {
    background: rgba(251, 191, 36, 0.18);
    color: #fde68a;
}

.therapy-history-status--active {
    background: rgba(34, 197, 94, 0.18);
    color: #bbf7d0;
}

.therapy-history-status--error {
    background: rgba(239, 68, 68, 0.18);
    color: #fecaca;
}

.therapy-history-error {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.22);
    color: #fecaca;
    font-size: 14px;
}

.therapy-history-row__actions {
    display: flex;
    justify-content: flex-end;
}

.therapy-history-delete-form {
    margin: 0;
}

.therapy-history-row__actions .therapy-remove-btn {
    white-space: nowrap;
}

.therapy-history-block-chip {
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.22);
}

.therapy-history-block-chip__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.therapy-history-block-chip__title {
    font-weight: 400;
    color: #dcfce7;
}

.therapy-history-block-chip__count {
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.16);
    border: 1px solid rgba(34, 197, 94, 0.26);
    color: #bbf7d0;
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
}

.therapy-history-block-chip__children {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.therapy-history-chip--child {
    background: rgba(15, 23, 42, 0.36);
    border-color: rgba(255, 255, 255, 0.10);
    color: #e2e8f0;
}

.therapy-history-chip__meta {
    margin-left: 6px;
    color: #94a3b8;
    font-size: 12px;
}

@media (max-width: 760px) {
    .therapy-history-row__actions .therapy-remove-btn {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .therapy-history-row {
        grid-template-columns: 1fr;
    }

    .therapy-history-row__actions {
        justify-content: stretch;
    }

    .therapy-history-row__actions .btn,
    .therapy-order-card-head .btn {
        width: 100%;
    }
}

/* ===== Help drawer / справочник ===== */

.diagnostic-section-head__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.help-trigger {
    appearance: none;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 999px;
    border: 1px solid rgba(191, 219, 254, 0.38);
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,0.22), transparent 34%),
        rgba(59, 130, 246, 0.16);
    color: #dbeafe;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.10),
        0 8px 18px rgba(0,0,0,0.16);
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.help-trigger:hover {
    transform: translateY(-1px);
    background: rgba(59, 130, 246, 0.26);
    border-color: rgba(191, 219, 254, 0.58);
    color: #ffffff;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.14),
        0 10px 22px rgba(37, 99, 235, 0.22);
}

.help-drawer {
    position: fixed;
    inset: 0;
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    max-width: 100vw;

    transition:
        opacity 0.22s ease,
        visibility 0s linear 0.30s;
}

.help-drawer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    transition-delay: 0s;
}

.help-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(480px, calc(100vw - 24px));
    height: 100%;
    box-sizing: border-box;
    padding: 22px;
    overflow-y: auto;
    pointer-events: auto;
    overscroll-behavior: contain;

    background:
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.16), transparent 38%),
        linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
    border-left: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: -24px 0 60px rgba(0,0,0,0.42);

    transform: translateX(calc(100% + 32px));
    transition:
        transform 0.30s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.30s ease;
    will-change: transform;

    color: #e2e8f0;
}

.help-drawer.is-open .help-drawer__panel {
    transform: translateX(0);
}

.help-drawer__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.help-drawer__eyebrow {
    margin-bottom: 6px;
    color: rgba(191, 219, 254, 0.78);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.help-drawer__title {
    margin: 0;
    color: #f8fafc;
    font-size: 24px;
    line-height: 1.2;
    text-shadow: none;
}

.help-drawer__close {
    appearance: none;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: #cbd5e1;
    cursor: pointer;
    transition: 0.18s ease;
}

.help-drawer__close:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(248, 113, 113, 0.34);
    color: #ffffff;
}

.help-drawer__short {
    margin-bottom: 16px;
    padding: 13px 14px;
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(255,255,255,0.035));
    border: 1px solid rgba(96, 165, 250, 0.24);
    color: rgba(226, 232, 240, 0.94);
    font-size: 14px;
    line-height: 1.5;
}

.help-drawer__short.is-hidden {
    display: none;
}

.help-drawer__body {
    font-size: 15px;
    line-height: 1.6;
    color: rgba(226, 232, 240, 0.92);
}

.help-drawer__body h2 {
    margin: 24px 0 12px;
    font-size: 22px;

}

.help-drawer__body h3 {
    margin: 22px 0 10px;
    font-size: 19px;

}

.help-drawer__body h4 {
    margin: 18px 0 8px;
    font-size: 16px;
    font-weight: 800;
    color: rgba(226, 232, 240, 0.96);
}

.help-drawer__body h2 {
    margin: 26px 0 12px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 22px;
    font-weight: 900;
}

.help-drawer__body h2:first-child {
    padding-top: 0;
    border-top: none;
}

.help-drawer__body h3:first-child,
.help-drawer__body h4:first-child {
    margin-top: 0;
}

.help-drawer__body p {
    margin: 0 0 13px;
}

.help-drawer__loading,
.help-drawer__empty {
    padding: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(226, 232, 240, 0.82);
}

.organ-side-card__title-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    margin-left: auto;
}

.organ-side-card__title-actions .organ-share-form {
    margin: 0;
}

@media (max-width: 760px) {
    .organ-side-card__title-row {
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    .organ-side-card__title-actions {
        width: auto;
        justify-content: flex-end;
        margin-left: auto;
    }

    .organ-side-card__title-actions .help-trigger {
        width: 34px;
        min-width: 34px;
    }

    .organ-side-card__title-actions .organ-share-form,
    .organ-side-card__title-actions .consultation-section-share__button {
        width: auto;
    }
}

/* ===== Help markdown marker ===== */

.help-drawer__body .help-marker {
    display: inline;
    padding: 0.03em 0.28em;
    border-radius: 0.35em;
    background:
        linear-gradient(
            90deg,
            rgba(250, 204, 21, 0.26),
            rgba(245, 158, 11, 0.34)
        );
    color: #fff7d6;
    font-weight: 600;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    box-shadow:
        0 0 0 1px rgba(250, 204, 21, 0.10) inset,
        0 0 14px rgba(245, 158, 11, 0.10);
}

@media (prefers-reduced-motion: reduce) {
    .help-drawer,
    .help-drawer__panel {
        transition: none;
    }
}

@media (max-width: 640px) {
    .diagnostic-section-head__actions {
        width: 100%;
        justify-content: flex-start;
    }

    .help-drawer__panel {
        width: 100vw;
        padding: 18px;
    }

    .help-drawer__title {
        font-size: 22px;
    }
}

@media (max-width: 900px) {
    .filters-bars {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
    }

    .filter-bar-card__chart {
        min-width: 0;
    }

    .filter-bar-card__bar {
        width: min(68px, 78%);
    }
}

@media (max-width: 640px) {
    .filters-bars {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px 10px;
    }

    .filter-bar-card__bar {
        width: 100%;
        max-width: 58px;
    }
}

/* Убираем технический горизонтальный overflow в блоке "Реальное / Мнимое" */
.diagnostic-viewer-shell,
.page-shell,
.card,
.filters-layout,
.filters-section,
.filters-bars {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.filters-layout,
.filters-section,
.filters-bars {
    overflow-x: clip;
}

@supports not (overflow: clip) {
    .filters-layout,
    .filters-section,
    .filters-bars {
        overflow-x: hidden;
    }
}

/* ===== Tooltip edge alignment for Qualities / Filters ===== */

/* Левая привязка подсказки */
.filters-bars > .filter-bar-card.is-tooltip-left::after,
.qualities-grid > .quality-card.is-tooltip-left::after,
.qualities-insight__items > .qualities-chip.is-tooltip-left::after {
    left: 0;
    right: auto;
    transform: translateX(0) translateY(4px);
}

.filters-bars > .filter-bar-card.is-tooltip-left::before,
.qualities-grid > .quality-card.is-tooltip-left::before,
.qualities-insight__items > .qualities-chip.is-tooltip-left::before {
    left: 34px;
    right: auto;
    transform: translateX(0) translateY(4px);
}

/* Правая привязка подсказки */
.filters-bars > .filter-bar-card.is-tooltip-right::after,
.qualities-grid > .quality-card.is-tooltip-right::after,
.qualities-insight__items > .qualities-chip.is-tooltip-right::after {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(4px);
}

.filters-bars > .filter-bar-card.is-tooltip-right::before,
.qualities-grid > .quality-card.is-tooltip-right::before,
.qualities-insight__items > .qualities-chip.is-tooltip-right::before {
    left: auto;
    right: 34px;
    transform: translateX(0) translateY(4px);
}

.filters-bars > .filter-bar-card.is-tooltip-left:hover::after,
.filters-bars > .filter-bar-card.is-tooltip-right:hover::after,
.qualities-grid > .quality-card.is-tooltip-left:hover::after,
.qualities-grid > .quality-card.is-tooltip-right:hover::after,
.qualities-insight__items > .qualities-chip.is-tooltip-left:hover::after,
.qualities-insight__items > .qualities-chip.is-tooltip-right:hover::after {
    transform: translateX(0) translateY(0);
}

.filters-bars > .filter-bar-card.is-tooltip-left:hover::before,
.filters-bars > .filter-bar-card.is-tooltip-right:hover::before,
.qualities-grid > .quality-card.is-tooltip-left:hover::before,
.qualities-grid > .quality-card.is-tooltip-right:hover::before,
.qualities-insight__items > .qualities-chip.is-tooltip-left:hover::before,
.qualities-insight__items > .qualities-chip.is-tooltip-right:hover::before {
    transform: translateX(0) translateY(0);
}

/* ===== Real / Imaginary analytical lists ===== */

.filter-insights-panel {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.34), rgba(255,255,255,0.025));
    border: 1px solid rgba(255,255,255,0.08);
}

.filter-insights-panel--consultation {
    margin-top: 16px;
}

.filter-insights-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.filter-insights-column {
    min-width: 0;
    display: grid;
    gap: 10px;
}

.filter-insights-column__title {
    color: #f8fafc;
    font-size: 16px;
    line-height: 1.25;
    padding: 0 2px;
}

.stage-balance-card--filter-over-limit {
    border-color: rgba(249, 115, 22, 0.34);
    background:
        linear-gradient(135deg, rgba(249, 115, 22, 0.13), rgba(255,255,255,0.025));
}

.stage-balance-card--filter-over-limit::before {
    background: rgba(249, 115, 22, 0.92);
}

.stage-balance-card--filter-low-resources {
    border-color: rgba(148, 163, 184, 0.24);
    background:
        linear-gradient(135deg, rgba(148, 163, 184, 0.10), rgba(255,255,255,0.025));
}

.stage-balance-card--filter-low-resources::before {
    background: rgba(148, 163, 184, 0.72);
}

@media (max-width: 760px) {
    .filter-insights-columns {
        grid-template-columns: 1fr;
    }

    .filter-insights-panel {
        padding: 12px;
    }
}

/* ===== Help media inside drawer ===== */

.help-media {
    margin: 18px 0;
}

.help-media__frame {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(96, 165, 250, 0.24);
    background: rgba(10, 16, 25, 0.38);
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.05) inset,
        0 14px 30px rgba(0,0,0,0.18);
}

.help-media__image {
    display: block;
    width: 100%;
    height: auto;
    background: #050812;
}

.help-media__video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #050812;
}

.help-media__caption {
    margin-top: 8px;
    color: rgba(203, 213, 225, 0.82);
    font-size: 13px;
    line-height: 1.45;
}

.help-media-missing {
    margin: 14px 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.24);
    color: #fecaca;
    font-size: 13px;
    line-height: 1.4;
}

.help-media-missing code {
    color: #ffffff;
}
