body {
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

html,
body,
#map {
    height: 100%;
}

.row {
    display: flex;
    flex-direction: row;
}

.row-2 {
    display: flex;
    gap: 12px;          /* расстояние между инпутами */
    width: 100%;
}

.row-2 .input-group {
    flex: 1;            /* по 50% */
    display: flex;
    flex-direction: column;
}

.row-2 label {
    margin-bottom: 6px;
    font-size: 14px;
}

.row-2 input {
    width: 100%;
    box-sizing: border-box;
}


.gap-auto {
    justify-content: space-between;
}

.maplibregl-popup {
    max-width: 400px;
    font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
}

/* Панель управления */
.control-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1;
    min-width: 300px;
    max-height: 90vh;
    overflow-y: auto;
}

.control-panel h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}

.status {
    padding: 10px;
    background: #e3f2fd;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #1976d2;
    font-weight: 500;
}

.coordinates-display {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 12px;
    font-family: monospace;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.input-group input:focus {
    outline: none;
    border-color: #2196f3;
}

.input-group .input-with-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group .input-with-label input {
    flex: 1;
}

.input-group .input-with-label .value-display {
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    color: #2196f3;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.input-group .input-with-label .value-display:focus {
    outline: none;
    border-color: #2196f3;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
}

.btn-primary:disabled,
.btn-primary[disabled] {
    background: #90caf9; /* более светлый оттенок синего */
    color: #e0e0e0; /* серый текст */
    cursor: not-allowed; /* показывает, что кнопка недоступна */
    opacity: 0.6; /* слегка прозрачная для визуальной подсказки */
    box-shadow: none; /* убираем тень, если есть */
}


.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

/* Стрелка-курсор */
.direction-arrow {
    position: absolute;
    width: 60px;
    height: 60px;
    pointer-events: none;
    z-index: 999;
    display: none;
    transform-origin: center center;
}

.direction-arrow svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.info-text {
    font-size: 11px;
    color: #666;
    margin-top: 10px;
    line-height: 1.4;
}

.section-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 15px 0;
}


/* Фон модального окна */
.popup {
    display: none;
    /* скрыто по умолчанию */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

/* Контейнер содержимого */
.popup-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    max-width: 80%;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Кнопка закрытия */
.popup-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.popup-close:hover {
    color: red;
}

/* Картинка */
.popup img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}


#progress-container {
  width: 100%;
  background: #eee;
  height: 10px;
  border-radius: 5px;
  margin-top: 10px;
  overflow: hidden;
}

#progress-bar {
  width: 0%;
  height: 100%;
  background: #4caf50;
  transition: width 0.2s;
}

/* Список сохранённых секторов */
.saved-sectors {
    margin-top: 15px;
}

.saved-sectors h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.saved-sectors h4 .count {
    background: #2196f3;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
}

.sector-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

.sector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
}

.sector-item:last-child {
    border-bottom: none;
}

.sector-item:hover {
    background: #f0f0f0;
}

.sector-item.active {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.sector-info {
    flex: 1;
    font-size: 12px;
}

.sector-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.sector-details {
    font-size: 11px;
    color: #666;
}

.sector-actions {
    display: flex;
    gap: 5px;
}

.sector-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.sector-btn.load {
    background: #2196f3;
    color: white;
}

.sector-btn.load:hover {
    background: #1976d2;
}

.sector-btn.delete {
    background: #f44336;
    color: white;
}

.sector-btn.delete:hover {
    background: #d32f2f;
}

.empty-list {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 12px;
}

/* Модальное окно сохранения */
.save-modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.save-modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 25px;
    border-radius: 8px;
    max-width: 400px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.save-modal h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}

.save-modal input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.save-modal input:focus {
    outline: none;
    border-color: #2196f3;
}

.save-modal-buttons {
    display: flex;
    gap: 10px;
}

.save-modal-buttons button {
    flex: 1;
}


/* Выбор страницы */
  .page-switcher {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;

    display: flex;
    gap: 8px;

    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    padding: 8px 12px;
    border-radius: 12px;
  }

  .page-switcher a {
    color: #fff;
    text-decoration: none;
    font-family: Arial, sans-serif;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 8px;
    opacity: 0.7;
    transition: background 0.2s, opacity 0.2s;
  }

  .page-switcher a:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
  }

  .page-switcher a.active {
    background: rgba(255, 255, 255, 0.35);
    opacity: 1;
    pointer-events: none;
  }
/* Ввод координат */
.coord-input-wrapper {
    display: flex;
    gap: 8px;
}

.coord-input-wrapper input {
    flex: 1;
}

.btn-coord {
    padding: 8px 12px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-coord:hover {
    background: #1976d2;
}

/* Кнопки экспорта */
.export-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-export {
    flex: 1;
    padding: 10px;
    background: #9c27b0;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-export:hover {
    background: #7b1fa2;
}

.btn-import {
    width: 100%;
    padding: 10px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-import:hover {
    background: #f57c00;
}

/* Переключатель режимов */
.mode-switcher {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    background: #f5f5f5;
    color: #666;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.mode-btn.active {
    background: #2196f3;
    color: white;
    border-color: #2196f3;
}

/* Список точек в папке */
.points-list-container {
    margin-top: 15px;
}

.points-list-container h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.points-list-container h4 .count {
    background: #4caf50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
}

.points-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

.point-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.2s;
}

.point-item:last-child {
    border-bottom: none;
}

.point-item:hover {
    background: #f0f0f0;
}

.point-item.active {
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
}

.point-info {
    flex: 1;
    font-size: 12px;
}

.point-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.point-details {
    font-size: 11px;
    color: #666;
}

.point-actions {
    display: flex;
    gap: 5px;
}

.point-btn {
    padding: 4px 8px;
    font-size: 14px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.point-btn.edit {
    color: #2196f3;
}

.point-btn.edit:hover {
    background: #e3f2fd;
}

.point-btn.delete {
    color: #f44336;
    font-size: 18px;
    font-weight: bold;
}

.point-btn.delete:hover {
    background: #ffebee;
}


        /* Кнопка настроек */
        #settings-button {
            position: fixed;
            bottom: 20px;
            right: 20px;
            padding: 12px 24px;
            background-color: #4a6fa5;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            z-index: 1000;
            box-shadow: 0 2px 10px rgba(0,0,0,0.2);
            transition: background-color 0.3s;
        }

        #settings-button:hover {
            background-color: #3a5a8c;
        }

        /* Модальное окно */
        #settings-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
            z-index: 1001;
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: white;
            padding: 30px;
            border-radius: 8px;
            width: 90%;
            max-width: 600px;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        }

        h3 {
            margin-top: 0;
            margin-bottom: 20px;
            color: #333;
            border-bottom: 2px solid #4a6fa5;
            padding-bottom: 10px;
        }
        /* Кнопки действий */
        .button-group {
            display: flex;
            gap: 10px;
            margin-top: 20px;
            flex-wrap: wrap;
        }

        .btn-settings {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: background-color 0.3s;
        }

        /* Цветной индикатор */
        .color-preview {
            width: 30px;
            height: 30px;
            border-radius: 4px;
            border: 1px solid #ccc;
            margin-left: 10px;
        }

        /* Пример шкалы */
        .scale-preview {
            margin-top: 25px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }

        .preview-item {
            display: inline-block;
            padding: 5px 15px;
            margin: 2px;
            border-radius: 4px;
            color: white;
            font-size: 12px;
            text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
        }

        .scale-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        /* --- СТИЛИ ДЛЯ ГАЛЕРЕИ ГРАФИКОВ --- */
        #gallery-button {
            position: fixed;
            bottom: 20px;
            right: 20px;
            padding: 12px 24px;
            background-color: #4a6fa5;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            z-index: 1000;
            box-shadow: 0 2px 10px rgba(0,0,0,0.2);
            transition: background-color 0.3s;
        }

        .btn-gallery {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: background-color 0.3s;
        }
.gallery-modal {
    display: none; 
    position: fixed; 
    inset: 0; 
    background-color: rgba(0, 0, 0, 0.6); 
    z-index: 2000; /* Должно быть поверх карты */
    backdrop-filter: blur(2px);
}

.gallery-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    height: 90%;
    background-color: #fff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
}

.gallery-header {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gallery-header h3 { margin: 0; color: #333; }
.gallery-close { font-size: 24px; cursor: pointer; color: #666; transition: 0.2s; }
.gallery-close:hover { color: #f44336; }

.gallery-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Левая панель (Папки) */
.gallery-sidebar {
    width: 300px;
    min-width: 250px;
    background-color: #fafafa;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 15px;
}

.folder-wrapper { margin-bottom: 10px; }
.folder-header {
    cursor: pointer;
    font-weight: bold;
    padding: 8px 10px;
    background: #eef2f5;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}
.folder-header:hover { background: #e0e6ed; }
.folder-header::before {
    content: '📁'; margin-right: 8px; font-size: 14px;
}
.folder-header.expanded::before { content: '📂'; }

.sectors-list {
    margin-top: 5px;
    padding-left: 20px;
    display: none; /* Скрыто по умолчанию */
}
.folder-wrapper.expanded .sectors-list { display: block; }

.db-sector-item {
    display: flex;
    align-items: center;
    padding: 5px;
    margin-bottom: 2px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.db-sector-item:hover { background: #eaeff5; }
.db-sector-item.highlighted { background: #d0e3f7; font-weight: bold; }
.db-sector-item input[type="checkbox"] { margin-right: 8px; cursor: pointer; }

/* Правая панель (Графики) */
.gallery-main {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f0f2f5;
}

.graphs-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-content: flex-start;
}

.empty-gallery-msg {
    width: 100%; text-align: center; color: #888; font-size: 16px; margin-top: 50px;
}

.graph-card {
    background: #fff;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 10px;
    width: calc(33.333% - 15px); /* По 3 в ряд */
    min-width: 250px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.graph-card img {
    width: 100%; height: auto; border-radius: 4px; display: block;
}
.graph-card p {
    margin: 10px 0 0 0; font-size: 14px; color: #555; text-align: center;
}

/* Подсветка связанных графиков */
.graph-card.highlighted-graph {
    border-color: #2196F3;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.4);
    transform: scale(1.02);
}
/* === ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ДЛЯ УЛУЧШЕНИЙ === */

/* Кнопки редактирования в галерее */
.folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
}

.folder-name {
    flex: 1;
}

.folder-edit-btn,
.sector-edit-btn {
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.2s;
}

.folder-edit-btn:hover,
.sector-edit-btn:hover {
    opacity: 1;
    background: rgba(33, 150, 243, 0.1);
}

.db-sector-item {
    display: flex;
    align-items: center;
    padding: 5px;
    margin-bottom: 2px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    gap: 8px;
}

.db-sector-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.db-sector-item .sector-label {
    flex: 1;
    user-select: none;
}

.sector-edit-btn {
    flex-shrink: 0;
    margin-left: auto;
}

/* Улучшенные стили для графиков */
.graph-card {
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.graph-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.graph-card::after {
    content: '🔍';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.graph-card:hover::after {
    opacity: 1;
}

/* Анимация для полноэкранного просмотра */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#fullscreen-image-viewer {
    animation: fadeIn 0.3s ease;
}

#fullscreen-image-viewer img {
    animation: fadeIn 0.5s ease;
}

/* Улучшенная подсветка выбранных элементов */
.db-sector-item.highlighted {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.graph-card.highlighted-graph {
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    transform: scale(1.03);
}

/* Стили для кнопок экспорта (оставляем только JSON) */
.export-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.export-buttons .btn-export {
    flex: 1;
}

/* Улучшенные состояния кнопок */
button:active {
    transform: scale(0.98);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Индикатор загрузки */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #2196f3;
    animation: spin 1s linear infinite;
}

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

/* Улучшенные тултипы */
[title] {
    position: relative;
}

/* Адаптивность для галереи */
@media (max-width: 1200px) {
    .graph-card {
        width: calc(50% - 15px); /* По 2 в ряд на средних экранах */
    }
}

@media (max-width: 768px) {
    .graph-card {
        width: 100%; /* По 1 в ряд на маленьких экранах */
    }
    
    .gallery-sidebar {
        width: 200px;
        min-width: 200px;
    }
}
