/* =========================================================
   Мобильная админка: строка в один ряд + плюс справа
   Исправляет ситуацию, когда "+" уходит под менеджера.
   Также скрывает значок i в мобильной версии админки.
   ========================================================= */

@media (max-width: 950px) {
    /* В закрытом виде: менеджер | клиент | сумма | направление/тип | + */
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open),
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) {
        display: grid !important;
        grid-template-columns:
            minmax(58px, .72fr)
            minmax(92px, 1.22fr)
            minmax(70px, .78fr)
            minmax(62px, .68fr)
            30px !important;
        align-items: center !important;
        column-gap: 5px !important;
        row-gap: 0 !important;

        padding: 8px 7px !important;
        padding-right: 7px !important;
        min-height: 44px !important;
        overflow: hidden !important;
    }

    /* Все основные поля — компактно, без подписи */
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td.admin-mobile-main-cell,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td.admin-mobile-main-cell {
        display: block !important;
        min-width: 0 !important;
        max-width: 100% !important;

        padding: 0 !important;
        margin: 0 !important;

        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;

        font-size: 11.5px !important;
        line-height: 1.15 !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td.admin-mobile-main-cell::before,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td.admin-mobile-main-cell::before {
        display: none !important;
        content: none !important;
    }

    /* Скрываем подробные поля в закрытом виде */
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td.admin-mobile-detail-cell,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td.admin-mobile-detail-cell {
        display: none !important;
    }

    /* Принудительный порядок в строке */
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Менеджер"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Менеджер"] {
        order: 1 !important;
        font-weight: 900 !important;
        color: #111827 !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Клиент"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Клиент"],
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Имя"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Имя"] {
        order: 2 !important;
        font-weight: 900 !important;
        color: #111827 !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Сумма"],
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Деньги"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Сумма"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Деньги"] {
        order: 3 !important;
        text-align: right !important;
        font-weight: 900 !important;
        color: #111827 !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Направление"],
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Тип"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Направление"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Тип"] {
        order: 4 !important;
        text-align: right !important;
        font-weight: 800 !important;
        color: #374151 !important;
    }

    /* Если нет направления/типа, статус может занять 4-ю колонку */
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Статус"],
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) td[data-label="Статус"] {
        order: 4 !important;
        text-align: right !important;
        font-weight: 800 !important;
        color: #374151 !important;
    }

    /* Кнопка + всегда в правой колонке той же строки */
    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) .admin-mobile-toggle-cell,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) .admin-mobile-toggle-cell {
        order: 5 !important;
        position: static !important;
        display: block !important;
        width: 30px !important;
        min-width: 30px !important;
        padding: 0 !important;
        margin: 0 !important;
        justify-self: end !important;
        align-self: center !important;
        grid-column: auto !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) .admin-mobile-toggle-cell::before,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) .admin-mobile-toggle-cell::before {
        display: none !important;
        content: none !important;
    }

    #adminSection .admin-mobile-toggle-btn,
    #waitingLaunchSection .admin-mobile-toggle-btn {
        width: 28px !important;
        min-width: 28px !important;
        height: 28px !important;
        min-height: 28px !important;
        padding: 0 !important;
        border-radius: 8px !important;
        font-size: 18px !important;
        line-height: 1 !important;
    }

    /* В мобильной админке знак i не нужен */
    #adminSection .client-info-btn,
    #waitingLaunchSection .client-info-btn {
        display: none !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) .client-name-cell,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) .client-name-cell {
        display: block !important;
        max-width: 100% !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    #adminSection tr.admin-mobile-prepared:not(.admin-mobile-open) .client-name-cell span,
    #waitingLaunchSection tr.admin-mobile-prepared:not(.admin-mobile-open) .client-name-cell span {
        display: block !important;
        max-width: 100% !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }

    /* Раскрытая строка остается удобной карточкой */
    #adminSection tr.admin-mobile-prepared.admin-mobile-open,
    #waitingLaunchSection tr.admin-mobile-prepared.admin-mobile-open {
        display: block !important;
        padding: 10px !important;
        padding-right: 52px !important;
        min-height: auto !important;
        overflow: visible !important;
    }

    #adminSection tr.admin-mobile-prepared.admin-mobile-open .admin-mobile-toggle-cell,
    #waitingLaunchSection tr.admin-mobile-prepared.admin-mobile-open .admin-mobile-toggle-cell {
        position: absolute !important;
        top: 10px !important;
        right: 10px !important;
        width: 30px !important;
        display: block !important;
    }

    #adminSection tr.admin-mobile-prepared.admin-mobile-open .admin-mobile-toggle-cell::before,
    #waitingLaunchSection tr.admin-mobile-prepared.admin-mobile-open .admin-mobile-toggle-cell::before {
        display: none !important;
    }

    #adminSection tr.admin-mobile-prepared.admin-mobile-open td,
    #waitingLaunchSection tr.admin-mobile-prepared.admin-mobile-open td {
        display: grid !important;
        grid-template-columns: 92px 1fr !important;
        gap: 8px !important;
        padding: 6px 0 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    #adminSection tr.admin-mobile-prepared.admin-mobile-open td::before,
    #waitingLaunchSection tr.admin-mobile-prepared.admin-mobile-open td::before {
        display: block !important;
        content: attr(data-label) !important;
    }

    /* При раскрытии i тоже не нужен */
    #adminSection tr.admin-mobile-prepared.admin-mobile-open .client-info-btn,
    #waitingLaunchSection tr.admin-mobile-prepared.admin-mobile-open .client-info-btn {
        display: none !important;
    }
}
