/* ===========================================
   СИСТЕМА УМНЫЙ ДОМ - ПОЛНЫЕ СТИЛИ
   =========================================== */

/* Общие стили */
.system-wrapper {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Шапка системы */
.system-header {
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.system-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: #f1f5f9;
    border-radius: 30px;
    color: #475569;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.back-link:hover {
    background: #e2e8f0;
}

.system-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.system-icon {
    font-size: 48px;
}

.system-name {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
}

.system-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 5px;
    color: #64748b;
    font-size: 14px;
}

.mode-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #10b98120;
    color: #10b981;
    padding: 8px 16px;
    border-radius: 30px;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
}

/* Панель управления режимами */
.control-panel {
    background: white;
    border-radius: 50px;
    padding: 10px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.mode-switch {
    display: flex;
    gap: 5px;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 40px;
}

.mode-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    background: transparent;
    color: #64748b;
}

.mode-btn.active {
    background: #3b82f6;
    color: white;
}

.board-id-input {
    flex: 1;
    display: flex;
    gap: 10px;
    max-width: 500px;
}

.board-id-input input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 30px;
    font-family: monospace;
}

.config-actions {
    display: flex;
    gap: 10px;
}

/* Кнопки */
.btn-primary {
    padding: 10px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-outline {
    padding: 10px 20px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: #f1f5f9;
}

.btn-icon {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 30px !important;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    width: auto !important;
    height: auto !important;
}

.btn-icon:hover {
    background: #e2e8f0;
    border-color: #3b82f6;
    color: #3b82f6;
}

.btn-icon.danger {
    background: #fee2e2;
    color: #ef4444;
}

.btn-icon.danger:hover {
    background: #fecaca;
}

.btn-icon-small {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}
.dashboard-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.dashboard-modal.active {
    display: flex;
}

.dashboard-modal .modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.btn-icon-small.danger {
    color: #ef4444;
}

.btn-danger {
    padding: 10px 20px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Навигация */
.system-nav {
    background: white;
    border-radius: 15px;
    padding: 10px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    background: transparent;
    color: #64748b;
}

.nav-btn.active {
    background: #3b82f6;
    color: white;
}

/* Секции */
.system-section {
    background: transparent;
    display: none;
}

.system-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

/* ===========================================
   ДАШБОРД
   =========================================== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dashboard-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.dashboard-actions {
    display: flex;
    gap: 10px;
}

.dashboard-wrapper {
    height: calc(100vh - 200px);
    min-height: 600px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    height: 100%;
}

/* Левая панель с датчиками */
.sensors-panel {
    background: white;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.panel-header {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-indicator {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.mode-indicator.test {
    background: #f59e0b20;
    color: #f59e0b;
}

.sensors-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Группы комнат */
.room-group {
    margin-bottom: 20px;
}

.room-header {
    font-weight: 600;
    font-size: 14px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 8px;
    color: #2563eb;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.room-header i {
    transition: transform 0.2s;
}

.room-header.collapsed i {
    transform: rotate(-90deg);
}

.room-header span:last-child {
    margin-left: auto;
    font-size: 11px;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 20px;
}

.room-sensors {
    padding-left: 8px;
}

.room-sensors.collapsed {
    display: none;
}

/* Элементы датчиков */
.sensor-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 6px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.sensor-item:hover {
    background: #f1f5f9;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1);
}

.sensor-item:active {
    cursor: grabbing;
}

.sensor-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.sensor-icon {
    font-size: 16px;
}

.sensor-name {
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.sensor-type {
    font-size: 9px;
    color: #64748b;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

.sensor-value {
    font-size: 11px;
    color: #2563eb;
    font-weight: 600;
}

.sensor-unit {
    font-size: 9px;
    color: #94a3b8;
    margin-left: 2px;
}

/* Правая панель - холст */
.canvas-panel {
    background: white;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.canvas-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: white;
}
.canvas-toolbar > div:first-child {
    font-weight: 500;
    color: #334155;
    font-size: 14px;
    white-space: nowrap;
}

.canvas-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.canvas-controls input {
    width: 80px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    text-align: center;
    font-size: 13px;
}
.canvas-controls span {
    font-size: 12px;
    color: #64748b;
}
.canvas-controls .btn-icon {
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 30px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    transition: all 0.2s;
    white-space: nowrap;
}
.canvas-controls .btn-icon i {
    font-size: 14px;
}
.canvas-controls .btn-icon.icon-only {
    padding: 8px 12px;
}

.canvas-controls .btn-icon:hover {
    background: #e2e8f0;
    border-color: #2563eb;
}
/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .canvas-controls .btn-icon {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .canvas-controls .btn-icon i {
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .canvas-controls .btn-icon span {
        display: none;
    }
    
    .canvas-controls .btn-icon {
        padding: 8px 12px;
    }
    
    .canvas-controls .btn-icon i {
        margin: 0;
    }
}

/* Холст */
.canvas {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    align-content: start;
    transition: all 0.2s;
}

.canvas.drop-active {
    background: #f1f5f9;
    border: 2px dashed #2563eb;
}

/* Виджеты */
.widget {
    background: white;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    cursor: move;
    transition: all 0.2s;
    position: relative;
    user-select: none;
    min-width: 0;
}

.widget:hover {
    border-color: #2563eb;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.1);
}

.widget.selected {
    border: 2px solid #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.widget[data-size="1"] { grid-column: span 2; }
.widget[data-size="2"] { grid-column: span 4; }
.widget[data-size="3"] { grid-column: span 6; }
.widget[data-size="4"] { grid-column: span 12; }

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.widget-title {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.widget:hover .widget-actions {
    opacity: 1;
}

.widget-action {
    background: white;
    border: 1px solid #e2e8f0;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 12px;
    transition: all 0.2s;
}

.widget-action:hover {
    background: #f1f5f9;
    color: #2563eb;
    border-color: #2563eb;
}

.widget-action.delete:hover {
    color: #ef4444;
    border-color: #ef4444;
}

.widget-content {
    font-size: 24px;
    font-weight: 700;
    color: #2563eb;
    margin: 8px 0;
    text-align: center;
}

.widget-footer {
    font-size: 10px;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
}

.resize-handle {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.2s;
    background: linear-gradient(135deg, transparent 50%, #94a3b8 50%);
    border-radius: 0 0 8px 0;
    z-index: 20;
}

.widget:hover .resize-handle {
    opacity: 0.5;
}

.resize-handle:hover {
    opacity: 1 !important;
    background: linear-gradient(135deg, transparent 50%, #2563eb 50%);
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Формы */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #475569;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
}

/* ===========================================
   КОМНАТЫ
   =========================================== */
.rooms-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.room-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.room-icon {
    font-size: 32px;
}

.room-name-input {
    font-size: 20px;
    font-weight: 600;
    border: 1px solid transparent;
    padding: 5px;
    border-radius: 5px;
    width: 200px;
}

.room-name-input:hover,
.room-name-input:focus {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.room-stats {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #64748b;
}

.room-actions {
    display: flex;
    gap: 10px;
}

.room-sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.sensor-in-room {
    background: #f8fafc;
    border-radius: 12px;
    padding: 15px;
}

.sensor-in-room .sensor-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sensor-in-room .sensor-icon {
    font-size: 20px;
}

.sensor-in-room .sensor-function {
    font-size: 11px;
    color: #64748b;
}

.sensor-in-room .sensor-data {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sensor-in-room .sensor-value {
    font-size: 24px;
    font-weight: 700;
}

.sensor-in-room .sensor-board {
    font-size: 12px;
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 20px;
}

.empty-sensors {
    grid-column: 1/-1;
    text-align: center;
    padding: 30px;
    background: #f8fafc;
    border-radius: 12px;
    color: #64748b;
}

.btn-add-sensor {
    width: 100%;
    padding: 8px 16px;
    background: transparent;
    border: 1px dashed #94a3b8;
    border-radius: 30px;
    color: #64748b;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.btn-add-sensor:hover {
    background: #f1f5f9;
    border-color: #2563eb;
    color: #2563eb;
}

.empty-state {
    text-align: center;
    padding: 40px;
    background: #f8fafc;
    border-radius: 20px;
    color: #64748b;
}

/* ===========================================
   ДАТЧИКИ - ТАБЛИЦА
   =========================================== */
.filters-bar {
    background: white;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar select,
.filters-bar input {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.sensor-count {
    margin-left: auto;
    font-size: 14px;
    color: #64748b;
}

.sensors-table-wrapper {
    background: white;
    border-radius: 20px;
    padding: 20px;
    overflow-x: auto;
}

.sensors-table {
    width: 100%;
    border-collapse: collapse;
}

.sensors-table th,
.sensors-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.sensors-table th {
    background: #f8fafc;
    font-weight: 600;
}

.sensors-table tr:hover {
    background: #f8fafc;
}

.sensor-name-input {
    border: 1px solid transparent;
    padding: 4px;
    width: 120px;
    background: transparent;
}

.sensor-name-input:hover,
.sensor-name-input:focus {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.pin-badge {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    margin: 2px;
    display: inline-block;
}

.sensor-value-display {
    font-weight: 600;
    color: #2563eb;
}

.sensor-update-time {
    font-size: 12px;
    color: #64748b;
}

.empty-table {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

/* ===========================================
   КОНТРОЛЛЕРЫ
   =========================================== */
.controllers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.controller-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.controller-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.controller-header h3 {
    margin: 0;
    font-size: 18px;
}

.controller-header h3 input {
    font-size: 18px;
    font-weight: 600;
    border: 1px solid transparent;
    padding: 5px;
    border-radius: 5px;
    width: 200px;
    background: transparent;
}

.controller-header h3 input:hover,
.controller-header h3 input:focus {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.controller-type-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    display: inline-block;
}

/* Контроллеры - действия */
.controller-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}
.controller-actions .demo-disabled {
    white-space: nowrap;
    font-size: 12px;
    padding: 4px 8px;
    background: #f1f5f9;
    border-radius: 20px;
}

/* Для мобильных */
@media (max-width: 640px) {
    .controller-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}
.demo-badge {
    background: #f1f5f9;
    color: #475569;
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.toggle-switch {
    display: inline-block;
    width: 40px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 20px;
    position: relative;
    transition: all 0.2s;
    cursor: pointer;
}

.toggle-switch.active {
    background: #10b981;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}

.toggle-switch.active::after {
    left: 22px;
}

.controller-body {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
}

.controller-inputs,
.controller-outputs {
    margin-bottom: 10px;
}

.controller-inputs span:first-child,
.controller-outputs span:first-child {
    color: #64748b;
    font-size: 11px;
    display: block;
    margin-bottom: 5px;
}

.controller-inputs-list,
.controller-outputs-list {
    font-size: 12px;
}

.controller-logic span:first-child {
    color: #64748b;
    font-size: 11px;
    display: block;
    margin-bottom: 5px;
}

.controller-logic pre {
    font-size: 11px;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #0f172a;
    background: transparent;
}

/* ===========================================
   MQTT
   =========================================== */
.mqtt-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    margin-top: 20px;
}

.mqtt-send-panel {
    background: white;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

.mqtt-send-panel h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Формы в MQTT */
.mqtt-send-panel .form-group {
    margin-bottom: 20px;
}

.mqtt-send-panel label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 13px;
    color: #475569;
}

.mqtt-send-panel select,
.mqtt-send-panel input,
.mqtt-send-panel textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: white;
}

.mqtt-send-panel select:focus,
.mqtt-send-panel input:focus,
.mqqtt-send-panel textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.mqtt-send-panel textarea {
    font-family: monospace;
    resize: vertical;
}

/* Кнопка отправки */
.mqtt-send-panel .btn-primary {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.mqtt-send-panel .btn-primary:hover {
    background: #2563eb;
}
.quick-commands {
    margin-top: 20px;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

.quick-commands h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #475569;
}

.quick-cmd {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    margin-bottom: 8px;
    transition: all 0.2s;
    font-size: 13px;
    color: #334155;
}

.quick-cmd:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
    color: #3b82f6;
}

.mqtt-console-panel {
    background: #0f172a;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.console-header {
    background: #1e293b;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.console-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.console-header button {
    background: #334155;
    color: #e2e8f0;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.console-header button:hover {
    background: #475569;
    color: white;
}


.mqtt-console {
    background: #0f172a;
    padding: 16px;
    height: 500px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
}
/* Стили для сообщений в консоли */
.mqtt-console .console-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
}

.mqtt-console .console-message.send {
    background: #1e293b;
    border-left: 3px solid #3b82f6;
}

.mqtt-console .console-message.receive {
    background: #1e293b;
    border-left: 3px solid #10b981;
}

.mqtt-console .console-message.error {
    background: #1e293b;
    border-left: 3px solid #ef4444;
}

.mqtt-console .console-time {
    color: #64748b;
    font-size: 10px;
    margin-bottom: 4px;
}

.mqtt-console .console-topic {
    color: #94a3b8;
    font-size: 11px;
    margin-bottom: 4px;
}

.mqtt-console .console-payload {
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Адаптивность для MQTT */
@media (max-width: 768px) {
    .mqtt-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .mqtt-console {
        height: 400px;
    }
}

/* ===========================================
   ИСТОРИЯ
   =========================================== */
.history-table-wrapper {
    background: white;
    border-radius: 20px;
    padding: 20px;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.history-table th {
    background: #f8fafc;
    font-weight: 600;
}

.pagination-controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
}

/* ===========================================
   ГРАФИКИ
   =========================================== */
.graphs-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 20px;
}

.graph-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.graph-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.graph-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.graph-header button {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
}

.graph-header button:hover {
    background: #fee2e2;
    color: #ef4444;
}

.graph-card canvas {
    width: 100% !important;
    height: 300px !important;
    background: #fafcff;
    border-radius: 12px;
    padding: 10px;
}

.graph-legend {
    margin-top: 16px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.graph-legend span {
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #f8fafc;
    border-radius: 20px;
    color: #475569;
}

/* Модальное окно добавления графика */
#add-graph-modal .modal-content {
    max-width: 600px;
}

#add-graph-modal .dataset-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

#add-graph-modal .dataset-row select {
    flex: 1;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
}

#add-graph-modal .dataset-row input[type="color"] {
    width: 50px;
    height: 42px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
}

#add-graph-modal .dataset-row .btn-icon {
    width: 42px;
    height: 42px;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
}

#add-graph-modal .dataset-row .btn-icon:hover {
    background: #fecaca;
}

/* Пустое состояние графиков */
.graphs-empty {
    text-align: center;
    padding: 60px;
    background: white;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    color: #64748b;
}

.graphs-empty .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.graphs-empty p {
    margin-bottom: 20px;
}

/* Адаптивность для графиков */
@media (max-width: 768px) {
    .graph-card canvas {
        height: 250px !important;
    }
    
    .graph-legend {
        gap: 10px;
    }
    
    .graph-legend span {
        font-size: 11px;
        padding: 2px 8px;
    }
    
    #add-graph-modal .dataset-row {
        flex-wrap: wrap;
    }
    
    #add-graph-modal .dataset-row select {
        min-width: 200px;
    }
}

/* ===========================================
   ФУНКЦИИ
   =========================================== */
.functions-table-wrapper {
    background: white;
    border-radius: 20px;
    padding: 20px;
    overflow-x: auto;
}

.functions-table {
    width: 100%;
    border-collapse: collapse;
}

.functions-table th,
.functions-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.functions-table th {
    background: #f8fafc;
    font-weight: 600;
}

.role-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
}

.role-badge.input {
    background: #3b82f620;
    color: #3b82f6;
}

.role-badge.output {
    background: #f59e0b20;
    color: #f59e0b;
}

.role-badge.control {
    background: #8b5cf620;
    color: #8b5cf6;
}

/* ===========================================
   УВЕДОМЛЕНИЯ
   =========================================== */
.notifications-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.notification-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    border: 1px solid #e2e8f0;
}

.notification-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.notification-card-header > div:first-child {
    display: flex;
    gap: 15px;
    align-items: center;
}

.notification-icon {
    font-size: 32px;
}

.notification-name {
    font-weight: 600;
    font-size: 16px;
}

.notification-status {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    margin-left: 10px;
}

.notification-actions {
    display: flex;
    gap: 8px;
}

.notification-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.detail-item {
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 8px;
}

.detail-label {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 2px;
}

.notification-footer {
    display: flex;
    gap: 20px;
    font-size: 11px;
    color: #94a3b8;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

/* ===========================================
   НАСТРОЙКИ
   =========================================== */
.settings-form {
    background: white;
    border-radius: 20px;
    padding: 30px;
}

.settings-form .form-group {
    margin-bottom: 20px;
}

.settings-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.settings-form input,
.settings-form textarea,
.settings-form select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
}

.form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 15px;
    justify-content: space-between;
}

/* ===========================================
   АДАПТИВНОСТЬ
   =========================================== */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 768px) {
    .system-wrapper {
        padding: 10px;
    }
    
    .system-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .system-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
    
    .nav-btn {
        white-space: nowrap;
    }
    
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    
    .sensors-panel {
        height: 300px;
    }
    
    .canvas-panel {
        height: 500px;
    }
    
    .mqtt-layout {
        grid-template-columns: 1fr;
    }
    
    .controllers-grid {
        grid-template-columns: 1fr;
    }
    
    .room-sensors-grid {
        grid-template-columns: 1fr;
    }
    
    .sensors-table-wrapper {
        overflow-x: scroll;
    }
    
    .sensors-table {
        min-width: 800px;
    }
}

@media (max-width: 480px) {
    .system-name {
        font-size: 20px;
    }
    
    .system-icon {
        font-size: 32px;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        border-radius: 20px;
    }
    
    .board-id-input {
        max-width: 100%;
    }
    
    .mode-switch {
        align-self: center;
    }
    
    .config-actions {
        justify-content: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .room-info {
        flex-wrap: wrap;
    }
}

/* Камеры */
.cameras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.camera-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.camera-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.camera-preview {
    background: #0f172a;
    height: 200px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.camera-preview img,
.camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-preview .play-icon {
    position: absolute;
    font-size: 48px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    opacity: 0.8;
    transition: opacity 0.2s;
}

.camera-preview:hover .play-icon {
    opacity: 1;
    transform: scale(1.1);
}

.camera-info {
    padding: 12px 16px;
}

.camera-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.camera-type {
    font-size: 12px;
    color: #64748b;
}

.camera-stats {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
}

.camera-actions {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Видеоплеер */
#camera-video {
    background: #000;
    border-radius: 8px;
}

.recording-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ef4444;
    color: white;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
/* 3D Симуляция */
#simulation-container {
    position: relative;
    width: 100%;
    height: 70vh;
    min-height: 500px;
    background: #1e1e2e;
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

#simulation-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.simulation-controls {
    display: flex;
    gap: 10px;
}

.info-card {
    transition: transform 0.2s;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
/* Полноэкранный режим симуляции */
#simulation-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    padding: 0;
}

.simulation-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
/* Полноэкранный режим симуляции */
#simulation-container {
    position: relative;
    transition: all 0.3s ease;
}

#simulation-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

#simulation-container.fullscreen canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}
#simulation-container.fullscreen #simulation-controls-info {
    bottom: 30px;
    right: 30px;
    font-size: 14px;
    background: rgba(0,0,0,0.8);
}
/* Индикатор загрузки модели */
.model-upload-status {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.3s;
}

.model-upload-status.success {
    background: rgba(16,185,129,0.9);
}

.model-upload-status.error {
    background: rgba(239,68,68,0.9);
}

/* Анимация для информационной панели */
#simulation-controls-info {
    pointer-events: none;
    backdrop-filter: blur(4px);
    font-size: 11px;
    line-height: 1.4;
}

#simulation-controls-info strong {
    color: #3b82f6;
}