/* ============================================================
   T-026. ФИНАНСОВЫЙ СЦЕНАРИЙ, ПРЕДЕЛЬНАЯ ЦЕНА, ИСТОЧНИКИ
   Стили блока калькулятора рентабельности: ползунки сценария,
   предельная цена, список источников значений и пометка
   «расчёт предварительный».
   ============================================================ */

/* Полоса сценария, предельная цена и источники занимают всю ширину
   сетки метрик: в колонке 180 px ползунок с подписью не читается. */
.ta-scenario,
.ta-marginal,
.ta-sources {
    grid-column: 1 / -1;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
}

.ta-scenario[hidden],
.ta-marginal[hidden],
.ta-sources[hidden] {
    display: none;
}

/* ---------- Сценарий ---------- */

.ta-scenario-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.ta-scenario-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.ta-scenario-reset {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ta-scenario-reset:hover {
    background: #eef2f7;
    color: #0f172a;
}

.ta-scenario-reset:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.ta-scenario-row {
    display: grid;
    grid-template-columns: 130px minmax(120px, 1fr) 56px;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.ta-scenario-label {
    font-size: 12px;
    color: #475569;
    margin: 0;
}

.ta-scenario-value {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ta-scenario-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.ta-scenario-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
    cursor: pointer;
}

.ta-scenario-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
    cursor: pointer;
}

.ta-scenario-range:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 4px;
}

/* Красная зона: падение цены строго больше 25 % */
.ta-scenario.is-danger .ta-scenario-value {
    color: #dc2626;
}

.ta-scenario.is-danger .ta-scenario-range {
    background: #fecaca;
}

.ta-scenario.is-danger .ta-scenario-range::-webkit-slider-thumb {
    background: #dc2626;
}

.ta-scenario.is-danger .ta-scenario-range::-moz-range-thumb {
    background: #dc2626;
}

.ta-scenario-note {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: #64748b;
}

/* ---------- Предельная цена ---------- */

.ta-marginal-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.ta-marginal-label {
    font-size: 12px;
    color: #64748b;
}

.ta-marginal-value {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

.ta-marginal[data-state="insufficient"] .ta-marginal-value,
.ta-marginal[data-state="not_applicable"] .ta-marginal-value {
    font-size: 14px;
    font-weight: 600;
    color: #b45309;
}

.ta-marginal-note {
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: #64748b;
}

/* ---------- Источники значений ---------- */

.ta-sources-summary {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
}

.ta-sources-summary:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.ta-sources-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ta-source-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(90px, 140px) minmax(140px, auto) 1fr;
    align-items: baseline;
    gap: 10px;
    font-size: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.ta-source-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ta-source-label {
    color: #475569;
    font-weight: 600;
}

.ta-source-value {
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

/* Бейдж источника: цвет кодирует происхождение значения, поэтому
   пользователь видит «норматив» и «техническое допущение» по-разному. */
.ta-source-kind {
    justify-self: start;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.ta-source-kind--profile {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.ta-source-kind--notice {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.ta-source-kind--normative {
    background: #f5f3ff;
    border-color: #ddd6fe;
    color: #6d28d9;
}

.ta-source-kind--region {
    background: #f0fdfa;
    border-color: #99f6e4;
    color: #0f766e;
}

.ta-source-kind--calculation {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #475569;
}

.ta-source-kind--fallback {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}

.ta-source-kind--none {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.ta-source-note {
    color: #64748b;
    line-height: 1.35;
}

/* ---------- Достоверность ---------- */

.ta-reliability {
    margin-bottom: 14px;
    padding: 10px 14px;
    border: 1px solid #fde68a;
    border-left: 3px solid #d97706;
    border-radius: 8px;
    background: #fffbeb;
}

.ta-reliability[hidden] {
    display: none;
}

.ta-reliability-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #b45309;
    font-size: 13px;
    font-weight: 700;
}

.ta-reliability-reasons {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.5;
    color: #78350f;
}

.ta-reliability-reasons li {
    margin-bottom: 2px;
}

/* Пометка на панели: цифры остаются читаемыми, но результат больше не
   выглядит подтверждённым — серая рамка вместо акцентной. */
#tender-financial-model[data-reliability="provisional"] .ta-metrics {
    border-radius: 10px;
}

#tender-financial-model[data-reliability="provisional"] .ta-metric {
    border-style: dashed;
    border-color: #e2e8f0;
    background: #fcfdff;
}

/* ---------- Узкие экраны ---------- */

@media (max-width: 720px) {
    .ta-scenario-row {
        grid-template-columns: 1fr 56px;
        row-gap: 4px;
    }

    .ta-scenario-label {
        grid-column: 1 / -1;
    }

    .ta-source-row {
        grid-template-columns: 1fr auto;
        row-gap: 2px;
    }

    .ta-source-label,
    .ta-source-value {
        grid-column: auto;
    }

    .ta-source-kind {
        grid-column: 2;
        justify-self: end;
    }

    .ta-source-note {
        grid-column: 1 / -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ta-scenario-reset {
        transition: none;
    }
}

/* В печати управление сценарием не нужно, а посчитанное — нужно. */
@media print {
    .ta-scenario {
        display: none;
    }

    .ta-reliability {
        border-color: #cbd5e1;
        background: none;
    }
}
