/* 
 * Светлая минималистичная тема (по мотивам sample_interface)
 * 
 * Архитектура: Система построена на виджетах - переиспользуемых компонентах.
 * Виджеты имеют класс .chart-card и могут комбинироваться для создания страниц.
 */
:root {
    --bg: #ffffff;
    --fg: #1e2330;
    --muted: #616b7a;
    --accent: #2f6df6;
    --border: #e8ecf3;
    --tab: #f6f8fc;
    --tab-active: #eef2fb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Arial, sans-serif;
    padding: 0;
    min-height: 100vh;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Вкладки */
.tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 0px 16px;
    position: sticky;
    top: 0;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    z-index: 10000; /* Выше бургер-меню, чтобы кнопки были видны поверх */
    background: var(--bg);
}

/* Когда меню открыто - страница не меняется, меню просто накладывается поверх */
body.burger-menu-open {
    overflow: hidden; /* Блокируем прокрутку */
}

.tabs-title {
    font-size: 30px;
    font-weight: 700;
    color: var(--fg);
    white-space: nowrap;
    flex-shrink: 0;
    z-index: 2;
    margin-right: 4px;
    line-height: 1.2;
    height: auto;
    display: flex;
    align-items: center;
}

/* Кнопка бургер-меню (скрыта по умолчанию, показывается на мобильных) */
.burger-menu-button {
    display: none; /* Скрыта по умолчанию, показывается на мобильных */
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--tab);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, transform 0.06s;
    box-sizing: border-box;
    position: relative;
    z-index: 10002; /* Выше всего, чтобы всегда была видна */
}

.burger-menu-button:hover {
    background: var(--tab-active);
    border-color: #d0d8eb;
}

.burger-menu-button:active {
    transform: translateY(1px);
}

.burger-menu-button svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

/* Меню-бургер (скрыто по умолчанию, показывается на мобильных) */
.burger-menu-overlay {
    display: none; /* Скрыт по умолчанию */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000; /* Ниже шапки, но выше контента */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.burger-menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.burger-menu {
    display: none; /* Скрыто по умолчанию */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg);
    z-index: 10001; /* Выше overlay, выше шапки */
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

.burger-menu[aria-hidden="false"] {
    transform: translateX(0);
}

.burger-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--tab);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, transform 0.06s;
}

.burger-menu-close:hover {
    background: var(--tab-active);
    border-color: #d0d8eb;
}

.burger-menu-close:active {
    transform: translateY(1px);
}

.burger-menu-close svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.burger-menu-header {
    padding: 16px 16px 0px 16px;
    display: flex;
    justify-content: flex-end;
}

.burger-menu-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: calc(100% - 72px);
    min-height: 0;
}

.burger-menu-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.burger-menu-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    flex-shrink: 0;
}

.burger-menu-item {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--tab);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background .15s, color .15s, border-color .15s, transform .06s, box-shadow .15s;
    height: 40px;
    position: relative;
    font-family: inherit;
}

.burger-menu-item:hover {
    border-color: #d0d8eb;
    color: var(--fg);
}

.burger-menu-item:active {
    transform: translateY(1px);
}

.burger-menu-item-name {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: inherit;
}

.burger-menu-item.active {
    background: var(--tab-active);
    color: var(--fg);
    border-color: #d8def0;
}

.burger-menu-item .positioning-beacon-name {
    font-size: 14px;
    font-weight: 500;
}

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--tab);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background .15s, color .15s, border-color .15s, transform .06s, box-shadow .15s;
    height: 40px;
    position: relative;
    font-family: inherit;
}

.tab[aria-selected="true"] {
    background: var(--tab-active);
    color: var(--fg);
    border-color: #d8def0;
}

.tab:hover {
    border-color: #d0d8eb;
    color: var(--fg);
}

.tab:active {
    transform: translateY(1px);
}

.tab .title {
    font-weight: 500;
    letter-spacing: 0.2px;
    font-size: 16px;
    padding: 0 10px;
}

.content {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px); /* Высота экрана минус шапка */
}

.tab-content {
    display: none;
    flex: 1 1 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

.tab-content[aria-hidden="false"] {
    display: flex !important;
}

.empty-tab-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: var(--muted);
    font-size: 18px;
}

/* ==========================================
   ВКЛАДКА "ТЕСТ"
   ========================================== */

.test-widgets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    width: 100%;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    padding-bottom: 16px;
}

/* Виджет "Работники за неделю" занимает половину ширины (2 колонки из 4) */
.test-widget-wide {
    grid-column: span 2;
    max-height: 50vh; /* Ограничиваем высоту до половины экрана */
}

.test-widget-wide .chart-container {
    max-height: calc(50vh - 80px); /* Учитываем padding и заголовок */
}

.test-widget-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--muted);
    font-size: 14px;
}

.container {
    margin: 0;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

.overview-container {
    flex-direction: row;
    gap: 16px;
    align-items: stretch;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.positioning-panel {
    flex: 0 0 25%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-height: 100%;
}

.map-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-right: 0;
}

/* Виджеты */
.info-card {
    background: var(--bg);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

/* Базовый класс для всех виджетов */
.chart-card {
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.info-card h2,
.chart-card h2 {
    color: var(--fg);
    margin-bottom: 10px;
    font-size: 20px;
    font-weight: 600;
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chart-count {
    background: #2196F3;
    color: white;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    border: 2px solid #1976D2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Графики в ряд */
.charts-section-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;
    align-items: stretch;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 180px;
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-container canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.pie-chart-section .chart-card {
    display: flex;
    flex-direction: column;
}

.pie-chart-container {
    position: relative;
    flex: 1;
    min-height: 180px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pie-chart-container canvas {
    max-width: 70%;
    max-height: 60%;
    flex-shrink: 1;
}

.positioning-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    height: 100%;
    max-height: 100%;
}

.positioning-search-container {
    padding: 12px 12px 12px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.positioning-search-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--fg);
    background: var(--tab);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.positioning-search-input:focus {
    border-color: var(--accent);
    background: var(--bg);
}

.positioning-search-input::placeholder {
    color: var(--muted);
}

.positioning-content {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    max-height: 100%;
    padding: 12px 12px 12px 12px;
}

.positioning-content::-webkit-scrollbar {
    width: 6px;
}

.positioning-content::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 3px;
}

.positioning-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.positioning-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.positioning-geofence {
    margin-bottom: 8px;
}

.positioning-geofence-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--tab);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.positioning-geofence-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.positioning-geofence-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.positioning-geofence-header:hover {
    border-color: #d0d8eb;
}

.positioning-chevron {
    transition: transform 0.2s ease;
    color: var(--muted);
    flex-shrink: 0;
}

.positioning-chevron.expanded {
    transform: rotate(90deg);
}

.positioning-count-badge {
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    padding: 0;
    flex-shrink: 0;
}

.positioning-beacons {
    padding: 8px 0 0 0;
    margin-top: 4px;
    display: none;
}

.positioning-beacons.expanded {
    display: block;
}

.positioning-beacon {
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.15s, border-color 0.15s;
    overflow: hidden;
}

.positioning-beacon:hover {
    background: var(--tab);
    border-color: #d0d8eb;
}

.positioning-beacon:last-child {
    margin-bottom: 0;
}

.positioning-beacon-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
}

.positioning-beacon-status-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.positioning-beacon-status-icon.online {
    background: #4CAF50;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
}

.positioning-beacon-status-icon.offline {
    background: #F44336;
    box-shadow: 0 0 4px rgba(244, 67, 54, 0.5);
}

.positioning-beacon-name {
    color: var(--fg);
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.positioning-beacon-chevron {
    margin-left: 8px;
    flex-shrink: 0;
    transition: transform 0.2s;
    color: var(--muted);
}

.positioning-beacon-chevron.expanded {
    transform: rotate(90deg);
}

.positioning-beacon-details {
    display: none;
    padding: 12px;
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid #e8ecf4;
}

.positioning-beacon-details.expanded {
    display: block;
}

.positioning-beacon-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

.positioning-beacon-detail-row:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: var(--muted);
    font-weight: 500;
    margin-right: 8px;
    flex-shrink: 0;
}

.detail-value {
    color: var(--fg);
    font-weight: 400;
    text-align: right;
    flex: 1;
    min-width: 0;
}

.detail-value.small {
    font-size: 11px;
    word-break: break-all;
}

.detail-value.status-online {
    color: #4CAF50;
    font-weight: 500;
}

.detail-value.status-offline {
    color: #F44336;
    font-weight: 500;
}

/* Метки на связи - выпадающий список */
.positioning-beacon-detail-row.connected-beacons-row {
    position: relative;
}

.positioning-beacon-detail-row.connected-beacons-row.clickable {
    cursor: pointer;
    transition: background 0.15s;
    margin: 0 -10px;
    padding: 6px 10px;
    border-radius: 6px;
}

.positioning-beacon-detail-row.connected-beacons-row.clickable:hover {
    background: var(--tab);
}

.connected-beacons-chevron {
    margin-left: 4px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.connected-beacons-chevron.expanded {
    transform: rotate(90deg);
}

.connected-beacons-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin: 4px 0 0 0;
    padding: 0;
}

.connected-beacons-list.expanded {
    max-height: 500px;
    padding: 8px 0 0 0;
}

.connected-beacon-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--tab);
    border-radius: 6px;
    margin-bottom: 6px;
    gap: 12px;
}

.connected-beacon-item:last-child {
    margin-bottom: 0;
}

.connected-beacon-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
    flex: 1;
}

.connected-beacon-serial {
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}

.battery-bar {
    width: 60px;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-left: 8px;
    flex-shrink: 0;
}

.battery-fill {
    height: 100%;
    background: #4CAF50;
    transition: width 0.3s ease;
}

.positioning-beacon-status {
    color: var(--muted);
    font-size: 12px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Стили для popup радаров на карте */
.leaflet-popup-content-wrapper {
    background: var(--bg);
    border-radius: 8px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    min-width: 200px;
    max-width: 250px;
}

.radar-popup-content {
    padding: 0;
}

.radar-popup-header {
    padding: 8px 30px 8px 10px;  /* Отступ справа для кнопки закрытия */
}

.radar-popup-header strong {
    color: var(--fg);
    font-size: 13px;
    font-weight: 500;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.radar-popup-details {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.02);
}

.radar-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

.radar-popup-row:last-child {
    margin-bottom: 0;
}

.popup-label {
    color: var(--muted);
    font-weight: 500;
    margin-right: 8px;
    flex-shrink: 0;
}

.popup-value {
    color: var(--fg);
    font-weight: 400;
    text-align: right;
    flex: 1;
    min-width: 0;
}

.popup-value.small {
    font-size: 11px;
    word-break: break-all;
}

.battery-bar-popup {
    width: 60px;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-left: 8px;
    flex-shrink: 0;
}

.battery-bar-popup .battery-fill {
    height: 100%;
    background: #4CAF50;
    transition: width 0.3s ease;
}

/* Стили для категорий обслуживания */
.maintenance-category {
    margin-bottom: 8px;
}

.maintenance-category:last-child {
    margin-bottom: 0;
}

/* Стили для пустых категорий */
.maintenance-category.empty .positioning-geofence-header.disabled {
    cursor: default;
}

.empty-positioning {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* Отступы для больших экранов (все, кроме мобильной версии) */
@media (min-width: 481px) {
    .positioning-search-container {
        padding: 16px 16px 16px 16px;
    }
    
    .positioning-content {
        padding: 16px 16px 16px 16px;
    }
}

/* Адаптивность для виджета позиционирования */
@media (max-width: 1024px) {
    /* Виджет позиционирования */
    .overview-container {
        flex-direction: column;
    }
    
    .positioning-panel {
        flex: 0 0 auto;
        max-height: 300px;
    }
    
    .map-panel {
        flex: 1;
    }
    
    /* Графики и карты */
    .charts-section-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .pie-chart-section {
        width: 100%;
        max-width: 100%;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .test-widgets-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .chart-container {
        height: 280px;
    }
    
    .pie-chart-container {
        height: 280px;
    }
    
    .map-container {
        min-height: 400px;
        max-height: 100%;
    }
    
    .map-card {
        max-height: 100%;
    }
    
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Устройства */
    .devices-filters {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px;
    }
    
    .devices-filter-search {
        grid-column: 1 / -1;
    }
    
    .devices-list {
        grid-template-columns: 1fr !important;
    }
    
    .device-item {
        grid-column: 1 / -1;
        grid-template-columns: 1fr !important;
        gap: 8px;
        padding: 12px 0;
    }
    
    .device-type-column,
    .device-status-column,
    .device-activity-column,
    .device-battery-column {
        text-align: left;
    }
    
    .device-type-column {
        align-items: flex-start;
    }
    
    .device-status-column,
    .device-activity-column,
    .device-battery-column,
    .device-checkbox-column {
        justify-content: flex-start !important;
    }
    
    /* Показываем названия столбцов на планшетах */
    .device-status-column::before {
        content: 'Статус:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
        margin-right: 8px;
    }
    
    .device-activity-column::before {
        content: 'Движение:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
        margin-right: 8px;
    }
    
    .device-battery-column::before {
        content: 'Заряд:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
        margin-right: 8px;
    }
    
    .device-checkbox-column::before {
        content: 'Тестовая:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
        margin-right: 8px;
    }
}

.map-card {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.map-container {
    position: relative;
    flex: 1;
    min-height: 500px;
    border-radius: 12px;
    overflow: hidden;
}

.map-container #map {
    width: 100% !important;
    height: 100% !important;
    min-height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.map-container #map {
    border-radius: 8px;
    background: var(--bg) !important;
}

/* Убираем серый фон Leaflet когда нет тайлов */
.leaflet-container {
    background: var(--bg) !important;
}

/* Кастомная кнопка "Показать все радары" на карте обслуживания */
.leaflet-control-show-all {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
}

.leaflet-control-show-all-button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.leaflet-control-show-all-button:hover {
    background: var(--tab-active);
    color: var(--accent);
}

.leaflet-control-show-all-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Стили для маркеров Leaflet */
.beacon-marker {
    background: transparent !important;
    border: none !important;
}

.leaflet-popup-content {
    font-family: inherit;
    font-size: 14px;
}

.leaflet-popup-content strong {
    color: var(--fg);
    font-weight: 600;
}

/* Стили для меток геозон */
.geofence-count-label {
    display: flex;
    align-items: center;
    justify-content: center;
}

.geofence-count-badge {
    background: #2196F3;
    color: white;
    font-weight: 700;
    font-size: 20px;
    text-align: center;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid #1976D2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Стили для маркеров радаров */
.radar-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-marker-badge {
    background: #2196F3;
    color: white;
    text-align: center;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid #1976D2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    cursor: pointer;
}

.radar-marker-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.radar-marker-badge svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Цветовая палитра для иконок радаров по уровню заряда */
.radar-marker-badge.battery-red {
    background: #F44336;
    border-color: #D32F2F;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.radar-marker-badge.battery-red:hover {
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.5);
}

.radar-marker-badge.battery-orange {
    background: #FF9800;
    border-color: #F57C00;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.radar-marker-badge.battery-orange:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.5);
}

.radar-marker-badge.battery-blue {
    background: #2196F3;
    border-color: #1976D2;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.radar-marker-badge.battery-blue:hover {
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.5);
}

.radar-marker-badge.battery-green {
    background: #4CAF50;
    border-color: #388E3C;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.radar-marker-badge.battery-green:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.5);
}

.radar-marker-badge.battery-gray {
    background: #9E9E9E;
    border-color: #757575;
    box-shadow: 0 2px 8px rgba(158, 158, 158, 0.3);
    opacity: 0.8;
}

.radar-marker-badge.battery-gray:hover {
    box-shadow: 0 4px 12px rgba(158, 158, 158, 0.5);
}

.pie-chart-container canvas {
    display: block !important;
    max-width: 100%;
    max-height: 100%;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.info-item {
    padding: 16px;
    background: var(--tab);
    border-radius: 12px;
    border: 1px dashed var(--border);
    transition: background 0.15s, border-color 0.15s;
}

.info-item:hover {
    background: var(--tab-active);
    border-color: #d0d8eb;
}

.info-item strong {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}

.info-item span {
    display: block;
    color: var(--fg);
    font-size: 18px;
    font-weight: 600;
    text-align: left;
}


/* ==========================================
   АДАПТИВНЫЙ ДИЗАЙН
   ========================================== */

/* Ноутбуки (1024px - 1400px) */
@media (max-width: 1400px) and (min-width: 1025px) {
    .info-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Планшеты в портретной ориентации (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .tabs {
        padding: 16px 16px 0px 16px;
    }
    
    /* Фиксируем высоту контента с учетом шапки */
    
    /* Карта и список позиционирования должны делить экран 50/50 */
    .overview-container {
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    .positioning-panel {
        flex: 0 0 calc(50% - 8px) !important;
        max-height: calc(50% - 8px) !important;
        min-height: 0 !important;
    }
    
    .map-panel {
        flex: 0 0 calc(50% - 8px) !important;
        max-height: calc(50% - 8px) !important;
        min-height: 0 !important;
    }
    
    .map-container {
        min-height: 0 !important;
        max-height: 100% !important;
        height: 100% !important;
    }
    
    .map-card {
        min-height: 0 !important;
        max-height: 100% !important;
        height: 100% !important;
    }
}

/* Планшеты и большие телефоны (768px) */
@media (max-width: 768px) {

    .tabs {
        padding: 16px 16px 0px 16px;
        flex-wrap: wrap;
        gap: 6px;
        position: relative;
    }

    .tabs-title {
        margin-right: 8px;
    }

    .tab {
        padding: 8px 12px;
        height: 36px;
        flex: 0 0 auto;
    }

    .tab .title {
        font-size: 14px;
        padding: 0;
    }

    .burger-menu-button {
        display: flex;
    }

    .burger-menu-overlay {
        display: block;
    }

    .burger-menu {
        display: flex;
        flex-direction: column;
    }
    
    .tab:not(.logout-button) {
        display: none !important;
    }
    
    .tab.logout-button {
        display: none !important;
    }

    .charts-section-row {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .pie-chart-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .test-widgets-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .chart-card h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .chart-container {
        height: 240px;
        margin-top: 10px;
    }
    
    .pie-chart-container {
        height: 240px;
        margin-top: 10px;
    }
    
    .map-container {
        min-height: 350px;
    }
    
    .map-card {
        min-height: 350px;
    }
    
    /* Устройства */
    .devices-filters {
        grid-template-columns: 1fr;
}

    /* Устройства - полностью вертикальное отображение */
    .device-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 8px 12px; !important;
        border: 1px dashed var(--border); !important;
        border-radius: 12px !important;
        margin-bottom: 12px !important;
        grid-template-columns: none !important;
    }

    .device-type-column,
    .device-status-column,
    .device-activity-column,
    .device-battery-column,
    .device-checkbox-column {
        width: 100%;
    }

    .device-status-column,
    .device-activity-column,
    .device-battery-column,
    .device-checkbox-column {
        display: flex;
        align-items: center;
        justify-content: flex-start !important; /* По левому краю на мобильной */
        gap: 8px;
    }

    .device-status-column::before {
        content: 'Статус:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
    }

    .device-activity-column::before {
        content: 'Движение:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
    }

    .device-battery-column::before {
        content: 'Заряд:';
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
    }

    
    /* Вкладка "Обслуживание" - разделение экрана пополам */
    #maintenance .overview-container {
        flex-direction: column;
        gap: 16px;
        padding: 0;
    }
    
    #maintenance .positioning-panel {
        flex: 0 0 calc(50% - 8px);
        min-height: 0;
        max-height: calc(50% - 8px);
        overflow-y: auto;
    }
    
    #maintenance .map-wrapper {
        flex: 0 0 calc(50% - 8px);
        min-height: 0;
        max-height: calc(50% - 8px);
    }
    
    #maintenance .chart-card {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    #maintenance .positioning-content {
        flex: 1;
        overflow-y: auto;
    }
    
    #maintenanceMap {
        height: 100% !important;
    }
    
    /* Вкладка "Обзор" - список сверху, карта снизу */
    #overview .overview-container {
        flex-direction: column;
        gap: 16px;
        padding: 0;
    }
    
    #overview .positioning-panel {
        flex: 0 0 calc(50% - 8px);
        min-height: 0;
        max-height: calc(50% - 8px);
        overflow-y: auto;
    }
    
    #overview .map-wrapper {
        flex: 0 0 calc(50% - 8px);
        min-height: 0;
        max-height: calc(50% - 8px);
    }
    
    #overview .chart-card {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    #overview .positioning-content {
        flex: 1;
        overflow-y: auto;
    }
    
    #map {
        height: 100% !important;
    }
}

/* Планшеты и телефоны средней ширины (601px - 768px) */
@media (max-width: 768px) and (min-width: 601px) {
    /* Карта и список должны делить экран 50/50 */
    .overview-container {
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    .positioning-panel {
        flex: 0 0 calc(50% - 8px) !important;
        max-height: calc(50% - 8px) !important;
    }
    
    .map-panel {
        flex: 0 0 calc(50% - 8px) !important;
        max-height: calc(50% - 8px) !important;
    }
    
    .map-container {
        min-height: 0 !important;
        max-height: 100% !important;
        height: 100% !important;
    }
    
    .map-card {
        min-height: 0 !important;
        max-height: 100% !important;
        height: 100% !important;
    }
}

/* Мобильные телефоны (600px) */
@media (max-width: 600px) {

    .tabs-title {
        margin-right: 6px;
    }

    .tab .title {
        font-size: 13px;
    }
    
    .chart-card h2 {
    font-size: 16px;
        margin-bottom: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-container,
    .pie-chart-container {
        height: 200px;
        margin-top: 8px;
    }

    .map-container {
        min-height: 300px;
    }
    
    .map-card {
        min-height: 300px;
    }

    .chart-count {
        font-size: 12px;
        padding: 4px 10px;
    }
    
    .charts-section-row,
    .pie-chart-section {
        gap: 10px;
        margin-bottom: 10px;
    }
}

/* Маленькие мобильные телефоны (480px) */
@media (max-width: 480px) {

    .tabs-title {
        margin-right: 4px;
    }

    .tabs {
        padding: 16px 16px 0px 16px;
    }

    .tab {
        padding: 5px 8px;
        height: 30px;
    border-radius: 8px;
    }

    .tab .title {
        font-size: 12px;
    }
    
    .chart-card h2 {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .chart-container,
    .pie-chart-container {
        height: 180px;
        margin-top: 6px;
    }

    .map-container {
        min-height: 250px;
    }
    
    .map-card {
        min-height: 250px;
    }
    
    .charts-section-row,
    .pie-chart-section {
        gap: 8px;
        margin-bottom: 8px;
    }
}

/* ==========================================
   ВКЛАДКА "УСТРОЙСТВА"
   ========================================== */

.devices-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 16px;
}

.devices-filters {
    display: grid;
    /* Автоматически подстраивается через JavaScript - при добавлении фильтра ничего менять не нужно */
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 12px;
    flex-shrink: 0;
    margin-bottom: 16px;
}

.devices-list-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    padding: 0 16px 8px 16px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 8px;
}

.devices-filter-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
    margin-bottom: 6px;
    text-align: center;
}

.devices-filter-group {
    min-width: 0;
}

.devices-filter-search {
    min-width: 0;
}

.devices-filter-select,
.devices-search-input {
    padding: 10px 14px;
    font-size: 14px;
    color: var(--fg);
    background: var(--tab);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.devices-filter-select:focus,
.devices-search-input:focus {
    border-color: var(--accent);
    background: var(--bg);
}

.devices-search-input::placeholder {
    color: var(--muted);
}


.devices-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    display: grid;
    /* Автоматически подстраивается через JavaScript - при добавлении фильтра ничего менять не нужно */
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: start;
}

.device-item {
    display: grid;
    grid-column: 1 / -1;
    /* Автоматически подстраивается через JavaScript - все 4 колонки равномерные */
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    border: 1px dashed var(--border);
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.15s, border-color 0.15s;
}

.device-empty-column {
    /* Пустая колонка для растяжения строки на весь виджет */
    min-width: 0;
}

.device-item:first-child {
    margin-top: 4px;
}

.device-item:last-child {
    margin-bottom: 0;
}

.device-item:hover {
    background: var(--tab);
    border-color: #d0d8eb;
}

.device-item:last-child {
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.device-item:hover {
    background: var(--tab);
    border-color: var(--border);
}

.device-name-column {
    min-width: 0;
}

.device-type-column {
    min-width: 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.device-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
    max-width: 100%;
}

.device-serial {
    font-size: 13px;
    color: var(--muted);
}

.device-status-column,
.device-activity-column,
.device-battery-column {
    font-size: 14px;
    color: var(--fg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-checkbox-column {
    display: flex;
    justify-content: center; /* По левому краю на всех разрешениях */
    gap: 8px;
}

/* Показываем метку "Тестовая:" на десктопе */
.device-checkbox-column::before {
    content: 'Тестовая:';
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.device-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2196F3;
}

.device-status-empty {
    color: var(--muted);
    font-style: italic;
}

.device-status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.device-status-active {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
}

.device-status-inactive {
    background: rgba(244, 67, 54, 0.1);
    color: #F44336;
}

.device-status-moving {
    background: rgba(33, 150, 243, 0.1);
    color: #2196F3;
}

.device-status-stationary {
    background: rgba(158, 158, 158, 0.1);
    color: #9E9E9E;
}

.device-battery-level {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
}

.device-battery-high {
    color: #4CAF50;
}

.device-battery-medium {
    color: #FF9800;
}

.device-battery-low {
    color: #F44336;
}

.empty-devices {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
    color: var(--muted);
    font-size: 15px;
}

/* Чекбоксы для меток на вкладке "Устройства" */
.devices-checkboxes {
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.beacon-checkbox-item {
    display: inline-flex;
    align-items: center;
}

.beacon-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--fg);
}

.beacon-checkbox-name {
    font-weight: 500;
}

.beacon-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2196F3;
}

.device-checkbox-column {
    display: flex;
    align-items: center;
    justify-content: center; /* По левому краю на всех разрешениях */
    gap: 8px;
}

/* Показываем метку "Тестовая:" на десктопе */
.device-checkbox-column::before {
    content: 'Тестовая:';
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.device-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2196F3;
}

/* Пагинация устройств */
.devices-pagination {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: var(--bg);
}

.pagination-info {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-button {
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--fg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 44px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-button:hover {
    border-color: #d0d8eb;
}

.pagination-button.active {
    background: var(--tab-active);
    color: var(--fg);
    border-color: #d8def0;
    font-weight: 600;
}

.pagination-button:active {
    transform: scale(0.98);
}

.pagination-ellipsis {
    padding: 0 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

/* Кастомные селекты */
.custom-select {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    z-index: 1;
    display: block;
}

.custom-select.open {
    z-index: 1000;
}

.custom-select-button {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--tab);
    color: var(--fg);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.custom-select-button::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
    transition: transform 0.15s;
    flex-shrink: 0;
    margin-left: 8px;
}

.custom-select.open .custom-select-button::after {
    transform: rotate(180deg);
}

.custom-select-button:hover,
.custom-select.open .custom-select-button {
    border-color: var(--accent);
    background: var(--bg);
}

.custom-select-dropdown {
    position: absolute;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    box-sizing: border-box;
    top: calc(100% + 4px);
    left: 0;
    right: auto;
    width: 100%;
}

.custom-select-option {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
    color: var(--fg);
    font-family: inherit;
    box-sizing: border-box;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.custom-select-option:hover {
    background: var(--tab);
}

.custom-select-option.selected {
    background: var(--tab-active);
    color: var(--accent);
    font-weight: 500;
}

/* ==========================================
   АВТОРИЗАЦИЯ
   ========================================== */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 30px;
    font-weight: 700;
    color: var(--fg);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--fg);
}

.login-form-group input {
    padding: 12px 16px;
    font-size: 16px;
    color: var(--fg);
    background: var(--tab);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.login-form-group input:focus {
    border-color: var(--accent);
    background: var(--bg);
}

.login-form-group input::placeholder {
    color: var(--muted);
}

.login-error {
    padding: 12px 16px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 8px;
    color: #F44336;
    font-size: 14px;
    text-align: center;
    display: none;
}

.login-button {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.06s;
    font-family: inherit;
    margin-top: 8px;
}

.login-button:hover {
    background: #2563eb;
}

.login-button:active {
    transform: translateY(1px);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.logout-button {
    margin-left: auto;
}

.logout-button:hover {
    background: rgba(244, 67, 54, 0.1);
    border-color: rgba(244, 67, 54, 0.3);
    color: #F44336;
}

@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
    }
    
    .login-header h1 {
        font-size: 24px;
    }
}


