/* 
 * Светлая минималистичная тема (по мотивам 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: 12px 12px 0px 12px;
    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 .tabs {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 10001;
    background: var(--bg);
}

/* Скрываем кнопку открытия когда меню открыто (переопределяет медиа-запросы) */
body.burger-menu-open .burger-menu-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Скрываем кнопку "Выход" из шапки когда меню открыто */
body.burger-menu-open .logout-button {
    display: none !important;
}

.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 !important;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    min-height: 40px;
    background: var(--tab);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    padding: 10px;
    margin-left: auto;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, transform 0.06s;
    box-sizing: border-box;
}

.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 !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

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

.burger-menu {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: var(--bg);
    z-index: 9999;
    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: none;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    min-height: 40px;
    background: var(--tab);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    padding: 10px;
    margin-left: auto;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, transform 0.06s;
    box-sizing: border-box;
}

.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-content {
    padding: 16px;
    padding-top: 68px; /* Отступ сверху для кнопки закрытия в шапке (16px padding tabs + ~52px высота шапки) */
    padding-bottom: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

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

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

.burger-menu-item {
    width: 100%;
    text-align: left;
    cursor: pointer;
    position: relative;
}

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

.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);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    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: 16px;
    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;
    padding: 16px;
    padding-right: 16px; /* 16px + 6px (ширина скроллбара) */
    max-height: 100%;
    scrollbar-gutter: stable;
}

.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 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.15s, border-color 0.15s;
}

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

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

.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-status {
    color: var(--muted);
    font-size: 12px;
    margin-left: 8px;
    flex-shrink: 0;
}

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

/* Адаптивность для виджета позиционирования */
@media (max-width: 1024px) {
    .overview-container {
        flex-direction: column;
    }
    
    .positioning-panel {
        flex: 0 0 auto;
        max-height: 300px;
    }
    
    .map-panel {
        flex: 1;
    }
}

.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 */
.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);
}

.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);
    }
}

/* Планшеты в альбомной ориентации и небольшие ноутбуки (1024px) */
@media (max-width: 1024px) {
    .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;
    }
    
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Планшеты в портретной ориентации (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .content {
        padding: 14px;
    }
    
    .chart-card {
        padding: 20px;
    }
    
    .tabs {
        padding: 16px 16px 0px 16px;
    }
}

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

    .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 !important;
    }

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

    .burger-menu {
        display: flex !important;
        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 {
        padding: 18px;
    }

    .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;
    }
}

/* Мобильные телефоны (600px) */
@media (max-width: 600px) {
    .content {
        padding: 10px;
    }
    
    .tabs {
        padding: 16px 16px 0px 16px;
        position: relative;
    }

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

    .tab {
        display: none;
    }

    .tab.logout-button {
        display: none;
    }

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

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

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

    .tab .title {
        font-size: 13px;
    }

    .chart-card {
        padding: 15px;
    }
    
    .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) {
    .content {
        padding: 8px;
    }

    .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 {
        padding: 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);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    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-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;
}

/* Кастомные селекты */
.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;
}

/* Адаптивность для фильтров устройств */
@media (max-width: 1024px) {
    .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 {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .devices-filters {
        grid-template-columns: 1fr;
    }
}

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

.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;
    }
}


