:root {
    --marino-950: #08122b;
    --marino-900: #0b1736;
    --marino-800: #0f2048;
    --marino-700: #152c5f;
    --marino-600: #1d3a78;
    --primario: #172d63;
    --verde: #0f9e7b;
    --verde-osc: #0b7a5f;
    --verde-claro: #def5ec;
    --lima: #a3d846;
    --texto: #12203f;
    --tenue: #66728c;
    --fondo: #f3f6fb;
    --superficie: #ffffff;
    --borde: #e3e8f1;
    --borde-2: #cfd7e6;
    --campo: #edf2fd;
    --ok: #0b7a5f;
    --ok-fondo: #def5ec;
    --error: #b42318;
    --error-fondo: #fdeceb;
    --aviso: #8a5300;
    --aviso-fondo: #fff4df;
    --radio: 14px;
    --radio-chico: 10px;
    --sombra: 0 1px 2px rgba(15, 32, 72, .04), 0 6px 18px rgba(15, 32, 72, .05);
    --sombra-alta: 0 24px 60px rgba(4, 12, 34, .45);
    --fuente: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --ancho-lateral: 258px;
}

/* =========================================================
   BASE
   ========================================================= */
* {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: var(--fuente);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--marino-600);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

h1,
h2,
h3 {
    margin: 0 0 .4rem;
    line-height: 1.2;
    letter-spacing: -.01em;
}

h1 {
    color: var(--marino-800);
    font-size: 1.5rem;
    font-weight: 800;
}

h2 {
    color: var(--marino-800);
    font-size: 1.08rem;
    font-weight: 700;
}

h3 {
    font-size: .98rem;
    font-weight: 700;
}

p {
    margin: 0 0 .8rem;
}

small,
.tenue {
    color: var(--tenue);
}

.num {
    font-variant-numeric: tabular-nums;
}

.nowrap {
    white-space: nowrap;
}

.pre {
    white-space: pre-wrap;
}

/* =========================================================
   MENÚ LATERAL
   ========================================================= */
.lateral {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1100;
    width: var(--ancho-lateral);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, var(--marino-900), var(--marino-950));
}

.lat-marca {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 12px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

    .lat-marca:hover {
        color: #fff;
        text-decoration: none;
    }

    .lat-marca img {
        width: 50px;
        height: auto;
        flex: none;
        filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .35));
    }

    .lat-marca strong {
        display: block;
        font-size: 1.02rem;
        font-weight: 800;
        letter-spacing: -.01em;
    }

    .lat-marca small {
        display: block;
        color: var(--lima);
        font-size: .74rem;
        font-weight: 700;
        letter-spacing: .04em;
    }

.lat-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 12px;
    margin-top: 14px;
}

.lat-seccion {
    margin: 16px 6px 8px;
    color: #7f8db0;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.lat-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 43px;
    padding: 10px 13px;
    color: #aebbd5;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: .87rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

    .lat-nav a i {
        width: 20px;
        flex-shrink: 0;
        color: #8999ba;
        font-size: 1rem;
        text-align: center;
        transition: color .18s ease;
    }

    .lat-nav a span {
        flex: 1;
    }

    .lat-nav a:hover {
        color: #fff;
        background: rgba(255, 255, 255, .06);
        border-color: rgba(255, 255, 255, .08);
        text-decoration: none;
        transform: translateX(2px);
    }

        .lat-nav a:hover i {
            color: var(--lima);
        }

    .lat-nav a.activo {
        color: #fff;
        background: rgba(15, 158, 123, .13);
        border-color: rgba(37, 190, 151, .65);
        box-shadow: inset 3px 0 0 var(--verde);
    }

        .lat-nav a.activo i {
            color: var(--lima);
        }

    .lat-nav a:focus,
    .lat-nav a:active {
        color: #fff;
        text-decoration: none;
    }

/* Pie del menú / usuario */
.lat-pie {
    margin-top: auto;
    padding: 16px 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.lat-usuario {
    display: flex;
    align-items: center;
    gap: 9px;
}

.lat-datos-usuario {
    min-width: 0;
    flex: 1;
}

.lat-nombre {
    display: block;
    overflow: hidden;
    color: #fff;
    font-size: .77rem;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lat-rol {
    display: block;
    margin-top: 2px;
    color: var(--lima);
    font-size: .67rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.avatar {
    width: 31px;
    height: 31px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--verde);
    border-radius: 8px;
    font-size: .61rem;
    font-weight: 800;
}

.lat-salir {
    width: 100%;
    min-height: 37px;
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 12px;
    padding: 8px 10px;
    color: #9eabc4;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    font-size: .76rem;
    font-weight: 600;
    text-decoration: none;
    transition: color .18s ease, background .18s ease, border-color .18s ease;
}

    .lat-salir i {
        font-size: .92rem;
    }

    .lat-salir:hover {
        color: #fff;
        background: rgba(255, 255, 255, .06);
        border-color: rgba(255, 255, 255, .15);
        text-decoration: none;
    }

/* =========================================================
   ÁREA PRINCIPAL / BARRA SUPERIOR
   ========================================================= */
.principal {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin-left: var(--ancho-lateral);
}

.superior {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 22px;
    background: rgba(243, 246, 251, .92);
    border-bottom: 1px solid var(--borde);
    backdrop-filter: blur(8px);
}

.ruta {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: var(--tenue);
    font-size: .9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .ruta strong {
        color: var(--texto);
        font-weight: 700;
    }

.reloj {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 5px 6px 5px 12px;
    color: var(--tenue);
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 999px;
    box-shadow: var(--sombra);
    font-size: .86rem;
}

.reloj-dia {
    padding: 2px 9px;
    color: var(--verde-osc);
    background: var(--verde-claro);
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.reloj-hora {
    padding: 3px 10px;
    color: var(--marino-800);
    background: #eef2f9;
    border-radius: 999px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: .82rem;
    font-weight: 700;
}

.btn-menu {
    display: none;
    padding: 7px;
    color: var(--marino-800);
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 10px;
    cursor: pointer;
}

.contenido {
    width: 100%;
    padding: 22px 24px 48px;
}

.velo {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(4, 12, 30, .55);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}

/* =========================================================
   CONTENEDORES GENERALES
   ========================================================= */
.encabezado {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

    .encabezado p {
        margin: 2px 0 0;
        color: var(--tenue);
    }

.acciones {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.migas {
    margin-bottom: 4px;
    color: var(--verde-osc);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

    .migas a {
        color: var(--verde-osc);
    }

.tarjeta {
    margin-bottom: 18px;
    padding: 20px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
}

    .tarjeta > h2:first-child,
    .tarjeta > h3:first-child {
        margin-bottom: 14px;
    }

.tarjeta-sin-relleno {
    padding: 0;
    overflow: hidden;
}

    .tarjeta-sin-relleno > .cabeza {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 14px 20px;
        border-bottom: 1px solid var(--borde);
        flex-wrap: wrap;
    }

        .tarjeta-sin-relleno > .cabeza h2 {
            margin: 0;
        }

.columnas {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.columnas-1-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 18px;
}

/* =========================================================
   MENSAJES
   ========================================================= */
.alerta {
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: var(--radio-chico);
    font-weight: 500;
}

.alerta-ok {
    color: var(--ok);
    background: var(--ok-fondo);
    border-color: #b5e6d3;
}

.alerta-error {
    color: var(--error);
    background: var(--error-fondo);
    border-color: #f4c2bd;
}

.alerta-aviso {
    color: var(--aviso);
    background: var(--aviso-fondo);
    border-color: #f2d49e;
}

.validation-summary-errors ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.field-validation-error {
    color: var(--error);
    font-size: .82rem;
}

/* =========================================================
   FORMULARIOS
   ========================================================= */
.form-rejilla {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
}

    .form-rejilla .completo {
        grid-column: 1 / -1;
    }

.campo label,
.campo .etiqueta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--marino-800);
    font-size: .85rem;
    font-weight: 700;
}

.campo .ayuda {
    margin-top: 4px;
    color: var(--tenue);
    font-size: .8rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    color: var(--texto);
    background: var(--campo);
    border: 1px solid #d6e0f3;
    border-radius: var(--radio-chico);
    font: inherit;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        background: #fff;
        border-color: var(--verde);
        box-shadow: 0 0 0 3px rgba(15, 158, 123, .16);
    }

    input[disabled],
    select[disabled],
    textarea[disabled],
    input[readonly],
    textarea[readonly] {
        color: #4b5671;
        background: #f1f3f8;
        border-color: var(--borde);
    }

.input-validation-error {
    border-color: var(--error) !important;
}

.pie-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.filtros {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 20px;
    background: #f8faff;
    border-bottom: 1px solid var(--borde);
    flex-wrap: wrap;
}

    .filtros .campo {
        min-width: 160px;
    }

        .filtros .campo.ancho {
            min-width: 260px;
            flex: 1;
        }

/* =========================================================
   BOTONES
   ========================================================= */
.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--marino-800);
    background: #fff;
    border: 1px solid var(--borde-2);
    border-radius: var(--radio-chico);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, box-shadow .15s, transform .05s;
}

    .btn:hover {
        background: #f2f5fb;
        text-decoration: none;
    }

    .btn:active {
        transform: translateY(1px);
    }

.btn-primario {
    color: #fff;
    background: linear-gradient(135deg, #1d3a78 0%, #0f2048 100%);
    border-color: #0f2048;
    box-shadow: 0 6px 16px rgba(15, 32, 72, .22);
}

    .btn-primario:hover {
        color: #fff;
        background: linear-gradient(135deg, #24468f 0%, #13285a 100%);
    }

.btn-ok {
    color: #fff;
    background: linear-gradient(135deg, #13b08a, var(--verde-osc));
    border-color: var(--verde-osc);
    box-shadow: 0 6px 16px rgba(11, 122, 95, .22);
}

    .btn-ok:hover {
        color: #fff;
        background: linear-gradient(135deg, #12a07e, #096a52);
    }

.btn-peligro {
    color: var(--error);
    border-color: #efb4ae;
}

    .btn-peligro:hover {
        background: var(--error-fondo);
    }

.btn-chico {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .8rem;
}

.btn-icono {
    min-height: 30px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: .85rem;
}

.btn[disabled],
.btn.deshabilitado {
    opacity: .5;
    pointer-events: none;
}

/* =========================================================
   TABLAS / ETIQUETAS
   ========================================================= */
.tabla-marco {
    overflow-x: auto;
}

table.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.tabla th {
    position: sticky;
    top: 0;
    padding: 11px 14px;
    color: #50607f;
    background: #f8faff;
    border-bottom: 1px solid var(--borde);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.tabla td {
    padding: 11px 14px;
    border-bottom: 1px solid #eef1f6;
    vertical-align: top;
}

.tabla tbody tr:hover td {
    background: #fafcff;
}

.vacio {
    padding: 38px 20px;
    color: var(--tenue);
    text-align: center;
}

.etq {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    white-space: nowrap;
}

.etq-ok {
    color: var(--ok);
    background: var(--ok-fondo);
}

.etq-error {
    color: var(--error);
    background: var(--error-fondo);
}

.etq-aviso {
    color: var(--aviso);
    background: var(--aviso-fondo);
}

.etq-neutra {
    color: #3b4865;
    background: #eef2f9;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1000px) {
    .columnas,
    .columnas-1-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    body.menu-abierto {
        overflow: hidden;
    }

    .lateral {
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 86vw);
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        transform: translateX(-105%);
        transition: transform .25s ease;
        -webkit-overflow-scrolling: touch;
    }

    body.menu-abierto .lateral {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, .4);
    }

    body.menu-abierto .velo {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .principal {
        position: relative;
        z-index: 1;
        margin-left: 0;
    }

    .btn-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .reloj-fecha {
        display: none;
    }

    .contenido {
        padding: 18px 16px 40px;
    }

    .lat-nav,
    .lat-pie {
        position: relative;
        z-index: 1101;
        pointer-events: auto;
    }

    .lat-filtro,
    .lat-filtro select {
        position: relative;
        z-index: 1101;
        pointer-events: auto;
    }

        .lat-filtro select {
            touch-action: manipulation;
        }
}

@media (max-width: 700px) {
    .form-rejilla {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .reloj-dia {
        display: none;
    }

    .superior {
        padding: 9px 12px;
    }

    .reloj {
        gap: 6px;
        padding-left: 9px;
    }

    .contenido {
        padding: 14px 12px 32px;
    }
}

/* =========================================================
   IMPRESIÓN
   ========================================================= */
.solo-impresion {
    display: none;
}

@media print {
    .lateral,
    .superior,
    .velo,
    .no-imprimir,
    .pie-form {
        display: none !important;
    }

    .principal {
        margin-left: 0;
    }

    .solo-impresion {
        display: block;
    }

    body {
        background: #fff;
    }

    .contenido {
        max-width: none;
        padding: 0;
    }

    .tarjeta {
        padding: 0;
        border: 0;
        box-shadow: none;
    }
}
/* =========================================================
   CORRECCIÓN RELOJ SUPERIOR
   ========================================================= */

.reloj {
    flex-shrink: 0;
    min-width: max-content;
    white-space: nowrap;
}

    .reloj .ico {
        width: 15px;
        height: 15px;
        flex: 0 0 15px;
    }

.reloj-dia,
.reloj-hora {
    flex-shrink: 0;
    white-space: nowrap;
}

.reloj-dia {
    min-width: 42px;
    text-align: center;
}

.reloj-hora {
    min-width: 82px;
    text-align: center;
}

@media (max-width: 980px) {
    .reloj {
        margin-left: auto;
    }
}

@media (max-width: 520px) {
    .reloj-dia {
        display: none;
    }

    .reloj-hora {
        min-width: 78px;
    }
}
