html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
}

/* Додав щоб текст на кнопці Додати був зеленим */
a.btn-outline-success {
    color: var(--bs-success) !important;
}

    a.btn-outline-success:hover {
        color: #fff !important;
    }


/* ==========================================
   ControlX: Table toolbar
   ========================================== */

.table-toolbar__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

/* Левая группа */
.table-toolbar__left {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.75rem;
    min-width: 0;
}

/* Правая группа */
.table-toolbar__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

.table-toolbar__status {
    margin: 0;
}

    .table-toolbar__status .form-select {
        width: auto;
        min-width: 124px;
        min-height: 38px;
    }

/* Массовый выбор и счётчики */
.table-toolbar__selection {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-height: 48px;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background: var(--bs-tertiary-bg);
}

    .table-toolbar__selection .btn {
        white-space: nowrap;
    }

.table-toolbar__count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: nowrap;
}

    /* Текст внутри бейджа "Вибрано" */
    .table-toolbar__count .badge {
        font-size: inherit;
        font-weight: 400;
    }


/* ==========================================
   ControlX: Entity data table
   ========================================== */

/* Внешняя рамка */
.entity-data-table-wrapper {
    width: 100%;
    border: 1px solid #e1e5ea;
    border-radius: 0.375rem;
    overflow-x: auto;
    background-color: var(--bs-body-bg);
}

/* Таблица */
.entity-data-table {
    width: 100%;
    margin-bottom: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
    /* Более светлые разделители Bootstrap */
    --bs-table-border-color: #e5e8ed;
}

    /* Строка фильтров */
    /* Фильтры вплотную к внешней рамке */
    .entity-data-table > thead > tr:first-child > th {
        padding: 0.25rem 0.2rem 0.25rem 0;
        vertical-align: bottom;
        border-bottom: 0;
        background-color: var(--bs-body-bg);
    }

    /* Поля фильтров */
    .entity-data-table > thead > tr:first-child .form-control,
    .entity-data-table > thead > tr:first-child .btn {
        border-radius: 0.2rem;
    }

    /* Заголовки столбцов */
    .entity-data-table > thead > tr:nth-child(2) > th {
        padding: 0.7rem 0.5rem;
        vertical-align: middle;
        white-space: nowrap;
        font-weight: 600;
        background-color: var(--bs-tertiary-bg);
        box-shadow: none;
        border-top: 1px solid #e5e8ed;
        border-bottom: 1px solid #dfe3e8;
    }

    /* Поля занимают всю ширину ячеек */
    .entity-data-table > thead > tr:first-child .form-control {
        width: 100%;
        min-width: 0;
    }

    /* Текст кнопки не переносится */
    .entity-data-table > thead > tr:first-child .btn {
        white-space: nowrap;
    }
        /* Заголовки и сортировка */
        .entity-data-table > thead > tr:nth-child(2) > th a {
            color: var(--bs-emphasis-color);
            text-decoration: none;
            white-space: nowrap;
        }

            .entity-data-table > thead > tr:nth-child(2) > th a:hover {
                color: var(--bs-primary);
                text-decoration: underline;
            }

    /* Более лёгкие линии строк */
    .entity-data-table > tbody > tr > td {
        border-bottom: 1px solid #e5e8ed;
    }

    /* Последняя строка: нижнюю границу рисует внешняя рамка */
    .entity-data-table > tbody > tr:last-child > td {
        border-bottom: 0;
    }

/* ==========================================
   ControlX: Responsive TableLayout
   Адаптивність панелі інструментів
   ========================================== */

/* Не дозволяємо flex-елементам розпирати контейнер */
.table-toolbar__bar,
.table-toolbar__left,
.table-toolbar__actions,
.table-toolbar__selection {
    min-width: 0;
}

    /* Прибираємо зайві відступи форм у панелі кнопок */
    .table-toolbar__actions form {
        margin: 0;
    }


/* ==========================================
   Планшети та мобільні пристрої
   ========================================== */

@media (max-width: 991.98px) {

    /* Основна панель */
    .table-toolbar__bar {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Ліва група */
    .table-toolbar__left {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Фільтр статусу */
    .table-toolbar__status {
        width: 100%;
    }

        .table-toolbar__status .form-select {
            width: 100%;
            min-width: 0;
        }

    /* Панель вибору записів */
    .table-toolbar__selection {
        width: 100%;
        min-height: 0;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
    }

        /* Кнопки Вибрати все / Зняти вибір */
        .table-toolbar__selection .btn-group {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            width: 100%;
            gap: 0.4rem;
        }

            .table-toolbar__selection .btn-group > .btn {
                width: 100%;
                margin: 0;
                border-radius: 0.375rem !important;
                white-space: normal;
            }

    /* Лічильники */
    .table-toolbar__count {
        white-space: normal;
    }


    /* ======================================
       Права група — основні кнопки
       ====================================== */

    .table-toolbar__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        margin-left: 0;
        justify-content: stretch;
        gap: 0.5rem;
    }

        /* Елементи всередині панелі */
        .table-toolbar__actions > * {
            width: 100%;
            min-width: 0;
        }

        /* Форми: Export, Delete, Restore тощо */
        .table-toolbar__actions form {
            display: block !important;
            width: 100%;
            margin: 0;
        }

        /* Усі кнопки та посилання */
        .table-toolbar__actions .btn {
            display: block;
            width: 100%;
            max-width: 100%;
            min-width: 0;
            white-space: normal;
        }
}


/* ==========================================
   Дуже вузькі екрани
   ========================================== */

@media (max-width: 420px) {

    /* Основні кнопки розташовуються одна під одною */
    .table-toolbar__actions {
        grid-template-columns: 1fr;
    }

    /* Кнопки масового вибору також одна під одною */
    .table-toolbar__selection .btn-group {
        grid-template-columns: 1fr;
    }
}