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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --card-bg: #1a1a24;
    --card-bg-hover: #22222e;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --border-radius: 12px;
    --card-border-radius: 10px;
    --transition: all 0.2s ease;
    --glass-bg: rgba(26, 26, 36, 0.7);
    --glass-border: rgba(255, 255, 255, 0.03);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(145deg, #0a0a0f 0%, #0f0f17 100%);
    min-height: 100vh;
    color: var(--text-primary);
    padding: 16px;
    position: relative;
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.4;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 70% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

#app {
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

[data-flex-gap="not-supported"] #app > div { margin-bottom:16px; }


/* Header */
.weather-header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 16px 24px;
    border: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.location-info h1 {
    font-size: 1.8rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
}

.location-info .domain {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.datetime {
    text-align: right;
}

.date {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.time {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--accent-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Основная температура */
.main-temperature {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 20px 24px;
    border: 1px solid var(--glass-border);
}

.temp-large {
    display: flex;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
}

.temp-value {
    font-size: 3.5rem;
    font-weight: 300;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.temp-value .number {
    font-weight: 600;
    color: white;
}

.temp-value .unit {
    font-size: 1.4rem;
    color: var(--text-muted);
}

.sun-moon-info {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
}
[data-flex-gap="not-supported"] .sun-moon-info > * { margin-left:28px; }


.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-emoji {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.1));
}

.info-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.info-text strong {
    color: var(--text-primary);
    display: block;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Сетка карточек */
.weather-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.weather-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--card-border-radius);
    padding: 14px 16px;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.weather-card:hover {
    background: var(--card-bg-hover);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-header span:first-child {
    font-size: 1rem;
}

.card-value {
    font-size: 1.8rem;
    font-weight: 300;
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 2px;
}
[data-flex-gap="not-supported"] .card-value > * { margin-left:4px; }


.card-value .number {
    font-weight: 600;
    color: white;
}

.card-value .unit {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card-trend {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
[data-flex-gap="not-supported"] .card-trend > * { margin-left:4px; }


/* Специальные карточки */
.card-large {
    grid-column: span 2;
}

.battery-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
[data-flex-gap="not-supported"] .battery-detail > * { margin-left:8px; }


.battery-detail .battery-level {
    flex: 1;
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.battery-detail .battery-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    border-radius: 2px;
    transition: width 0.2s ease;
}

.battery-detail .battery-fill.low {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.battery-detail .battery-fill.critical {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

.battery-percent {
    font-weight: 500;
    font-size: 0.9rem;
    color: white;
}

.battery-voltage {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
}

/* Секция питания */
.power-section {
    margin-bottom: 4px;
}

.power-card-large {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.power-card-large:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

.power-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.power-header span:first-child {
    font-size: 1.2rem;
    color: var(--accent-primary);
}

.power-phases-large {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
[data-flex-gap="not-supported"] .power-phases-large > * { margin-left:12px; }


.phase-large {
    flex: 1;
    min-width: 100px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Нормальное состояние (в пределах стандарта) */
.phase-large.normal {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.phase-large.normal:hover {
    border-color: rgba(16, 185, 129, 0.8);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

/* Предупреждение (отклонение от нормы) */
.phase-large.warning {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
    background: linear-gradient(145deg, rgba(245, 158, 11, 0.05), rgba(0, 0, 0, 0.2));
}

.phase-large.warning:hover {
    border-color: rgba(245, 158, 11, 0.9);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.25);
}

/* Критическое состояние (опасные значения) */
.phase-large.critical {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.08), rgba(0, 0, 0, 0.2));
    animation: phasePulse 1.5s ease-in-out infinite;
}

.phase-large.critical:hover {
    border-color: rgba(239, 68, 68, 1);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
}

/* Ошибка (нет данных или некорректные значения) */
.phase-large.error {
    border-color: rgba(156, 163, 175, 0.3);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.2));
    opacity: 0.7;
    border-style: dashed;
}

.phase-large.error:hover {
    border-color: rgba(156, 163, 175, 0.6);
}

/* Анимация пульсации для критических значений */
@keyframes phasePulse {
    0% {
        border-color: rgba(239, 68, 68, 0.5);
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
    }
    50% {
        border-color: rgba(239, 68, 68, 0.9);
        box-shadow: 0 0 18px rgba(239, 68, 68, 0.35);
    }
    100% {
        border-color: rgba(239, 68, 68, 0.5);
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
    }
}

/* Индикатор состояния (маленькая точка в углу) */
.phase-large::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.phase-large.normal::after {
    background: var(--success);
    opacity: 0.6;
}

.phase-large.warning::after {
    background: var(--warning);
    opacity: 0.8;
}

.phase-large.critical::after {
    background: var(--danger);
    opacity: 1;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.phase-large.error::after {
    background: var(--text-muted);
    opacity: 0.5;
}

@keyframes dotPulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Дополнительная подсветка для значений вне нормы */
.phase-large.warning .phase-value {
    color: var(--warning);
}

.phase-large.critical .phase-value {
    color: var(--danger);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.phase-large.error .phase-value {
    color: var(--text-muted);
}

.phase-large .phase-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.phase-large .phase-value {
    font-weight: 600;
    font-size: 1.4rem;
    color: white;
    transition: all 0.2s ease;
}

.phase-large .phase-angle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.phase-large .phase-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 2px;
}

/* График внутри power-section */
.power-graph-container {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.power-graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.power-graph-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.power-graph-legend {
    display: flex;
    gap: 12px;
}

[data-flex-gap="not-supported"] .power-graph-legend > * { margin-left:12px; }


.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
}
[data-flex-gap="not-supported"] .legend-item > * { margin-left:4px; }


.legend-color {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

#powerGraph {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

/* Секция камер */
.cameras-section {
    margin-top: 4px;
}

.cameras-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cameras-header span:first-child {
    font-size: 1.2rem;
    color: var(--accent-primary);
}

.cameras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
}

.camera-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 4px;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.camera-card:hover {
    background: var(--card-bg-hover);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.camera-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.camera-title span:first-child {
    font-size: 1rem;
}

.camera-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
}

.camera-status.online {
    color: var(--success);
}

.camera-status.offline {
    color: var(--danger);
}

.camera-image-container {
    position: relative;
    width: 100%;
    height: 240px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.camera-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.camera-image.loading {
    opacity: 0.5;
}

.camera-timestamp {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.camera-update-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.camera-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.camera-location {
    display: flex;
    align-items: center;
    gap: 4px;
}

.camera-viewers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.camera-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--text-muted);
    font-size: 0.8rem;
    gap: 8px;
}

.camera-loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Адаптивность */
@media (max-width: 1024px) {
    .weather-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .weather-header {
        flex-direction: column;
        text-align: center;
        padding: 14px 16px;
    }

    .datetime {
        text-align: center;
    }

    .temp-large {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .sun-moon-info {
        justify-content: center;
        gap: 20px;
    }

    .weather-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .card-large {
        grid-column: span 2;
    }

    .power-phases-large {
        flex-direction: row;
        gap: 8px;
    }
    
    .phase-large {
        min-width: 80px;
    }
    
    .cameras-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    /* .weather-grid {
        grid-template-columns: 1fr;
    } */
    
    /* .card-large {
        grid-column: span 1;
    } */
     
    .card-value {
        font-size: 1.2rem;
    }
    
    .temp-value {
        font-size: 2.8rem;
    }
    
    .time {
        font-size: 1.4rem;
    }
    
    .power-phases-large {
        flex-direction: column;
    }
    
    .camera-image-container {
        height: 240px;
    }
}

/* Утилиты */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.text-glow {
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Скрытые элементы */
.hidden {
    display: none !important;
}