/* Основные стили страницы и шрифты */
body { font-family: 'Segoe UI', Tahoma, sans-serif; background: #f4f7f6; margin: 0; padding: 0 !important; }

/* 1. Закрепляем панель фильтров (самый верх) */
.filter-panel {
    position: sticky;
    top: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 1000;
    background: #eceff1; 
    padding: 15px 20px;
    border-bottom: 2px solid #ccc;
    display: flex; 
    gap: 12px; 
    flex-wrap: wrap; 
    align-items: flex-end; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.f-item { display: flex; flex-direction: column; font-size: 12px; color: #444; font-weight: 600; }
input, select { padding: 7px; border: 1px solid #ccc; border-radius: 4px; margin-top: 4px; background: #fff; }

/* Стили для select с множественным выбором */
select[multiple] { height: 60px; padding: 2px; }

/* 2. Закрепляем строку "Найдено телеграмм / Обработать" */
.info-bar {
    position: sticky;
    top: 92px;
    z-index: 999;
    background: #eceff1;
    padding: 10px 15px;
    margin: 0 !important;
    font-weight: bold; 
    color: #2e7d32;
    border-bottom: 1px solid #ddd;
}
.table-container { width: 100%; max-height: 85vh; overflow: auto; border: 1px solid #1b5e20; background: #fff; position: relative; }

/* 3. Закрепляем шапку таблицы */
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: auto; min-width: 2500px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
thead th {
    position: sticky!important;
    top: 0; /* Отступ = Высота фильтров + Высота инфо-строки */
    z-index: 100;
    background: #455a64; color: #fff; padding: 10px 5px; font-size: 11px; border: 1px solid #37474f;
	border-bottom: 2px solid #37474f;
    border-right: 1px solid #37474f;
    cursor: pointer; transition: background 0.2s;
	vertical-align: top;
	white-space: nowrap;  
}
thead th:hover { background: #546e7a; }
thead th:not(.check-col)::after { content: ' \21D5'; font-size: 10px; opacity: 0.5; }

/********************************************************/

/* 4. ФИКСАЦИЯ ПЕРВОЙ КОЛОНКИ (Чекбокс) */
.check-col,
th:nth-child(1),
td:nth-child(1) {
    position: sticky!important;
    left: 0!important;
    z-index: 10;
    background-color: #fff;
    min-width: 40px;
    max-width: 40px;
    width: 40px;
    box-shadow: inset -1px 0 0 #ccc; /* Имитация границы справа */
}

/* 5. ФИКСАЦИЯ ВТОРОЙ КОЛОНКИ (Станция) */
th:nth-child(2),
td:nth-child(2) {
    position: sticky;
    left: 40px; /* Должно быть равно ширине первой колонки */
    z-index: 10;
    background-color: #e1f5fe;
    box-shadow: inset -1px 0 0 #ccc;
}

/* 6. УГЛОВЫЕ ЯЧЕЙКИ (Пересечение липкой шапки и липких колонок) */
thead th:nth-child(1) {
    z-index: 120; /* Самый высокий */
    top: 0;
    left: 0;
    background-color: #455a64;
}

thead th:nth-child(2) {
    z-index: 120;
    top: 0;
    left: 40px;
    background-color: #455a64;
}

/* 7. Исправление фонов при наведении и специальных строк */
tr:hover td {
    background-color: #f1f1f1 !important;
}

/* Чтобы sticky-ячейки в спец-строках не теряли цвет */
tr.row-cccc td:nth-child(1),
tr.row-cccc td:nth-child(2) {
    background-color: #fff9c4 !important;
}

/* Фикс для станций в теле таблицы, чтобы не перекрывался цвет */
td:nth-child(2).st-hint {
    background-color: #e1f5fe; 
}
/********************************************************/

/* Стили ячеек таблицы */
td { border: 1px solid #eee; padding: 2px; text-align: center; font-size: 13px; white-space: nowrap; vertical-align: top;}
.row-cccc { background-color: #fff9c4; } 
.kod-main { font-weight: bold; color: #2980b9; }
.time-cell { font-size: 11px; color: #78909c; }
.check-col { width: 35px; text-align: center; background: #f8f9fa; }
.selected-row { background-color: #e3f2fd !important; } 

/* Стили для индикаторов штормового предупреждения */
.storm-none { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; padding: 8px 15px; border-radius: 4px; font-weight: bold; cursor: default;}
.storm-danger { background-color: #f8d7da; color: #721c24; border: 2px solid #f5c6cb; animation: blinker 1.5s linear infinite; padding: 8px 15px; border-radius: 4px; font-weight: bold; cursor: default;}
@keyframes blinker { 50% { opacity: 0.5; } }

/* Выпадающие меню (Каскад) */
.dropdown { position: relative; display: inline-block; }
.dropbtn { padding: 8px 15px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; color: #444; font-size: 12px; text-decoration: none; display: flex; align-items: center; gap: 5px; }
.dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 2000; border-radius: 4px; overflow: hidden; }
.dropdown-content a { color: black; padding: 10px 16px; text-decoration: none; display: block; font-size: 12px; }
.dropdown-content a:hover { background-color: #f1f1f1; }
.dropdown:hover .dropdown-content { display: block; }

/* Подсказка для станции */
.st-hint { cursor: help; text-decoration: underline dotted #2980b9; }

/* Всплывающее окно (Модалка) для текста телеграммы */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color: #fff; margin: 10% auto; padding: 20px; border: 1px solid #888; width: 50%; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
.close-modal { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.close-modal:hover { color: black; }
#rawTextContent { background: #f4f7f6; padding: 15px; border-radius: 4px; font-family: monospace; white-space: pre-wrap; font-size: 14px;}

/* =========================================
   СТИЛИ ДЛЯ ВЫПАДАЮЩЕГО СПИСКА СТАНЦИЙ
   ========================================= */

/* 1. Контейнер — жестко фиксируем ширину */
.multiselect-container {
    position: relative;
    display: inline-block;
    width: 200px;
    min-width: 200px;
    max-width: 200px;
    vertical-align: middle;
    box-sizing: border-box;
}

/* 2. Поле выбора (кнопка) */
.select-box {
    position: relative;
    cursor: pointer;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 25px 5px 10px;
    font-size: 13px;
    height: 30px;
    line-height: 20px;
    
    /* Обрезка текста */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    
    display: block; 
    width: 100%;
    box-sizing: border-box;
}

/* Стрелочка */
.select-box:after {
    content: "▼";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #666;
    pointer-events: none;
}

/* 3. Сам выпадающий список */
.checkboxes-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 99999; /* Экстремально высокий z-index, чтобы ничего не перекрывало */
    background: #fff;
    border: 1px solid #aaa;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    
    /* Параметры прокрутки */
    width: 220px;
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    
    /* САМОЕ ВАЖНОЕ ИСПРАВЛЕНИЕ: Блокирует прокрутку страницы при наведении мыши на этот список */
    overscroll-behavior: contain; 
    
    padding: 0;
    margin-top: 2px;
    box-sizing: border-box;
}

/* Принудительно показываем блок */
.checkboxes-list.show {
    display: block !important;
}

/* Элементы списка */
.checkboxes-list label {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}

.checkboxes-list label:hover { 
    background: #e3f2fd; 
}

.checkboxes-list input { 
    margin-right: 10px; 
    flex-shrink: 0;
}

/* =========================================
   Кнопка управления автообновлением
   ========================================= */
 
.stop-btn {
    padding: 5px 15px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #455a64;
    background: #fff;
    transition: all 0.3s;
    margin-left: 10px;
    outline: none;
}

/* Состояние, когда обновление остановлено */
.stop-btn.active {
    background: #ff7675;
    color: white;
    border-color: #d63031;
}

.stop-btn.active::after {
    content: " (ВЫКЛ)";
}

.stop-btn:not(.active)::after {
    content: " (ВКЛ)";
}

/* Кнопка управления автообновлением */
.stop-btn {
    padding: 5px 15px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #455a64;
    background: #fff;
    transition: all 0.3s;
    margin-left: 10px;
    color: #444;
}

/* Состояние, когда обновление ОСТАНОВЛЕНО (Красная кнопка) */
.stop-btn.active {
    background: #ff7675 !important;
    color: white !important;
    border-color: #d63031 !important;
}

/* =========================================
   Кнопки переключения данных на карте
   ========================================= */
 
.map-btn {
    padding: 5px 15px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #455a64;
    background: #fff;
    transition: all 0.3s;
    margin-left: 10px;
    outline: none;
}

/* Кнопка управления */
.map-btn {
    padding: 5px 15px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #455a64;
    background: #fff;
    transition: all 0.3s;
    margin-left: 10px;
    color: #444;
}

/* Состояние, когда красная кнопка */
.map-btn.active {
    background: #ff7675 !important;
    color: white !important;
    border-color: #d63031 !important;
}


/* =========================================
   Контейнер для двухстрочного вывода в ячейке
   ========================================= */
.cell-data {
/*    display: flex;*/
    flex-direction: column;
    align-items: center;
/*    line-height: 1.2;*/
}

/* Стиль для первой строки (закодированной) */
.raw-code {
/*    font-weight: bold;*/
/*    font-size: 13px;*/
    color: #333;
}

/* Стиль для второй строки (расшифрованной) */
.decoded-val {
    font-size: 11px !important;
    color: #2980b9 !important; /* Спокойный синий цвет для расшифровки */
    border-top: 1px dashed #ddd;
    margin-top: 2px;
    width: 100%;
    text-align: center;
}

/* Уникальные стили для штормовой таблицы (добавить в style.css) */
.storm-code { font-weight: bold; color: #d32f2f; background: #ffebee; padding: 3px 6px; border-radius: 4px; }
/*.time-cell { font-size: 11px; color: #78909c; }
.check-col { width: 35px; text-align: center; background: #fff; }
.phenomenon-cell { text-align: center; padding-left: 10px; font-size: 14px; }

/* Стили выделения строк */
.selected-row { outline: 2px solid #2196F3 !important; background-color: #e3f2fd !important; color: #000 !important; }
.selected-row td { color: #000 !important; }

.row-danger-storm { background-color: #f2a2a2 !important; color: #ffffff !important; }
.row-danger-storm td { border-color: #a04040; }
.row-warning-storm { background-color: #fff176 !important; color: #333333 !important; }

/* Индикаторы опасности в шапке 
.storm-none { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.storm-danger { background-color: #f8d7da; color: #721c24; border: 2px solid #f5c6cb; animation: blinker 1.5s linear infinite; }
@keyframes blinker { 50% { opacity: 0.5; } }*/

/* =========================================
Таблица отклонения норм
   ========================================= */
    .content-wrapper { 
        display: flex; 
        gap: 20px; 
        padding: 15px; 
        align-items: flex-start; 
    }
    .table-section { 
        flex: 0 0 auto; /* Позволяет контейнеру принимать ширину самой таблицы */
        max-width: 50%; /* Защита, чтобы таблица не заняла больше половины экрана */
        overflow-x: auto; 
        background: #fff; 
        padding: 10px; 
        border-radius: 5px; 
        box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    }
    .chart-section { 
        flex: 0.65; /* График занимает всё оставшееся свободное место */
        background: #fff; 
        padding: 10px; 
        border-radius: 5px; 
        box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
        min-height: 500px; 
    }
    .excel-table { 
        border-collapse: collapse; 
        font-family: Arial, sans-serif; 
        font-size: 12px; /* Чуть уменьшили шрифт для компактности */
        text-align: center; 
        white-space: nowrap; /* Запрещаем перенос текста на новую строку */
        margin: 0 auto; /* Центрируем саму таблицу в блоке */
		min-width: min-content;
    }
    .excel-table th, .excel-table td { 
        border: 1px solid #ccc; 
        padding: 5px 8px; /* Делаем аккуратные отступы */
    }
    .excel-table th { 
       /* background: #f4f7f6; */
        font-weight: bold; 
    }
    .dev-plus { color: red; font-weight: bold; }
    .dev-minus { color: blue; font-weight: bold; }   
	
	.decoded-text {
    font-size: 10px;
    color: #2980b9; /* Синий оттенок для отличия от кода */
    display: block;
    margin-top: 2px;
}

table#hydroTable td {
    vertical-align: middle;
    border-bottom: 1px solid #eee;
}

/* =========================================
Карта гидрология   
========================================= */

/* Стили для всех областей */
  .subregion {
    stroke: #ffffff;
    stroke-width: 2px;
    transition: fill 0.3s ease; /* Плавная смена цвета */
    cursor: pointer;
	fill: #abccad;
  }
   .subregion2 {
	cursor: pointer;
	fill: #abccad;
  } 
  /* Эффект при наведении */
  .subregion:hover {
    fill: #3498db !important; /* !important перебьет любые другие стили */
  }


/* Базовый стиль точки */
.map-point {
    r: 10;
    fill: var(--point-color, #307991); /* Если переменная не задана, будет серым */
	stroke: #ffffff;
    stroke-width: 2px;
    transition: fill 0.3s ease; /* Плавная смена цвета */
    cursor: pointer;
}


.map-point:hover {
    r: 14;
    stroke: #ffffff;
    stroke-width: 2px;
    /* Убираем жесткую замену цвета на hover, чтобы видеть статус опасности */
    filter: brightness(1.2); 
}

/* Стиль для фоновых регионов (Хабаровский край и др.) */
.neighbor-region {
    fill: #f4f7f6 !important; /* Светло-серый */
    stroke: #ffffff !important; /* Белые границы */
    stroke-width: 0.2px;
    transition: fill 0.3s ease; /* Плавная смена цвета */
    cursor: pointer;
	fill: #444;
}
#map-container:active {
    cursor: grabbing;
}

#main-svg {
    display: block;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    /* max-width: 100vh;  <-- УДАЛИТЕ ИЛИ ЗАКОММЕНТИРУЙТЕ ЭТУ СТРОКУ */
    height: auto;
}

#map-container {
    width: 100%;    /* Гарантируем полную ширину */
    height: 90vh;   /* Или любая удобная вам высота */
    overflow: hidden;
    position: relative;
	cursor: grab;
    touch-action: none; /* Важно для мобильных и корректного скролла */
}

/*Всплывающее окно*/
/* Контейнер панели */
.sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100%;
    background-color: #ffffff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    transition: left 0.3s ease;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
    /* Добавьте эти строки: */
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
}

/* Чтобы заголовок не уезжал при скролле (опционально) */
.sidebar-header {
    position: sticky;
    top: -20px;
    background: white;
    padding-bottom: 10px;
    z-index: 10;
    border-bottom: 1px solid #eee;
}

/* Класс, который добавлять через JS */
.sidebar.active {
    left: 0;
}

/* Кнопка закрытия (крестик) */
.close-btn {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
	z-index: 10001; /* Убедитесь, что крестик поверх всего */
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.close-btn:hover { color: #333; transform: scale(1.1);}

        .river-line { fill: none; stroke: #3498db; stroke-width: 2px; stroke-linejoin: round; }
 /*       .map-point { r: 6; fill: #e74c3c; stroke: #fff; stroke-width: 2px; cursor: pointer; transition: r 0.3s; }*/
 /*       .map-point:hover { r: 9; fill: #c0392b; }*/
        .station-label { font-family: Arial, sans-serif; font-size: 12px; fill: #333; pointer-events: none; }
		
/************************************************/
/* Верхняя плашка */
.map-top-panel {
    position: fixed;
    top: 80px; /* под фильтрами */
    left: 0px;
    right: 0px;
    background: #eceff1;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 10px 15px;
/*    box-shadow: 0 2px 5px rgba(0,0,0,0.2);*/
    z-index: 100;
/*    border-radius: 4px;*/
}

.menu-toggle {
    cursor: pointer;
    width: 30px;
    height: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background: #333;
    border-radius: 3px;
}

.panel-title {
    margin-left: 20px;
    font-weight: bold;
    font-size: 18px;
}

/* Список постов в сайдбаре */
.stations-list {
    list-style: none;
    padding: 0;
    margin-top: 20px;
	font-size: 12px;
}

.station-item {
    padding: 5px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.station-item:hover {
    background: #f0f4f8;
    color: #007bff;
}

/* Плавный переход для карты */
#viewport {
    transition: transform 0.3s ease-out; /* Чтобы карта "летала" к точкам */
}
/************************************************/
/* Стили для легенды в углу */
.map-legend {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.5); /* Белый фон с прозрачностью 70% */
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000; /* Поверх всех слоев (кроме активного сайдбара) */
    pointer-events: none; /* Чтобы легенда не мешала кликать по карте под ней */
    backdrop-filter: blur(4px); /* Эффект размытия заднего фона (для современных браузеров) */
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-circle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    border: 1px solid rgba(0, 0, 0, 0.2); /* Тонкая обводка кружков */
}

.legend-text {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

/* Скрытие легенды на очень маленьких экранах, если она мешает */
@media (max-width: 480px) {
    .map-legend {
        bottom: 10px;
        left: 10px;
        padding: 8px;
        font-size: 11px;
    }
    .legend-circle {
        width: 10px;
        height: 10px;
    }
}	

.city-label {
    font-size: 20px;
    color: #333;
    font-weight: 500;
	/*stroke-width: 0.2px;
	stroke: #ffffff;*/
}
    .back-btn { background: #455a64; color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; margin-bottom: 15px; font-weight: bold; width: 100%; transition: background 0.2s; }
    .back-btn:hover { background: #546e7a; }