body { 
    font-family: Arial, sans-serif; 
    background: #f4f4f4; 
    display: flex; 
    justify-content: center; 
    padding: 10px; 
    font-size: 13px;
    margin: 0;
}

/* Карточка справочников: один в один как в настройках */
.card { 
    background: white; 
    padding: 15px; 
    border: 1px solid #ccc;
    width: 100%;          
    max-width: 360px;     
    position: relative;
    padding-top: 60px !important; 
    box-sizing: border-box;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

h2 { 
    margin-top: 0; 
    color: #000; 
    font-size: 15px; 
    text-align: center; 
    border-bottom: 1px solid #ccc; 
    padding-bottom: 5px; 
    margin-bottom: 15px;
}

.cat-control label { 
    display: block;
    margin: 10px 0 3px 0; 
    font-size: 14px; 
    color: #000; 
    font-weight: bold; 
}

.cat-control input[type="text"] { 
    width: 100%; 
    padding: 6px; 
    margin-bottom: 10px; 
    border: 1px solid #999; 
    box-sizing: border-box; 
    font-size: 13px;
    background: #fff;
    height: 32px;
    border-radius: 4px;
}

/* Синхронный sticky-bar */
.sticky-action-bar {
    position: sticky;
    top: -10px;
    left: 0;
    right: 0;
    height: 50px;
    background: #ffffff;
    border-bottom: 1px solid #ccc;
    padding: 6px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    z-index: 10;
    margin-top: -60px; 
    margin-bottom: 15px;
    width: calc(100% + 30px); 
    margin-left: -15px;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45%;
    height: 36px;
    background: #7f8c8d;
    color: white !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-weight: bold;
    font-size: 13px;
    box-sizing: border-box;
}

.save_btn_sticky {
    width: 50% !important;
    height: 36px;
    background: #27ae60 !important;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    box-sizing: border-box;
}

/* КОНТЕЙНЕР ДЛЯ СКРОЛЛА ТАБЛИЦЫ */
.table-container {
    max-height: 420px;          /* Максимальная высота таблицы до появления скролла */
    overflow-y: auto;           /* Включаем вертикальный скролл при переполнении */
    overflow-x: hidden;         /* Запрещаем горизонтальный скролл */
    margin-top: 15px;
    border: 1px solid #ccc;     /* Рамка вокруг прокручиваемой области */
    border-radius: 4px;
    -webkit-overflow-scrolling: touch; /* Плавный скролл на смартфонах */
}

/* Таблица справочников */
.cat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

/* ФИКСИРОВАННАЯ ШАПКА ТАБЛИЦЫ */
.cat-table th {
    background-color: #ebebeb;
    color: #333;
    font-weight: bold;
    padding: 8px;
    border: 1px solid #ccc;
    text-align: left;
    position: sticky;           /* Заголовок липнет к верху контейнера */
    top: 0;
    z-index: 2;                 /* Чтобы текст строк не перекрывал шапку */
}

/* Фикс для углов рамки при sticky позиционировании */
.cat-table th::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    border-bottom: 1px solid #ccc;
}

.cat-table td {
    padding: 6px 8px;
    border: 1px solid #ccc;
    text-align: left;
    background: #fff;
    vertical-align: middle;
}

.cat-name-cell {
    font-weight: bold;
    font-size: 14px;
}

/* Аккуратные цветные бейджи типов */
.badge-type {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
}
.badge-type.type-location { background: #2980b9; } /* Синий для локаций */
.badge-type.type-group { background: #8e44ad; }    /* Фиолетовый для групп */

/* Кнопка удаления */
.btn-del-cat {
    background: #e74c3c;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-del-cat:hover {
    background: #c0392b;
}

/* Кнопка карандаша в таблице */
.btn-edit-cat {
    background: #f39c12; /* Оранжевый цвет для привлечения внимания */
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit-cat:hover {
    background: #e67e22; /* Чуть темнее при наведении мыши */
}

/* Эффект нажатия пальцем для смартфонов */
.btn-edit-cat:active {
    transform: scale(1.15);
}

/* Мягкая подсветка строки, которую мы сейчас редактируем */
.cat-table tbody tr.row-editing-active td {
    background-color: #fdf2e2 !important; /* Легкий бежево-оранжевый оттенок */
    border-top: 1px solid #f39c12;
    border-bottom: 1px solid #f39c12;
}

/* Главный контейнер, который выстраивает текст и овал в одну линию */
.cat-switch-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 5px 0;
    background: #fafafa;
    border-radius: 6px;
    border: 1px dashed #ccc;
}

/* Боковые текстовые подписи */
.switch-label {
    font-size: 13px;
    font-weight: bold;
    color: #7f8c8d;
    transition: color 0.2s ease;
    user-select: none;
}

/* Оболочка самого переключателя */
.cat-switch-wrapper {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Скрываем радио-кнопки, которые теперь лежат прямо в контейнере */
.cat-switch-container input[type="radio"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

/* Наш ОВАЛ (задний фон тумблера) */
.cat-switch-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #bdc3c7;
    border-radius: 30px;
    transition: background-color 0.2s ease;
}

/* Наш КРУЖОК внутри овала */
.cat-switch-slider:before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: #2c3e50;
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ЛОГИКА ДЛЯ ПРАВОГО ПОЛОЖЕНИЯ (Выбрана Группа) */
#type_group:checked ~ .cat-switch-wrapper .cat-switch-slider {
    background-color: #d2b4de; 
}
#type_group:checked ~ .cat-switch-wrapper .cat-switch-slider:before {
    transform: translateX(26px);
    background-color: #8e44ad; 
}

/* ЛОГИКА ДЛЯ ЛЕВОГО ПОЛОЖЕНИЯ (Выбрана Локация) */
#type_location:checked ~ .cat-switch-wrapper .cat-switch-slider {
    background-color: #aed6f1;
}
#type_location:checked ~ .cat-switch-wrapper .cat-switch-slider:before {
    background-color: #2980b9;
}