* {
    box-sizing: border-box;
}

:root {
    --fondo: #f4f7fb;
    --panel: #ffffff;
    --sidebar: #0f172a;
    --sidebar-secundario: #1e293b;
    --principal: #2563eb;
    --principal-oscuro: #1d4ed8;
    --texto: #172033;
    --texto-suave: #64748b;
    --borde: #e2e8f0;
    --peligro: #dc2626;
    --exito: #15803d;
}

body {
    margin: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 265px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    background: var(--sidebar);
    color: white;
}

.marca {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 5px 25px;
}

.marca-logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--principal);
    font-size: 25px;
    font-weight: 800;
}

.marca h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 1px;
}

.marca p {
    margin: 4px 0 0;
    color: #94a3b8;
    font-size: 11px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.sidebar nav a {
    padding: 13px 14px;
    border-radius: 9px;
    color: #cbd5e1;
    text-decoration: none;
    transition: .2s;
}

.sidebar nav a:hover,
.sidebar nav a.activo {
    background: var(--sidebar-secundario);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #334155;
}

.usuario-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}

.usuario-info span {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 12px;
}

.boton-salir {
    width: 100%;
    padding: 11px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: transparent;
    color: white;
    cursor: pointer;
}

.contenido {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.topbar h2 {
    margin: 0;
    font-size: 28px;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--texto-suave);
}

.fecha-actual {
    color: var(--texto-suave);
    font-size: 13px;
    text-transform: capitalize;
}

.metricas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metrica,
.panel {
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
}

.metrica {
    padding: 20px;
}

.metrica span {
    display: block;
    color: var(--texto-suave);
    font-size: 14px;
}

.metrica strong {
    display: block;
    margin: 10px 0 6px;
    font-size: 31px;
}

.metrica small {
    color: var(--texto-suave);
}

.grid-dos-columnas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.panel {
    padding: 20px;
    margin-bottom: 20px;
}

.panel-titulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.panel-titulo h3 {
    margin: 0;
}

.panel-titulo p {
    margin: 5px 0 0;
    color: var(--texto-suave);
    font-size: 13px;
}

.enlace-panel {
    color: var(--principal);
    font-weight: bold;
    text-decoration: none;
}

.ubicacion-fila,
.producto-resumen-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--borde);
}

.ubicacion-fila:last-child,
.producto-resumen-fila:last-child {
    border-bottom: 0;
}

.ubicacion-fila div,
.producto-resumen-fila div {
    display: flex;
    flex-direction: column;
}

.ubicacion-fila span,
.producto-resumen-fila span {
    margin-top: 4px;
    color: var(--texto-suave);
    font-size: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.formulario label {
    display: block;
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 14px;
}

.formulario input,
.formulario select,
.formulario textarea {
    width: 100%;
    margin-top: 7px;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: var(--texto);
}

.formulario textarea {
    min-height: 90px;
    resize: vertical;
}

.boton-principal,
.boton-peligro {
    border: 0;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.boton-principal {
    padding: 12px 19px;
    background: var(--principal);
}

.boton-principal:hover {
    background: var(--principal-oscuro);
}

.boton-peligro {
    padding: 8px 10px;
    background: var(--peligro);
}

.tabla-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--borde);
    text-align: left;
    white-space: nowrap;
    font-size: 13px;
}

th {
    background: #f8fafc;
    color: #475569;
}

.tipo,
.etiqueta,
.estado-activo,
.estado-inactivo {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: bold;
}

.tipo-entrada {
    background: #dcfce7;
    color: #166534;
}

.tipo-salida {
    background: #fee2e2;
    color: #991b1b;
}

.tipo-devolucion {
    background: #fef3c7;
    color: #92400e;
}

.tipo-danado {
    background: #ede9fe;
    color: #5b21b6;
}

.etiqueta {
    background: #e0e7ff;
    color: #3730a3;
}

.estado-activo {
    background: #dcfce7;
    color: #166534;
}

.estado-inactivo {
    background: #e2e8f0;
    color: #475569;
}

.aviso,
.aviso-lectura {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 10px;
}

.aviso {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.aviso-lectura {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.estado-vacio {
    padding: 25px;
    color: var(--texto-suave);
    text-align: center;
}

.numero-negativo {
    color: var(--peligro);
}

.pie {
    padding: 16px;
    color: var(--texto-suave);
    text-align: center;
    font-size: 12px;
}

/* LOGIN */

.login-body {
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
}

.login-contenedor {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px;
}

.login-tarjeta {
    width: 100%;
    max-width: 440px;
    padding: 38px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.login-marca {
    text-align: center;
    margin-bottom: 28px;
}

.login-marca h1 {
    margin: 0;
    color: #0f172a;
    font-size: 30px;
    letter-spacing: 2px;
}

.login-marca h2 {
    margin: 10px 0 5px;
    color: #334155;
    font-size: 20px;
}

.login-marca p {
    margin: 5px 0;
    color: #64748b;
}

.login-linea {
    width: 70px;
    height: 3px;
    margin: 18px auto;
    background: #2563eb;
    border-radius: 10px;
}

.login-formulario label {
    display: block;
    margin-bottom: 18px;
    color: #334155;
    font-weight: bold;
}

.login-formulario input {
    width: 100%;
    margin-top: 8px;
    padding: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.login-formulario button {
    width: 100%;
    padding: 14px;
    border: 0;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.login-error {
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    text-align: center;
    font-weight: bold;
}

.login-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}

.login-footer p {
    margin: 4px 0;
}

@media (max-width: 1050px) {
    .metricas {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-dos-columnas {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .app-layout {
        display: block;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }

    .sidebar-footer {
        margin-top: 25px;
    }

    .contenido {
        padding: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .metricas,
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.consulta-contenido {
    width: 94%;
    max-width: 1450px;
    margin: 0 auto;
    padding: 30px 0;
}

.consulta-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.consulta-cabecera h1 {
    margin: 0;
    font-size: 30px;
}

.consulta-cabecera p {
    margin: 7px 0 0;
    color: var(--texto-suave);
}

.boton-salir-consulta {
    padding: 11px 18px;
    border: 0;
    border-radius: 8px;
    background: #0f172a;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.consulta-bienvenida {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 15px 18px;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: #eff6ff;
    color: #1e40af;
}

.consulta-bienvenida strong {
    font-size: 17px;
}

.consulta-metricas {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.consulta-ubicaciones {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
}

.consulta-ubicacion {
    padding: 20px;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #f8fafc;
    text-align: center;
}

.consulta-ubicacion span {
    display: block;
    color: var(--texto-suave);
    font-size: 13px;
}

.consulta-ubicacion strong {
    display: block;
    margin: 12px 0 5px;
    font-size: 31px;
}

.consulta-ubicacion small {
    color: var(--texto-suave);
}

.consulta-actualizacion {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px;
    border-radius: 12px;
    background: #0f172a;
    color: white;
    text-align: center;
}

.consulta-actualizacion span,
.consulta-actualizacion small {
    color: #cbd5e1;
}

@media (max-width: 1100px) {
    .consulta-metricas {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .consulta-ubicaciones {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .consulta-cabecera {
        align-items: flex-start;
        flex-direction: column;
    }

    .consulta-metricas,
    .consulta-ubicaciones {
        grid-template-columns: 1fr;
    }
}

.consulta-acciones {
    display: flex;
    align-items: center;
    gap: 10px;
}

.boton-tema {
    padding: 11px 18px;
    border: 1px solid var(--borde);
    border-radius: 8px;
    background: var(--panel);
    color: var(--texto);
    font-weight: bold;
    cursor: pointer;
}

html[data-theme="oscuro"] {
    --fondo: #0b1120;
    --panel: #111827;
    --sidebar: #020617;
    --sidebar-secundario: #1e293b;
    --principal: #3b82f6;
    --principal-oscuro: #2563eb;
    --texto: #f8fafc;
    --texto-suave: #94a3b8;
    --borde: #334155;
    --peligro: #ef4444;
    --exito: #22c55e;
}

html[data-theme="oscuro"] body {
    background: var(--fondo);
    color: var(--texto);
}

html[data-theme="oscuro"] .panel,
html[data-theme="oscuro"] .metrica,
html[data-theme="oscuro"] .consulta-ubicacion {
    background: var(--panel);
    border-color: var(--borde);
    color: var(--texto);
}

html[data-theme="oscuro"] th {
    background: #1e293b;
    color: #cbd5e1;
}

html[data-theme="oscuro"] td {
    border-color: var(--borde);
}

html[data-theme="oscuro"] .consulta-bienvenida {
    background: #172554;
    border-color: #1d4ed8;
    color: #dbeafe;
}

html[data-theme="oscuro"] .consulta-ubicacion {
    background: #0f172a;
}

html[data-theme="oscuro"] .boton-tema {
    background: #1e293b;
    color: white;
    border-color: #475569;
}

html[data-theme="oscuro"] .consulta-actualizacion {
    background: #020617;
    border: 1px solid #334155;
}

html[data-theme="oscuro"] input,
html[data-theme="oscuro"] select,
html[data-theme="oscuro"] textarea {
    background: #0f172a;
    color: white;
    border-color: #475569;
}

@media (max-width: 650px) {
    .consulta-acciones {
        width: 100%;
        justify-content: space-between;
    }
}

.topbar-acciones {
    display: flex;
    align-items: center;
    gap: 14px;
}

html[data-theme="oscuro"] .contenido {
    background: var(--fondo);
}

html[data-theme="oscuro"] .topbar h2,
html[data-theme="oscuro"] .panel-titulo h3,
html[data-theme="oscuro"] .metrica strong,
html[data-theme="oscuro"] .ubicacion-fila strong,
html[data-theme="oscuro"] .producto-resumen-fila strong {
    color: var(--texto);
}

html[data-theme="oscuro"] .sidebar {
    background: #020617;
}

html[data-theme="oscuro"] .sidebar nav a:hover,
html[data-theme="oscuro"] .sidebar nav a.activo {
    background: #1e293b;
}

html[data-theme="oscuro"] .formulario input,
html[data-theme="oscuro"] .formulario select,
html[data-theme="oscuro"] .formulario textarea {
    background: #0f172a;
    color: #f8fafc;
    border-color: #475569;
}

@media (max-width: 760px) {
    .topbar-acciones {
        width: 100%;
        align-items: flex-start;
        flex-direction: column;
    }
}

.oculto {
    display: none !important;
}

.operacion-bloque {
    margin: 20px 0;
    padding: 18px;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #f8fafc;
}

.operacion-bloque h3 {
    margin-top: 0;
}

.calculo-operacion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    padding: 18px;
    border-radius: 10px;
    background: #e0e7ff;
    color: #3730a3;
}

.calculo-operacion strong {
    font-size: 25px;
}

.resumen-operacion {
    margin: 20px 0;
    padding: 18px;
    border-left: 5px solid var(--principal);
    border-radius: 10px;
    background: #eff6ff;
}

.resumen-operacion h3 {
    margin: 0 0 8px;
}

.resumen-operacion p {
    margin: 0;
    font-weight: bold;
}

html[data-theme="oscuro"] .operacion-bloque {
    background: #0f172a;
    border-color: #334155;
}

html[data-theme="oscuro"] .calculo-operacion {
    background: #172554;
    color: #dbeafe;
}

html[data-theme="oscuro"] .resumen-operacion {
    background: #172554;
    color: #dbeafe;
}

.desglose-salidas {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.desglose-tarjeta {
    padding: 18px;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #f8fafc;
}

.desglose-tarjeta span {
    display: block;
    color: var(--texto-suave);
    font-size: 13px;
}

.desglose-tarjeta strong {
    display: block;
    margin: 10px 0 5px;
    font-size: 20px;
}

.desglose-tarjeta small {
    color: var(--texto-suave);
}

.tipo-envio {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: bold;
}

.tipo-envio-unitario {
    background: #dcfce7;
    color: #166534;
}

.tipo-envio-doble {
    background: #dbeafe;
    color: #1e40af;
}

.tipo-envio-triple {
    background: #ede9fe;
    color: #5b21b6;
}

.tipo-envio-personalizado {
    background: #ffedd5;
    color: #9a3412;
}

.tipo-envio-otro {
    background: #e2e8f0;
    color: #475569;
}

html[data-theme="oscuro"] .desglose-tarjeta {
    background: #0f172a;
    border-color: #334155;
}

@media (max-width: 1100px) {
    .desglose-salidas {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .desglose-salidas {
        grid-template-columns: 1fr;
    }
}

.botones-periodo {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 18px;
}

.boton-periodo {
    padding: 9px 13px;
    border: 1px solid var(--borde);
    border-radius: 8px;
    background: var(--panel);
    color: var(--texto);
    text-decoration: none;
    font-weight: bold;
    font-size: 13px;
}

.boton-periodo:hover,
.boton-periodo.activo {
    background: var(--principal);
    border-color: var(--principal);
    color: white;
}

.rango-fechas {
    grid-template-columns: 1fr 1fr auto;
}

.campo-boton-filtro {
    display: flex;
    align-items: end;
    padding-bottom: 15px;
}

html[data-theme="oscuro"] .boton-periodo {
    background: #0f172a;
    border-color: #475569;
    color: #f8fafc;
}

html[data-theme="oscuro"] .boton-periodo:hover,
html[data-theme="oscuro"] .boton-periodo.activo {
    background: var(--principal);
    border-color: var(--principal);
}

@media (max-width: 760px) {
    .rango-fechas {
        grid-template-columns: 1fr;
    }

    .campo-boton-filtro {
        padding-bottom: 0;
    }
}
