/* =============================================
   Тендеры — реестр (/tenders) и карточка (/tenders/{id}).
   А2 (Docs/Plans/План-ТендерыДашборд.html §6): демо-данные, тёмная тема — см. app.css :root.
   ============================================= */

.tnd-period {
    color: var(--fg-2);
    font-size: 13px;
    margin: 2px 0 12px;
}

.tnd-kpis { margin-bottom: 14px; }

.tnd-rate-chosen { color: var(--fg-0); }
.tnd-loss { color: var(--err); font-weight: 500; }

/* А4.1: «выбор не определён» — нейтрально, без оценки куратора (не «лучшая» и не нарушение). */
.st.unk {
    color: var(--fg-1);
    background: transparent;
    border: 1px dashed var(--line-2);
}

.st.unk::before {
    background: transparent;
    border: 1px solid currentColor;
}

/* ── Карточка тендера (/tenders/{id}) ─────────────────────────────── */
/* Компоновка — по макету «Тендерна картка — одна угода»: без ограничения ширины,
   шапка → паттерн → факты → лента котировок → предложения → итог → статус. */

.tnd-detail {
    --tnd-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --tnd-warn-bg: rgba(208, 163, 106, 0.10);
    --tnd-warn-line: rgba(208, 163, 106, 0.35);
    --tnd-ok-bg: rgba(111, 191, 168, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 32px;
}

.tnd-back { margin-bottom: -8px; }

.tnd-mono {
    font-family: var(--tnd-mono);
    font-variant-numeric: tabular-nums;
}

.tnd-ok { color: var(--ok); }
.tnd-err { color: var(--err); }

.tnd-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-3);
}

.tnd-label--ok { color: var(--ok); }
.tnd-label--warn { color: var(--pause); }

.tnd-card {
    background: var(--bg-2);
    border: 1px solid var(--line-0);
    border-radius: var(--r);
    padding: 18px 22px;
}

.tnd-card__head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 14px;
}

.tnd-card__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--fg-0);
}

.tnd-card__hint {
    font-size: 12px;
    color: var(--fg-2);
}

.tnd-card__hint--right { margin-left: auto; }

/* Шапка */

.tnd-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    background: var(--bg-0);
    border: 1px solid var(--line-1);
    border-radius: var(--r);
    padding: 22px 26px;
}

.tnd-hero__main { min-width: 0; }

.tnd-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--fg-2);
}

.tnd-hero__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 6px 0;
}

.tnd-hero__title {
    margin: 0;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--fg-0);
}

.tnd-hero__deal-btn {
    flex-shrink: 0;
}

.tnd-hero__sub {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    font-size: 14px;
    color: var(--fg-1);
}

.tnd-hero__sub b {
    color: var(--fg-0);
    font-weight: 600;
}

.tnd-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.tnd-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--line-2);
    color: var(--fg-2);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.tnd-chip--ok { background: var(--ok); border-color: var(--ok); color: var(--bg-0); }
.tnd-chip--warn { background: var(--pause); border-color: var(--pause); color: var(--bg-0); }
.tnd-chip--err { background: var(--err); border-color: var(--err); color: var(--bg-0); }
.tnd-chip--unk { background: var(--fg-2); border-color: var(--fg-2); color: var(--bg-0); }

.tnd-alert {
    flex: 0 1 460px;
    min-width: 300px;
    background: var(--tnd-warn-bg);
    border: 1px solid var(--tnd-warn-line);
    border-left: 3px solid var(--pause);
    border-radius: 10px;
    padding: 14px 18px;
}

.tnd-alert__title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--pause);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tnd-alert__amount {
    margin-top: 8px;
    font-family: var(--tnd-mono);
    font-variant-numeric: tabular-nums;
    font-size: 26px;
    font-weight: 600;
    color: var(--fg-0);
}

.tnd-alert__approx {
    display: inline-block;
    margin-left: 6px;
    white-space: nowrap;
    font-size: 16px;
    color: var(--fg-1);
}

.tnd-alert__reason {
    margin-top: 6px;
    font-size: 12px;
    color: var(--fg-2);
}

.tnd-alert--unk {
    background: rgba(147, 160, 181, 0.08);
    border-color: var(--line-2);
    border-left-color: var(--fg-2);
}

.tnd-alert--unk .tnd-alert__title { color: var(--fg-1); }

.tnd-alert__text {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--fg-0);
}

/* Паттерн */

.tnd-pattern {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--tnd-warn-bg);
    border: 1px solid rgba(208, 163, 106, 0.24);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--fg-1);
}

.tnd-pattern__icon { flex: none; color: var(--pause); }

.tnd-pattern__label {
    flex: none;
    color: var(--pause);
    font-weight: 600;
}

.tnd-pattern__text { flex: 1 1 auto; min-width: 0; }

.tnd-pattern__link {
    flex: none;
    color: var(--pause);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.tnd-pattern__link:hover { text-decoration: underline; }

/* Факты и проверки */

.tnd-facts { padding: 0; }

/* На широком экране — по содержимому, чтобы значения не переносились (как в макете);
   на узких (media ниже) — равные колонки с переносом. */
.tnd-kpi-row {
    display: grid;
    grid-template-columns: repeat(5, max-content);
    justify-content: space-between;
    gap: 16px 24px;
    padding: 18px 22px;
}

.tnd-kpi__value {
    display: block;
    margin-top: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--fg-0);
}

.tnd-checks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 28px;
    padding: 16px 22px 18px;
    border-top: 1px solid var(--line-0);
}

.tnd-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tnd-check__icon { flex: none; margin-top: 1px; }

.tnd-check--ok .tnd-check__icon,
.tnd-check--ok .tnd-check__title { color: var(--ok); }

.tnd-check--fail .tnd-check__icon,
.tnd-check--fail .tnd-check__title { color: var(--err); }

.tnd-check__title { font-size: 14px; font-weight: 600; }

.tnd-check__detail {
    margin-top: 3px;
    font-size: 12px;
    color: var(--fg-2);
}

/* Лента котировок — шкала окна тендера. Вертикаль (px от верха .tnd-axis):
   подписи скобки и решения 4–20, скобка 24–34, курс 40–60, точка 66–82
   (центр 74 = ось), время и края окна 88–104.
   Ширина = 100% карточки (без горизонтального скролла). Если события скучены
   на краю длинного окна — Razor зумит шкалу на кластер (AxisView).
   Остаточные коллизии курсов — .tnd-axis__pt--stagger; у краёв — near-start/end. */

.tnd-legend {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    font-size: 12px;
    color: var(--fg-1);
}

.tnd-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tnd-dot {
    display: inline-block;
    box-sizing: border-box;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--fg-3);
    background: var(--bg-2);
}

.tnd-dot--best { background: var(--ok); border-color: var(--ok); }
.tnd-dot--chosen { background: var(--pause); border-color: var(--pause); }

.tnd-axis {
    position: relative;
    width: 100%;
    height: 112px;
    margin: 8px 0 0;
    overflow: visible;
}

.tnd-axis__track {
    position: absolute;
    top: 73px;
    height: 0;
    border-top: 2px solid var(--fg-3);
}

.tnd-axis__track--before { left: 0; }

.tnd-axis__track--after {
    right: 0;
    border-top: 2px dashed var(--line-2);
}

.tnd-axis__tick {
    position: absolute;
    top: 66px;
    height: 16px;
    border-left: 2px solid var(--fg-3);
    transform: translateX(-1px);
}

.tnd-axis__edge,
.tnd-axis__time {
    font-family: var(--tnd-mono);
    font-size: 12px;
    color: var(--fg-3);
    white-space: nowrap;
}

.tnd-axis__edge {
    position: absolute;
    top: 88px;
}

.tnd-axis__edge--start {
    left: 0;
    transform: none;
}

.tnd-axis__edge--end {
    right: 0;
    left: auto;
    transform: none;
    text-align: right;
}

.tnd-axis__decision {
    position: absolute;
    top: 8px;
    height: 76px;
    border-left: 2px dashed var(--pause);
    z-index: 4;
}

.tnd-axis__decision span {
    position: absolute;
    top: -4px;
    left: 10px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: var(--pause);
}

/* У правого края — подпись слева от линии, чтобы не вылезала за карточку. */
.tnd-axis__decision--flip span {
    left: auto;
    right: 10px;
    text-align: right;
}

.tnd-axis__bracket {
    position: absolute;
    top: 24px;
    height: 10px;
    border: 2px solid var(--err);
    border-bottom: none;
}

.tnd-axis__bracket span {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 4px);
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: var(--err);
}

.tnd-axis__pt {
    position: absolute;
    top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
    z-index: 1;
}

.tnd-axis__pt--best,
.tnd-axis__pt--chosen { z-index: 2; }

.tnd-axis__pt--near-start .tnd-axis__rate,
.tnd-axis__pt--near-start .tnd-axis__time {
    align-self: flex-start;
    margin-left: 0;
    transform: translateX(4px);
    text-align: left;
}

.tnd-axis__pt--near-end .tnd-axis__rate,
.tnd-axis__pt--near-end .tnd-axis__time {
    align-self: flex-end;
    margin-right: 0;
    transform: translateX(-4px);
    text-align: right;
}

.tnd-axis__rate {
    height: 20px;
    line-height: 20px;
    font-family: var(--tnd-mono);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--fg-2);
    white-space: nowrap;
}

/* Плотный сосед: только курс выше оси, точка и время на месте. */
.tnd-axis__pt--stagger {
    z-index: 3;
}

.tnd-axis__pt--stagger .tnd-axis__rate {
    position: relative;
    top: -22px;
    margin-bottom: -22px;
    padding: 0 3px;
    background: var(--bg-2);
    border-radius: 3px;
}

.tnd-axis__pt .tnd-dot {
    width: 16px;
    height: 16px;
    margin-top: 6px;
}

.tnd-axis__time {
    margin-top: 6px;
    line-height: 16px;
}

.tnd-axis__pt--best .tnd-axis__rate { color: var(--ok); font-weight: 700; }
.tnd-axis__pt--chosen .tnd-axis__rate { color: var(--pause); font-weight: 700; }

.tnd-axis__note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--err);
}

.tnd-axis__crop-note {
    margin-top: 6px;
    font-size: 11px;
    color: var(--fg-3);
}

/* Предложения контрагентов */

.tnd-offers-wrap {
    overflow-x: auto;
    margin: 0 -22px -18px;
}

.tnd-offers {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tnd-offers th {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-1);
    text-align: left;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-3);
}

.tnd-offers td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-0);
    color: var(--fg-1);
    vertical-align: middle;
}

.tnd-offers th:first-child,
.tnd-offers td:first-child { padding-left: 22px; }

.tnd-offers th:last-child,
.tnd-offers td:last-child { padding-right: 22px; }

.tnd-offers tbody tr:last-child td { border-bottom: none; }

/* Всё, кроме первой колонки, — по содержимому и без переноса («16 548» не рвётся);
   свободная ширина уходит контрагенту. */
.tnd-offers th:not(:first-child),
.tnd-offers td:not(:first-child) {
    width: 1%;
    white-space: nowrap;
}

.tnd-offers .num { text-align: right; }

.tnd-offers .src {
    width: 1%;
    text-align: right;
}

.tnd-offers .src .tnd-src-btn {
    color: var(--fg-2);
}

.tnd-offers .src .tnd-src-btn:hover {
    color: var(--accent);
}

.tnd-offer__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg-0);
}

.tnd-offer__meta {
    margin-top: 3px;
    font-size: 12px;
    color: var(--fg-2);
}

.tnd-offer__rate {
    font-family: var(--tnd-mono);
    font-variant-numeric: tabular-nums;
    font-size: 16px;
    font-weight: 700;
    color: var(--fg-0);
}

.tnd-offer--best td { background: var(--tnd-ok-bg); }
.tnd-offer--best .tnd-offer__rate { color: var(--ok); }

.tnd-offer--chosen td { background: var(--tnd-warn-bg); }

/* А3.1: цены без привязки к заявке — приглушены и свёрнуты, в расчёт не входят. */
.tnd-offer--unbound td { color: var(--fg-2); }
.tnd-offer--unbound .tnd-offer__name,
.tnd-offer--unbound .tnd-offer__rate { color: var(--fg-2); }
.tnd-validity--muted { color: var(--fg-2); }

.tnd-offers__more td { padding-top: 8px; padding-bottom: 8px; }

.tnd-more-btn {
    padding: 0;
    border: none;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 12px;
    text-align: left;
    white-space: normal;
    cursor: pointer;
}

.tnd-more-btn:hover { text-decoration: underline; }
.tnd-offer--chosen .tnd-offer__rate,
.tnd-offer--chosen .tnd-offer__meta { color: var(--pause); }

.tnd-offer__diff {
    font-family: var(--tnd-mono);
    white-space: nowrap;
}

.tnd-diff--base { color: var(--ok); font-weight: 700; }

.tnd-diff--loss {
    display: block;
    color: var(--err);
    font-weight: 700;
}

.tnd-diff--sub {
    display: block;
    font-size: 12px;
    color: var(--err);
}

.tnd-validity--warn { color: var(--pause); }

.tnd-validity__detail {
    display: block;
    font-size: 12px;
    color: var(--fg-2);
}

.tnd-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.tnd-tag--best { background: var(--ok); color: var(--bg-0); }
.tnd-tag--chosen { background: var(--pause); color: var(--bg-0); }

/* Итог */

.tnd-summary {
    display: grid;
    grid-template-columns: auto auto minmax(320px, 1fr);
    align-items: center;
    gap: 20px 40px;
}

.tnd-summary__pair {
    display: flex;
    align-items: center;
    gap: 28px;
    padding-right: 40px;
    border-right: 1px solid var(--line-1);
}

.tnd-summary__big {
    margin-top: 6px;
    white-space: nowrap;
    font-size: 26px;
    font-weight: 700;
    color: var(--fg-0);
}

.tnd-summary__sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--fg-2);
}

.tnd-summary__arrow {
    font-size: 20px;
    color: var(--fg-3);
}

.tnd-summary__approx {
    display: inline-block;
    margin-left: 6px;
    white-space: nowrap;
    font-size: 16px;
    font-weight: 600;
}

.tnd-summary__loss {
    justify-self: end;
    width: 100%;
    max-width: 520px;
    background: var(--tnd-warn-bg);
    border: 1px solid var(--tnd-warn-line);
    border-radius: 10px;
    padding: 14px 18px;
}

.tnd-summary__loss--none {
    background: var(--tnd-ok-bg);
    border-color: rgba(111, 191, 168, 0.30);
}

.tnd-summary__prov {
    margin-top: 6px;
    max-width: 320px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--fg-3);
}

.tnd-summary--unk { grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr); }

.tnd-summary--unk .tnd-summary__sub { max-width: 640px; line-height: 1.45; }

.tnd-summary__loss--unk {
    background: rgba(147, 160, 181, 0.08);
    border-color: var(--line-2);
}

/* Статус проверки */

.tnd-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px 20px;
    padding: 14px 22px;
}

.tnd-footer__label {
    flex: none;
    max-width: 90px;
    line-height: 1.35;
}

.tnd-pill {
    flex: none;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.tnd-pill--pending {
    background: rgba(208, 163, 106, 0.14);
    border: 1px solid rgba(208, 163, 106, 0.40);
    color: var(--pause);
}

.tnd-pill--done {
    background: rgba(111, 191, 168, 0.12);
    border: 1px solid rgba(111, 191, 168, 0.35);
    color: var(--ok);
}

.tnd-footer__note {
    flex: 1 1 280px;
    font-size: 12px;
    color: var(--fg-2);
}

.tnd-footer__explain {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px 12px;
}

.tnd-footer__explain-field {
    flex: 1 1 280px;
    min-width: 0;
}

.tnd-footer__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: auto;
}

/* Адаптив */

@media (max-width: 1280px) {
    .tnd-kpi-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-content: stretch;
    }
    .tnd-summary { grid-template-columns: auto 1fr; }
    .tnd-summary__loss {
        grid-column: 1 / -1;
        justify-self: stretch;
        max-width: none;
    }
}

@media (max-width: 900px) {
    .tnd-hero {
        flex-direction: column;
        align-items: stretch;
    }
    .tnd-alert { flex: none; min-width: 0; }
    .tnd-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tnd-checks { grid-template-columns: 1fr; }
    .tnd-legend,
    .tnd-card__hint--right { margin-left: 0; }
    .tnd-summary { grid-template-columns: 1fr; }
    .tnd-summary__pair {
        padding-right: 0;
        border-right: none;
    }
}

@media (max-width: 600px) {
    .tnd-hero__title { font-size: 26px; }
    .tnd-alert__amount,
    .tnd-summary__big { font-size: 22px; }
    .tnd-summary__big { white-space: normal; }
    .tnd-pattern { flex-wrap: wrap; }
    .tnd-footer__actions { margin-left: 0; }
}
