/* ============================================================
   RESET Y BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; background: #07111F; color: #E8EDF5; }
.app-container { display: flex; width: 100vw; height: 100vh; overflow: hidden; }

/* ============================================================
   SIDEBAR - ESTRUCTURA COMPLETA
   ============================================================ */
.sidebar {
    width: 18%;
    height: 100%;
    min-width: 220px;
    max-width: 300px;
    background: #0A1628;
    border-right: 1px solid rgba(0, 150, 255, 0.06);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   SIDEBAR LOGO - VERSIÓN ALTERNATIVA
   ============================================================ */
.sidebar-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 20px;
    min-height: 90px;
    max-height: 130px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.06);
    flex-shrink: 0;
    background: #0A1628;
    width: 100%;
}

.sidebar-logo img {
    width: 90%;
    max-width: 220px;
    height: auto;
    max-height: 100px;
    object-fit: contain;
}

/* PC - pantallas grandes */
@media (min-width: 1400px) {
    .sidebar-logo {
        min-height: 100px;
        max-height: 140px;
        padding: 18px 22px;
    }
    .sidebar-logo img {
        max-width: 250px;
        max-height: 110px;
    }
}

/* Laptops */
@media (max-width: 1400px) {
    .sidebar-logo {
        min-height: 80px;
        max-height: 110px;
        padding: 14px 16px;
    }
    .sidebar-logo img {
        max-width: 200px;
        max-height: 85px;
    }
}

/* Tablets y pantallas pequeñas */
@media (max-width: 1200px) {
    .sidebar-logo {
        min-height: 70px;
        max-height: 95px;
        padding: 10px 14px;
    }
    .sidebar-logo img {
        max-width: 170px;
        max-height: 75px;
    }
}

/* Móviles */
@media (max-width: 992px) {
    .sidebar-logo {
        min-height: 65px;
        max-height: 85px;
        padding: 10px 12px;
    }
    .sidebar-logo img {
        max-width: 180px;
        max-height: 70px;
    }
}

@media (max-width: 600px) {
    .sidebar-logo {
        min-height: 55px;
        max-height: 75px;
        padding: 8px 10px;
    }
    .sidebar-logo img {
        max-width: 150px;
        max-height: 60px;
    }
}

/* MENÚ - ocupa todo el espacio disponible */
.sidebar-menu {
    flex: 1;
    padding: 4px 8px 4px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.sidebar-menu::-webkit-scrollbar {
    width: 2px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 102, 255, 0.2);
    border-radius: 4px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

/* ============================================================
   NAVEGACIÓN - LINKS
   ============================================================ */
.sidebar-menu .nav-link {
    color: #6A8AA8;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    margin-bottom: 1px;
    height: 30px;
}

.sidebar-menu .nav-link i {
    width: 18px;
    font-size: 13px;
    text-align: center;
    color: #4A6A8A;
    transition: color 0.2s ease;
}

.sidebar-menu .nav-link:hover {
    color: #E8EDF5;
    background: rgba(0, 102, 255, 0.06);
}

.sidebar-menu .nav-link:hover i {
    color: #4A9AFF;
}

.sidebar-menu .nav-link.active {
    color: #4A9AFF;
    background: rgba(0, 102, 255, 0.10);
    box-shadow: inset 3px 0 0 #4A9AFF;
}

.sidebar-menu .nav-link.active i {
    color: #4A9AFF;
}

.sidebar-menu .nav-link .badge {
    margin-left: auto;
    font-size: 7px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}

/* ============================================================
   SECCIONES DEL MENÚ
   ============================================================ */
.nav-section {
    margin-bottom: 2px;
}

.nav-section-title {
    font-size: 7px;
    font-weight: 700;
    color: #4A6A8A;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 10px 2px 10px;
    margin-top: 2px;
    opacity: 0.5;
}

.nav-section .nav-link {
    padding-left: 14px;
    font-size: 10.5px;
    height: 28px;
}

.nav-section .nav-link i {
    font-size: 12px;
    width: 18px;
    text-align: center;
}

.nav-section .nav-link .badge {
    font-size: 6px;
    padding: 1px 5px;
    border-radius: 6px;
}

/* SEPARADOR */
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.03);
    margin: 4px 10px;
}

/* ============================================================
   NAV-LINK CONTAINER (MODO)
   ============================================================ */
.nav-link-container {
    position: relative;
}

.nav-link-container .nav-link {
    cursor: pointer;
}

.nav-link-container .nav-link {
    padding-right: 6px;
}

#modoActualBadge {
    font-size: 7px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#modoChevron {
    transition: transform 0.3s ease;
    font-size: 8px;
    color: #4A6A8A;
}

#modoChevron.rotated {
    transform: rotate(180deg);
}

#modoMenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #0A1628;
    border: 1px solid rgba(0, 150, 255, 0.08);
    border-radius: 6px;
    margin-top: 2px;
    padding: 3px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    min-width: 180px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.modo-option {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 4px 10px !important;
    border: none !important;
    background: transparent !important;
    color: #6A8AA8 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 10px !important;
    font-family: inherit !important;
    text-align: left !important;
}

.modo-option:hover {
    background: rgba(0, 102, 255, 0.08) !important;
    color: #E8EDF5 !important;
}

.modo-option.active {
    background: rgba(0, 102, 255, 0.12) !important;
    color: #4A9AFF !important;
}

.modo-option .modo-check {
    margin-left: auto;
    color: #4A9AFF;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modo-option.active .modo-check {
    opacity: 1;
}

/* ============================================================
   FOOTER - STATUS + RELOJ (PEGADO AL FONDO)
   ============================================================ */
.sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 150, 255, 0.06);
    padding: 10px 14px 8px 14px;
    background: rgba(0, 0, 0, 0.12);
    margin-top: auto;
}

/* STATUS */
.sidebar-status {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}

.sidebar-status .status-header {
    font-size: 8px;
    color: #4A6A8A;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.sidebar-status .status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.sidebar-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    animation: pulse-dot 2s infinite;
    flex-shrink: 0;
}

.sidebar-status .status-dot.offline {
    background: #EF4444;
    animation: none;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.sidebar-status .status-text {
    font-size: 11px;
    font-weight: 600;
    color: #E8EDF5;
    line-height: 1.3;
}

.sidebar-status .status-sub {
    font-size: 9px;
    color: #4A6A8A;
    line-height: 1.3;
}

/* KML STATUS */
.kml-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 8px;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.15);
    margin-top: 4px;
}

.kml-status-indicator i {
    font-size: 9px;
}

.kml-status-indicator.empty {
    background: rgba(74, 106, 138, 0.1);
    color: #4A6A8A;
    border-color: rgba(74, 106, 138, 0.1);
}

/* RELOJ */
.sidebar-clock {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 0 2px 0;
    border-top: 1px solid rgba(0, 150, 255, 0.04);
    margin-top: 6px;
    flex-shrink: 0;
}

.sidebar-clock .clock-time {
    font-size: 18px;
    font-weight: 300;
    color: #E8EDF5;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    line-height: 1.2;
}

.sidebar-clock .clock-date {
    font-size: 9px;
    color: #4A6A8A;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* ============================================================
   OVERLAY
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================================
   ÁREA PRINCIPAL - 82% × 100%
   ============================================================ */
.main-area {
    width: 82%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 8px 16px 8px 16px;
    overflow: hidden;
    background: #07111F;
}

/* ============================================================
   HEADER - 8%
   ============================================================ */
.header {
    height: 8%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 0 8px;
    border-bottom: 1px solid rgba(0, 150, 255, 0.04);
    flex-shrink: 0;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left .title {
    font-size: 16px;
    font-weight: 700;
    color: #E8EDF5;
    letter-spacing: 0.5px;
}

.header-left .subtitle {
    font-size: 9px;
    color: #4A6A8A;
    letter-spacing: 0.3px;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #E8EDF5;
    font-size: 18px;
    padding: 4px 6px;
    cursor: pointer;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-metrics {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-metric {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: #6A8AA8;
    background: #0F1C2F;
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0, 150, 255, 0.04);
}

.header-metric i {
    color: #4A9AFF;
    font-size: 12px;
}

.header-metric .value {
    color: #E8EDF5;
    font-weight: 600;
    font-size: 11px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-actions .btn-icon {
    background: rgba(15, 28, 47, 0.5);
    border: 1px solid rgba(0, 150, 255, 0.06);
    color: #6A8AA8;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    position: relative;
}

.header-actions .btn-icon:hover {
    background: rgba(0, 102, 255, 0.08);
    color: #E8EDF5;
    border-color: rgba(0, 102, 255, 0.15);
}

.header-actions .btn-icon .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 7px;
    padding: 1px 5px;
    border-radius: 50%;
    background: #EF4444;
    color: #fff;
    min-width: 14px;
    text-align: center;
}

.header-actions .btn-connect {
    background: rgba(16, 185, 129, 0.10);
    border: 1px solid rgba(16, 185, 129, 0.15);
    color: #10B981;
    padding: 3px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-actions .btn-connect:hover {
    background: rgba(16, 185, 129, 0.18);
}

.header-actions .btn-connect.offline {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

/* ============================================================
   DASHBOARD - GRID
   ============================================================ */
.dashboard-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 30% 42% 28%;
    grid-template-rows: 26% 26% 22% 26%;
    gap: 10px;
    padding: 6px 0 4px 0;
    min-height: 0;
}

.panel-resumen { grid-row: 1 / 2; grid-column: 1 / 2; }
.panel-mapa { grid-row: 1 / 3; grid-column: 2 / 3; }
.panel-estado-zonas { grid-row: 1 / 3; grid-column: 3 / 4; }
.panel-consumo { grid-row: 2 / 3; grid-column: 1 / 2; }
.panel-sensores { grid-row: 3 / 4; grid-column: 1 / 2; }
.panel-programacion { grid-row: 3 / 4; grid-column: 2 / 3; }
.panel-historico { grid-row: 3 / 4; grid-column: 3 / 4; }
.panel-alertas { grid-row: 4 / 5; grid-column: 1 / 3; }
.panel-eficiencia { grid-row: 4 / 5; grid-column: 3 / 4; }

/* ============================================================
   PANELES
   ============================================================ */
.panel {
    background: #0F1C2F;
    border: 1px solid rgba(0, 150, 255, 0.04);
    border-radius: 10px;
    padding: 10px 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    min-height: 0;
}

.panel:hover {
    border-color: rgba(0, 102, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.panel-title {
    font-size: 10px;
    font-weight: 600;
    color: #4A6A8A;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.panel-title i {
    color: #4A9AFF;
    font-size: 12px;
}

.panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ============================================================
   KPI
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 6px;
    height: 100%;
    align-content: center;
}

.kpi-item {
    background: rgba(0, 102, 255, 0.03);
    border-radius: 6px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid rgba(0, 150, 255, 0.04);
    transition: all 0.2s ease;
    text-align: center;
    min-height: 55px;
}

.kpi-item:hover {
    background: rgba(0, 102, 255, 0.06);
    border-color: rgba(0, 102, 255, 0.10);
}

.kpi-item .kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #E8EDF5;
    line-height: 1.1;
}

.kpi-item .kpi-label {
    font-size: 9px;
    color: #4A6A8A;
    font-weight: 500;
}

.kpi-item .kpi-icon {
    font-size: 14px;
    color: #4A9AFF;
    display: block;
    margin-bottom: 2px;
}

/* ============================================================
   MAPA
   ============================================================ */
.map-container {
    flex: 1;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    background: #07111F;
    min-height: 0;
}

.map-container #googleMap {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.map-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.map-controls button {
    background: rgba(15, 28, 47, 0.9);
    border: 1px solid rgba(0, 150, 255, 0.05);
    color: #E8EDF5;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.map-controls button:hover {
    background: rgba(0, 102, 255, 0.15);
    border-color: rgba(0, 102, 255, 0.15);
}

.map-indicators {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 3px 0 1px 0;
    flex-shrink: 0;
    margin-top: 2px;
}

.map-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 8.5px;
    color: #6A8AA8;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.map-indicator .led {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.map-indicator .led-green {
    background: #10B981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.map-indicator .led-blue {
    background: #3B82F6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.map-indicator .led-gray {
    background: #4A6A8A;
    box-shadow: 0 0 8px rgba(74, 106, 138, 0.2);
}

/* ============================================================
   ESTADO DE ZONAS
   ============================================================ */
.table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.table-wrapper::-webkit-scrollbar {
    width: 3px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.01);
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 102, 255, 0.2);
    border-radius: 4px;
}

.table-ams {
    width: 100%;
    font-size: 10px;
    border-collapse: collapse;
}

.table-ams thead th {
    color: #4A6A8A;
    font-weight: 600;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-align: left;
    position: sticky;
    top: 0;
    background: #0F1C2F;
    z-index: 5;
}

.table-ams tbody td {
    padding: 2px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    color: #C8D0DC;
    font-size: 9.5px;
}

.table-ams tbody tr:hover td {
    background: rgba(0, 102, 255, 0.03);
}

/* ============================================================
   BADGES
   ============================================================ */
.status-badge {
    font-size: 8px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.status-badge .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.12);
    color: #10B981;
}

.status-badge.active .dot {
    background: #10B981;
}

.status-badge.scheduled {
    background: rgba(59, 130, 246, 0.12);
    color: #3B82F6;
}

.status-badge.scheduled .dot {
    background: #3B82F6;
}

.status-badge.inactive {
    background: rgba(74, 106, 138, 0.12);
    color: #4A6A8A;
}

.status-badge.inactive .dot {
    background: #4A6A8A;
}

.status-badge.alarm {
    background: rgba(239, 68, 68, 0.12);
    color: #EF4444;
}

.status-badge.alarm .dot {
    background: #EF4444;
    animation: pulse-dot 1s infinite;
}

/* ============================================================
   ZONE VALVE
   ============================================================ */
.zone-valve {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 10px;
    font-size: 8.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-transform: uppercase;
}

.zone-valve.off {
    background: rgba(74, 106, 138, 0.12);
    color: #4A6A8A;
    border-color: rgba(74, 106, 138, 0.12);
}

.zone-valve.on {
    background: rgba(16, 185, 129, 0.12);
    color: #10B981;
    border-color: rgba(16, 185, 129, 0.15);
}

.zone-valve:hover {
    transform: scale(1.02);
}

/* ============================================================
   CONSUMO
   ============================================================ */
.consumo-grid {
    display: flex;
    gap: 12px;
    height: 100%;
    align-items: center;
}

.consumo-chart {
    width: 48%;
    height: 85%;
    min-height: 50px;
    position: relative;
}

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

.consumo-indicators {
    width: 52%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.consumo-indicators .ind-item {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #6A8AA8;
    padding: 1px 0;
}

.consumo-indicators .ind-item .ind-value {
    color: #E8EDF5;
    font-weight: 600;
}

.consumo-indicators .ind-item .ind-bar {
    width: 100%;
    height: 2px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    margin-top: 1px;
}

.consumo-indicators .ind-item .ind-bar .fill {
    height: 100%;
    border-radius: 4px;
    background: #4A9AFF;
    transition: width 0.8s ease;
}

/* ============================================================
   HISTÓRICO
   ============================================================ */
.history-chart-container {
    flex: 1;
    min-height: 40px;
    position: relative;
}

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

/* ============================================================
   SENSORES
   ============================================================ */
.sensor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 5px;
    height: 100%;
}

.sensor-item {
    background: rgba(0, 102, 255, 0.03);
    border-radius: 6px;
    padding: 5px 8px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 150, 255, 0.04);
    transition: all 0.2s ease;
    justify-content: center;
    min-height: 38px;
}

.sensor-item:hover {
    background: rgba(0, 102, 255, 0.06);
    border-color: rgba(0, 102, 255, 0.10);
}

.sensor-item .sensor-top {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sensor-item .sensor-icon {
    font-size: 11px;
    color: #4A9AFF;
}

.sensor-item .sensor-label {
    font-size: 7px;
    color: #4A6A8A;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sensor-item .sensor-value {
    font-size: 16px;
    font-weight: 700;
    color: #E8EDF5;
    line-height: 1.1;
}

.sensor-item .sensor-value .unit {
    font-size: 9px;
    font-weight: 400;
    color: #4A6A8A;
    margin-left: 2px;
}

.sensor-item .sensor-spark {
    height: 16px;
    margin-top: 1px;
}

.sensor-item .sensor-spark canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   PROGRAMACIÓN
   ============================================================ */
.table-schedule {
    width: 100%;
    font-size: 10px;
    border-collapse: collapse;
}

.table-schedule thead th {
    color: #4A6A8A;
    font-weight: 600;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-align: left;
}

.table-schedule tbody td {
    padding: 2px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    color: #C8D0DC;
    font-size: 9.5px;
}

/* ============================================================
   ALERTAS
   ============================================================ */
.alert-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alert-list::-webkit-scrollbar {
    width: 3px;
}

.alert-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.01);
}

.alert-list::-webkit-scrollbar-thumb {
    background: rgba(0, 102, 255, 0.2);
    border-radius: 4px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.01);
    border-left: 3px solid transparent;
    transition: background 0.2s ease;
}

.alert-item:hover {
    background: rgba(255,255,255,0.02);
}

.alert-item.info { border-left-color: #3B82F6; }
.alert-item.warning { border-left-color: #F59E0B; }
.alert-item.success { border-left-color: #10B981; }
.alert-item.critical { border-left-color: #EF4444; }

.alert-item .alert-icon {
    font-size: 12px;
    width: 18px;
    text-align: center;
}

.alert-item.info .alert-icon { color: #3B82F6; }
.alert-item.warning .alert-icon { color: #F59E0B; }
.alert-item.success .alert-icon { color: #10B981; }
.alert-item.critical .alert-icon { color: #EF4444; }

.alert-item .alert-content { flex: 1; }
.alert-item .alert-title { font-size: 11px; font-weight: 600; color: #E8EDF5; }
.alert-item .alert-text { font-size: 9.5px; color: #6A8AA8; }
.alert-item .alert-time { font-size: 8px; color: #4A6A8A; flex-shrink: 0; }
.alert-item .alert-btn {
    background: rgba(0, 102, 255, 0.10);
    border: 1px solid rgba(0, 102, 255, 0.10);
    color: #4A9AFF;
    padding: 1px 10px;
    border-radius: 10px;
    font-size: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.alert-item .alert-btn:hover {
    background: rgba(0, 102, 255, 0.20);
    border-color: rgba(0, 102, 255, 0.20);
}

/* ============================================================
   EFICIENCIA
   ============================================================ */
.eficiencia-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 6px;
}

.eficiencia-gauge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex: 1;
}

.eficiencia-gauge .gauge-ring {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.eficiencia-gauge .gauge-ring svg {
    transform: rotate(-90deg);
}

.eficiencia-gauge .gauge-ring .bg {
    fill: none;
    stroke: rgba(255,255,255,0.04);
    stroke-width: 7;
}

.eficiencia-gauge .gauge-ring .progress {
    fill: none;
    stroke: #4A9AFF;
    stroke-width: 7;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}

.eficiencia-gauge .gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 700;
    color: #E8EDF5;
}

.eficiencia-gauge .gauge-value .gauge-unit {
    font-size: 11px;
    font-weight: 400;
    color: #4A6A8A;
}

.eficiencia-gauge .gauge-label {
    font-size: 9px;
    color: #4A6A8A;
}

.eficiencia-stats {
    display: flex;
    gap: 6px;
}

.eficiencia-stats .estat {
    flex: 1;
    background: rgba(0, 102, 255, 0.03);
    border-radius: 4px;
    padding: 4px 6px;
    text-align: center;
    border: 1px solid rgba(0, 150, 255, 0.04);
}

.eficiencia-stats .estat .estat-value {
    font-size: 13px;
    font-weight: 700;
    color: #E8EDF5;
}

.eficiencia-stats .estat .estat-label {
    font-size: 7px;
    color: #4A6A8A;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================================
   SELECTOR DE DISPOSITIVOS
   ============================================================ */
.device-selector-card {
    background: rgba(10, 14, 24, 0.6);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    margin-bottom: 6px;
}

.device-selector-card:hover {
    transform: translateY(-1px);
    background: rgba(20, 30, 50, 0.8);
    border-color: rgba(0, 150, 255, 0.15);
}

.device-selector-card.active {
    border-color: #4A9AFF;
    background: rgba(0, 102, 255, 0.06);
}

/* ============================================================
   KML ITEMS
   ============================================================ */
.kml-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(0,150,255,0.04);
}

.kml-item:hover {
    background: rgba(0,102,255,0.03);
}

.kml-item-actions button {
    background: transparent;
    border: none;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 9px;
    transition: all 0.2s ease;
}

.kml-item-actions button:hover {
    background: rgba(0,102,255,0.08);
}

/* ============================================================
   KML UPLOAD
   ============================================================ */
.kml-upload-btn {
    background: rgba(74, 154, 255, 0.10);
    border: 1px solid rgba(74, 154, 255, 0.15);
    color: #4A9AFF;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 8.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kml-upload-btn:hover {
    background: rgba(74, 154, 255, 0.20);
}

.kml-upload-btn i {
    font-size: 10px;
}

#kmlFileInput {
    display: none;
}

/* ============================================================
   MODALES
   ============================================================ */
.modal-horario {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.modal-horario-content {
    background: #0F1C2F;
    border-radius: 16px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    border: 1px solid rgba(0, 150, 255, 0.1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-horario-content h4 {
    color: #4A9AFF;
    margin-bottom: 16px;
    font-weight: 600;
}

.modal-horario-content label {
    color: #6A8AA8;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.modal-horario-content .form-control {
    background: #07111F;
    color: #E8EDF5;
    border: 1px solid rgba(0, 150, 255, 0.1);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    width: 100%;
}

.modal-horario-content .form-control:focus {
    outline: none;
    border-color: #4A9AFF;
    box-shadow: 0 0 12px rgba(74, 154, 255, 0.1);
}

.modal-horario-content .checkbox-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.modal-horario-content .checkbox-group label {
    font-size: 10px;
    color: #C8D0DC;
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: none;
}

.modal-horario-content .checkbox-group input[type="checkbox"],
.modal-horario-content .checkbox-group input[type="radio"] {
    accent-color: #4A9AFF;
}

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 20000;
    display: none;
    justify-content: center;
    align-items: center;
}

.confirm-modal-content {
    background: #0F1C2F;
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
    max-width: 400px;
    width: 90%;
}

.confirm-modal-content h3 {
    color: #EF4444;
    margin-bottom: 12px;
    font-weight: 600;
}

.confirm-modal-content p {
    color: #C8D0DC;
    margin-bottom: 18px;
    font-size: 14px;
}

.confirm-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-modal-buttons button {
    padding: 8px 24px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 12px;
}

.btn-confirm-yes {
    background: #EF4444;
    color: white;
}

.btn-confirm-yes:hover {
    background: #DC2626;
}

.btn-confirm-no {
    background: #4A6A8A;
    color: white;
}

.btn-confirm-no:hover {
    background: #3A5A7A;
}

/* ============================================================
   TOAST Y LOADING
   ============================================================ */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    width: 100%;
}

.toast-item {
    background: #0F1C2F;
    border: 1px solid rgba(0, 150, 255, 0.08);
    border-radius: 10px;
    padding: 12px 18px;
    color: #E8EDF5;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.toast-item.show {
    transform: translateX(0);
}

.toast-item.hide {
    transform: translateX(120%);
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 30000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(74, 154, 255, 0.1);
    border-top-color: #4A9AFF;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================================
   SCROLLBAR GLOBAL
   ============================================================ */
::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.01);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 102, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 102, 255, 0.3);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* ============================================================
   RESPONSIVE - AJUSTES PARA MÓVILES
   ============================================================ */

/* ===== TABLETS Y PANTALLAS PEQUEÑAS ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
        min-width: 180px;
        max-width: 220px;
    }
    .main-area {
        width: calc(100% - 200px);
        padding: 6px 10px;
    }
    .dashboard-grid {
        gap: 8px;
    }
    .kpi-item .kpi-value {
        font-size: 20px;
    }
    .sensor-grid {
        grid-template-columns: 1fr 1fr;
    }
    .header-metric {
        font-size: 8px;
        padding: 2px 6px;
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== DISPOSITIVOS MÓVILES (TABLETS PEQUEÑAS Y TELÉFONOS) ===== */
@media (max-width: 768px) {
    /* Sidebar - oculto con hamburguesa */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050;
        border-right: 1px solid rgba(0, 150, 255, 0.05);
        max-width: 280px;
        min-width: 260px;
        height: 100%;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Área principal - ocupa todo el ancho */
    .main-area {
        width: 100%;
        padding: 6px 8px;
        height: 100vh;
        overflow-y: auto;
    }

    /* Header - más compacto */
    .header {
        min-height: 44px;
        padding: 0 4px;
        flex-wrap: wrap;
    }
    .menu-toggle {
        display: block;
    }
    .header-left .subtitle {
        display: none;
    }
    .header-left .title {
        font-size: 12px;
    }
    .header-metrics {
        display: none;
    }
    .header-actions .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    .header-actions .btn-connect {
        font-size: 8px;
        padding: 2px 8px;
    }

    /* ===== DASHBOARD - CASCADA (UNO DEBAJO DEL OTRO) ===== */
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 4px 0;
        min-height: auto;
    }

    /* Todos los paneles ocupan el 100% */
    .panel {
        width: 100%;
        min-height: auto;
        max-height: none;
        padding: 10px 12px;
    }

    /* Paneles específicos con altura adecuada */
    .panel-resumen {
        min-height: 120px;
        max-height: 180px;
    }
    .panel-mapa {
        min-height: 280px;
        max-height: 400px;
    }
    .panel-estado-zonas {
        min-height: 180px;
        max-height: 300px;
    }
    .panel-consumo {
        min-height: 160px;
        max-height: 240px;
    }
    .panel-sensores {
        min-height: 140px;
        max-height: 200px;
    }
    .panel-programacion {
        min-height: 160px;
        max-height: 260px;
    }
    .panel-historico {
        min-height: 160px;
        max-height: 240px;
    }
    .panel-alertas {
        min-height: 140px;
        max-height: 220px;
    }
    .panel-eficiencia {
        min-height: 160px;
        max-height: 240px;
    }

    /* Eliminar posiciones de grid */
    .panel-resumen,
    .panel-mapa,
    .panel-estado-zonas,
    .panel-consumo,
    .panel-sensores,
    .panel-programacion,
    .panel-historico,
    .panel-alertas,
    .panel-eficiencia {
        grid-row: auto;
        grid-column: auto;
    }

    /* KPI - 2 columnas */
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        align-content: start;
    }
    .kpi-item {
        min-height: 50px;
        padding: 4px 6px;
    }
    .kpi-item .kpi-value {
        font-size: 20px;
    }
    .kpi-item .kpi-label {
        font-size: 8px;
    }

    /* Mapa */
    .map-container {
        min-height: 200px;
    }
    .map-controls button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    .map-indicators {
        gap: 10px;
        flex-wrap: wrap;
    }
    .map-indicator {
        font-size: 7px;
    }
    .map-indicator .led {
        width: 7px;
        height: 7px;
    }

    /* Sensores - 2 columnas */
    .sensor-grid {
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }
    .sensor-item {
        min-height: 45px;
        padding: 4px 6px;
    }
    .sensor-item .sensor-value {
        font-size: 14px;
    }
    .sensor-item .sensor-label {
        font-size: 6px;
    }

    /* Consumo */
    .consumo-grid {
        flex-direction: row;
        gap: 8px;
    }
    .consumo-chart {
        width: 45%;
        height: 80%;
        min-height: 60px;
    }
    .consumo-indicators {
        width: 55%;
    }
    .consumo-indicators .ind-item {
        font-size: 8px;
    }
    .consumo-indicators .ind-item .ind-value {
        font-size: 9px;
    }

    /* Programación */
    .table-schedule {
        font-size: 8px;
    }
    .table-schedule thead th {
        font-size: 7px;
        padding: 2px 4px;
    }
    .table-schedule tbody td {
        font-size: 8px;
        padding: 2px 4px;
    }

    /* Estado de Zonas */
    .table-ams {
        font-size: 8px;
    }
    .table-ams thead th {
        font-size: 7px;
        padding: 2px 4px;
    }
    .table-ams tbody td {
        font-size: 8px;
        padding: 2px 4px;
    }
    .zone-valve {
        font-size: 7px;
        padding: 1px 6px;
    }

    /* Eficiencia */
    .eficiencia-gauge .gauge-ring {
        width: 65px;
        height: 65px;
    }
    .eficiencia-gauge .gauge-value {
        font-size: 20px;
    }
    .eficiencia-stats .estat .estat-value {
        font-size: 12px;
    }
    .eficiencia-stats .estat .estat-label {
        font-size: 6px;
    }

    /* Alertas */
    .alert-item {
        padding: 4px 6px;
    }
    .alert-item .alert-title {
        font-size: 10px;
    }
    .alert-item .alert-text {
        font-size: 8px;
    }
    .alert-item .alert-time {
        font-size: 7px;
    }

    /* Panel de dispositivos */
    .device-selector-card {
        padding: 8px 10px;
    }
    .device-selector-card .device-name {
        font-size: 12px;
    }
    .device-selector-card .device-code {
        font-size: 10px;
    }

    /* Panel KML */
    .kml-upload-btn {
        font-size: 8px;
        padding: 3px 8px;
    }
    .kml-item {
        padding: 3px 6px;
    }
    .kml-item span {
        font-size: 8px;
    }

    /* Modo de operación */
    .modos-panel .btn-modo {
        font-size: 8px;
        padding: 2px 8px;
    }
}

/* ===== TELÉFONOS MUY PEQUEÑOS (menos de 480px) ===== */
@media (max-width: 480px) {
    .main-area {
        padding: 4px 6px;
    }

    .header-left .title {
        font-size: 10px;
    }
    .header-actions .btn-icon {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    .header-actions .btn-connect {
        font-size: 7px;
        padding: 2px 6px;
    }

    .panel {
        padding: 6px 8px;
        border-radius: 8px;
    }
    .panel-title {
        font-size: 8px;
        margin-bottom: 3px;
    }
    .panel-title i {
        font-size: 10px;
    }

    /* KPI */
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }
    .kpi-item {
        min-height: 40px;
        padding: 3px 4px;
    }
    .kpi-item .kpi-value {
        font-size: 16px;
    }
    .kpi-item .kpi-label {
        font-size: 7px;
    }
    .kpi-item .kpi-icon {
        font-size: 11px;
        margin-bottom: 1px;
    }

    /* Mapa */
    .panel-mapa {
        min-height: 200px;
        max-height: 280px;
    }
    .map-container {
        min-height: 150px;
    }
    .map-controls button {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    /* Sensores */
    .sensor-grid {
        grid-template-columns: 1fr 1fr;
        gap: 3px;
    }
    .sensor-item {
        min-height: 35px;
        padding: 3px 4px;
    }
    .sensor-item .sensor-value {
        font-size: 12px;
    }
    .sensor-item .sensor-icon {
        font-size: 9px;
    }
    .sensor-item .sensor-label {
        font-size: 5px;
    }
    .sensor-item .sensor-spark {
        height: 12px;
    }

    /* Consumo */
    .consumo-grid {
        flex-direction: column;
        gap: 6px;
    }
    .consumo-chart {
        width: 100%;
        height: 50px;
        min-height: 40px;
    }
    .consumo-indicators {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 2px;
    }
    .consumo-indicators .ind-item {
        font-size: 7px;
        padding: 0 4px;
        flex: 1;
        min-width: 60px;
    }
    .consumo-indicators .ind-item .ind-value {
        font-size: 8px;
    }

    /* Estado de Zonas */
    .panel-estado-zonas {
        min-height: 140px;
        max-height: 220px;
    }
    .table-ams {
        font-size: 7px;
    }
    .table-ams thead th {
        font-size: 6px;
        padding: 1px 3px;
    }
    .table-ams tbody td {
        font-size: 7px;
        padding: 1px 3px;
    }
    .zone-valve {
        font-size: 6px;
        padding: 1px 4px;
    }

    /* Eficiencia */
    .eficiencia-gauge .gauge-ring {
        width: 50px;
        height: 50px;
    }
    .eficiencia-gauge .gauge-value {
        font-size: 16px;
    }
    .eficiencia-gauge .gauge-label {
        font-size: 7px;
    }
    .eficiencia-stats .estat .estat-value {
        font-size: 10px;
    }

    /* Sidebar en móvil */
    .sidebar {
        width: 260px;
        max-width: 260px;
        min-width: 240px;
    }
    .sidebar-logo img {
        max-width: 140px;
    }
    .sidebar-logo {
        min-height: 50px;
        max-height: 65px;
        padding: 6px 8px;
    }
    .sidebar-menu .nav-link {
        font-size: 10px;
        height: 28px;
        padding: 4px 8px;
    }
    .nav-section .nav-link {
        font-size: 9.5px;
        height: 26px;
        padding-left: 8px;
    }
    .nav-section-title {
        font-size: 6px;
        padding: 2px 6px 1px 6px;
    }
    .sidebar-footer {
        padding: 6px 8px 4px 8px;
    }
    .sidebar-status .status-text {
        font-size: 9px;
    }
    .sidebar-status .status-sub {
        font-size: 7px;
    }
    .sidebar-clock .clock-time {
        font-size: 14px;
    }
    .sidebar-clock .clock-date {
        font-size: 7px;
    }

    /* Toast */
    #toastContainer {
        max-width: 280px;
        bottom: 12px;
        right: 12px;
    }
    .toast-item {
        font-size: 11px;
        padding: 8px 12px;
    }

    /* Pull to refresh */
    .pull-to-refresh .pull-content {
        font-size: 10px;
        gap: 8px;
    }
    .pull-to-refresh .pull-icon {
        font-size: 14px;
    }
    .pull-to-refresh .pull-spinner {
        width: 16px;
        height: 16px;
    }
    .pull-to-refresh .pull-text {
        font-size: 9px;
    }
}

/* ===== AJUSTES PARA MÓVILES EN LANDSCAPE ===== */
@media (max-width: 900px) and (orientation: landscape) {
    .main-area {
        padding: 4px 8px;
    }
    .dashboard-grid {
        gap: 6px;
    }
    .panel {
        min-height: auto;
        max-height: none;
        padding: 6px 10px;
    }
    .panel-mapa {
        min-height: 180px;
        max-height: 250px;
    }
    .panel-resumen {
        min-height: 80px;
        max-height: 120px;
    }
    .panel-estado-zonas {
        min-height: 120px;
        max-height: 180px;
    }
    .kpi-item .kpi-value {
        font-size: 16px;
    }
    .sensor-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .sensor-item {
        min-height: 30px;
        padding: 2px 4px;
    }
    .sensor-item .sensor-value {
        font-size: 11px;
    }
}

/* ============================================================
   RESPONSIVE - FOOTER
   ============================================================ */
@media (max-width: 1400px) {
    .sidebar-footer {
        padding: 8px 12px 6px 12px;
    }
    .sidebar-status .status-text {
        font-size: 10px;
    }
    .sidebar-status .status-sub {
        font-size: 8px;
    }
    .sidebar-clock .clock-time {
        font-size: 16px;
    }
    .sidebar-clock .clock-date {
        font-size: 8px;
    }
    .kml-status-indicator {
        font-size: 7px;
        padding: 1px 8px;
    }
}

@media (max-width: 1200px) {
    .sidebar-footer {
        padding: 6px 10px 4px 10px;
    }
    .sidebar-status .status-text {
        font-size: 9px;
    }
    .sidebar-status .status-sub {
        font-size: 7px;
    }
    .sidebar-status .status-dot {
        width: 6px;
        height: 6px;
    }
    .sidebar-clock .clock-time {
        font-size: 14px;
    }
    .sidebar-clock .clock-date {
        font-size: 7px;
    }
    .kml-status-indicator {
        font-size: 6px;
        padding: 1px 6px;
    }
}

@media (max-width: 992px) {
    .sidebar-footer {
        padding: 10px 14px 8px 14px;
    }
    .sidebar-status .status-text {
        font-size: 11px;
    }
    .sidebar-status .status-sub {
        font-size: 9px;
    }
    .sidebar-status .status-dot {
        width: 8px;
        height: 8px;
    }
    .sidebar-clock .clock-time {
        font-size: 18px;
    }
    .sidebar-clock .clock-date {
        font-size: 9px;
    }
    .kml-status-indicator {
        font-size: 8px;
        padding: 2px 10px;
    }
}

@media (max-width: 600px) {
    .sidebar-footer {
        padding: 8px 10px 6px 10px;
    }
    .sidebar-status .status-text {
        font-size: 10px;
    }
    .sidebar-status .status-sub {
        font-size: 8px;
    }
    .sidebar-status .status-dot {
        width: 7px;
        height: 7px;
    }
    .sidebar-clock .clock-time {
        font-size: 16px;
    }
    .sidebar-clock .clock-date {
        font-size: 8px;
    }
    .kml-status-indicator {
        font-size: 7px;
        padding: 1px 8px;
    }
}


/* ============================================================
   PULL TO REFRESH - ACTUALIZAR AL DESLIZAR
   ============================================================ */
.pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0A1628;
    z-index: 9999;
    transition: top 0.3s ease;
    border-bottom: 1px solid rgba(0, 150, 255, 0.06);
}

.pull-to-refresh .pull-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #4A6A8A;
    font-size: 12px;
    font-weight: 500;
}

.pull-to-refresh .pull-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(74, 154, 255, 0.1);
    border-top-color: #4A9AFF;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.pull-to-refresh .pull-icon {
    font-size: 20px;
    color: #4A6A8A;
    transition: transform 0.3s ease;
}

.pull-to-refresh .pull-icon.rotate {
    transform: rotate(180deg);
}

.pull-to-refresh .pull-text {
    color: #4A6A8A;
}

.pull-to-refresh .pull-text.refreshing {
    color: #4A9AFF;
}

.pull-to-refresh.active {
    top: 0;
}

.pull-to-refresh .pull-spinner.active {
    display: block;
}

.pull-to-refresh .pull-icon.hidden {
    display: none;
}

/* Animación de refresco */
@keyframes refresh-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pull-to-refresh .pull-text.refreshing {
    animation: refresh-pulse 1s ease-in-out infinite;
}


/* ============================================================
   MODO PANTALLA COMPLETA EN MÓVILES
   ============================================================ */

/* Cuando está en pantalla completa */
body.fullscreen-active .header {
    padding-top: env(safe-area-inset-top);
}

body.fullscreen-active .main-area {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Ajuste para el contenido cuando está en pantalla completa */
body.fullscreen-active .content {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Ocultar scrollbar en pantalla completa en móviles */
body.fullscreen-active ::-webkit-scrollbar {
    width: 2px;
}

body.fullscreen-active ::-webkit-scrollbar-thumb {
    background: rgba(0, 102, 255, 0.15);
}

/* Mejorar experiencia táctil en móviles */
@media (max-width: 768px) {
    /* Aumentar área de toque para botones */
    .nav-link,
    .btn-icon,
    .btn-connect,
    .kml-upload-btn,
    .zone-valve,
    .modo-option {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevenir selección de texto */
    .sidebar-menu,
    .panel,
    .header {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Aumentar área de toque para tabs y botones pequeños */
    .btn-icon {
        min-width: 36px;
        min-height: 36px;
    }

    .nav-link {
        min-height: 36px;
    }

    /* Scroll suave */
    .content {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Ajuste para notch y bordes redondeados */
    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .main-area {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Ocultar el botón de pantalla completa en Safari iOS cuando ya está en pantalla completa */
@media (display-mode: fullscreen) {
    .fullscreen-btn {
        display: none !important;
    }
}