:root {
    --azul-sidebar: #1c3f60;
    --azul-sidebar-hover: #274f74;
    --aguamarina: #d5f3ec;
    --amarillo-ruta: #f4c430;
    --amarillo-ruta-hover: #e0b220;
    --gris-bloqueado: #c9c9c9;
    --texto-oscuro: #1f2a30;
    --blanco: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--texto-oscuro);
}

/* ---------- Login ---------- */

.login-page {
    height: 100vh;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8vh;
    background:
        linear-gradient(
            to bottom,
            rgba(20, 30, 55, 0.55) 0%,
            rgba(20, 30, 55, 0.15) 40%,
            rgba(20, 30, 55, 0.65) 100%
        ),
        url('/assets/img/login-fondo.jpg');
    background-size: cover;
    background-position: center;
}

.login-box {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    padding: 2rem 2.5rem;
    width: 320px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    text-align: center;
}

.login-brand {
    margin-bottom: 1.5rem;
}

.login-brand .ceo {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--azul-sidebar);
    letter-spacing: 1px;
}

.login-brand .x-business {
    font-size: 1rem;
    font-weight: 400;
    color: var(--texto-oscuro);
    margin-left: 0.35rem;
}

.login-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}

.login-box button {
    width: 100%;
    padding: 0.65rem;
    background: var(--azul-sidebar);
    color: var(--blanco);
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.login-box button:hover {
    background: var(--azul-sidebar-hover);
}

.login-error {
    background: #fbdede;
    color: #8a1f1f;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.login-suspendido {
    background: #fff3cd;
    color: #6b4e00;
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ---------- Layout principal ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--azul-sidebar);
    color: var(--blanco);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand .ceo {
    font-size: 1.4rem;
    font-weight: 800;
}

.sidebar-brand .x-business {
    font-size: 0.75rem;
    opacity: 0.85;
}

.sidebar-empresa {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    opacity: 0.9;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1rem;
}

.sidebar-logout {
    margin-top: 1rem;
    display: block;
    color: var(--blanco);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.85;
}

.sidebar-logout:first-of-type {
    margin-top: 2rem;
}

/* ---------- Sidebar: navegación de módulos ---------- */

.sidebar-nav {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.sidebar-modulo-titulo {
    display: block;
    font-weight: 600;
    padding: 0.5rem 0;
    cursor: pointer;
}

.sidebar-submenu {
    list-style: none;
    margin: 0 0 0.75rem 0;
    padding: 0;
    display: none;
}

.sidebar-modulo.abierto .sidebar-submenu {
    display: block;
}

.sidebar-submenu li {
    padding: 0.35rem 0 0.35rem 0.75rem;
}

.sidebar-submenu a {
    color: var(--blanco);
    text-decoration: none;
    opacity: 0.85;
}

.sidebar-submenu a:hover,
.sidebar-submenu a.activo {
    opacity: 1;
    text-decoration: underline;
}

.sidebar-modulo-simple {
    padding: 0.5rem 0;
    font-weight: 600;
}

.deshabilitado {
    opacity: 0.45;
    cursor: not-allowed;
}

.sidebar-logout:hover {
    opacity: 1;
    text-decoration: underline;
}

.content-area {
    flex-grow: 1;
    background: var(--aguamarina);
    padding: 2rem;
}

.principal-fondo {
    min-height: calc(100vh - 4rem);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 320px;
}

.rutas-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    max-width: 760px;
    margin: 0 auto;
}

.ruta-btn {
    display: block;
    background: var(--amarillo-ruta);
    border: none;
    border-radius: 10px;
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--texto-oscuro);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.ruta-btn:hover {
    background: var(--amarillo-ruta-hover);
}

.ruta-btn .ruta-fecha {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.ruta-btn.bloqueada {
    background: var(--gris-bloqueado);
    color: #6b6b6b;
    cursor: not-allowed;
    box-shadow: none;
}

.ruta-celda {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ruta-fecha-form {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.ruta-fecha-form input[type="date"] {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    padding: 0.2rem;
}

.ruta-fecha-form button {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    white-space: nowrap;
}

.consolidado-btn {
    display: block;
    grid-column: 1 / -1;
    background: var(--azul-sidebar);
    color: var(--blanco);
    border: none;
    border-radius: 10px;
    padding: 1.25rem;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.consolidado-btn:hover {
    background: var(--azul-sidebar-hover);
}

.inicio-btn {
    display: block;
    max-width: 760px;
    margin: 1.25rem auto 0;
    text-align: center;
    background: transparent;
    border: 2px solid var(--azul-sidebar);
    color: var(--azul-sidebar);
    border-radius: 10px;
    padding: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.inicio-btn:hover {
    background: var(--azul-sidebar);
    color: var(--blanco);
}

/* ---------- Tablas y formularios (módulos internos) ---------- */

.content-area h1 {
    font-size: 1.4rem;
    color: var(--azul-sidebar);
}

.tabla-datos {
    width: 100%;
    border-collapse: collapse;
    background: var(--blanco);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.tabla-datos th,
.tabla-datos td {
    text-align: left;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #e4e4e4;
    font-size: 0.9rem;
}

.tabla-datos th {
    background: var(--azul-sidebar);
    color: var(--blanco);
    font-weight: 600;
}

.form-datos {
    max-width: 480px;
    background: var(--blanco);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.form-datos label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    font-weight: 600;
    gap: 0.3rem;
}

.form-datos label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.form-datos .campo-destacado {
    font-size: 1.05rem;
    color: var(--azul-sidebar);
}

.form-datos .campo-resumen {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px dashed #ccc;
}

.form-datos input,
.form-datos select {
    padding: 0.5rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 400;
}

.form-datos button {
    align-self: flex-start;
    padding: 0.6rem 1.5rem;
    background: var(--azul-sidebar);
    color: var(--blanco);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.form-datos button:hover {
    background: var(--azul-sidebar-hover);
}

.acciones-cliente {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.boton-link {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--azul-sidebar);
    color: var(--blanco);
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
}

.boton-link:hover {
    background: var(--azul-sidebar-hover);
}

.form-datos .cancelar {
    color: var(--azul-sidebar);
    text-decoration: none;
    font-size: 0.85rem;
    align-self: center;
}

.form-errores {
    max-width: 480px;
    background: #fbdede;
    color: #8a1f1f;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.form-errores ul {
    margin: 0;
    padding-left: 1.1rem;
}

.buscador {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

.buscador input {
    padding: 0.5rem 0.7rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
}

.buscador button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: var(--azul-sidebar);
    color: var(--blanco);
    cursor: pointer;
}

.ref-posicion {
    max-width: 480px;
    background: var(--blanco);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.ref-posicion table {
    width: 100%;
    border-collapse: collapse;
}

.ref-posicion td {
    padding: 0.25rem 0.4rem;
    border-bottom: 1px solid #eee;
}

.badge-alerta {
    background: #fbdede;
    color: #8a1f1f;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.tabla-datos tr.mora-alta td {
    background: #fbdede;
    color: #8a1f1f;
}

.tabla-datos tr.fila-inconsistente td {
    background: #fff3cd;
    color: #7a5b00;
}

/* ---------- Tabla de trabajo (Cobro Diario): debe destacar del resto de tablas ---------- */

.tabla-trabajo th,
.tabla-trabajo td {
    font-size: 1.05rem;
}

.tabla-trabajo td {
    font-weight: 600;
    color: var(--texto-oscuro);
}

.tabla-trabajo td[data-label="Cliente"] {
    font-weight: 700;
}

/* ---------- Reportes: exportar a Excel / imprimir ---------- */

.reporte-acciones {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.reporte-acciones button,
.reporte-acciones a {
    padding: 0.5rem 1rem;
    border: 1px solid var(--azul-sidebar);
    border-radius: 6px;
    background: var(--blanco);
    color: var(--azul-sidebar);
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
}

.reporte-acciones button:hover,
.reporte-acciones a:hover {
    background: var(--azul-sidebar);
    color: var(--blanco);
}

@media print {
    .sidebar,
    .no-imprimir {
        display: none !important;
    }

    .app-shell,
    .content-area {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        background: var(--blanco) !important;
    }
}

/* ---------- Móvil: Login, Principal, Cobro Diario ---------- */

.menu-toggle {
    display: none;
}

@media (max-width: 768px) {
    .login-box {
        width: 90%;
        max-width: 320px;
    }

    input,
    select,
    button {
        font-size: 16px;
    }

    .menu-toggle {
        display: block;
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 60;
        width: 2.5rem;
        height: 2.5rem;
        border: none;
        border-radius: 6px;
        background: var(--azul-sidebar);
        color: var(--blanco);
        font-size: 1.3rem;
        cursor: pointer;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        width: 240px;
        z-index: 50;
        transition: left 0.2s ease-in-out;
        overflow-y: auto;
    }

    .sidebar.abierta {
        left: 0;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
    }

    .content-area {
        padding: 1rem;
        padding-top: 4rem;
    }

    .rutas-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.85rem;
    }

    .principal-fondo {
        background-size: 180px;
    }
}

@media (max-width: 400px) {
    .rutas-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .tabla-responsive thead {
        display: none;
    }

    .tabla-responsive,
    .tabla-responsive tbody,
    .tabla-responsive tr,
    .tabla-responsive td {
        display: block;
        width: 100%;
    }

    .tabla-responsive tr {
        margin-bottom: 0.75rem;
        border: 1px solid #e4e4e4;
        border-radius: 8px;
        padding: 0.5rem 0.75rem;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    }

    .tabla-responsive td {
        border-bottom: none;
        padding: 0.3rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    .tabla-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #555;
        flex-shrink: 0;
    }

    .tabla-responsive td.celda-abono {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabla-responsive td.celda-abono::before {
        margin-bottom: 0.3rem;
    }
}
