/* «Бумажные» окна: «Мой счёт», чек баллов, история абонемента, справка о
   баллах. Одна поверхность на весь стек: бумажная карточка на ночной
   подложке. */

    .tx-receipt-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: linear-gradient(180deg, var(--bp-night-scrim-top), var(--bp-night-scrim));
        align-items: center;
        justify-content: center;
        /* Поля с учётом выреза и полосы «домой»: кнопка закрытия не уходит
           под системные панели. */
        padding: max(var(--bp-space-6), var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) var(--bp-space-4)
                 max(var(--bp-space-6), var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    }
    .tx-receipt-overlay.open { display: flex; }
    /* Порядок в стеке задаёт порядок в разметке: счёт, история, чек, справка. */

    .tx-receipt {
        position: relative;
        width: 100%;
        max-width: 380px;
        max-height: 100%;
        display: flex;
        flex-direction: column;
        background: var(--bp-paper);
        color: var(--bp-ink);
        border-radius: var(--bp-radius-lg);
        box-shadow: var(--bp-night-shadow-modal);
        overflow: hidden;
        isolation: isolate;
    }
    /* Окно со списками — постоянной высоты, прокрутка внутри: пока блоки
       загружаются, карточка не растёт ступеньками и не скачет по центру. */
    .tx-receipt--sheet { height: 85vh; height: 85dvh; }
    /* Справка статична: высота по содержимому, не выше окна. */
    .tx-receipt--fit { max-height: 85vh; max-height: 85dvh; }
    .tx-receipt::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        opacity: 0.5;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.09  0 0 0 0 0.094  0 0 0 0 0.102  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>");
        mix-blend-mode: multiply;
    }

    .tx-receipt-close {
        position: absolute;
        top: var(--bp-space-2);
        right: var(--bp-space-2);
        z-index: 2;
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        border: 1px solid var(--bp-line-strong);
        background: var(--bp-paper-2);
        color: var(--bp-ink);
        font-size: var(--bp-fs-h2);
        cursor: pointer;
    }

    /* Заголовок по центру кнопки закрытия: высота строки = её высоте. */
    .tx-receipt-head {
        flex-shrink: 0;
        padding: var(--bp-space-2) calc(44px + var(--bp-space-4)) var(--bp-space-4) var(--bp-space-4);
    }
    .tx-receipt-title {
        display: flex;
        align-items: center;
        min-height: 44px;
        margin: 0;
        font-family: var(--ff-body);
        font-weight: 600;
        font-size: var(--bp-fs-body);
        line-height: 1.2;
        color: var(--bp-ink);
    }
    .tx-receipt-caption {
        margin: 0;
        font-family: var(--ff-body);
        font-size: var(--bp-fs-secondary);
        line-height: 1.4;
        color: var(--bp-ink-soft);
    }

    /* Число-герой окна: баланс баллов. */
    .sheet-hero {
        margin: var(--bp-space-1) 0;
        font-family: var(--ff-display);
        font-weight: 900;
        font-size: var(--bp-fs-display);
        line-height: 1.2;
        font-variant-numeric: tabular-nums;
        color: var(--bp-ink);
    }

    /* Подпись раздела — одна на все окна. */
    .sheet-label {
        margin: 0 0 var(--bp-space-2);
        font-family: var(--ff-mono);
        font-weight: 600;
        font-size: var(--bp-fs-micro);
        line-height: 1.2;
        letter-spacing: .16em;
        text-transform: uppercase; /* caps-gate: подписи чека повторяют вид документа */
        color: var(--bp-ink-soft);
    }

    /* Переход вглубь: строка-ссылка во всю высоту пальца. */
    .sheet-link {
        display: inline-flex;
        align-items: center;
        gap: var(--bp-space-1);
        min-height: 44px;
        padding: 0;
        border: 0;
        background: none;
        font-family: var(--ff-body);
        font-weight: 600;
        font-size: var(--bp-fs-body);
        line-height: 1.2;
        color: var(--bp-blue);
        cursor: pointer;
    }

    /* Отрывная перфорация между шапкой и телом. */
    .tx-receipt-perforation {
        position: relative;
        flex-shrink: 0;
        height: 0;
        border-top: 1px dashed var(--bp-line-strong);
    }
    .tx-receipt-perforation::before,
    .tx-receipt-perforation::after {
        content: "";
        position: absolute;
        top: -10px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: var(--bp-night-scrim);
    }
    .tx-receipt-perforation::before { left: -10px; }
    .tx-receipt-perforation::after  { right: -10px; }

    .tx-receipt-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: var(--bp-space-4);
        background: var(--bp-paper-2);
    }

    .tx-receipt-foot {
        flex-shrink: 0;
        padding: 0 var(--bp-space-4);
        text-align: center;
        border-top: 1px dashed var(--bp-line-strong);
        background: var(--bp-paper-2);
    }

    /* Пустой список и ошибка — высотой одной карточки (см. `.sheet-skel`),
       чтобы на месте каркаса ничего не сдвигалось. */
    .sheet-msg {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: var(--bp-space-2) var(--bp-space-3);
        min-height: 64px;
        text-align: center;
        font-family: var(--ff-body);
        font-size: var(--bp-fs-secondary);
        line-height: 1.4;
        color: var(--bp-ink-soft);
    }
    .sheet-retry {
        min-height: 44px;
        padding: 0 var(--bp-space-4);
        border: 1px solid var(--bp-line-strong);
        border-radius: var(--bp-radius-sm);
        background: var(--bp-paper);
        color: var(--bp-ink);
        font-family: var(--ff-body);
        font-weight: 600;
        font-size: var(--bp-fs-secondary);
        cursor: pointer;
    }

    /* Каркас — плашки высотой строк, которые придут на их место.
       замер: карточка счёта 64 px на 320/390/430 (82 на 320, если название
       в две строки); предложение 118 px на 320/390/430; строка чека с
       подписью о сгорании 82 px на 320/390/430; движение абонемента 59 px
       на 320/390/430. */
    .sheet-skel { display: flex; flex-direction: column; }
    .sheet-skel__item {
        border-bottom: 1px dashed var(--bp-line);
        background: linear-gradient(90deg, var(--bp-paper-2) 25%, var(--bp-line) 37%, var(--bp-paper-2) 63%);
        background-size: 400% 100%;
        animation: sheet-skel-shimmer 1.4s ease infinite;
    }
    .sheet-skel__item:last-child { border-bottom: 0; }
    .sheet-skel--card .sheet-skel__item { height: 64px; }
    .sheet-skel--offer .sheet-skel__item { height: 118px; }
    .sheet-skel--row .sheet-skel__item { height: 82px; }
    .sheet-skel--mv .sheet-skel__item { height: 59px; }
    @keyframes sheet-skel-shimmer {
        0% { background-position: 100% 50%; }
        100% { background-position: 0 50%; }
    }
    @media (prefers-reduced-motion: reduce) {
        .sheet-skel__item { animation: none; }
    }

    /* Ближайшие сгорания — над строками чека, в том же теле. */
    .tx-upcoming {
        margin-bottom: var(--bp-space-4);
        padding-bottom: var(--bp-space-2);
        border-bottom: 1px dashed var(--bp-line-strong);
    }
    .tx-upcoming-row {
        display: flex;
        justify-content: space-between;
        gap: var(--bp-space-3);
        padding: var(--bp-space-3) 0;
        border-bottom: 1px dashed var(--bp-line);
    }
    .tx-upcoming-row:last-child { border-bottom: 0; }
    .tx-upcoming-row .d {
        font-family: var(--ff-body);
        font-size: var(--bp-fs-secondary);
        line-height: 1.4;
        color: var(--bp-ink);
    }
    .tx-upcoming-row .a {
        font-family: var(--ff-mono);
        font-weight: 600;
        font-size: var(--bp-fs-secondary);
        line-height: 1.4;
        font-variant-numeric: tabular-nums;
        color: var(--bp-stamp-red);
        white-space: nowrap;
    }

    /* Страница под открытым окном не прокручивается (стек окон шапки). */
    body.bp-modal-open { overflow: hidden; }
