/* =================== ОСНОВНЫЕ СТИЛИ =================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background: linear-gradient(135deg, #eef5f9 0%, #dfe9f2 100%);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #326273, #5C9EAD, #326273);
    z-index: 1000;
}

/* ОСНОВНОЙ КОНТЕЙНЕР ПРИЛОЖЕНИЯ */
.desktop-app {
    width: 98vw;
    height: 98vh;
    background: white;
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* =================== ШАПКА =================== */
.app-header {
    background: #2c3e50; /* Темно-синий, но не черный */
    color: white;
    padding: 0 30px;
    font-size: 16px;
    font-weight: 400;
    height: 60px;
    display: flex;
    align-items: center;
    position: absolute;
    left: 320px;
    right: 0;
    top: 0;
    z-index: 11;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #1e2b37;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

/* Скрываем гамбургер на десктопе */
.mobile-menu-btn {
    display: none;
}

/* Левая часть с логотипом и названием (скрываем на десктопе) */
.header-left {
    display: none;
}

/* Навигация на десктопе */
.header-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    flex: 1;
    margin: 0 20px;
}

.header-nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    padding: 5px 0;
    position: relative;
}

.header-nav a:hover {
    color: white;
}

.header-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #5C9EAD;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.header-nav a:hover::after {
    transform: scaleX(1);
}

/* Кнопки аутентификации */
.header-auth-buttons {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: 38px;
}

.login-btn {
    background: #28a745; /* Зеленый */
    color: white;
}

.login-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

.logout-btn {
    background: #326273; /* Цвет приложения */
    color: white;
}

.logout-btn:hover {
    background: #2a5465;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(50, 98, 115, 0.3);
}

.auth-btn i {
    font-size: 14px;
}

/* ===== ВЫПАДАЮЩЕЕ МЕНЮ "УСЛУГИ" ===== */
.header-nav .nav-link-home {
    font-weight: 600;
}

.header-nav .dropdown {
    position: relative;
}

.header-nav .dropdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 5px 0;
    transition: color 0.3s ease;
}

.header-nav .dropdown-toggle:hover {
    color: white;
}

.header-nav .dropdown-toggle i {
    font-size: 11px;
    transition: transform 0.3s ease;
}

.header-nav .dropdown:hover .dropdown-toggle i {
    transform: rotate(180deg);
}

.header-nav .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%; /* Убираем отступ, чтобы не было разрыва */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    min-width: 240px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 8px 0;
    list-style: none;
    z-index: 10000;
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Добавляем небольшой "мостик", чтобы курсор не "падал" */
    padding-top: 4px;
    margin-top: -4px;
}

/* Добавляем прозрачную область-мостик между пунктом и списком */
.header-nav .dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 14px;
    background: transparent;
}

.header-nav .dropdown:hover .dropdown-menu {
    display: block;
    animation: dropdownFade 0.25s ease;
}

.header-nav .dropdown-menu li {
    margin: 0;
    padding: 0;
}

.header-nav .dropdown-menu li a {
    display: block;
    padding: 10px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 0;
}

.header-nav .dropdown-menu li a:hover {
    background: #f0f4ff;
    color: #326273;
}

.header-nav .dropdown-menu li:first-child a {
    border-radius: 12px 12px 0 0;
}

.header-nav .dropdown-menu li:last-child a {
    border-radius: 0 0 12px 12px;
}

@keyframes dropdownFade {
    0% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 768px) {
    .header-nav .dropdown {
        width: 100%;
        position: relative;
    }
    
    .header-nav .dropdown-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 15px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        color: white;
    }
    
    .header-nav .dropdown-toggle:hover {
        color: white;
    }
    
    .header-nav .dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        background: rgba(255, 255, 255, 0.05);
        margin: 0;
        padding: 5px 0;
        border: none;
        min-width: 100%;
        width: 100%;
    }
    
    .header-nav .dropdown-menu::before {
        display: none;
    }
    
    .header-nav .dropdown.open .dropdown-menu {
        display: block;
    }
    
    .header-nav .dropdown.open .dropdown-toggle i {
        transform: rotate(180deg);
    }
    
    .header-nav .dropdown-menu li a {
        padding: 12px 20px 12px 40px !important;
        color: rgba(255, 255, 255, 0.85) !important;
        font-size: 14px;
        border-radius: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .header-nav .dropdown-menu li a:hover {
        background: rgba(255, 255, 255, 0.1) !important;
        color: white !important;
    }
    
    .header-nav .dropdown-menu li:first-child a,
    .header-nav .dropdown-menu li:last-child a {
        border-radius: 0 !important;
    }
}

/* =================== ОСНОВНОЕ ТЕЛО =================== */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f9fbfd;
    min-height: 0;
}

/* =================== ЛЕВАЯ ПАНЕЛЬ =================== */
.left-panel {
    width: 320px;
    background: linear-gradient(180deg, #1a2b3c 0%, #243b53 100%);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

/* Стили для прокрутки левой панели */
.left-panel::-webkit-scrollbar {
    width: 6px;
}

.left-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.left-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #5C9EAD, #326273);
    border-radius: 3px;
}

.left-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #4a8a9a, #2a5465);
}

/* Блоки в левой панели */
.left-panel > div {
    padding: 15px 20px;
    position: relative;
}

/* ТОНКИЕ РАЗДЕЛИТЕЛЬНЫЕ ЛИНИИ */
.divider-line {
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(92, 158, 173, 0.15), 
        transparent);
    margin: 10px 20px;
}

/* 1. БЛОК ЛОГОТИПА */
.logo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
    margin: 2px 0;
}

.app-logo {
    margin: 2px 0;
}

.app-logo-img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    border-radius: 10px;
}

.app-title-block {
    margin: 2px 0;
}

.app-title-block h1 {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    text-align: center;
    width: 100%;
}

.app-title-block p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-weight: 400;
    margin-top: 3px;
    text-align: center;
}

/* 2. БЛОК ОСНОВНЫХ ДЕЙСТВИЙ */
.main-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 20px !important;
}

.action-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.action-btn:hover {
    background: rgba(92, 158, 173, 0.2);
    border-color: rgba(92, 158, 173, 0.4);
    color: white;
}

.action-btn i {
    font-size: 15px;
    color: #3a7184;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.action-btn.active {
    background: rgba(92, 158, 173, 0.15);
    border-color: rgba(92, 158, 173, 0.5);
    color: white;
}

.action-btn.active i {
    color: white;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
}

/* ПОДСКАЗКИ В ЛЕВОЙ ПАНЕЛИ - ТОЛЬКО НА ЗНАК ВОПРОСА */
.left-panel .tooltip-left-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    border-radius: 50%;
    background: #5C9EAD; /* Светлее для заметности */
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.left-panel .tooltip-left-icon:hover {
    background: #326273;
    transform: scale(1.05);
}

.left-panel .tooltip-left-text {
    position: fixed;
    left: 340px;
    top: 50%;
    transform: translateY(-50%);
    background: #2c3e50;
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    white-space: normal;
    width: 280px;
    z-index: 999999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
    display: none;
    margin-left: 0;
    pointer-events: none;
}

.left-panel .tooltip-left-text::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #2c3e50;
}

/* Показываем подсказку ТОЛЬКО при наведении на знак вопроса */
.left-panel .tooltip-left-icon:hover + .tooltip-left-text {
    display: block;
}

/* Убираем показ подсказки при наведении на кнопку */
.action-wrapper:hover .tooltip-left-text {
    display: none;
}

/* 3. БЛОК ОРГАНИЗАЦИИ */
.organization-block {
    padding: 12px 20px !important;
}

.org-name {
    color: #5C9EAD;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.4;
    padding: 8px 10px;
    background: rgba(92, 158, 173, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(92, 158, 173, 0.2);
    text-align: center;
}

.info-card {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.info-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-label {
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    font-weight: 400;
    flex: 0 0 40px;
}

.info-value {
    color: white;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
    flex: 1;
    padding-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* СТИЛИ БЕЙДЖЕЙ ТАРИФОВ */
.badge-test,
.badge-base,
.badge-prof {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    min-width: 60px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-test {
    background: #ffc107;
    color: #212529;
}

.badge-base {
    background: #326273;
    color: white;
}

.badge-prof {
    background: #198754;
    color: white;
}

/* 4. БЛОК СТАТИСТИКИ */
.stats-block {
    padding: 12px 20px !important;
}

.block-title {
    color: #5C9EAD;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    padding: 6px 10px;
    background: rgba(92, 158, 173, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(92, 158, 173, 0.2);
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    border: 1px solid rgba(92, 158, 173, 0.2);
    transition: all 0.2s ease;
}

.stat-item:hover {
    border-color: rgba(92, 158, 173, 0.4);
    background: rgba(0, 0, 0, 0.2);
}

.stat-label {
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    font-weight: 400;
}

.stat-value {
    color: white;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 35px;
    text-align: center;
}

/* 5. ИНФОРМАЦИЯ */
.info-block {
    padding: 12px 20px !important;
    margin-top: auto;
}

.info-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.info-btn:hover {
    background: rgba(92, 158, 173, 0.15);
    border-color: rgba(92, 158, 173, 0.3);
    color: white;
}

.info-btn i {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* =================== ОСНОВНОЕ СОДЕРЖИМОЕ =================== */
.main-content {
    position: absolute;
    left: 320px;
    right: 0;
    top: 60px;
    bottom: 0;
    padding: 25px;
    overflow-y: auto;
    background: #f9fbfd;
}

/* Полоса прокрутки для основного содержимого */
.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #5C9EAD, #326273);
    border-radius: 4px;
    border: 2px solid #f1f5f9;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #4a8a9a, #2a5465);
}

/* ВЕРХНИЙ КОНТЕЙНЕР ФРЕЙМОВ */
.frames-container {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
    min-height: 200px;
    height: auto;
    flex-wrap: wrap;
    padding-top: 17px;
}

/* ОСНОВНЫЕ ФРЕЙМЫ */
.frame {
    background: white;
    border-radius: 14px;
    border: 1px solid #e8edf3;
    display: flex;
    flex-direction: column;
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    position: relative;
    overflow: hidden;
    flex: 1;
    min-width: 300px;
    margin-bottom: 25px;
    transition: all 0.3s ease;
    height: auto;
}

.frame-waiting,
.frame-registry {
    min-height: 160px;
    margin-bottom: 20px;
}

.frame-protocol {
    min-height: 280px;
}

.frame:hover {
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(92, 158, 173, 0.2) inset;
}

.frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.frame-waiting::before {
    background: linear-gradient(90deg, #326273, #5C9EAD, #326273);
}

.frame-registry::before {
    background: linear-gradient(90deg, #2c3e50, #3a556e, #2c3e50);
}

.frame-protocol::before {
    background: linear-gradient(90deg, #3a7184, #326273, #3a7184);
}

.frame-header {
    color: white;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center; /* Текст по центру */
    gap: 8px;
    position: relative;
    min-height: 55px;
}

.frame-waiting .frame-header {
    background: #3a7184; /* Без градиента */
    color: white;
}

.frame-registry .frame-header {
    background: #3a7184; /* Без градиента */
    color: white;
}

.frame-protocol .frame-header {
    background: #3a7184; /* Без градиента */
    color: white;
}

.frame-header i:first-child {
    font-size: 18px;
    flex-shrink: 0;
}

.frame-header span:first-of-type {
    text-align: center;
}

.frame-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    height: auto;
}

.frame-protocol .frame-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* КНОПКИ В ФРЕЙМАХ */
.frame-content .frame-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    color: #2c3e50;
    border: 2px solid #d8e4f0;
    padding: 14px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 50px;
    min-width: 240px;
    width: 100%;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

.frame-content .frame-btn:first-child {
    margin-bottom: 15px;
}

.frame-btn:hover {
    background: linear-gradient(135deg, #5C9EAD 0%, #4a8a9a 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(92, 158, 173, 0.3);
}

.frame-btn i {
    margin-right: 10px;
    font-size: 15px;
}

/* ПОДСКАЗКИ ВО ФРЕЙМАХ (ДЕСКТОП) */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5C9EAD;
    color: white;
    font-size: 12px;
    font-weight: bold;
    margin-left: 4px;
    cursor: help;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(92, 158, 173, 0.3);
    position: relative;
    z-index: 10;
}

.tooltip-icon:hover {
    background: #326273;
    transform: scale(1.1);
}

.tooltip-text {
    position: fixed;
    background: #2c3e50;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    white-space: normal;
    width: 280px;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
    font-weight: normal;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
}

.tooltip-icon:hover + .tooltip-text,
.tooltip-text:hover {
    visibility: visible;
    opacity: 1;
}

/* СЕКЦИЯ ИСТОЧНИКА ДАННЫХ ДЛЯ ПРОТОКОЛА */
.data-source-section {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.data-source-title {
    color: #2c3e50;
    font-size: 14px;
    text-align: center;
    padding: 10px 15px;
    background: transparent;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(0,0,0,0.05); /* Тонкая линия снизу */
}

/* Кнопки источников данных */
.source-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
    padding: 0 20px;
}

.source-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    color: #2c3e50;
    border: 2px solid #d8e4f0;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 55px; /* фиксированная высота */
    max-height: 55px; /* ограничение максимальной высоты */
    min-height: 45px; /* минимальная высота */
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
    gap: 5px;
    text-align: center;
    flex: 0 1 280px;
    min-width: 250px;
    max-width: 320px;
    overflow: hidden; /* скрываем лишнее содержимое */
}

.source-btn-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.source-btn-icon i {
    font-size: 14px;
}

.source-btn-text {
    flex: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.source-btn-text span {
    margin: 0;
    padding: 0;
    text-align: center;
    width: 100%;
}

.source-btn:hover {
    background: linear-gradient(135deg, #5C9EAD 0%, #4a8a9a 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 5px 15px rgba(92, 158, 173, 0.25);
}

/* Настройки протокола */
.protocol-settings {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    border-radius: 8px;
    padding: 12px 15px;
    border: 1px solid #e8edf3;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
    margin-top: 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: white;
    border: 1px solid #e8edf3;
    flex: 1;
    min-width: 240px;
    margin-bottom: 0;
}

.checkbox-group:hover {
    background: rgba(92, 158, 173, 0.08);
    border-color: rgba(92, 158, 173, 0.4);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #2c3e50;
    font-size: 13px;
    font-weight: 500;
    position: relative;
    white-space: nowrap;
    width: 100%;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e0;
    border-radius: 4px;
    margin-right: 10px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    background: white;
    appearance: none;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
    background: #5C9EAD;
    border-color: #5C9EAD;
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* =================== КОМПАКТНЫЕ ШАБЛОНЫ EXCEL С КНОПКОЙ СПРАВА =================== */
.template-section {
    margin-top: 0;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8edf3;
    position: relative;
    overflow: visible;
    height: fit-content;
}

.template-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #5C9EAD, #326273, #5C9EAD);
}

.template-section h3 {
    color: #326273;
    margin-bottom: 20px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.template-section h3 i {
    color: #5C9EAD;
    font-size: 18px;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.template-card {
    background: white;
    border: 1px solid #e8edf3;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    height: fit-content;
    min-height: 90px;
}

.template-card:hover {
    border-color: #5C9EAD;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #5C9EAD, #326273);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.template-card:hover::before {
    opacity: 1;
}

.template-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.template-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #5C9EAD 0%, #326273 100%);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.template-info {
    flex: 1;
    min-width: 0;
    padding-right: 10px;
}

.template-info h4 {
    color: #2c3e50;
    margin: 0 0 3px 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-info p {
    color: #718096;
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-wrap: break-word;
    max-height: 2.8em;
}

/* КНОПКА СКАЧАТЬ */
.download-btn {
    background: linear-gradient(135deg, #217346 0%, #1a5c38 100%);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(33, 115, 70, 0.2);
    border: none;
    cursor: pointer;
    width: auto;
    min-width: 80px;
    flex-shrink: 0;
    white-space: nowrap;
}

.download-btn:hover {
    background: linear-gradient(135deg, #1a5c38 0%, #14482d 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(33, 115, 70, 0.3);
    text-decoration: none;
}

.download-btn i {
    font-size: 12px;
}

/* =================== ССЫЛКА НА МИНТРУД =================== */
.mintrud-link {
    margin-top: 20px;
    text-align: center;
    padding-top: 12px;
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.mintrud-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(to right, 
        transparent, 
        rgba(92, 158, 173, 0.2), 
        transparent);
}

.mintrud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    color: #326273 !important;
    border: 2px solid #326273 !important;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(50, 98, 115, 0.1);
    position: relative;
    overflow: hidden;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    gap: 10px;
}

.mintrud-btn:hover {
    background: rgba(50, 98, 115, 0.05) !important;
    color: #2a5465 !important;
    border-color: #2a5465 !important;
    box-shadow: 0 4px 15px rgba(50, 98, 115, 0.15);
    transform: translateY(-1px);
}

.mintrud-btn i {
    font-size: 14px;
    color: #326273;
}

.mintrud-btn:hover i {
    color: #2a5465;
}

/* =================== КНОПКА ВЫХОДА =================== */
.logout-section {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.logout-btn {
    background: #326273 100%;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(92, 158, 173, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.logout-btn:hover {
    background: #2a5465;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(50, 98, 115, 0.3);
}

/* =================== МОДАЛЬНЫЕ ОКНА =================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 25px;
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid #e8edf3;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.modal-header h3 {
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #718096;
    transition: color 0.2s ease;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.modal-body {
    color: #4a5568;
    line-height: 1.5;
    font-size: 13px;
}

.modal-body p {
    margin-bottom: 10px;
}

.modal-body hr {
    border: none;
    border-top: 1px solid #e8edf3;
    margin: 15px 0;
}

/* МОДАЛЬНОЕ ОКНО ДЛЯ НЕАВТОРИЗОВАННЫХ */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.auth-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.auth-modal-dialog {
    position: relative;
    width: 90%;
    max-width: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
}

.auth-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.auth-modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s;
}

.auth-modal-close:hover {
    color: #343a40;
}

.auth-modal-body {
    padding: 20px;
}

.auth-modal-footer {
    padding: 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.auth-modal-cancel,
.auth-modal-login {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-modal-cancel {
    background: #6c757d;
    color: white;
}

.auth-modal-cancel:hover {
    background: #5a6268;
}

.auth-modal-login {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.auth-modal-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =================== МОДАЛЬНОЕ ОКНО XML =================== */
.xml-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

.xml-modal[style*="display: flex"] {
    display: flex;
}

.xml-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1;
}

.xml-modal-dialog {
    position: relative;
    width: 700px;
    max-width: 90vw;
    max-height: 80vh;
    z-index: 2;
    margin: 0 auto;
    animation: xmlModalSlideIn 0.3s ease;
}

@keyframes xmlModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xml-modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 2px solid #e9ecef;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
    width: 100%;
}

.xml-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 2px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
    height: 65px;
}

.xml-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.xml-modal-title i {
    color: #326273;
    font-size: 18px;
}

.xml-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.xml-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.xml-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: white;
    max-height: calc(80vh - 130px);
}

.xml-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 18px 24px;
    border-top: 2px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
    gap: 14px;
    flex-shrink: 0;
    height: 75px;
}

/* Область перетаскивания XML */
.xml-drop-zone {
    background: rgba(76, 175, 80, 0.08);
    border: 3px dashed #4CAF50;
    border-radius: 12px;
    padding: 25px 20px;
    transition: all 0.2s ease;
    text-align: center;
    cursor: pointer;
    margin-bottom: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xml-drop-zone:hover {
    background: rgba(76, 175, 80, 0.12);
    border-color: #45a049;
}

.xml-drop-zone.dragover {
    background: rgba(76, 175, 80, 0.18);
    border-color: #3d8b40;
    border-style: solid;
}

.xml-drop-zone-content i {
    color: #4CAF50;
    font-size: 36px;
    margin-bottom: 12px;
    display: block;
}

.xml-drop-zone-content h6 {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 6px;
}

.xml-drop-zone-content p {
    color: #64748b;
    margin-bottom: 16px;
    font-size: 13px;
}

.xml-select-files-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 9px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 140px;
    height: 38px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.xml-select-files-btn:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.3);
}

.xml-select-files-btn i {
    font-size: 14px;
    color: white;
}

.xml-hidden-input {
    display: none;
}

.xml-file-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 2px solid #e8edf3;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    height: 56px;
}

.xml-counter-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
}

.xml-counter-content i {
    color: #198754;
    font-size: 16px;
}

#fileCountBadge {
    background: none;
    color: #198754;
    padding: 0;
    border-radius: 0;
    font-size: 14px;
    font-weight: 700;
    min-width: auto;
    text-align: center;
    margin-left: 5px;
    box-shadow: none;
}

.xml-clear-all-btn {
    background: transparent;
    border: 2px solid #ef4444;
    color: #ef4444;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    height: 34px;
}

.xml-clear-all-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.xml-clear-all-btn.hidden {
    display: none;
}

.xml-file-list {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px;
    border: 2px solid #e8edf3;
    margin-bottom: 24px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.xml-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #e8edf3;
    border-radius: 8px;
    transition: all 0.2s ease;
    height: 44px;
}

.xml-file-item:hover {
    background: #f8fafc;
    border-color: #d8e4f0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.xml-file-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 8px;
}

.xml-file-info i {
    color: #198754;
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
}

.xml-file-details {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.xml-file-name {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 480px;
}

.xml-remove-file-btn {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.xml-remove-file-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 3px 8px rgba(239, 68, 68, 0.2);
}

.xml-loading-indicator {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px solid #e8edf3;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    height: 60px;
}

.xml-loading-indicator.hidden {
    display: none;
}

.xml-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(50, 98, 115, 0.2);
    border-top-color: #326273;
    border-radius: 50%;
    animation: xmlSpinner 1s linear infinite;
}

@keyframes xmlSpinner {
    to {
        transform: rotate(360deg);
    }
}

.xml-loading-indicator span {
    font-size: 15px;
    font-weight: 600;
    color: #326273;
}

.xml-error-message {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(220, 38, 38, 0.05));
    border-left: 4px solid #ef4444;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.1);
    height: auto;
    min-height: 70px;
}

.xml-error-message.hidden {
    display: none;
}

.xml-error-content {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.xml-error-content i {
    color: #ef4444;
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.xml-error-content h6 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #b91c1c;
}

#xmlErrorContent {
    font-size: 13px;
    line-height: 1.4;
    color: #b91c1c;
}

.xml-cancel-btn {
    background: transparent;
    border: 2px solid #64748b;
    color: #64748b;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 120px;
    height: 42px;
}

.xml-cancel-btn:hover {
    background: #64748b;
    color: white;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.2);
}

.xml-process-btn {
    background: linear-gradient(135deg, #326273, #5C9EAD);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 140px;
    height: 42px;
    box-shadow: 0 4px 12px rgba(50, 98, 115, 0.2);
}

.xml-process-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2a5465, #4a8a9a);
    box-shadow: 0 6px 16px rgba(50, 98, 115, 0.3);
}

.xml-process-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

/* =================== МОДАЛЬНОЕ ОКНО РЕЕСТРА =================== */
.registry-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.registry-modal[style*="display: flex"] {
    display: flex;
}

.registry-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1;
}

.registry-modal-dialog {
    position: relative;
    width: 700px;
    max-width: 90vw;
    max-height: 80vh;
    z-index: 2;
    margin: 0 auto;
    animation: registryModalSlideIn 0.3s ease;
}

@keyframes registryModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.registry-modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 2px solid #e9ecef;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
    width: 100%;
}

.registry-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 2px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
    height: 65px;
}

.registry-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.registry-modal-title i {
    color: #326273;
    font-size: 18px;
}

.registry-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.registry-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.registry-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: white;
    max-height: calc(80vh - 130px);
}

.registry-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 18px 24px;
    border-top: 2px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
    gap: 14px;
    flex-shrink: 0;
    height: 75px;
}

.registry-tabs {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 20px;
}

.registry-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.registry-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    color: #475569;
}

.registry-tab.active {
    background: white;
    color: #326273;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.registry-tab-content {
    display: none;
}

.registry-tab-content.active {
    display: block;
}

/* Область перетаскивания реестра */
.registry-drop-zone {
    background: rgba(41, 128, 185, 0.08);
    border: 3px dashed #2980b9;
    border-radius: 12px;
    padding: 25px 20px;
    transition: all 0.2s ease;
    text-align: center;
    cursor: pointer;
    margin-bottom: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.registry-drop-zone:hover {
    background: rgba(41, 128, 185, 0.12);
    border-color: #1c6ea4;
}

.registry-drop-zone.dragover {
    background: rgba(41, 128, 185, 0.18);
    border-color: #155a8a;
    border-style: solid;
}

.registry-drop-zone-content i {
    color: #2980b9;
    font-size: 36px;
    margin-bottom: 12px;
    display: block;
}

.registry-drop-zone-content h6 {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 6px;
}

.registry-drop-zone-content p {
    color: #64748b;
    margin-bottom: 16px;
    font-size: 13px;
}

.registry-select-files-btn {
    background: linear-gradient(135deg, #2980b9, #1c6ea4);
    color: white;
    border: none;
    padding: 9px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 140px;
    height: 38px;
    box-shadow: 0 4px 12px rgba(41, 128, 185, 0.2);
}

.registry-select-files-btn:hover {
    background: linear-gradient(135deg, #1c6ea4, #155a8a);
    box-shadow: 0 6px 16px rgba(41, 128, 185, 0.3);
}

.registry-hidden-input {
    display: none;
}

.registry-file-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 2px solid #e8edf3;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    height: 56px;
}

.registry-counter-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
}

.registry-counter-content i {
    color: #198754;
    font-size: 16px;
}

.registry-file-count-badge {
    background: none;
    color: #198754;
    padding: 0;
    border-radius: 0;
    font-size: 14px;
    font-weight: 700;
    min-width: auto;
    text-align: center;
    margin-left: 5px;
    box-shadow: none;
}

.registry-clear-all-btn {
    background: transparent;
    border: 2px solid #ef4444;
    color: #ef4444;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    height: 34px;
}

.registry-clear-all-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.registry-clear-all-btn.hidden {
    display: none;
}

.registry-file-list {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px;
    border: 2px solid #e8edf3;
    margin-bottom: 24px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.registry-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #e8edf3;
    border-radius: 8px;
    transition: all 0.2s ease;
    height: 44px;
}

.registry-file-item:hover {
    background: #f8fafc;
    border-color: #d8e4f0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.registry-file-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 8px;
}

.registry-file-info i {
    color: #198754;
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
}

.registry-file-details {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.registry-file-name {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 480px;
}

.registry-remove-btn {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.registry-remove-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 3px 8px rgba(239, 68, 68, 0.2);
}

.registry-loading-indicator {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px solid #e8edf3;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    height: 60px;
}

.registry-loading-indicator.hidden {
    display: none;
}

.registry-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(50, 98, 115, 0.2);
    border-top-color: #326273;
    border-radius: 50%;
    animation: registrySpinner 1s linear infinite;
}

@keyframes registrySpinner {
    to {
        transform: rotate(360deg);
    }
}

.registry-loading-indicator span {
    font-size: 15px;
    font-weight: 600;
    color: #326273;
}

.registry-error-message {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(220, 38, 38, 0.05));
    border-left: 4px solid #ef4444;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.1);
    height: auto;
    min-height: 70px;
}

.registry-error-message.hidden {
    display: none;
}

.registry-error-content {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.registry-error-content i {
    color: #ef4444;
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.registry-error-content h6 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #b91c1c;
}

.registry-error-content p {
    font-size: 13px;
    line-height: 1.4;
    color: #b91c1c;
    margin: 0;
}

.registry-cancel-btn {
    background: transparent;
    border: 2px solid #64748b;
    color: #64748b;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 120px;
    height: 42px;
}

.registry-cancel-btn:hover {
    background: #64748b;
    color: white;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.2);
}

.registry-process-btn {
    background: linear-gradient(135deg, #326273, #5C9EAD);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 140px;
    height: 42px;
    box-shadow: 0 4px 12px rgba(50, 98, 115, 0.2);
}

.registry-process-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2a5465, #4a8a9a);
    box-shadow: 0 6px 16px rgba(50, 98, 115, 0.3);
}

.registry-process-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

/* =================== ПАНЕЛЬНЫЕ КНОПКИ =================== */
.panel-toggle-btn {
    display: none;
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    margin: 5px 0;
    transition: all 0.3s ease;
}

.panel-toggle-btn:hover,
.panel-toggle-btn:active {
    background: rgba(92, 158, 173, 0.2);
    border-color: rgba(92, 158, 173, 0.4);
}

.panel-toggle-btn i {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.panel-toggle-btn.active i {
    transform: rotate(180deg);
}

/* =================== ДИАЛОГ ВЫБОРА СЕРТИФИКАТА =================== */
.certificate-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.certificate-dialog {
    background: white;
    border-radius: 16px;
    padding: 25px;
    width: 650px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 2px solid #e9ecef;
    animation: slideIn 0.3s ease;
}

.certificate-dialog h5 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.certificate-dialog h5 i {
    color: #326273;
}

.certificate-item {
    padding: 15px;
    border: 2px solid #e8edf3;
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.certificate-item:hover {
    background: #edf2f7;
    border-color: #d8e4f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.certificate-item.selected {
    background: #e3f2fd;
    border-color: #326273;
    border-width: 2px;
}

.certificate-item .cert-name {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.certificate-item .cert-details {
    font-size: 13px;
    color: #718096;
    line-height: 1.5;
    margin-bottom: 5px;
}

.certificate-item .cert-details i {
    width: 16px;
    text-align: center;
    margin-right: 6px;
    color: #94a3b8;
}

.certificate-item .cert-status {
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
}

.certificate-item .cert-status.valid {
    background: #d4edda;
    color: #155724;
}

.certificate-item .cert-status.expiring {
    background: #fff3cd;
    color: #856404;
}

.certificate-item .cert-status.expired {
    background: #f8d7da;
    color: #721c24;
}





/* ===== СТИЛИ ДЛЯ ПОЛУЧЕНИЯ ЗАПИСЕЙ ИЗ РЕЕСТРА ===== */

/* ===== общие стили модалки ===== */
#registryFetcherModal .registry-modal-dialog {
    max-width: 900px;
    max-height: 90vh;
}

#registryFetcherModal .registry-modal-content {
    max-height: 90vh;
}

#registryFetcherModal .registry-modal-body {
    max-height: calc(90vh - 130px);
    overflow-y: auto;
}

#registryFetcherModal .registry-modal-header {
    padding: 18px 24px;
    border-bottom: 2px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#registryFetcherModal .registry-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

#registryFetcherModal .registry-modal-title i {
    color: #326273;
    font-size: 18px;
}

#registryFetcherModal .registry-modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

#registryFetcherModal .registry-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

#registryFetcherModal .registry-modal-footer {
    padding: 18px 24px;
    border-top: 2px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-shrink: 0;
}

/* ===== поля ввода - десктоп (1 колонка, надпись слева, поле справа) ===== */
.registry-fields-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    width: 100%;
}

.registry-field {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 8px 12px;
    align-items: center;
    width: 100%;
}

.registry-field label {
    color: #2c3e50;
    font-weight: 500;
    font-size: 13px;
    text-align: right;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.registry-field .registry-input {
    width: 100%;
    height: 38px;
    padding: 6px 12px;
    border: 2px solid #e8edf3;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #2c3e50;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.registry-field .registry-input:focus {
    outline: none;
    border-color: #326273;
    box-shadow: 0 0 0 3px rgba(50, 98, 115, 0.1);
}

.registry-field .registry-input::placeholder {
    color: #adb5bd;
}

.registry-field .registry-input[type="number"] {
    -moz-appearance: textfield;
}

.registry-field .registry-input[type="number"]::-webkit-inner-spin-button,
.registry-field .registry-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

select.registry-input {
    appearance: auto;
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

/* ===== кнопки действий - десктоп ===== */
.registry-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.registry-actions-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 15px;
}

.registry-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
    color: #2c3e50;
    border: 2px solid #e8edf3;
}

.registry-action-btn:hover:not(:disabled) {
    background: #edf2f7;
    border-color: #d8e4f0;
    transform: translateY(-1px);
}

.registry-action-btn i {
    font-size: 14px;
}

.registry-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* кнопка "найти записи" */
.registry-search-btn {
    background: linear-gradient(135deg, #326273, #5c9ead);
    color: white;
    border-color: #326273;
}

.registry-search-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #2a5465, #4a8a9a);
    border-color: #2a5465;
}

/* кнопка "скачать записи" */
.registry-download-btn {
    background: linear-gradient(135deg, #198754, #157347);
    color: white;
    border-color: #198754;
}

.registry-download-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #157347, #0f5c3a);
    border-color: #157347;
}

/* кнопка "создать протокол" */
.registry-protocol-btn {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: white;
    border-color: #0d6efd;
}

.registry-protocol-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0b5ed7, #0a58ca);
    border-color: #0b5ed7;
}

/* ===== кнопка очистить ===== */
.rf-action-btn {
    background: #3a7184;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.rf-action-btn:hover {
    background: #5c9ead;
    box-shadow: 0 4px 15px rgba(50, 98, 115, 0.3);
}

.rf-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.rf-action-btn i {
    font-size: 14px;
}

/* ===== чекбокс ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    gap: 8px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #326273;
    flex-shrink: 0;
}

/* ===== индикатор загрузки ===== */
.registry-loading-indicator {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px solid #e8edf3;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    height: 60px;
}

.registry-loading-indicator.hidden {
    display: none;
}

.registry-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(50, 98, 115, 0.2);
    border-top-color: #326273;
    border-radius: 50%;
    animation: registryspinner 1s linear infinite;
}

@keyframes registryspinner {
    to {
        transform: rotate(360deg);
    }
}

.registry-loading-indicator span {
    font-size: 15px;
    font-weight: 600;
    color: #326273;
}

/* ===== сообщение об ошибке ===== */
.registry-error-message {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(220, 38, 38, 0.05));
    border-left: 4px solid #ef4444;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.1);
    height: auto;
    min-height: 70px;
}

.registry-error-message.hidden {
    display: none;
}

.registry-error-content {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.registry-error-content i {
    color: #ef4444;
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.registry-error-content h6 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #b91c1c;
}

.registry-error-content p {
    font-size: 13px;
    line-height: 1.4;
    color: #b91c1c;
    margin: 0;
}

/* ===== кнопка закрытия ===== */
.registry-cancel-btn {
    background: transparent;
    border: 2px solid #64748b;
    color: #64748b;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 120px;
    height: 42px;
}

.registry-cancel-btn:hover {
    background: #64748b;
    color: white;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.2);
}

/* ===== результаты поиска ===== */
#rf_results {
    display: none;
    margin-top: 20px;
    border-top: 2px solid #e8edf3;
    padding-top: 15px;
}

#rf_results[style*="display: block"] {
    display: block !important;
}

#rf_results > div:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

#rf_results > div:first-child span {
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
}

#rf_count_badge {
    background: #326273;
    color: white;
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

#rf_results .table-wrapper,
#rf_results > div:last-child {
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e8edf3;
    overflow: auto;
    max-height: 300px;
}

#rf_results table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: 'Segoe UI', sans-serif;
    min-width: 700px;
}

#rf_results thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

#rf_results thead tr {
    background: #326273;
    color: white;
}

#rf_results thead th {
    padding: 8px 10px;
    text-align: left;
    border: 1px solid #2a5465;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

#rf_results tbody td {
    padding: 6px 10px;
    border: 1px solid #e8edf3;
    vertical-align: middle;
    font-size: 12px;
}

#rf_results tbody tr:hover {
    background: rgba(50, 98, 115, 0.06);
}

#rf_results tbody tr:nth-child(even) {
    background: #fafbfc;
}

#rf_results tbody tr:nth-child(even):hover {
    background: rgba(50, 98, 115, 0.08);
}

/* ===== мобильная адаптация (до 768px) ===== */
@media (max-width: 768px) {
    /* поля ввода - надпись сверху, поле снизу */
    .registry-fields-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;
        margin-top: 10px !important;
        width: 100% !important;
    }

    .registry-field {
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;
        padding: 2px 0 !important;
        width: 100% !important;
    }

    .registry-field label {
        font-size: 12px !important;
        text-align: left !important;
        color: #2c3e50 !important;
        font-weight: 500 !important;
        padding: 0 2px !important;
        margin: 0 !important;
        display: block !important;
        width: 100% !important;
    }

    .registry-field .registry-input {
        width: 100% !important;
        height: 36px !important;
        padding: 6px 10px !important;
        font-size: 13px !important;
        border: 2px solid #e8edf3 !important;
        border-radius: 6px !important;
        background: white !important;
        color: #2c3e50 !important;
        box-sizing: border-box !important;
    }

    select.registry-input {
        height: 36px !important;
        padding: 6px 10px !important;
        font-size: 13px !important;
    }

    /* ===== ВСЕ КНОПКИ В СТОЛБИК ===== */
.registry-actions-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 14px !important;
    width: 100% !important;
}

.registry-actions-bottom {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 10px !important;
    width: 100% !important;
}

    .registry-actions-row .rf-action-btn {
        width: 100%;
        min-height: 40px;
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 6px;
        justify-content: center;
    }

    .registry-actions-bottom .rf-action-btn {
        width: 100%;
        min-height: 40px;
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 6px;
        justify-content: center;
    }

    /* чекбокс - уменьшенная высота */
    .registry-actions-bottom .rf-checkbox-wrapper {
        padding: 4px 12px !important;
        min-height: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        background: #f8fafc !important;
        border: 1px solid #e8edf3 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 6px !important;
    }

    .checkbox-label {
        font-size: 13px !important;
        gap: 6px !important;
        padding: 0 !important;
        margin: 0 !important;
        line-height: 1 !important;
        height: auto !important;
        min-height: auto !important;
    }

    .checkbox-label input[type="checkbox"] {
        width: 16px !important;
        height: 16px !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }

    /* таблица результатов */
    #rf_results .table-wrapper,
    #rf_results > div:last-child {
        border-radius: 6px;
        max-height: 250px;
    }

    #rf_results table {
        font-size: 11px;
        min-width: 700px;
    }

    #rf_results thead th {
        padding: 6px 8px;
        font-size: 10px;
        white-space: nowrap;
    }

    #rf_results tbody td {
        padding: 5px 6px;
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 80px;
    }

    #rf_count_badge {
        font-size: 11px;
        padding: 2px 10px;
    }

    /* футер модалки */
    #registryFetcherModal .registry-modal-footer {
        padding: 12px 16px;
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .registry-cancel-btn {
        padding: 8px 18px;
        font-size: 13px;
        height: 38px;
        min-width: 100px;
        border-radius: 6px;
        width: 100%;
        justify-content: center;
    }

    /* общие стили модалки - мобильные */
    #registryFetcherModal .registry-modal-dialog {
        width: 95vw;
        max-width: 95vw;
        max-height: 95vh;
        margin: 10px auto;
        padding: 0;
    }

    #registryFetcherModal .registry-modal-content {
        max-height: 95vh;
        border-radius: 16px;
        overflow: hidden;
    }

    #registryFetcherModal .registry-modal-header {
        padding: 14px 16px;
        height: auto;
        min-height: 54px;
        flex-wrap: wrap;
        gap: 8px;
    }

    #registryFetcherModal .registry-modal-title {
        font-size: 15px;
        font-weight: 600;
    }

    #registryFetcherModal .registry-modal-title i {
        font-size: 16px;
    }

    #registryFetcherModal .registry-modal-close {
        width: 36px;
        height: 36px;
        font-size: 16px;
        padding: 4px;
    }

    #registryFetcherModal .registry-modal-body {
        padding: 14px 14px 10px 14px;
        max-height: calc(95vh - 120px);
        overflow-y: auto;
    }

    #registryFetcherModal .registry-modal-body > div:first-of-type {
        font-size: 13px;
        margin-bottom: 12px;
        text-align: center;
    }
}




/* =================== ВСПЛЫВАЮЩИЕ УВЕДОМЛЕНИЯ =================== */
.app-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 300px;
    max-width: 400px;
    z-index: 99999;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 
        0 15px 40px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

.message-success {
    background: linear-gradient(135deg, rgba(212, 237, 218, 0.95) 0%, rgba(195, 230, 203, 0.95) 100%);
    color: #155724;
    border-color: #c3e6cb;
}

.message-error {
    background: linear-gradient(135deg, rgba(248, 215, 218, 0.95) 0%, rgba(245, 198, 203, 0.95) 100%);
    color: #721c24;
    border-color: #f5c6cb;
}

.message-warning {
    background: linear-gradient(135deg, rgba(255, 243, 205, 0.95) 0%, rgba(255, 234, 167, 0.95) 100%);
    color: #856404;
    border-color: #ffeaa7;
}

.message-info {
    background: linear-gradient(135deg, rgba(209, 236, 241, 0.95) 0%, rgba(190, 229, 235, 0.95) 100%);
    color: #0c5460;
    border-color: #bee5eb;
}

.message-content {
    display: flex;
    align-items: center;
    position: relative;
}

.message-content i {
    margin-right: 10px;
    font-size: 18px;
}

.message-content span {
    flex: 1;
    padding-right: 25px;
    font-size: 13px;
    font-weight: 500;
}

.message-close {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    padding: 0 5px;
    color: inherit;
}

.message-close:hover {
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* =================== АНИМАЦИИ =================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =================== ПРОКРУТКА МОДАЛЬНЫХ ОКОН =================== */
.xml-modal-body::-webkit-scrollbar,
.registry-modal-body::-webkit-scrollbar {
    width: 8px;
}

.xml-modal-body::-webkit-scrollbar-track,
.registry-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.xml-modal-body::-webkit-scrollbar-thumb,
.registry-modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #5C9EAD, #326273);
    border-radius: 4px;
    border: 2px solid #f1f5f9;
}

.xml-modal-body::-webkit-scrollbar-thumb:hover,
.registry-modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #4a8a9a, #2a5465);
}

/* =================== ПРЕДОТВРАЩЕНИЕ ПРОКРУТКИ =================== */
body.modal-open {
    overflow: hidden;
}

/* =================== МОБИЛЬНАЯ АДАПТАЦИЯ =================== */

/* Планшеты (до 992px) */
@media (max-width: 992px) {
    .desktop-app {
        width: 100vw;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        position: relative;
        display: flex;
        flex-direction: column;
    }
    
    body {
        background: white;
        overflow-y: auto;
        display: block;
        height: auto;
        min-height: 100vh;
        position: relative;
    }
    
    body::before {
        display: none;
    }
    
    .app-header {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        height: 60px;
        min-height: 60px;
        padding: 0 15px;
        background: #2c3e50;
        border-bottom: 1px solid #1e2b37;
        display: flex;
        align-items: center;
    }
    
    .header-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 10px;
    }
    
    .mobile-menu-btn {
        display: flex;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        cursor: pointer;
        padding: 0;
        flex-direction: column;
        gap: 4px;
        flex-shrink: 0;
        order: 1;
        width: 38px;
        height: 38px;
        border-radius: 6px;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }
    
    .mobile-menu-btn:hover,
    .mobile-menu-btn:active {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .mobile-menu-btn span {
        display: block;
        width: 18px;
        height: 2px;
        background: white;
        border-radius: 2px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-btn.active {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(4px, 4px);
    }
    
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(4px, -4px);
    }
    
    .header-left {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        flex: 0 1 auto;
        min-width: 0;
        order: 2;
        margin: 0 auto;
        max-width: 60%;
    }
    
    .header-logo {
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }
    
    .header-logo-img {
        width: 28px;
        height: 28px;
        object-fit: contain;
    }
    
    .header-title-mobile {
        font-size: 16px;
        font-weight: 600;
        color: white;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
        text-align: center;
    }
    
    .header-title-mobile {
        font-size: 16px;
        font-weight: 600;
        color: white;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
        text-align: center;
    }
    
    .header-auth-buttons {
        display: flex;
        gap: 0;
        flex-shrink: 0;
        order: 3;
        margin-left: 0;
    }
    
    .auth-btn {
        padding: 0;
        width: 38px;
        height: 38px;
        min-width: 38px;
        max-width: 38px; 
        border-radius: 6px;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(255, 255, 255, 0.15);
        transition: all 0.2s ease;
    }
    
    .auth-btn i {
        font-size: 16px;
        margin: 0;
    }
    
    .auth-btn span {
        display: none;
    }
    
    .login-btn {
        background: #28a745; /* Зеленый цвет */
        color: white;
    }
    
    .login-btn:hover,
    .login-btn:active {
        background: #218838; /* Темно-зеленый при наведении */
    }
    
    .logout-btn {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
    
    .logout-btn:hover,
    .logout-btn:active {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .header-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: #2c3e50;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        border-top: 1px solid #1e2b37;
        border-bottom: 1px solid #1e2b37;
        z-index: 100;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .header-nav.show {
        display: flex;
    }
    
    .header-nav a {
        width: 100%;
        padding: 15px 20px;
        color: white;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        text-align: left;
        font-size: 15px;
        font-weight: 500;
        text-decoration: none;
        transition: background 0.2s ease;
    }
    
    .header-nav a:last-child {
        border-bottom: none;
    }
    
    .header-nav a:hover,
    .header-nav a:active {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
    
    .app-body {
        display: flex;
        flex-direction: column;
        overflow: visible;
        position: relative;
        min-height: auto;
    }
    
    .left-panel {
        position: relative;
        width: 100%;
        height: auto;
        max-height: none;
        overflow: visible;
        padding: 15px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        flex-direction: column;
        z-index: 10;
        flex-shrink: 0;
    }
    
    .logo-block {
        display: none;
    }
    
    .main-actions {
        padding: 10px 0 !important;
        width: 100%;
    }
    
    .action-wrapper {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .action-btn {
        font-size: 16px;
        padding: 14px 16px;
        min-height: 52px;
        flex: 1; /* Занимает всё доступное место внутри wrapper */
        width: auto;
    }
    
    .action-btn i {
        font-size: 18px;
        width: 24px;
    }
    
    /* Знак вопроса - фиксированная ширина */
    .left-panel .tooltip-left-icon {
        width: 52px;
        height: 52px;
        min-width: 52px;
        max-width: 52px;
        border-radius: 50%; /* Круглый */
        font-size: 20px;
        background: #5C9EAD;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
    }
    
    /* Панельная кнопка (Статистика) - такая же ширина как action-wrapper */
    .panel-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
        min-height: 52px;
        margin: 8px 0;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 8px;
        color: rgba(255, 255, 255, 0.9);
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    /* Убедимся, что заголовки блоков тоже одинаковой ширины */
    .block-title {
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(92, 158, 173, 0.1);
        border: 1px solid rgba(92, 158, 173, 0.2);
        border-radius: 8px;
        margin-bottom: 12px;
    }
    
    .organization-block,
    .stats-block {
        display: none !important;
        transition: all 0.3s ease;
        opacity: 0;
        max-height: 0;
        overflow: hidden;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .organization-block.open,
    .stats-block.open {
        display: block !important;
        opacity: 1;
        max-height: 500px;
        padding: 12px 20px !important;
        margin: 0 !important;
        overflow: visible;
    }
    
    .organization-block.open .org-name,
    .stats-block.open .block-title {
        font-size: 13px;
        padding: 6px 8px;
        text-align: center;
    }
    
    .left-panel .tooltip-left-icon {
        width: 18px;
        height: 18px;
        min-width: 18px;
        max-width: 18px;
        border-radius: 50%;
        font-size: 12px;
        background: #5C9EAD;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
    }
    
    .left-panel .tooltip-left-text {
        display: none;
    }
    
    .mobile-tooltip {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: #2c3e50;
        color: white;
        padding: 25px 20px 20px 20px;
        border-radius: 16px;
        font-size: 16px;
        line-height: 1.6;
        width: 320px;
        max-width: 90vw;
        z-index: 1000000;
        box-shadow: 0 25px 60px rgba(0,0,0,0.5);
        border: 2px solid rgba(255,255,255,0.15);
        text-align: left;
        display: none;
        pointer-events: auto;
    }
    
    .mobile-tooltip.show {
        display: block;
    }
    
    .mobile-tooltip-close {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.1);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 18px;
        cursor: pointer;
        transition: all 0.2s ease;
        padding: 0;
        line-height: 1;
    }
    
    .mobile-tooltip-close:hover,
    .mobile-tooltip-close:active {
        background: rgba(255,255,255,0.2);
    }
    
    .mobile-tooltip-content {
        padding: 10px 0 5px 0;
        font-size: 15px;
        line-height: 1.6;
        word-break: break-word;
        margin-top: 10px;
    }
    
    .mobile-tooltip-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.7);
        z-index: 999999;
        display: none;
        backdrop-filter: blur(3px);
    }
    
    .mobile-tooltip-overlay.show {
        display: block;
    }
    
    .main-content {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        bottom: auto;
        padding: 20px 15px;
        overflow-y: visible;
        display: flex;
        flex-direction: column;
        min-height: auto;
        flex: 1 0 auto;
        width: 100%;
        background: #f9fbfd;
    }
    
    .frames-container {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px;
        flex-wrap: nowrap;
        height: auto;
    }
    
    .frame {
        width: 100%;
        min-width: 100%;
        margin-bottom: 15px;
        display: flex;
        flex-direction: column;
    }
    
    .frame-waiting,
    .frame-registry {
        min-height: auto;
        height: auto;
    }
    
    .frame-header {
        padding: 12px 15px;
        font-size: 14px;
        min-height: 48px;
        flex-wrap: nowrap;
    }
    
    .frame-header span:first-of-type {
        flex: 0 1 auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .frame-header i:not(.tooltip-icon) {
        flex-shrink: 0;
        font-size: 16px;
        width: 20px;
        text-align: center;
    }
    
    .frame-header .tooltip-icon {
        width: 20px;
        height: 20px;
        min-width: 20px;
        max-width: 20px;
        font-size: 12px;
        margin-left: auto;
    }
    
    .frame-content {
        padding: 15px;
    }
    
    .frame-content .frame-btn {
        min-width: 100%;
        width: 100%;
        max-width: 100%;
        margin: 0 0 8px 0;
    }
    
    .frame-content .frame-btn:last-child {
        margin-bottom: 0;
    }
    
    .source-buttons {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 15px;
        padding: 0 10px;
    }
    
    .source-btn {
        padding: 12px 15px;
        height: auto;
        min-height: 50px;
        width: 100%;
        max-width: 300px; 
    }
    
    .protocol-settings {
        flex-direction: column;
        padding: 10px;
        gap: 8px;
        margin-top: 10px;
    }
    
    .checkbox-group {
        width: 100%;
        min-width: 100%;
        padding: 8px 12px;
        min-height: 40px;
        height: 40px;
        margin: 0;
    }
    
    .template-section {
        padding: 15px;
        margin-top: 10px;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .template-card {
        padding: 12px;
        min-height: 80px;
        height: auto;
    }
    
    .template-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        width: 100%;
    }
    
    .template-icon {
        width: 36px;
        height: 36px;
    }
    
    .template-info {
        flex: 1;
        text-align: left;
        padding-right: 10px;
        min-width: 0;
    }
    
    .template-info h4 {
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .template-info p {
        text-align: left;
        white-space: normal;
        max-height: 2.8em;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .download-btn {
        min-width: 70px;
        height: 32px;
        align-self: center;
    }
    
    .mintrud-link {
        margin-top: 20px;
        padding-top: 15px;
        width: 100%;
    }
    
    .mintrud-btn {
        width: 100%;
        max-width: 100%;
        padding: 12px 15px;
        justify-content: flex-start;
        text-align: left;
    }
    
    .mintrud-btn i {
        margin-right: 8px;
    }
    
    .mintrud-btn span {
        flex: 1;
        text-align: left;
    }
    
    .logout-section {
        position: relative;
        bottom: auto;
        right: auto;
        margin: 20px auto;
        width: 100%;
        text-align: center;
    }
    
    .logout-btn {
        width: 100%;
        max-width: 300px;
        justify-content: center;
        margin: 0 auto;
    }
    
    .xml-modal-dialog,
    .registry-modal-dialog {
        width: calc(100% - 30px);
        max-width: none;
        margin: 15px auto;
        max-height: 85vh;
    }
    
    .xml-modal-header,
    .registry-modal-header,
    .xml-modal-body,
    .registry-modal-body,
    .xml-modal-footer,
    .registry-modal-footer {
        padding: 15px 18px;
    }
    
    .xml-modal-header,
    .registry-modal-header {
        height: 60px;
    }
    
    .xml-modal-body,
    .registry-modal-body {
        max-height: calc(85vh - 120px);
    }
    
    .xml-file-name,
    .registry-file-name {
        max-width: 180px;
    }
    
    .xml-cancel-btn,
    .xml-process-btn,
    .registry-cancel-btn,
    .registry-process-btn {
        padding: 8px 18px;
        font-size: 13px;
        min-width: 100px;
        height: 38px;
    }
    
    .xml-select-files-btn,
    .registry-select-files-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 120px;
        height: 36px;
    }
    
    .xml-drop-zone,
    .registry-drop-zone {
        padding: 20px 15px;
        min-height: 100px;
    }
    
    .xml-file-counter,
    .registry-file-counter {
        height: 50px;
        padding: 12px 15px;
    }
    
    .xml-file-item,
    .registry-file-item {
        height: 48px;
        padding: 8px 12px;
    }
    
    .xml-file-list,
    .registry-file-list {
        max-height: 180px;
    }
    
    .xml-modal-footer,
    .registry-modal-footer {
        height: 70px;
    }
    
    .registry-tabs {
        flex-direction: column;
        gap: 5px;
    }
    
    .registry-tab {
        padding: 10px 15px;
    }


}

/* Смартфоны (до 768px) */
@media (max-width: 768px) {
    .app-header {
        height: 55px;
        min-height: 55px;
        padding: 0 12px;
    }
    
    .header-title-mobile {
        font-size: 15px;
    }
    
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }
    
    .mobile-menu-btn span {
        width: 17px;
    }
    
    .auth-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .auth-btn i {
        font-size: 15px;
    }
    
    .header-left {
        max-width: 55%;
    }
    
    .header-logo-img {
        width: 26px;
        height: 26px;
    }

    .left-panel {
        padding: 12px;
    }
    
    .panel-toggle-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .frame-header {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 45px;
    }
    
    .frame-header .tooltip-icon {
        width: 18px;
        height: 18px;
        min-width: 18px;
        max-width: 18px;
        font-size: 11px;
    }
    
    .frame-content .frame-btn {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .source-btn {
        height: 48px !important;
        max-height: 48px !important;
        min-height: 40px !important;
        padding: 6px 12px !important;
        font-size: 14px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .checkbox-group {
        padding: 6px 10px;
        min-height: 38px;
        height: 38px;
    }
    
    .checkbox-label {
        font-size: 12px;
    }
    
    .checkbox-label input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
    
    .template-section h3 {
        font-size: 15px;
        margin-bottom: 15px;
    }
    
    .template-card {
        padding: 10px;
        min-height: 75px;
        height: auto;
    }

    .template-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .template-icon {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .template-info {
        flex: 1;
        min-width: 0; /* важно для обрезки текста */
        padding-right: 8px;
    }

    .template-info h4 {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0 0 2px 0;
    }

.template-info p {
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    max-width: 100%;
    line-height: 1.3;
    max-height: 2.6em;
}

    .download-btn {
        min-width: 65px;
        padding: 4px 8px;
        font-size: 11px;
        height: 30px;
        flex-shrink: 0;
    }
    
    .download-btn i {
        font-size: 11px;
    }
    
    .mintrud-btn {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .mintrud-btn i {
        font-size: 13px;
    }

    .action-btn {
        font-size: 15px;
        padding: 12px 14px;
        min-height: 48px;
    }
    
    .action-btn i {
        font-size: 17px;
        width: 22px;
    }
    
    .left-panel .tooltip-left-icon {
        width: 18px;
        height: 18px;
        min-width: 18px;
        max-width: 18px;
        font-size: 12px;
    }
    
    .panel-toggle-btn {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 48px;
    }
    
    .block-title {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 48px;
    }
}

@media (max-width: 480px) {
    .header-title-mobile {
        font-size: 14px;
    }
    
    .mobile-menu-btn {
        width: 34px;
        height: 34px;
    }
    
    .mobile-menu-btn span {
        width: 16px;
    }
    
    .auth-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        max-width: 34px;
    }
    
    .auth-btn i {
        font-size: 14px;
    }
    
    .header-left {
        max-width: 55%;
    }

    .header-logo-img {
        width: 24px;
        height: 24px;
    }
    
    .header-left {
        gap: 6px;
    }

    .action-btn {
        font-size: 14px;
        padding: 10px 12px;
        min-height: 44px;
    }
    
    .action-btn i {
        font-size: 16px;
        width: 20px;
    }
    
    .left-panel .tooltip-left-icon {
        width: 18px;
        height: 18px;
        min-width: 18px;
        max-width: 18px;
        font-size: 12px;
    }
    
    .panel-toggle-btn {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .block-title {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 44px;
    }
}

@media (max-width: 360px) {
    .header-logo-img {
        width: 22px;
        height: 22px;
    }
    
    .header-left {
        gap: 4px;
    }

    .header-title-mobile {
        font-size: 13px;
    }
    
    .mobile-menu-btn {
        width: 32px;
        height: 32px;
    }
    
    .auth-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        max-width: 32px;
    }
    
    .header-left {
        max-width: 50%;
    }
}

@media (min-width: 993px) {
    .panel-toggle-btn {
        display: none !important;
    }
    
    .organization-block,
    .stats-block {
        display: block !important;
        opacity: 1 !important;
        max-height: none !important;
        padding: 12px 20px !important;
        overflow: visible !important;
    }
    
    .mobile-menu-btn {
        display: none;
    }
    
    .header-nav {
        display: flex !important;
    }
    
    .logo-block {
        display: flex;
    }
}









/* =================== УЛУЧШЕНИЯ ДЛЯ ТАЧ-УСТРОЙСТВ =================== */
@media (hover: none) and (pointer: coarse) {
    button,
    .action-btn,
    .frame-btn,
    .source-btn,
    .download-btn,
    .panel-toggle-btn,
    [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    .checkbox-label {
        min-height: 36px;
        display: flex;
        align-items: center;
    }
    
    .xml-remove-file-btn,
    .registry-remove-btn,
    .modal-close,
    .xml-modal-close,
    .registry-modal-close {
        min-width: 44px;
        min-height: 44px;
    }
}

/* =================== БЕЗОПАСНЫЕ ЗОНЫ (NOTCH) =================== */
@supports (padding: max(0px)) {
    .desktop-app {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
        padding-top: max(15px, env(safe-area-inset-top));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* =================== УЛУЧШЕНИЕ СКРОЛЛА НА iOS =================== */
.left-panel,
.main-content,
.xml-modal-body,
.registry-modal-body,
.registry-file-list,
.xml-file-list {
    -webkit-overflow-scrolling: touch;
}

/* =================== ТЕМНАЯ ТЕМА =================== */
@media (prefers-color-scheme: dark) {
    .desktop-app {
        background: #121212;
    }
    
    .main-content {
        background: #121212;
    }
    
    .frame {
        background: #1e1e1e;
        border-color: #2d2d2d;
    }
    
    .frame-content .frame-btn,
    .source-btn,
    .template-card {
        background: #2d2d2d;
        border-color: #3d3d3d;
        color: #e0e0e0;
    }
    
    .source-btn {
        background: #2d2d2d;
        border-color: #3d3d3d;
        color: #e0e0e0;
    }
    
    .template-section {
        background: #1e1e1e;
        border-color: #2d2d2d;
    }
    
    .template-card {
        background: #2d2d2d;
        border-color: #3d3d3d;
    }
    
    .template-info h4 {
        color: #e0e0e0;
    }
    
    .template-info p {
        color: #b0b0b0;
    }
    
    .protocol-settings {
        background: #2d2d2d;
        border-color: #3d3d3d;
    }
    
    .checkbox-group {
        background: #1e1e1e;
        border-color: #3d3d3d;
    }
    
    .checkbox-label {
        color: #e0e0e0;
    }
    
    .data-source-title {
        background: #2d2d2d;
        border-color: #3d3d3d;
        color: #e0e0e0;
    }
    
    .download-btn {
        background: linear-gradient(135deg, #198754, #157347);
        color: white;
    }
    
    .mintrud-btn {
        background: transparent !important;
        border-color: #326273 !important;
        color: #5C9EAD !important;
    }
    
    .mintrud-btn i {
        color: #5C9EAD;
    }
    
    .panel-toggle-btn {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.8);
    }
    
    .panel-toggle-btn:hover {
        background: rgba(92, 158, 173, 0.15);
        border-color: rgba(92, 158, 173, 0.3);
    }
}

/* =================== ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ =================== */
#registrySignedModal .xml-process-btn {
    min-width: 180px;
}

#selectCertBtn {
    background: #007bff !important;
}

#selectCertBtn:hover {
    background: #0069d9 !important;
}

#changeCertBtn {
    background: #6c757d !important;
    border-color: #6c757d !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
}

#changeCertBtn:hover {
    background: #5a6268 !important;
}

#registrySignedXlsxLoading,
#registrySignedXmlLoading {
    display: none !important;
}

.certificate-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.certificate-section h6 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.btn-small {
    background: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}










/* Стили для модального окна создания протокола */
.protocol-settings-modal {
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin: 15px 0;
}

.protocol-settings-modal h6 {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.protocol-settings-modal input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #326273;
}

.protocol-settings-modal label {
    color: #495057;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.protocol-settings-modal label:hover {
    color: #326273;
}









/* Индикатор загрузки для последнего набора */
.app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(3px);
}

.app-loading-content {
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.app-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.app-loading-text h4 {
    margin: 0 0 5px 0;
    color: #2c3e50;
}

.app-loading-text p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}





/* =================== МОДАЛЬНЫЕ ОКНА ДЛЯ ТАРИФОВ =================== */
.tariff-upgrade-modal,
.license-expired-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
}

#getAccessBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(50, 98, 115, 0.4) !important;
}

#closeUpgradeModal:hover,
#closeLicenseModal:hover {
    background: #f8f9fa !important;
    color: #495057 !important;
}

#getTariffBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(50, 98, 115, 0.4) !important;
}

/* Анимации для модальных окон */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}


/* ===== ПРИНУДИТЕЛЬНОЕ СКРЫТИЕ ЭЛЕМЕНТОВ МОДАЛКИ РЕЕСТРА ===== */
#registryFetcherModal #rf_loading,
#registryFetcherModal #rf_error,
#registryFetcherModal #rf_results {
    display: none !important;
}

#registryFetcherModal #rf_loading[style*="display: flex"] {
    display: flex !important;
}

#registryFetcherModal #rf_error[style*="display: block"] {
    display: block !important;
}

#registryFetcherModal #rf_results[style*="display: block"] {
    display: block !important;
}

/* Дополнительная защита от мобильных стилей */
@media (max-width: 768px) {
    #registryFetcherModal #rf_loading,
    #registryFetcherModal #rf_error,
    #registryFetcherModal #rf_results {
        display: none !important;
    }
    
    #registryFetcherModal #rf_loading[style*="display: flex"] {
        display: flex !important;
    }
    
    #registryFetcherModal #rf_error[style*="display: block"] {
        display: block !important;
    }
    
    #registryFetcherModal #rf_results[style*="display: block"] {
        display: block !important;
    }
}




/* =================== ОБУЧАЮЩИЙ ГИД =================== */

/* Затемнение фона с "окном" для подсвечиваемого элемента */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    display: none;
    pointer-events: none;
}

.tutorial-overlay.active {
    display: block;
}

.tutorial-overlay svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tutorial-overlay .overlay-rect {
    fill: rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.tutorial-overlay .highlight-hole {
    fill: transparent;
    stroke: rgba(92, 158, 173, 0.8);
    stroke-width: 2;
    rx: 8;
    ry: 8;
    pointer-events: none;
}

/* Подсветка элемента - только рамка, без анимации */
.tutorial-highlight {
    position: relative;
    z-index: 100000 !important;
    border-radius: 8px;
    box-shadow: 0 0 0 2px rgba(92, 158, 173, 0.8) !important;
}

/* Подсветка карточки - только рамка, без анимации */
.tutorial-card-highlight {
    position: relative;
    z-index: 100000 !important;
    border-radius: 14px !important;
    box-shadow: 0 0 0 2px rgba(92, 158, 173, 0.8) !important;
}

/* Подсветка секции - только рамка, без анимации */
.tutorial-section-highlight {
    position: relative;
    z-index: 100000 !important;
    border-radius: 14px !important;
    box-shadow: 0 0 0 2px rgba(92, 158, 173, 0.8) !important;
}

/* Всплывающая подсказка обучения */
.tutorial-tooltip {
    position: fixed;
    z-index: 100001;
    background: #ffffff;
    color: #2c3e50;
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    border: 1px solid #e0e0e0;
    display: none;
    pointer-events: auto;
}

/* Убираем стрелку-указатель */
.tutorial-tooltip::before {
    display: none !important;
}

.tutorial-tooltip.active {
    display: block;
}

/* Заголовок с крестиком */
.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}

.tutorial-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    line-height: 1.3;
}

.tutorial-header h3 .step-badge {
    background: #326273;
    color: white;
    padding: 1px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}

/* Крестик закрытия */
.tutorial-close-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
}

.tutorial-close-btn:hover {
    color: #333;
}

.tutorial-tooltip p {
    margin: 0 0 10px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
}

.tutorial-tooltip .tutorial-image {
    margin: 8px 0 12px 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #e8edf3;
    text-align: center;
}

.tutorial-tooltip .tutorial-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}

/* Кнопки управления */
.tutorial-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8edf3;
    flex-wrap: wrap;
    justify-content: center;
}

.tutorial-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tutorial-btn-primary {
    background: #28a745;
    color: white;
}

.tutorial-btn-primary:hover {
    background: #1e7e34;
}

.tutorial-btn-success {
    background: #28a745;
    color: white;
}

.tutorial-btn-success:hover {
    background: #1e7e34;
}

.tutorial-btn-back {
    background: #e9ecef;
    color: #495057;
}

.tutorial-btn-back:hover {
    background: #dee2e6;
}

/* Индикатор прогресса (точки) */
.tutorial-progress {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    justify-content: center;
}

.tutorial-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d0d0d0;
    transition: all 0.2s ease;
}

.tutorial-dot.active {
    background: #28a745;
    width: 20px;
    border-radius: 4px;
}

.tutorial-dot.done {
    background: #a8d5a8;
}

/* Скрываем дублирующий текст */
.tutorial-counter {
    display: none !important;
}

/* Кнопка пропуска (скрыта) */
.tutorial-skip-fixed {
    display: none !important;
}

/* Стили для кнопки перезапуска в левой панели - всегда видна */
#btn-restart-tutorial {
    display: flex !important;
}

#btn-restart-tutorial.tutorial-highlight {
    box-shadow: 0 0 0 2px rgba(92, 158, 173, 0.8) !important;
    border-radius: 8px;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .tutorial-tooltip {
        padding: 16px 18px;
        max-width: 95vw;
        bottom: 15px !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        border-radius: 12px;
        max-height: 70vh;
        overflow-y: auto !important;
    }
    
    .tutorial-tooltip::before {
        display: none !important;
    }
    
    .tutorial-header h3 {
        font-size: 15px;
    }
    
    .tutorial-tooltip p {
        font-size: 13px;
    }
    
    .tutorial-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .tutorial-btn {
        width: 100%;
        justify-content: center;
    }
}



/* ===== АНИМАЦИЯ ДЛЯ УВЕДОМЛЕНИЯ ===== */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}