/* Основные стили */
:root {
    --primary-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --text-color: #333;
    --border-color: #e0e0e0;
    --card-shadow: 0 4px 12px rgba(0,0,0,0.08);
    --toolbar-height: 40px;
    --mobile-toolbar-height: 32px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    flex: 1;
    min-width: 250px;
}

    .header-left h2 {
        margin: 0;
        font-size: 1.5rem;
        color: #333;
    }

    .header-left p {
        margin: 5px 0 0 0;
        color: #666;
        font-size: 0.9rem;
    }

.header-right {
    display: flex;
    align-items: center;
    gap: 13px;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: space-around;
    padding-top: 15px;
}

/* Стили для состояния "нет связи" - для значений параметров */
.no-connection {
    /* Для контейнера с классом no-connection */
    border: 1px solid #ff00ff !important;
    position: relative;
}

/* Стиль для самого значения (текста) когда нет связи */
.value-display.no-connection,
.card .value-display.no-connection {
    background-color: #ff00ff !important;
    color: #ffffff !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    text-align: center !important;
    display: inline-block !important;
    min-width: 100px !important;
    box-shadow: 0 2px 4px rgba(255, 0, 255, 0.3) !important;
    position: relative;
    z-index: 2;
}

/* Эффект пульсации для привлечения внимания */
.value-display.no-connection {
    animation: pulse-fuchsia 2s infinite !important;
}

@keyframes pulse-fuchsia {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 255, 0.7);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(255, 0, 255, 0);
        transform: scale(1.02);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 255, 0);
        transform: scale(1);
    }
}

/* Иконка предупреждения рядом со значением */
.value-display.no-connection::before {
    content: '⚠️ ';
    margin-right: 5px;
    font-size: 1.1em;
}

/* Для заголовков карточек при отсутствии связи */
.card h5:has(+ .value-display.no-connection) {
    color: #ff00ff !important;
    font-weight: 600 !important;
}

/* Для всей карточки при отсутствии связи */
.card:has(.value-display.no-connection) {
    border-color: #ff00ff !important;
    background-color: rgba(255, 0, 255, 0.05) !important;
}

/* Стили для других элементов на странице при отсутствии связи */
.update-footer:has(~ .card .value-display.no-connection) {
    border-color: #ff00ff !important;
    color: #ff00ff !important;
}

/* Специфичные стили для разных типов значений */
.float-value.no-connection,
.int-value.no-connection {
    background: linear-gradient(135deg, #ff00ff, #cc00cc) !important;
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
}

/* Темный вариант для лучшей читаемости */
.value-display.no-connection.dark {
    background: linear-gradient(135deg, #cc00cc, #990099) !important;
    color: white !important;
    border: 2px solid #ff66ff !important;
}

/* Мобильная адаптация для состояния "нет связи" */
@media (max-width: 768px) {
    .value-display.no-connection {
        padding: 6px 8px !important;
        min-width: 80px !important;
        font-size: 0.9em !important;
    }

    @keyframes pulse-fuchsia-mobile {
        0% {
            box-shadow: 0 0 0 0 rgba(255, 0, 255, 0.5);
        }

        50% {
            box-shadow: 0 0 0 5px rgba(255, 0, 255, 0);
        }

        100% {
            box-shadow: 0 0 0 0 rgba(255, 0, 255, 0);
        }
    }

    .value-display.no-connection {
        animation: pulse-fuchsia-mobile 2s infinite !important;
    }
}

/* Статус соединения */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
}

.status-connected {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

.status-disconnected {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.3);
}

.status-connecting {
    background-color: var(--warning-color);
    color: var(--text-color);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
}

#statusIndicator {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

/* Сетки */
.real-time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

/* Карточки */
.card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
    display: flex;
    flex-direction: row;
    min-height: 120px;
}

.card1 {
    background: white;
    border-radius: 10px;
    padding: 15px;
    padding-top: 0px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 50px;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.card h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.value-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
    color: #333;
    border-radius: 8px;
    background: #f8f9fa;
    margin: 5px 0;
    padding: 10px;
    min-height: 50px;
    transition: all 0.3s;
}

.float-value {
    color: #2196F3;
}

.int-value {
    color: #4CAF50;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0px;
    padding-top: 0px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #888;
}

.update-time {
    font-style: italic;
}

.value-type {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
}

.temperature-type {
    background: #ffebee;
    color: #c62828;
}

.pressure-type {
    background: #e3f2fd;
    color: #1565c0;
}

.int-type {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Стили для bool значений */
.bool-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 13px;
    width: 100%;
    justify-content: center;
}

.bool-connected {
    background-color: #28a745;
    color: white;
}

.bool-disconnected {
    background-color: #dc3545;
    color: white;
}

/* Карточка графика */
.chart-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    height: auto; /* теперь карточка растёт вниз */
    min-height: 500px; /* сохраняем "как было" без слайдера */
    overflow: visible;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative; /* Добавлено для позиционирования минилегенды */
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.chart-container-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 300px;
    width: 100%;
    touch-action: pinch-zoom;
}

#combinedChart {
    width: 100% !important;
    height: 100% !important;
}

/* Панель инструментов тренда */
.trend-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

    .trend-toolbar::-webkit-scrollbar {
        height: 4px;
    }

    .trend-toolbar::-webkit-scrollbar-track {
        background: #e9ecef;
        border-radius: 2px;
    }

    .trend-toolbar::-webkit-scrollbar-thumb {
        background: #adb5bd;
        border-radius: 2px;
    }

.toolbar-btn {
    padding: 6px 10px;
    background: white;
    border: 1px solid #ced4da;
    color: #1d1c38;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    user-select: none;
    min-width: 32px;
    justify-content: center;
}

    .toolbar-btn:hover {
        background: #e9ecef;
        border-color: #adb5bd;
    }

    .toolbar-btn.active {
        background: #007bff;
        color: white;
        border-color: #007bff;
    }

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

.toolbar-icon {
    font-size: 14px;
}

.toolbar-text {
    display: inline;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: #dee2e6;
    margin: 0 4px;
    flex-shrink: 0;
}

/* Управление временным интервалом */
.time-range-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.time-display {
    font-size: 11px;
    color: #495057;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ced4da;
    min-width: 120px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.time-nav-btn {
    padding: 4px 8px;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-width: 28px;
    text-align: center;
}

    .time-nav-btn:hover {
        background: #e9ecef;
    }

/* Ползунки масштабирования */
.zoom-sliders {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.zoom-slider {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .zoom-slider label {
        font-size: 11px;
        color: #495057;
        min-width: 60px;
    }

    .zoom-slider input {
        flex: 1;
        height: 6px;
        -webkit-appearance: none;
        appearance: none;
        background: #dee2e6;
        border-radius: 3px;
        outline: none;
    }

        .zoom-slider input::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            background: #007bff;
            border-radius: 50%;
            cursor: pointer;
        }

        .zoom-slider input::-moz-range-thumb {
            width: 16px;
            height: 16px;
            background: #007bff;
            border-radius: 50%;
            cursor: pointer;
        }

/* Окно минилегенды - ИЗМЕНЕНО: позиционирование внутри chart-card */
.mini-legend-window {
    position: absolute; /* Изменено с fixed на absolute */
    top: 60px; /* Позиция от верха карточки графика */
    right: 20px; /* Позиция от правого края карточки графика */
    width: 300px;
    max-width: calc(100% - 40px); /* Адаптация под ширину карточки */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid #dee2e6;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
    max-height: 500px;
    overflow: hidden;
}

.mini-legend-header {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    border-radius: 8px 8px 0 0;
}

    .mini-legend-header h4 {
        margin: 0;
        font-size: 14px;
        color: #495057;
    }

.legend-close-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

    .legend-close-btn:hover {
        background: #e9ecef;
        color: #dc3545;
    }

.mini-legend-content {
    max-height: 400px;
    overflow-y: auto;
}

.mini-legend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

    .mini-legend-table th {
        background: #f1f3f5;
        padding: 8px 10px;
        text-align: left;
        font-weight: 600;
        color: #495057;
        border-bottom: 1px solid #dee2e6;
        position: sticky;
        top: 0;
    }

    .mini-legend-table td {
        padding: 8px 10px;
        border-bottom: 1px solid #f1f3f5;
    }

    .mini-legend-table tr:hover {
        background: #f8f9fa;
    }

    .mini-legend-table tr.selected {
        background: #e7f1ff;
    }

.legend-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.legend-color-cell {
    width: 20px;
}

.legend-color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

/* Курсор и подсказки */
.chart-cursor-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #007bff;
    pointer-events: none;
    z-index: 10;
    display: none;
}

.chart-cursor-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    pointer-events: none;
    z-index: 11;
    max-width: 200px;
    display: none;
}

.chart-selection-area {
    position: absolute;
    background: rgba(0, 123, 255, 0.1);
    border: 1px solid rgba(0, 123, 255, 0.3);
    pointer-events: none;
    z-index: 9;
    display: none;
}

.chart-loading-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    display: none;
    z-index: 12;
}

/* ДИАЛОГ ВЫБОРА ВРЕМЕНИ - ИСПРАВЛЕННЫЙ ВИЗУАЛ */
.time-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: none;
    width: 400px;
    max-width: 90vw;
    border: 1px solid #e1e5e9;
    overflow: hidden;
}

.time-dialog-header {
    padding: 18px 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

    .time-dialog-header h4 {
        margin: 0;
        font-size: 16px;
        color: #2c3e50;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 10px;
    }

        .time-dialog-header h4:before {
            content: "⏰";
            font-size: 18px;
        }

.time-dialog-content {
    padding: 24px;
    background: white;
}

.time-input-group {
    margin-bottom: 20px;
}

    .time-input-group:last-child {
        margin-bottom: 0;
    }

    .time-input-group label {
        display: block;
        margin-bottom: 8px;
        font-size: 14px;
        color: #495057;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 6px;
    }

        .time-input-group label:before {
            content: "📅";
            font-size: 14px;
        }

    .time-input-group input[type="datetime-local"] {
        width: 90%;
        padding: 15px 5px;
        border: 2px solid #e9ecef;
        border-radius: 8px;
        font-size: 15px;
        color: #495057;
        background: #f8f9fa;
        transition: all 0.3s ease;
        font-family: inherit;
    }

        .time-input-group input[type="datetime-local"]:focus {
            outline: none;
            border-color: #007bff;
            background: white;
            box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
        }

        .time-input-group input[type="datetime-local"]:hover {
            border-color: #adb5bd;
        }

.time-dialog-footer {
    padding: 20px 24px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    justify-content: space-evenly;
}

.dialog-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    min-width: 100px;
    transition: all 0.3s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dialog-btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: 1px solid #0056b3;
}

    .dialog-btn-primary:hover {
        background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 91, 187, 0.2);
    }

    .dialog-btn-primary:active {
        transform: translateY(0);
    }

.dialog-btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
    color: white;
    border: 1px solid #545b62;
}

    .dialog-btn-secondary:hover {
        background: linear-gradient(135deg, #545b62 0%, #3d4347 100%);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(108, 117, 125, 0.2);
    }

    .dialog-btn-secondary:active {
        transform: translateY(0);
    }

/* Оверлей для диалогов */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1999;
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.chart-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #666;
    flex-wrap: wrap;
    gap: 10px;
}

/* Элементы управления */
.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.time-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    min-width: 120px;
    background: white;
    cursor: pointer;
}

.refresh-btn {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .refresh-btn:hover {
        background: #0056b3;
    }

    .refresh-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        background: #6c757d;
    }

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

/* Переключатель автообновления */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

    .toggle-slider:before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 4px;
        bottom: 4px;
        background-color: white;
        transition: .4s;
        border-radius: 50%;
    }

input:checked + .toggle-slider {
    background-color: #28a745;
}

    input:checked + .toggle-slider:before {
        transform: translateX(24px);
    }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

/* Легенда */
.legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    user-select: none;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    white-space: nowrap;
}

    .legend-item:hover {
        background: #e9ecef;
        transform: translateY(-1px);
    }

.legend-hidden {
    opacity: 0.4;
    text-decoration: line-through;
    background: #f1f1f1;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Стили для кнопки скрытия оси */
.axis-toggle-btn {
    margin-left: 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
    background: #e9ecef;
    transition: background 0.2s;
    min-width: 20px;
    min-height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .axis-toggle-btn:hover {
        background: #dee2e6;
    }

/* Стили для осей на графике */
.y-axis-temperature {
    color: #c62828;
}

.y-axis-pressure {
    color: #1565c0;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding-bottom: 12px;
    }

    .header-left h2 {
        font-size: 1.3rem;
    }

    .header-left p {
        font-size: 0.85rem;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .connection-status {
        font-size: 12px;
        padding: 6px 12px;
        flex: 1;
    }

    #statusIndicator {
        font-size: 11px;
        flex-wrap: wrap;
        display: flex;
        gap: 5px;
        width: 100%;
    }
    /* Карточки в один столбец на мобильных */
    .real-time-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        padding: 12px;
        min-height: 110px;
    }

        .card h5 {
            font-size: 13px;
            margin-bottom: 8px;
        }

    .value-display {
        font-size: 24px;
        padding: 0px;
        min-height: 30px;
    }

    .card-footer {
        font-size: 10px;
        padding-top: 0px;
        flex-wrap: wrap;
        gap: 5px;
    }
    /* Панель инструментов на мобильных */
    .trend-toolbar {
        padding: 6px 8px;
        height: var(--mobile-toolbar-height);
        gap: 1px;
    }

    .toolbar-btn {
        padding: 4px 6px;
        font-size: 10px;
        min-width: 28px;
    }

    .toolbar-icon {
        font-size: 12px;
    }

    .toolbar-text {
        display: none;
    }

    .time-range-controls {
        gap: 4px;
    }

    .time-display {
        font-size: 10px;
        min-width: 90px;
        padding: 3px 6px;
    }

    .time-nav-btn {
        padding: 3px 6px;
        min-width: 24px;
        font-size: 10px;
    }
    /* График на мобильных */
    .chart-card {
        height: 450px;
        padding: 12px;
        border-radius: 10px;
    }

    .chart-container {
        min-height: 250px;
    }

    .chart-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 12px;
    }

    .chart-title {
        font-size: 14px;
        text-align: center;
    }
    /* Окно минилегенды на мобильных - ИЗМЕНЕНО */
    .mini-legend-window {
        width: calc(100% - 20px);
        right: 10px;
        left: auto;
        top: 50px;
        transform: none;
        max-width: none;
    }

    .mini-legend-table {
        font-size: 11px;
    }

        .mini-legend-table th,
        .mini-legend-table td {
            padding: 6px 8px;
        }
    /* Диалог выбора времени на мобильных */
    .time-dialog {
        width: 95vw;
        max-width: 95vw;
        border-radius: 10px;
    }

    .time-dialog-header {
        padding: 16px 20px;
    }

        .time-dialog-header h4 {
            font-size: 15px;
        }

    .time-dialog-content {
        padding: 20px;
    }

    .time-input-group {
        margin-bottom: 16px;
    }

        .time-input-group label {
            font-size: 13px;
        }

        .time-input-group input[type="datetime-local"] {
            padding: 14px 16px;
            font-size: 16px; /* Увеличиваем для удобства на мобильных */
        }

    .time-dialog-footer {
        padding: 16px 20px;
        flex-direction: column;
    }

    .dialog-btn {
        min-width: 100%;
        padding: 12px 16px;
        font-size: 15px;
    }
    /* Зум слайдеры на мобильных */
    .zoom-sliders {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .zoom-slider label {
        min-width: 50px;
        font-size: 10px;
    }
    /* Управление графиком */
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .time-select {
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }

    .refresh-btn {
        width: 100%;
        padding: 10px;
        font-size: 14px;
        justify-content: center;
    }

    .toggle-label {
        width: 100%;
        justify-content: space-between;
    }

    .chart-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding-top: 10px;
        margin-top: 10px;
    }
    /* Легенда с горизонтальной прокруткой на мобильных */
    .legend {
        max-height: 60px;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        padding: 5px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

        .legend::-webkit-scrollbar {
            height: 4px;
        }

        .legend::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 2px;
        }

        .legend::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 2px;
        }

    .legend-item {
        flex-shrink: 0;
        font-size: 10px;
        padding: 2px 6px;
        min-width: fit-content;
    }
    /* Адаптация для bool значений */
    .bool-status {
        font-size: 12px;
        padding: 5px 10px;
    }
    /* Информация о времени графика */
    #chartTimeInfo {
        text-align: center;
        width: 100%;
        font-size: 11px;
    }
}

/* Планшеты и маленькие ноутбуки */
@media (min-width: 769px) and (max-width: 1024px) {
    .real-time-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-card {
        height: 480px;
    }

    .chart-container {
        min-height: 280px;
    }

    .trend-toolbar {
        gap: 4px;
    }

    .toolbar-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .toolbar-text {
        display: inline;
    }
}

/* Большие экраны */
@media (min-width: 1025px) {
    .real-time-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }

    .trend-toolbar {
        gap: 6px;
    }

    .toolbar-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .dashboard-container {
        padding: 8px;
    }

    .card {
        padding: 10px;
    }

    .value-display {
        font-size: 22px;
    }

    .chart-card {
        height: 420px;
        padding: 10px;
    }

    .chart-container {
        min-height: 220px;
    }

    .trend-toolbar {
        padding: 4px 6px;
    }

    .toolbar-btn {
        padding: 3px 5px;
        min-width: 26px;
    }

    .legend-item {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* Портретная ориентация на мобильных */
@media (max-height: 700px) and (max-width: 768px) {
    .chart-card {
        height: 380px;
    }

    .chart-container {
        min-height: 200px;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-height: 500px) and (orientation: landscape) {
    .chart-card {
        height: 350px;
    }

    .chart-container {
        min-height: 180px;
    }

    .real-time-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .trend-toolbar {
        padding: 4px 6px;
        height: 36px;
    }

    .toolbar-text {
        display: none;
    }
}

/* Анимация обновления */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.updated {
    animation: pulse 0.5s ease;
}

/* Плавные переходы */
.card, .chart-card, .legend-item, .refresh-btn, .toolbar-btn {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Оптимизация для производительности */
.chart-container {
    contain: layout paint;
    will-change: transform;
}

/* Улучшение читаемости на мобильных */
@media (max-width: 768px) {
    body {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

/* Стили для инструментов графика */
.chart-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tool-btn {
    padding: 4px 8px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

    .tool-btn:hover {
        background: #e9ecef;
    }

/* Улучшенные тултипы */
.chart-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    border-radius: 6px !important;
    border: none !important;
    padding: 8px 12px !important;
    font-size: 12px !important;
}

/* Жесты для мобильных */
.gesture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

/* Индикатор загрузки */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

  