/* public/css/emitters.css
   Страница /emitters переиспользует .portfolio-builder/.builder-header/
   .filters-card/.primary-row/.field из portfolio-builder.css (загружается
   на каждой странице) — здесь только специфичное для списка эмитентов и
   модалки с подробностями. */

/* Зазор между строкой поиска и пилюлями быстрых фильтров "Все"/"ВДО" (чат
   2026-08-26) - .chip-row без своего margin-top (header.css, общий класс -
   там нет отступа, т.к. на главной он живёт внутри .app-toolbar с иным
   контекстом), пилюли на /emitters липли вплотную к полю поиска.
   Дескрипторный селектор через .emitters-page, а не голый .chip-row -
   тот же класс используют другие страницы с другим окружением. */
.emitters-page #emitters-quick-filters {
    margin-top: 12px;
}

.results-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.results-head h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.results-count {
    font-size: 12.5px;
    color: var(--text-faint);
}

.results-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: auto;
}

table.emitters {
    width: 100%;
    border-collapse: collapse;
}

table.emitters th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

table.emitters th.num,
table.emitters td.num {
    text-align: right;
}

table.emitters td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
    vertical-align: middle;
}

table.emitters tr:last-child td {
    border-bottom: none;
}

tr.emitter-row {
    cursor: pointer;
}

table.emitters tr:hover td {
    background: var(--surface-2);
}

.bond-name-cell {
    font-weight: 600;
    color: var(--text);
}

.bond-sub {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
}

.cell-hint {
    font-size: 11px;
    color: var(--text-faint);
}

/* Пилюли рейтинга и метки-сигналы */
.pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.rating-pill-good { background: var(--good-soft); color: var(--good); }
.rating-pill-mid { background: var(--ok-soft); color: var(--ok); }
.rating-pill-ok { background: var(--ok-soft); color: var(--ok); }
.rating-pill-poor { background: var(--poor-soft); color: var(--poor); }
.rating-pill-none { background: var(--neutral-pill); color: var(--text-faint); font-weight: 600; }

/* ===== Свод "Эмитенты по отраслям" ===== */
.industry-table-wrap { margin-bottom: 18px; }
table.industries { width: 100%; border-collapse: collapse; }
table.industries th {
    text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-faint); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.industries th.num, table.industries td.num { text-align: right; }
table.industries td { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); vertical-align: middle; }
table.industries tr:last-child td { border-bottom: none; }
tr.industry-row { cursor: pointer; }
table.industries tr.industry-row:hover td { background: var(--surface-2); }

.industry-name { font-weight: 600; }
.via-note { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }
.share-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.share-bar { width: 64px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; flex-shrink: 0; }
.share-bar-fill { display: block; height: 100%; background: var(--accent); }
.share-pct { font-family: var(--font-mono), var(--font-mono-fallback); font-size: 11px; color: var(--text-faint); width: 34px; text-align: right; }
.count-num { font-family: var(--font-mono), var(--font-mono-fallback); font-weight: 700; }
table.industries .chevron { color: var(--text-faint); font-size: 12px; width: 16px; }

table.industries .more-row td { text-align: center; color: var(--text-faint); font-size: 12px; cursor: pointer; }
table.industries .more-row:hover td { text-decoration: underline; background: var(--surface-2); }

/* ===== Плитка-итог "Эмитенты по отраслям" (см. чат 2026-08-18) =====
   Десктоп: <summary> сворачиваемого <details class="industries-accordion">
   (.hide-on-mobile/.mobile-only — общие утилиты из bond-diagnostics-shared.css,
   брейкпоинт 768px) — свод раскрывается прямо на месте, поиск и список
   эмитентов остаются видны сразу под плиткой. Мобильный/PWA: та же плитка,
   но <a href="/emitters/industries"> на отдельную страницу — на узком
   экране держать оба контекста (свод + поиск) одновременно неудобно. */
.industries-accordion { margin-bottom: 16px; }
.industries-accordion-body { margin-top: 10px; }

.industries-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 13px 16px;
    box-shadow: var(--shadow);
    list-style: none;
    text-decoration: none;
    color: inherit;
}
.industries-tile::-webkit-details-marker { display: none; }

/* .mobile-only(1 класс) задаёт display:block на ≤768px — двух-классовый
   селектор ниже намеренно перебивает его специфичностью, независимо от
   порядка подключения файлов (emitters.css грузится до
   bond-diagnostics-shared.css в layout.ejs). */
@media (max-width: 768px) {
    a.industries-tile.mobile-only { display: flex; }
}

.industries-tile-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.industries-tile-icon svg { width: 18px; height: 18px; }
.industries-tile-main { flex: 1; min-width: 0; }
.industries-tile-title { display: block; font-weight: 700; font-size: 13.5px; color: var(--text); }
.industries-tile-sub {
    display: block;
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.industries-tile-chevron {
    color: var(--text-faint);
    font-size: 13px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}
details[open] > .industries-tile .industries-tile-chevron { transform: rotate(90deg); }

/* ===== Ссылка "назад" на отдельных страницах-разделах (emitters-industries.ejs) ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 10px;
}
.back-link:hover { text-decoration: underline; }

/* ===== Модалка аналитики по отрасли (#industry-modal) ===== */
.industry-stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.industry-stat-box { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.industry-stat-box .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.industry-stat-box .value { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--text); }

.rating-mix { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-bottom: 6px; background: var(--surface-2); }
.rating-mix span { display: block; height: 100%; }
.rating-mix-good { background: var(--good); }
.rating-mix-ok { background: var(--ok); }
.rating-mix-poor { background: var(--poor); }
.rating-mix-none { background: var(--border-strong); }

.rating-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 10.5px; color: var(--text-muted); margin-bottom: 14px; }
.rating-legend .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.dot-good { background: var(--good); }
.dot-ok { background: var(--ok); }
.dot-poor { background: var(--poor); }
.dot-none { background: var(--border-strong); }

.industry-company-list { display: flex; flex-direction: column; }
.industry-company-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.industry-company-row:last-child { border-bottom: none; }
.industry-company-row:hover { background: var(--surface-2); }
.industry-company-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text); }
.industry-company-name .via { display: block; font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }
.industry-company-name .via b { color: var(--accent); font-weight: 600; }
.industry-company-ytm { font-family: var(--font-mono), var(--font-mono-fallback); font-size: 11.5px; color: var(--text-muted); width: 56px; text-align: right; flex-shrink: 0; }

.tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--ok-soft);
    color: var(--ok);
    margin-right: 4px;
}

.tag-poor {
    background: var(--poor-soft);
    color: var(--poor);
}

.tag-new {
    background: var(--accent-soft);
    color: var(--accent);
}

.tag-link {
    text-decoration: none;
    cursor: pointer;
}

.tag-link:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .results-table-wrap {
        font-size: 12px;
    }
}

/* ===== Денежные обязательства эмитента (emitter-cash-timeline.ejs) ===== */
.cash-timeline-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.cash-stat {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 8px 10px;
    text-align: center;
}

.cash-stat-value {
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.cash-stat-label {
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 2px;
}

.cash-timeline-list {
    display: flex;
    flex-direction: column;
}

.cash-timeline-row {
    display: grid;
    grid-template-columns: 70px 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}

.cash-timeline-row:last-child {
    border-bottom: none;
}

.cash-timeline-date {
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 12px;
}

.cash-timeline-bond a {
    text-decoration: none;
    font-weight: 600;
}

.cash-timeline-bond a:hover {
    text-decoration: underline;
}

.cash-event-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    text-align: center;
}

.cash-event-amort { background: var(--neutral-pill); color: var(--text-muted); }
.cash-event-offer { background: var(--ok-soft); color: var(--ok); }
.cash-event-final { background: var(--accent-soft); color: var(--accent); }

.cash-timeline-amount {
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .cash-timeline-row {
        grid-template-columns: 62px 1fr auto;
        row-gap: 4px;
    }
    .cash-timeline-amount {
        grid-column: 2 / -1;
        text-align: left;
    }
}

/* ===== Новое размещение (emitter-new-placement.ejs) ===== */
.debt-impact {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-strong);
}

.debt-impact-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 12.5px;
    margin-bottom: 6px;
}

.debt-impact-delta {
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--accent);
}

.debt-bar {
    display: flex;
    height: 10px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--neutral-pill);
}

.debt-bar-old { background: var(--border-strong); }
.debt-bar-new { background: var(--accent); min-width: 2px; }

.criticality-block {
    margin-top: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    background: var(--poor-soft);
}

.criticality-lead {
    font-size: 12.5px;
    color: var(--text);
}

.criticality-stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.criticality-stats > div {
    flex: 1;
    min-width: 120px;
}

.criticality-value {
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 17px;
    color: var(--poor);
}

.criticality-label {
    font-size: 10.5px;
    color: var(--text-faint);
}

/* ===== МОБИЛЬНЫЙ ВИД — карточки =====
   Обычная таблица шире экрана и "Сигналы" (переменное число тегов) на
   узком экране просто обрезались бы. Как и в .bonds-table — thead
   прячем, tr становится карточкой: имя+ИНН — шапка, рейтинг — плашка
   в углу, "Выпусков" — подпись+значение, теги сигналов — свободно
   оборачиваются под ними. */
@media (max-width: 640px) {
    .results-table-wrap {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    table.emitters thead {
        display: none;
    }

    table.emitters,
    table.emitters tbody {
        display: block;
        width: 100%;
    }

    table.emitters tr.emitter-row {
        position: relative;
        /* grid, не block (чат 2026-08-26) - "Выпусков" и "Купон" были двумя
           отдельными td, шли одной строкой каждая (заголовок→значение), и
           попросили свести их в одну строку с фиксированным порядком слева
           направо (count/coupon), который не совпадает с порядком колонок
           в DOM (нужным для десктопной <table>, тут не трогаем). Grid-area
           переставляет визуально без переноса DOM - тот же приём, что и в
           board_mobile_grid_alignment_fix (именованные области, а не
           одиночный order, чтобы не словить пресловутый "header без своего
           order" баг из CLAUDE.md). */
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "name name"
            "count coupon"
            "signals signals";
        row-gap: 6px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 20px;
        /* Горизонтальный margin сужен до 3px (чат 2026-08-23, тот же ~2мм
           зазор до края экрана, что и на /board, /favorites, главной и
           шапке — 8px необнулённого body-margin + 3px = 11px≈2мм).
           padding уже был 11px по горизонтали и раньше — не менялся. */
        margin: 8px 0;
        padding: 9px 11px 10px;
        box-shadow: var(--shadow);
    }

    table.emitters tr.emitter-row td {
        display: block;
        width: auto;
        padding: 0;
        border-bottom: none;
        white-space: normal;
    }

    table.emitters tr.emitter-row td:first-child {
        grid-area: name;
        padding-right: 60px;
        padding-bottom: 8px;
        border-bottom: 1px dotted var(--border);
    }

    table.emitters tr.emitter-row td.rating-cell {
        position: absolute;
        top: 9px;
        right: 11px;
    }

    table.emitters tr.emitter-row td.num {
        display: flex;
        align-items: baseline;
        gap: 6px;
        text-align: left;
        font-size: 12.5px;
    }

    table.emitters tr.emitter-row td.num::before {
        content: attr(data-label);
        color: var(--text-faint);
        font-size: 11px;
        font-weight: 500;
    }

    /* "Выпусков" слева, "Купон" справа на одной строке (чат 2026-08-26) -
       [data-label], не nth-of-type, порядок в DOM не трогаем (десктопная
       <table> использует те же td). */
    table.emitters tr.emitter-row td.num[data-label="Выпусков"] {
        grid-area: count;
    }

    /* Цифра купона - жирным (чат 2026-08-26); ::before задаёт свой
       font-weight:500 отдельно, каскад его не перебивает. */
    table.emitters tr.emitter-row td.num[data-label="Купон"] {
        grid-area: coupon;
        justify-content: flex-end;
        font-weight: 700;
    }

    table.emitters tr.emitter-row td.signals-cell {
        grid-area: signals;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    #emitters-search {
        font-size: 16px;
    }
}

/* ===== МОБИЛЬНЫЙ ВИД — "Эмитенты по отраслям" карточками =====
   Как и .results-table-wrap выше, tr.industry-row становится карточкой:
   название отрасли — заголовок, число эмитентов — пилюля в углу (как
   рейтинг на карточке эмитента), доля — бар на всю ширину карточки
   вместо зажатых 64px в табличной колонке. Шеврон скрыт — вся карточка
   и так кликабельна. */
@media (max-width: 640px) {
    table.industries thead {
        display: none;
    }

    table.industries,
    table.industries tbody {
        display: block;
        width: 100%;
    }

    table.industries tr.industry-row {
        position: relative;
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 16px;
        /* Тот же ~2мм зазор/поле, что везде (чат 2026-08-23). Правое поле
           (56px) не трогаем — это не отступ, а место под пилюлю числа
           эмитентов (position:absolute справа сверху), см. правило ниже. */
        margin: 8px 0;
        padding: 12px 56px 12px 11px;
        box-shadow: var(--shadow);
    }

    table.industries tr.industry-row td {
        display: block;
        width: auto;
        padding: 0;
        border-bottom: none;
        white-space: normal;
    }

    table.industries tr.industry-row td.count-num {
        position: absolute;
        top: 12px;
        right: 14px;
        text-align: center;
        background: var(--surface-2);
        border-radius: 999px;
        padding: 2px 9px;
    }

    table.industries tr.industry-row td.num:not(.count-num) {
        margin-top: 10px;
    }

    table.industries tr.industry-row td.num:not(.count-num) .share-cell {
        justify-content: flex-start;
    }

    table.industries tr.industry-row td.num:not(.count-num) .share-bar {
        width: auto;
        flex: 1;
    }

    table.industries tr.industry-row td.chevron {
        display: none;
    }

    table.industries tr.more-row td {
        display: block;
        padding: 11px;
        border-bottom: none;
        background: var(--surface);
        border: 1px dashed var(--border-strong);
        border-radius: 16px;
        margin: 8px 0;
    }
}

/* Внешний зазор карточки поиска/фильтров (.filters-card, портфель-билдер
   sitewide) и самого контейнера страницы — тот же ~2мм на телефоне (чат
   2026-08-23). Дескрипторный селектор .emitters-page .filters-card, а не
   голый .filters-card — тот же класс используют /portfolio-builder и
   /duration-analysis, трогать их не нужно; .emitters-page грузится в
   emitters.css ПОСЛЕ portfolio-builder.css (см. layout.ejs), так что даже
   при равной специфичности этот файл выигрывает каскад без доп. уточнений
   — но descendant-селектор всё равно даёт более высокую специфичность,
   так безопаснее. */
@media (max-width: 640px) {
    .emitters-page {
        padding-left: 3px;
        padding-right: 3px;
    }

    .emitters-page .filters-card {
        padding-left: 11px;
        padding-right: 11px;
    }
}
