/* Контейнер страницы ограничивает все локальные стили коллективного заказа */
.collective-order-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

.collective-order-content [hidden] {
    display: none !important;
}

/* Блок отправки ссылки образует самостоятельный шаг страницы */
.collective-order-content .collective-order-share {
    padding: 20px;
    text-align: center;
}

.collective-order-content .collective-order-share h2,
.collective-order-content .collective-order-tickets h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.25;
}

.collective-order-content .collective-order-share__description {
    max-width: 820px;
    margin: 8px auto 18px;
    color: #555;
    font-size: 16px;
    line-height: 1.45;
}

.collective-order-content .collective-order-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    width: 100%;
}

.collective-order-content .collective-order-head .elem-link,
.collective-order-content .collective-order-head .elem-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 160px;
    padding: 18px;
    border: 1px solid #e7e2dd;
    border-radius: 8px;
    background: #fff;
    text-align: center;
}

.collective-order-content .collective-order-share__label {
    margin-bottom: 6px;
    color: #444;
    font-size: 16px;
}

.collective-order-content .collective-order-share__link {
    display: block;
    max-width: 100%;
    color: #f37334;
    font-size: 20px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.collective-order-content .collective-order-share__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.collective-order-content .collective-order-share__button {
    align-items: center;
    display: inline-flex;
    justify-content: center;
}

.collective-order-content .collective-order-share__status {
    min-height: 18px;
    margin-top: 6px;
    color: #437843;
    font-size: 13px;
}

.collective-order-content .collective-order-share__status.is-error {
    color: #b23b36;
}

.collective-order-content .collective-order-head .elem-qr img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* Форма сохраняет существующий контракт отправки выбранных кодов */
.collective-order-content .collective-order-form {
    height: 0;
    margin: 0;
    overflow: hidden;
}

/* Заголовок выбора объясняет действующее ограничение до взаимодействия */
.collective-order-content .collective-order-tickets {
    padding: 18px 20px 0;
}

/* Последний раздел сохраняет отступ от нижней границы страницы при отсутствии действий */
.collective-order-content .collective-order-tickets--without-actions {
    padding-bottom: 24px;
}

.collective-order-content .collective-order-tickets__heading {
    margin-bottom: 14px;
    text-align: center;
}

.collective-order-content .collective-order-tickets__heading p {
    margin: 6px 0 0;
    color: #666;
    font-size: 14px;
}

.collective-order-content .collective-order-tickets__mobile-selection {
    display: none;
}

/* Единое состояние страницы заменяет противоречивые действия после завершения времени */
.collective-order-content .collective-order-notice {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: 720px;
    margin: 0 auto 16px;
    padding: 14px 18px;
    border: 1px solid #e5c27d;
    border-radius: 8px;
    background: #fff8e8;
    color: #5f4a20;
    text-align: center;
}

.collective-order-content .collective-order-notice:focus {
    outline: 2px solid #f37334;
    outline-offset: 3px;
}

/* Сетка сохраняет одинаковую ширину и высоту карточек на широких экранах */
.collective-order-content .collective-order-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    align-items: stretch;
}

.collective-order-content .collective-order-body-ticket {
    position: relative;
    min-width: 0;
}

.collective-order-content .collective-order-ticket__content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    min-width: 0;
    min-height: 150px;
    height: 100%;
    margin: 0;
    padding: 14px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.35;
    user-select: none;
}

/* Карточка переопределяет общую компактную геометрию checkbox с достаточной специфичностью */
.collective-order-content input.collective-order-ticket__control
    + label.collective-order-ticket__content {
    display: flex;
    min-height: 150px;
    height: 100%;
    padding: 14px;
    background: #fff;
    cursor: pointer;
    touch-action: manipulation;
}

.collective-order-content input.collective-order-ticket__control
    + label.collective-order-ticket__content::before {
    display: none;
}

.collective-order-content .available label.collective-order-ticket__content:hover {
    border-color: #bbb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.collective-order-content .collective-order-ticket__control:checked + label.collective-order-ticket__content,
.collective-order-content .collective-order-body-ticket.active label.collective-order-ticket__content {
    border-color: #f37334;
    box-shadow: none;
}

.collective-order-content .sell .collective-order-ticket__content {
    background: #f0faf0;
}

.collective-order-content .payment .collective-order-ticket__content {
    background: #fff8ed;
}

.collective-order-content .delete .collective-order-ticket__content {
    background: #fff2f1;
}

.collective-order-content .none .collective-order-ticket__content {
    background: #f6f6f6;
}

.collective-order-content.is-expired .available .collective-order-ticket__content {
    cursor: default;
    opacity: 0.65;
}

.collective-order-content .collective-order-ticket__header,
.collective-order-content .collective-order-ticket__footer {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.collective-order-content .collective-order-ticket__number {
    flex: 0 0 auto;
    color: #888;
    font-size: 13px;
}

.collective-order-content .ticket-status {
    min-width: 0;
    text-align: right;
}

.collective-order-content .ticket-status .label {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.collective-order-content .collective-order-ticket__place {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    text-align: center;
}

.collective-order-content .collective-order-ticket__place .ticket-block {
    color: #333;
    font-size: 18px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.collective-order-content .collective-order-ticket__place > span {
    margin-top: 3px;
    color: #555;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.collective-order-content .collective-order-ticket__buyer {
    color: #666;
    font-size: 13px;
    overflow-wrap: anywhere;
    text-align: center;
}

.collective-order-content .collective-order-ticket__price {
    color: #333;
    font-size: 18px;
    font-weight: 500;
    white-space: nowrap;
}

.collective-order-content .collective-order-ticket__selected {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    color: #b94f19;
    font-weight: 600;
    opacity: 0;
    visibility: hidden;
}

.collective-order-content .collective-order-ticket__control:checked
    + .collective-order-ticket__content
    .collective-order-ticket__selected,
.collective-order-content .collective-order-body-ticket.active
    .collective-order-ticket__selected {
    opacity: 1;
    visibility: visible;
}

/* Основные действия сохраняют порядок кнопки и таймера на широком экране */
.collective-order-content .collective-order-footer {
    padding: 20px 10px 10px;
    text-align: center;
}

.collective-order-content .collective-order-selection-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    justify-content: center;
    margin-bottom: 10px;
    color: #555;
    font-size: 16px;
}

/* Количество и итоговая цена сохраняют обычное начертание, а цена выделяется фирменным цветом */
.collective-order-content .collective-order-selection-summary output {
    display: inline;
    padding: 0;
    color: inherit;
    font: inherit;
    font-weight: 400;
}

.collective-order-content .collective-order-selection-summary [data-selected-total] {
    color: #f37334;
    font-weight: 400;
}

.collective-order-content .collective-order-footer [data-purchase-button] {
    min-height: 44px;
    font-size: 1.5em;
}

.collective-order-content .collective-order-footer .elem-timer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    margin: 20px auto 0;
}

.collective-order-content .elem-timer__description {
    color: #5c5c5c;
    font-size: 13px;
}

.collective-order-content .timer,
.collective-order-content [data-timer-output] {
    font-variant-numeric: tabular-nums;
}

.collective-order-content .collective-order-footer .timer {
    color: #f37133;
    font-size: 38px;
    font-weight: 300;
    white-space: nowrap;
}

.collective-order-content .collective-order-footer .collective-order-action-message {
    display: block;
}

.collective-order-content .collective-order-footer .collective-order-action-message:empty {
    display: none;
}

.collective-order-content .collective-order-action-message {
    min-height: 18px;
    margin-top: 5px;
    color: #437843;
    font-size: 13px;
}

.collective-order-content .collective-order-action-message.is-error {
    color: #b23b36;
}

/* Мобильная сводка появляется только на узких экранах */
.collective-order-content .collective-order-mobile-summary {
    display: none;
}

@media (min-width: 768px) {
    /* На широком экране ссылка и QR-код занимают две равные колонки */
    .collective-order-content .collective-order-head {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.999px) {
    /* Общая оболочка не ограничивает закреплённую сводку относительно подвала */
    body > #wrap {
        z-index: auto;
    }

    /* Карточка мероприятия повторяет компактную сетку обычного оформления */
    #collective-order-view .event-head .event-head-in {
        display: grid;
        grid-template-columns: clamp(96px, 28vw, 108px) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        padding: 12px;
    }

    #collective-order-view .event-head .i {
        float: none;
        width: 100%;
        padding-right: 0;
        margin-bottom: 0;
    }

    #collective-order-view .event-head .i img {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto;
        margin: 0;
    }

    #collective-order-view .event-head .c {
        display: contents;
    }

    #collective-order-view .event-head h1 {
        min-width: 0;
        margin: 0;
        font-size: 22px;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }

    #collective-order-view .event-head .quick-tickets-event-location {
        grid-column: 1 / -1;
        min-width: 0;
    }

    #collective-order-view .event-head .event-head-in > .clear {
        display: none;
    }

    .collective-order-content {
        padding-bottom: 12px;
    }

    .collective-order-content.has-mobile-summary {
        padding-bottom: 110px;
        padding-bottom: calc(var(--collective-order-mobile-summary-height, 98px) + 12px);
    }

    .collective-order-content .collective-order-share,
    .collective-order-content .collective-order-tickets {
        padding-right: 12px;
        padding-left: 12px;
    }

    .collective-order-content .collective-order-share h2,
    .collective-order-content .collective-order-tickets h2 {
        font-size: 21px;
    }

    .collective-order-content .collective-order-share__description {
        font-size: 15px;
    }

    .collective-order-content .collective-order-head .elem-link,
    .collective-order-content .collective-order-head .elem-qr {
        min-height: 0;
        padding: 14px;
    }

    .collective-order-content .collective-order-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .collective-order-content .collective-order-ticket__content {
        min-height: 136px;
    }

    .collective-order-content input.collective-order-ticket__control
        + label.collective-order-ticket__content {
        min-height: 136px;
    }

    /* Основные действия скрываются, потому что мобильная сводка остаётся на экране */
    .collective-order-content .collective-order-footer {
        display: none;
    }

    /* Закреплённая сводка повторяет структуру панели обычного оформления */
    .collective-order-content .collective-order-mobile-summary {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1030;
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        margin: 0;
        padding: 10px;
        padding: 10px max(10px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(10px, env(safe-area-inset-left));
        background: rgba(255, 255, 255, 0.97);
        border-top: 1px solid #ddd;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.1);
    }

    .collective-order-content .collective-order-mobile-summary__details {
        display: grid;
        gap: 3px;
        min-width: 0;
        line-height: 1.25;
    }

    .collective-order-content .collective-order-mobile-summary output {
        display: inline;
        padding: 0;
        color: inherit;
        font: inherit;
    }

    .collective-order-content .collective-order-tickets__mobile-selection {
        display: block;
        margin-top: 4px;
        color: #666;
        font-size: 13px;
    }

    /* Счётчик выбранных билетов отображается тем же начертанием, что и окружающий текст */
    .collective-order-content .collective-order-tickets__mobile-selection [data-selected-count] {
        display: inline;
        padding: 0;
        color: inherit;
        font: inherit;
        font-weight: 400;
    }

    .collective-order-content .collective-order-mobile-summary__total {
        display: flex;
        gap: 4px;
        align-items: baseline;
        overflow: hidden;
        color: #666;
        font-size: 16px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .collective-order-content .collective-order-mobile-summary__total > span {
        font-weight: 400;
    }

    .collective-order-content .collective-order-mobile-summary__total output {
        color: var(--quick-tickets-color-brand, #f37334);
        font-weight: 400;
    }

    .collective-order-content .collective-order-mobile-summary__timer {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
        min-width: 0;
    }

    .collective-order-content .collective-order-mobile-summary__time {
        display: inline-flex;
        flex: 0 1 auto;
        flex-wrap: nowrap;
        gap: 4px;
        align-items: baseline;
        min-width: 0;
        color: #666;
        font-size: 14px;
        line-height: 18px;
        white-space: nowrap;
    }

    .collective-order-content .collective-order-mobile-summary__extend {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        max-width: 100%;
        height: auto;
        min-height: 18px;
        padding: 0 5px;
        font-size: 13px;
        line-height: 1;
        white-space: nowrap;
    }

    .collective-order-content .collective-order-mobile-summary__submit {
        min-width: 0;
        max-width: 100%;
        min-height: 44px;
        padding-right: 6px;
        padding-left: 6px;
        white-space: nowrap;
    }

    .collective-order-content .collective-order-mobile-summary__message {
        grid-column: 1 / -1;
        min-height: 0;
        margin: -2px 0 0;
        text-align: center;
    }

    .collective-order-content .collective-order-mobile-summary__message:empty {
        display: none;
    }

    .collective-order-content .collective-order-mobile-summary__expired {
        grid-column: 1 / -1;
        padding: 8px;
        color: #7a3f23;
        font-weight: 600;
        text-align: center;
    }
}

@media (forced-colors: active) {
    /* Нативный checkbox остаётся видимым внутри карточки в системной контрастной палитре */
    .collective-order-content .collective-order-ticket__control {
        position: absolute;
        top: 14px;
        left: 14px;
        z-index: 1;
        width: 18px;
        height: 18px;
        margin: 0;
        overflow: visible;
        clip: auto;
        clip-path: none;
        border: initial;
        accent-color: Highlight;
    }

    /* Заголовок освобождает место для нативного checkbox в контрастном режиме */
    .collective-order-content input.collective-order-ticket__control
        + label.collective-order-ticket__content
        .collective-order-ticket__header {
        padding-left: 24px;
    }

    /* Галочка сохраняет нецветовой признак выбора в режиме высокой контрастности */
    .collective-order-content .collective-order-ticket__control:checked
        + .collective-order-ticket__content {
        outline: 3px solid CanvasText;
    }
}
