/*
 * com_tsj — стили компонента передачи показаний.
 * Все правила ограничены обертками .tsj и .tsj-alert, чтобы не зависеть от шаблона сайта
 * и не влиять на него. Цвет акцента задается в настройках компонента (--tsj-accent).
 */
.tsj,
.tsj-alert,
.tsj-debug {
    --tsj-accent: #16294f;
    --tsj-accent-text: #ffffff;
    --tsj-text: #111827;
    --tsj-muted: #6b7280;
    --tsj-border: #e3e6ea;
    --tsj-surface: #ffffff;
    --tsj-surface-alt: #f6f7f9;
    --tsj-danger: #b42318;
    --tsj-danger-bg: #fef3f2;
    --tsj-warning: #93370d;
    --tsj-warning-bg: #fffaeb;
    --tsj-success: #067647;
    --tsj-success-bg: #ecfdf3;
    --tsj-radius: 8px;
}

.tsj,
.tsj *,
.tsj *::before,
.tsj *::after {
    box-sizing: border-box;
}

/* Компонент не шире 720px и стоит по центру блока шаблона. Шрифт не задается: везде шрифт шаблона сайта */
.tsj {
    max-width: 720px;
    margin: 0 auto 24px;
    color: var(--tsj-text);
    font-size: 16px;
    line-height: 1.5;
}

.tsj .tsj-page-title {
    margin: 0 0 16px;
    padding: 0;
    color: var(--tsj-text);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
    border: 0;
}

.tsj .tsj-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tsj .tsj-icon {
    flex: none;
    width: 16px;
    height: 16px;
}

/* ---------- Шапка: значок, заголовок и подзаголовок ---------- */

.tsj .tsj-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 20px;
}

.tsj .tsj-header__badge {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: var(--tsj-accent);
    background: #dfe3ea;
    border-radius: var(--tsj-radius);
}

.tsj .tsj-header__badge .tsj-icon {
    width: 24px;
    height: 24px;
}

.tsj .tsj-header .tsj-page-title {
    margin: 0;
}

/* ---------- Шаги: лицевой счет → показания → проверка → готово ---------- */

.tsj .tsj-steps {
    display: flex;
    gap: 8px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
}

.tsj .tsj-steps__item {
    flex: 1;
    height: 4px;
    margin: 0;
    padding: 0;
    background: var(--tsj-border);
    border-radius: 2px;
}

.tsj .tsj-steps__item.is-done {
    background: var(--tsj-accent);
}

/* ---------- Карточка формы ---------- */

.tsj .tsj-card {
    margin: 0;
    padding: 32px;
    background: var(--tsj-surface);
    border: 1px solid var(--tsj-border);
    border-radius: 12px;
}

.tsj .tsj-card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 28px;
}

.tsj .tsj-badge {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--tsj-text);
    font-size: 16px;
    font-weight: 600;
    background: var(--tsj-surface-alt);
    border-radius: 50%;
}

.tsj .tsj-badge .tsj-icon {
    width: 20px;
    height: 20px;
}

.tsj .tsj-title {
    margin: 0;
    padding: 0;
    color: var(--tsj-text);
    font-size: 21px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    border: 0;
}

.tsj .tsj-subtitle {
    margin: 2px 0 0;
    color: var(--tsj-muted);
    font-size: 13px;
    line-height: 1.4;
}

.tsj .tsj-label {
    display: block;
    margin: 0 0 8px;
    color: var(--tsj-text);
    font-size: 15px;
    font-weight: 500;
}

.tsj .tsj-input {
    display: block;
    width: 100%;
    max-width: none;
    height: 50px;
    margin: 0;
    padding: 0 16px;
    color: var(--tsj-text);
    font: inherit;
    font-size: 17px;
    background: var(--tsj-surface-alt);
    border: 1px solid var(--tsj-border);
    border-radius: var(--tsj-radius);
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.tsj .tsj-input:focus {
    background: var(--tsj-surface);
    border-color: var(--tsj-accent);
    outline: 1px solid var(--tsj-accent);
    outline-offset: -2px;
}

/* Ошибка лицевого счета: и проверка в браузере, и ответ сервера («счет не найден» и т. п.) */
.tsj .tsj-error {
    margin: 16px 0 0;
    padding: 12px 16px;
    color: var(--tsj-danger);
    font-size: 14px;
    line-height: 1.45;
    background: var(--tsj-danger-bg);
    border: 1px solid #f4c7c3;
    border-radius: var(--tsj-radius);
}

.tsj .tsj-error[hidden] {
    display: none;
}

.tsj .tsj-captcha {
    margin: 20px 0 0;
}

.tsj .tsj-captcha:empty {
    display: none;
}

.tsj .tsj-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    margin: 0;
    padding: 0 24px;
    color: var(--tsj-accent-text);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    text-transform: none;
    text-shadow: none;
    background: var(--tsj-accent);
    background-image: none;
    border: 1px solid var(--tsj-accent);
    border-radius: var(--tsj-radius);
    box-shadow: none;
    cursor: pointer;
}

.tsj .tsj-button--block {
    display: flex;
    width: 100%;
    height: 56px;
    margin-top: 28px;
}

.tsj .tsj-button:hover,
.tsj .tsj-button:focus {
    color: var(--tsj-accent-text);
    text-decoration: none;
    background: var(--tsj-accent);
    filter: brightness(1.2);
}

.tsj .tsj-button:focus-visible {
    outline: 2px solid var(--tsj-accent);
    outline-offset: 2px;
}

.tsj .tsj-button[disabled] {
    cursor: progress;
    opacity: 0.75;
}

.tsj .tsj-button .tsj-icon {
    width: 18px;
    height: 18px;
}

/* Не все показания заполнены: кнопка серая, но нажимается и показывает, что исправить */
.tsj .tsj-button.is-inactive,
.tsj .tsj-button.is-inactive:hover {
    background: #a3a9b3;
    border-color: #a3a9b3;
    filter: none;
}

.tsj .tsj-button.is-loading .tsj-icon {
    display: none;
}

/* Второстепенная кнопка («Скорректировать») */
.tsj .tsj-button--secondary,
.tsj .tsj-button--secondary:hover,
.tsj .tsj-button--secondary:focus {
    color: var(--tsj-text);
    text-decoration: none;
    background: var(--tsj-surface-alt);
    border-color: var(--tsj-border);
    filter: none;
}

.tsj .tsj-button--secondary:hover {
    background: var(--tsj-border);
}

/* Две кнопки в ряд на шаге проверки */
.tsj .tsj-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 28px 0 0;
}

.tsj .tsj-buttons .tsj-button {
    width: 100%;
    height: 56px;
}

/* Индикатор загрузки на кнопке */
.tsj .tsj-button.is-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tsj-spin 0.7s linear infinite;
}

@keyframes tsj-spin {
    to {
        transform: rotate(360deg);
    }
}

.tsj .tsj-note {
    margin: 16px 0 0;
    padding: 14px 16px;
    color: var(--tsj-text);
    font-size: 14px;
    background: var(--tsj-surface-alt);
    border: 1px solid var(--tsj-border);
    border-radius: var(--tsj-radius);
}

.tsj .tsj-note p:last-child {
    margin-bottom: 0;
}

/* ---------- Сообщения ---------- */

.tsj-alert {
    box-sizing: border-box;
    max-width: 720px;
    margin: 0 auto 16px;
    padding: 14px 16px;
    font-size: 15px;
    line-height: 1.5;
    border: 1px solid;
    border-radius: var(--tsj-radius);
}

.tsj-alert a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.tsj-alert--danger {
    color: var(--tsj-danger);
    background: var(--tsj-danger-bg);
    border-color: #fecdca;
}

.tsj-alert--warning {
    color: var(--tsj-warning);
    background: var(--tsj-warning-bg);
    border-color: #fedf89;
}

.tsj-alert--success {
    color: var(--tsj-success);
    background: var(--tsj-success-bg);
    border-color: #abefc6;
}

.tsj-alert--info {
    color: var(--tsj-text);
    background: var(--tsj-surface-alt);
    border-color: var(--tsj-border);
}

/* ---------- Отладка: JSON запросов и ответов API (настройка «Показывать запросы и ответы API») ---------- */

.tsj-debug {
    box-sizing: border-box;
    max-width: 720px;
    margin: 0 auto 16px;
}

.tsj-debug .tsj-debug__call {
    margin: 0 0 8px;
    color: var(--tsj-text);
    background: var(--tsj-surface-alt);
    border: 1px solid var(--tsj-border);
    border-radius: var(--tsj-radius);
}

.tsj-debug .tsj-debug__call summary {
    padding: 10px 14px;
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tsj-debug .tsj-debug__label {
    margin: 0 14px 6px;
    padding: 0;
    color: var(--tsj-muted);
    font-size: 12px;
}

.tsj-debug .tsj-debug__json {
    box-sizing: border-box;
    max-height: 320px;
    margin: 0 14px 12px;
    padding: 10px 12px;
    overflow: auto;
    color: var(--tsj-text);
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre;
    word-break: normal;
    word-wrap: normal;
    background: var(--tsj-surface);
    border: 1px solid var(--tsj-border);
    border-radius: var(--tsj-radius);
}

/* ---------- Лицевой счет над формой показаний ---------- */

.tsj .tsj-account {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 16px;
    padding: 16px 24px;
    background: var(--tsj-surface);
    border: 1px solid var(--tsj-border);
    border-radius: 12px;
}

.tsj .tsj-account__mark {
    flex: none;
    font-size: 18px;
    font-weight: 700;
}

.tsj .tsj-account__body {
    flex: 1;
    min-width: 0;
}

.tsj .tsj-account__label,
.tsj .tsj-account__address {
    display: block;
    color: var(--tsj-muted);
    font-size: 13px;
    line-height: 1.4;
}

.tsj .tsj-account__number {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
}

.tsj .tsj-account__change,
.tsj .tsj-account__change:hover {
    flex: none;
    padding: 8px 0 8px 8px;
    color: var(--tsj-text);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.tsj .tsj-account__change:hover {
    text-decoration: underline;
}

/* ---------- Карточки счетчиков ---------- */

.tsj .tsj-meters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* Цвет карточки зависит от услуги: вода, горячая вода, электроэнергия, тепло */
.tsj .tsj-meter {
    --tsj-kind: var(--tsj-text);
    --tsj-kind-bg: var(--tsj-surface-alt);
    --tsj-kind-border: var(--tsj-border);
    /* Карточки в ряду одной высоты: название и номер сверху, показания и поле прижаты к низу */
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 16px;
    background: var(--tsj-kind-bg);
    border: 1px solid var(--tsj-kind-border);
    border-radius: var(--tsj-radius);
}

.tsj .tsj-meter--cold {
    --tsj-kind: #1d64b8;
    --tsj-kind-bg: #f1f6fd;
    --tsj-kind-border: #c5dbf4;
}

.tsj .tsj-meter--hot {
    --tsj-kind: #b4361e;
    --tsj-kind-bg: #fdf4f2;
    --tsj-kind-border: #f3cdc5;
}

.tsj .tsj-meter--power {
    --tsj-kind: #8a5a00;
    --tsj-kind-bg: #fdf9ec;
    --tsj-kind-border: #ecdca4;
}

.tsj .tsj-meter--heat {
    --tsj-kind: #a14d0c;
    --tsj-kind-bg: #fdf5ec;
    --tsj-kind-border: #f0d3b0;
}

.tsj .tsj-meter__service {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    color: var(--tsj-kind);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

/* Номер прибора, показания и поле прижаты к низу карточки, поэтому в соседних карточках они на одной линии,
   даже если название услуги в одной из них занимает две строки */
.tsj .tsj-meter__number {
    margin: auto 0 12px;
    color: var(--tsj-muted);
    font-size: 13px;
}

/* Номера у прибора нет: к низу прижимаются показания */
.tsj .tsj-meter__service + .tsj-meter__facts {
    margin-top: auto;
}

.tsj .tsj-meter__facts {
    margin: 0 0 14px;
    padding: 0;
    font-size: 14px;
    line-height: 1.5;
}

.tsj .tsj-meter__facts div {
    margin: 0 0 2px;
}

.tsj .tsj-meter__facts dt,
.tsj .tsj-meter__facts dd {
    display: inline;
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
}

.tsj .tsj-meter__facts dt {
    color: var(--tsj-muted);
    font-weight: 400;
}

.tsj .tsj-meter__facts dd {
    color: var(--tsj-text);
    font-weight: 600;
}

.tsj .tsj-meter .tsj-input {
    background: var(--tsj-surface);
}

.tsj .tsj-meter__error {
    margin: 8px 0 0;
    color: var(--tsj-danger);
    font-size: 13px;
    line-height: 1.4;
}

.tsj .tsj-meter__error[hidden] {
    display: none;
}

/* ---------- Шаг 4: показания приняты ---------- */

.tsj .tsj-done {
    text-align: center;
}

.tsj .tsj-done__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 0 20px;
    color: #1d64b8;
    background: #eaf3fd;
    border-radius: 12px;
}

.tsj .tsj-done__icon .tsj-icon {
    width: 28px;
    height: 28px;
}

.tsj .tsj-done .tsj-title {
    margin: 0 0 10px;
    font-size: 24px;
}

.tsj .tsj-done__text {
    max-width: 460px;
    margin: 0 auto;
    color: var(--tsj-muted);
    font-size: 15px;
    line-height: 1.5;
}

.tsj .tsj-done__text strong {
    color: var(--tsj-text);
    font-weight: 600;
}

.tsj .tsj-done .tsj-buttons {
    margin-top: 24px;
}

/* Расход на шаге проверки */
.tsj .tsj-meter__total {
    margin: 0;
    padding: 10px 14px;
    color: var(--tsj-muted);
    font-size: 15px;
    background: var(--tsj-surface);
    border-radius: var(--tsj-radius);
}

.tsj .tsj-meter__total strong {
    color: var(--tsj-text);
    font-weight: 600;
}

/* Правила ввода показаний под карточками */
.tsj .tsj-hint {
    display: flex;
    gap: 10px;
    margin: 20px 0 0;
    padding: 14px 16px;
    color: var(--tsj-muted);
    font-size: 13px;
    line-height: 1.5;
    background: var(--tsj-surface-alt);
    border-radius: var(--tsj-radius);
}

.tsj .tsj-hint .tsj-icon {
    margin-top: 2px;
    color: var(--tsj-text);
}

.tsj .tsj-hint p {
    margin: 0;
}

.tsj .tsj-hint p + p {
    margin-top: 6px;
}

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

@media (max-width: 480px) {
    .tsj .tsj-card {
        padding: 20px 16px;
    }

    .tsj .tsj-account {
        padding: 14px 16px;
    }

    .tsj .tsj-buttons {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 20px;
    }

    .tsj .tsj-card__head {
        margin-bottom: 20px;
    }

    .tsj .tsj-button--block {
        margin-top: 20px;
    }
}
