:root {
    --azul-oscuro: #0b1f3a;
    --azul: #0d5eb0;
    --azul-claro: #3b9dff;
    --gris-fondo: #f2f5f9;
    --verde-ok: #1c9d55;
    --naranja: #e8912d;
    --rojo: #d9364a;
    --gris-neutro: #6c7a89;
    --blanco: #ffffff;
    --radio: 12px;
}

* { box-sizing: border-box; }

body {
    background: var(--gris-fondo);
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    color: #1c2733;
}

/* ---------- Barra superior ---------- */
.navbar-app {
    background: linear-gradient(90deg, var(--azul-oscuro), var(--azul));
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.navbar-app .navbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    font-weight: 600;
}
.navbar-app .navbar-brand img {
    height: 38px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}
.navbar-app .nav-link {
    color: rgba(255,255,255,.85) !important;
}
.navbar-app .nav-link:hover { color: #fff !important; }

/* ---------- Sidebar (admin/colaborador) ---------- */
.layout-app { display: flex; min-height: calc(100vh - 60px); }
.sidebar-app {
    width: 230px;
    background: var(--azul-oscuro);
    color: #dce6f2;
    flex-shrink: 0;
    padding: 1rem 0;
}
.sidebar-app a {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #cddcee;
    text-decoration: none;
    padding: .65rem 1.2rem;
    font-size: .95rem;
    border-left: 3px solid transparent;
}
.sidebar-app a:hover, .sidebar-app a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: var(--azul-claro);
}
.main-content { flex: 1; padding: 1.3rem; min-width: 0; }

@media (max-width: 768px) {
    .layout-app { flex-direction: column; }
    .sidebar-app {
        width: 100%;
        display: flex;
        overflow-x: auto;
        padding: .3rem;
    }
    .sidebar-app a {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: .55rem .9rem;
    }
    .sidebar-app a:hover, .sidebar-app a.active {
        border-left-color: transparent;
        border-bottom-color: var(--azul-claro);
    }
}

/* ---------- Tarjetas del panel de control ---------- */
.kpi-card {
    background: var(--blanco);
    border-radius: var(--radio);
    padding: 1.1rem 1.3rem;
    box-shadow: 0 2px 10px rgba(15,44,70,.08);
    display: flex;
    align-items: center;
    gap: .9rem;
    height: 100%;
}
.kpi-card .icono {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
}
.kpi-card .valor { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.kpi-card .etiqueta { color: var(--gris-neutro); font-size: .85rem; }
.bg-clientes { background: var(--azul); }
.bg-pedidos { background: #6f42c1; }
.bg-pendientes { background: var(--naranja); }
.bg-nofactible { background: var(--rojo); }
.bg-instalados { background: var(--verde-ok); }

/* ---------- Badges de estado ---------- */
.badge-estado { font-size: .78rem; padding: .4em .7em; border-radius: 20px; font-weight: 600; }
.badge-no-revisado { background: #e2e6ea; color: #495057; }
.badge-factible { background: #fde9d0; color: #a6650f; }
.badge-no-factible { background: #fbdbe0; color: #9c2036; }
.badge-instalado { background: #d3f3e0; color: #157347; }

/* ---------- Alarma parpadeante (7 días sin cambio de estado) ---------- */
@keyframes parpadeoAlarma {
    0%   { background-color: #ffffff; }
    50%  { background-color: #ffd6db; }
    100% { background-color: #ffffff; }
}
tr.fila-alarma { animation: parpadeoAlarma 1.2s infinite; }
.icono-sirena { animation: parpadeoSirena 1s infinite; display: inline-block; }
@keyframes parpadeoSirena {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(1.15); }
}

/* ---------- WhatsApp / coordenadas en tablas ---------- */
.btn-whatsapp {
    background: #25D366; color: #fff; border: none;
    border-radius: 20px; padding: .3rem .8rem; font-size: .82rem;
    display: inline-flex; align-items: center; gap: .35rem;
    text-decoration: none;
}
.btn-whatsapp:hover { background: #1ebe5b; color: #fff; }
.link-coordenadas {
    font-family: monospace;
    font-size: .8rem;
    color: var(--azul);
    text-decoration: underline dotted;
}

/* ---------- Login (admin / colaborador) ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--azul-oscuro), var(--azul));
    padding: 1rem;
}
.login-card {
    background: #fff;
    border-radius: var(--radio);
    padding: 2.2rem 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    text-align: center;
}
/* Tamaño por defecto y seguro para el logotipo en cualquier contexto,
   evita que se vea "gigantesco" si el archivo subido tiene dimensiones
   grandes. Los selectores más específicos de abajo pueden ajustarlo. */
img.logo {
    height: 64px;
    width: auto;
    max-width: 240px;
    object-fit: contain;
}

.login-card img.logo { height: 70px; margin-bottom: 1rem; }

/* ---------- Módulo cliente ---------- */
.cliente-wrapper {
    max-width: 560px;
    margin: 0 auto;
    padding: 1.2rem;
}
.cliente-header { text-align: center; margin-bottom: 1rem; }
.cliente-header img.logo { height: 64px; margin-bottom: .5rem; }

.mensaje-alerta-ubicacion {
    animation: parpadeoAlertaUbicacion 0.9s infinite;
    color: #ffffff;
    font-weight: 800;
    letter-spacing: .03em;
    text-align: center;
    padding: .9rem;
    border-radius: var(--radio);
    background: var(--rojo);
    border: 2px solid #ffffff;
    box-shadow: 0 0 14px rgba(217,54,74,.55);
    font-size: 1.02rem;
}
@keyframes parpadeoAlertaUbicacion {
    0%, 100% { background-color: var(--rojo); transform: scale(1); }
    50% { background-color: #ff0022; transform: scale(1.02); }
}

.mensaje-ok-ubicacion {
    text-align: center;
    padding: .7rem;
    border-radius: var(--radio);
    background: #eafaf1;
    border: 1px solid var(--verde-ok);
    color: #157347;
    font-weight: 600;
}

#mapaCliente, #mapaEdicion, #mapaSectorial { height: 320px; border-radius: var(--radio); width: 100%; }

.card-form { background: #fff; border-radius: var(--radio); padding: 1.3rem; box-shadow: 0 2px 10px rgba(15,44,70,.08); }

.captcha-box {
    background: #eef3fa;
    border: 1px dashed var(--azul);
    border-radius: 8px;
    padding: .6rem .9rem;
    font-weight: 600;
    display: inline-block;
}

.thumb-elevacion { max-width: 100%; border-radius: 8px; border: 1px solid #dee2e6; }

/* Tabla responsiva compacta en móviles */
@media (max-width: 576px) {
    .table-responsive-stack thead { display: none; }
    .table-responsive-stack tr { display: block; margin-bottom: .8rem; border: 1px solid #e3e7ec; border-radius: 10px; padding: .6rem; background: #fff; }
    .table-responsive-stack td { display: flex; justify-content: space-between; gap: .6rem; padding: .35rem 0; border: none; text-align: right; }
    .table-responsive-stack td::before { content: attr(data-label); font-weight: 600; color: var(--gris-neutro); text-align: left; }
}
