* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: #eef1f5;
    color: #1f2937;
    font-family: Arial, Helvetica, sans-serif;
}

/* ============================================================
   BARRA SUPERIOR
   ============================================================ */

.topbar {
    background: #172033;
    color: white;
    padding: 14px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.topbar-content {
    width: 94%;
    max-width: 1150px;
    margin: auto;

    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.topbar p {
    margin: 3px 0 0;
    color: #cbd5e1;
    font-size: 14px;
}

.server-status {
    margin-left: auto;

    display: flex;
    align-items: center;
    gap: 7px;

    font-size: 13px;
    font-weight: bold;
}

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

.status-dot.green {
    background: #22c55e;
}

.logout-button {
    background: #374151;
    color: white;
    text-decoration: none;

    padding: 9px 14px;
    border-radius: 7px;

    font-size: 13px;
    font-weight: bold;
}

.logout-button:hover {
    background: #4b5563;
}


/* ============================================================
   CONTENEDOR
   ============================================================ */

.container {
    width: 94%;
    max-width: 1150px;
    margin: 20px auto;
}


/* ============================================================
   TARJETA GENERAL
   ============================================================ */

.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 18px;

    box-shadow: 0 2px 9px rgba(0, 0, 0, 0.07);
}


/* ============================================================
   SERVIDOR
   ============================================================ */

.server-card {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 18px;

    display: flex;
    align-items: center;
    gap: 15px;

    box-shadow: 0 2px 9px rgba(0, 0, 0, 0.07);
}

.server-icon {
    font-size: 38px;
}

.server-card h2 {
    margin: 0;
    font-size: 18px;
}

.server-card p {
    margin: 3px 0 0;
    color: #6b7280;
    font-size: 13px;
}

.online-badge {
    margin-left: auto;

    background: #dcfce7;
    color: #15803d;

    padding: 6px 10px;
    border-radius: 20px;

    font-size: 12px;
    font-weight: bold;
}


/* ============================================================
   ENCABEZADOS DE SECCIÓN
   ============================================================ */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 18px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-icon {
    font-size: 35px;
}

.section-title h2 {
    margin: 0;
    font-size: 21px;
}

.section-title p {
    margin: 3px 0 0;
    color: #6b7280;
    font-size: 13px;
}

.badge {
    padding: 6px 11px;
    border-radius: 20px;

    font-size: 12px;
    font-weight: bold;
}

.badge.online {
    background: #dcfce7;
    color: #15803d;
}

.badge.offline {
    background: #fee2e2;
    color: #b91c1c;
}


/* ============================================================
   DISPOSITIVOS PATIO
   ============================================================ */

.device-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 14px;
}

.device-card {
    background: #f8fafc;

    border: 1px solid #e2e8f0;
    border-radius: 10px;

    padding: 16px;

    min-height: 190px;

    display: flex;
    flex-direction: column;
}

.device-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.device-icon {
    font-size: 30px;
}

.device-info h3 {
    margin: 0;
    font-size: 15px;
}

.device-info p {
    margin: 3px 0 0;
    color: #64748b;
    font-size: 12px;
}

.device-status {
    display: flex;
    align-items: center;
    gap: 7px;

    margin: 18px 0 13px;

    font-size: 12px;
    font-weight: bold;
}


/* ============================================================
   INDICADORES
   ============================================================ */

.indicator {
    width: 12px;
    height: 12px;

    display: inline-block;

    border-radius: 50%;
}

.indicator.on {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.indicator.off {
    background: #9ca3af;
}


/* ============================================================
   BOTONES
   ============================================================ */

.action-button {
    display: block;

    width: 100%;

    text-align: center;

    text-decoration: none;

    border-radius: 7px;

    padding: 10px 8px;

    font-size: 12px;
    font-weight: bold;

    margin-top: auto;
}

.action-button.blue {
    background: #2563eb;
    color: white;
}

.action-button.green {
    background: #16a34a;
    color: white;
}

.action-button.gray {
    background: #64748b;
    color: white;
}

.action-button:hover {
    opacity: 0.86;
}

.two-buttons {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 7px;

    margin-top: auto;
}


/* ============================================================
   PORTÓN
   ============================================================ */

.gate-status-box {
    background: #f8fafc;

    border: 1px solid #e2e8f0;

    border-radius: 10px;

    padding: 16px;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 15px;

    margin-bottom: 18px;
}

.gate-icon {
    font-size: 48px;
}

.small-title {
    color: #64748b;
    font-size: 11px;
    font-weight: bold;
}

.big-status {
    margin-top: 4px;

    font-size: 22px;
    font-weight: bold;
}


/* ============================================================
   SUBTÍTULOS
   ============================================================ */

.sub-title {
    color: #64748b;

    font-size: 11px;

    font-weight: bold;

    margin: 15px 0 8px;

    letter-spacing: 0.4px;
}

/* =====================================================
   PORTÓN - SENSORES AGRUPADOS
   ===================================================== */

.gate-sensors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.gate-sensor-group {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding: 10px;
}

.gate-sensor-title {
    text-align: center;
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 9px;
}

.gate-sensor-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.gate-leaf-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 9px;
}

.gate-leaf-button {
    border: none;
    padding: 9px 5px;
    border-radius: 7px;
    color: white;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.gate-leaf-button:hover {
    opacity: 0.86;
}

.gate-leaf-button.open {
    background: #16a34a;
}

.gate-leaf-button.close {
    background: #2563eb;
}


/* =====================================================
   MODO Y EMERGENCIA
   ===================================================== */

.gate-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.gate-info-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding: 12px;
    text-align: center;
}

/* ============================================================
   SENSORES
   ============================================================ */

.sensor-grid {
    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 9px;
}

.sensor-card {
    background: #f8fafc;

    border: 1px solid #e2e8f0;

    border-radius: 8px;

    padding: 11px;

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 5px;

    text-align: center;
}

.sensor-card strong {
    font-size: 11px;
}

.sensor-card small {
    color: #64748b;
    font-size: 10px;
}


/* ============================================================
   MOTORES
   ============================================================ */

.motor-grid {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 10px;
}

.motor-card {
    background: #f8fafc;

    border: 1px solid #e2e8f0;

    border-radius: 9px;

    padding: 13px;

    display: flex;
    align-items: center;

    gap: 12px;
}

.motor-icon {
    font-size: 28px;
}

.motor-card strong {
    display: block;
    font-size: 13px;
}

.motor-card span {
    display: block;

    margin-top: 3px;

    color: #64748b;

    font-size: 12px;
}

.motor-card.active {
    background: #dcfce7;
    border-color: #86efac;
}

.motor-card.active span {
    color: #15803d;
    font-weight: bold;
}

.motor-card.fault {
    background: #fee2e2;
    border-color: #fca5a5;
}

.motor-card.fault span {
    color: #b91c1c;
    font-weight: bold;
}


/* ============================================================
   ADVERTENCIA
   ============================================================ */

.warning-box {
    display: block;

    background: #fff7ed;

    border: 1px solid #fdba74;

    color: #c2410c;

    border-radius: 8px;

    padding: 11px;

    margin-top: 12px;

    font-size: 12px;

    font-weight: bold;

    text-align: center;
}


/* ============================================================
   BOTONES PORTÓN
   ============================================================ */

.gate-buttons {
    display: grid;

    grid-template-columns:
        repeat(5, 1fr);

    gap: 8px;
}

.gate-button {
    text-decoration: none;

    text-align: center;

    padding: 12px 7px;

    border-radius: 7px;

    color: white;

    font-size: 12px;

    font-weight: bold;
}

.gate-button:hover {
    opacity: 0.86;
}

.gate-button.open {
    background: #16a34a;
}

.gate-button.close {
    background: #2563eb;
}

.gate-button.stop {
    background: #dc2626;
}

.gate-button.local {
    background: #d97706;
}

.gate-button.reset {
    background: #475569;
}


/* ============================================================
   CÁMARA
   ============================================================ */

.camera-box {
    background: #f8fafc;

    border: 1px solid #e2e8f0;

    border-radius: 9px;

    padding: 15px;

    display: flex;

    align-items: center;

    gap: 12px;
}

.camera-icon {
    font-size: 32px;
}

.camera-box strong {
    display: block;

    font-size: 14px;
}

.camera-box span {
    display: block;

    margin-top: 3px;

    font-size: 12px;

    color: #b91c1c;

    font-weight: bold;
}

.detector-message {
    margin-top: 10px;

    background: #fee2e2;

    color: #b91c1c;

    border-radius: 7px;

    padding: 9px;

    font-size: 12px;

    font-weight: bold;
}

.detector-message.active {
    background: #dcfce7;

    color: #15803d;
}


/* ============================================================
   EVENTOS
   ============================================================ */

.events {
    border: 1px solid #e2e8f0;

    border-radius: 8px;

    overflow: hidden;

    background: #f8fafc;
}

.event {
    padding: 11px 13px;

    border-bottom: 1px solid #e2e8f0;

    font-size: 13px;
}

.event:last-child {
    border-bottom: none;
}

.no-events {
    padding: 16px;

    color: #64748b;

    text-align: center;

    font-size: 13px;
}

.events-note {
    margin-top: 7px;

    color: #94a3b8;

    font-size: 11px;

    text-align: right;
}


/* ============================================================
   PIE
   ============================================================ */

footer {
    text-align: center;

    color: #94a3b8;

    font-size: 11px;

    padding: 10px 0 25px;
}


/* ============================================================
   RESPONSIVE - TABLET
   ============================================================ */

@media (max-width: 900px) {

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

    .gate-buttons {
        grid-template-columns:
            repeat(3, 1fr);
    }

}


/* ============================================================
   RESPONSIVE - CELULAR
   ============================================================ */

@media (max-width: 600px) {

    .topbar-content {
        flex-wrap: wrap;
    }

    .server-status {
        margin-left: 0;
    }

    .logout-button {
        margin-left: auto;
    }

    .container {
        width: 95%;
        margin-top: 12px;
    }

    .card {
        padding: 14px;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

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

    .motor-grid {
        grid-template-columns: 1fr;
    }

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

    .gate-status-box {
        padding: 13px;
    }

    .section-title h2 {
        font-size: 18px;
    }

    .section-icon {
        font-size: 30px;
    }

}

/* =====================================================
   ESTADO PORTÓN
   ===================================================== */

.big-status.normal {
    color: #16a34a;
}

.big-status.local {
    color: #d97706;
}

.big-status.emergency {
    color: #dc2626;
}
