:root {
    --fondo-1: #041E42;
    --fondo-2: #0A3F8A;
    --tile: rgba(8, 44, 104, .72);
    --borde: rgba(120, 180, 255, .45);
    --texto: #FFFFFF;
    --suave: #A9C7F2;
    --verde: #3DFF7A;
    --verde-osc: #14853B;
    --ambar: #FFC940;
    --rojo: #FF6B5E;
    --bs-body-bg: #041E42;
    --bs-body-color: #FFFFFF;
}

html { background: #0B4FA8; }
body {
    background: linear-gradient(170deg, var(--fondo-1) 0%, var(--fondo-2) 70%, #0B4FA8 100%);
    color: var(--texto); min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }

.barra { background: rgba(2, 18, 46, .85); border-bottom: 1px solid var(--borde); }
.marca { font-weight: 800; letter-spacing: .06em; }
.marca span, .login-marca span { color: var(--verde); }
.usuario { line-height: 1.15; color: #fff !important; font-size: .9rem; }
.usuario small { display: block; color: var(--suave); font-size: .75rem; }
.pie { text-align: center; font-size: .78rem; color: var(--suave); padding: .8rem; }
.conexion, .sub { color: var(--suave); }
.enlace { color: #fff; text-decoration: none; }
.enlace:hover { color: var(--verde); }

.btn-primary { background: #1565D8; border-color: #4C93F5; }
.btn-primary:hover, .btn-primary:focus { background: #0E4FB0; border-color: #4C93F5; }

.titulo { font-size: 1.3rem; font-weight: 800; margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.panel, .tile { background: var(--tile); border: 1px solid var(--borde); border-radius: 10px;
    box-shadow: inset 0 0 24px rgba(60, 140, 255, .12); }
.panel { padding: 1rem; }

/* Tiles de valores */
.tile { padding: .7rem 1rem .9rem; min-width: 0; }
.tile-titulo { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #E3EEFF; }
.tile-titulo small { color: var(--suave); font-weight: 600; }
.tile-cuerpo { display: flex; align-items: center; justify-content: center; gap: 1rem; min-height: 5.2rem; }
.tile-valor { font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
    text-align: center; display: flex; flex-direction: column; align-items: center; }
.unidad { font-size: 1rem; font-weight: 700; color: #DCE9FF; margin-top: .2rem; }
.icono { width: 2.4rem; height: 2.4rem; color: #BBD6FF; flex: none; }
.icono.sigma { font-size: 2.4rem; line-height: 1; width: auto; height: auto; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }
.kpis .tile-valor { flex-direction: row; align-items: baseline; gap: .4rem; font-size: 2.2rem; margin-top: .5rem; justify-content: flex-start; }
.kpis .unidad { margin: 0; }
.tile.destacado, .tile.flujo-inst { background: linear-gradient(180deg, #1FA54A, #0C6B2C); border-color: #6BFF9B;
    box-shadow: 0 0 18px rgba(61, 255, 122, .35); }
.grafico { height: 300px; }
.num { font-variant-numeric: tabular-nums; }
.num.grande { font-size: 1.15rem; font-weight: 700; color: var(--verde); }

.estado { font-size: .72rem; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.estado::before { content: ""; display: inline-block; width: .65rem; height: .65rem; border-radius: 50%;
    background: currentColor; margin-right: .4rem; }
.operativo { color: var(--verde); }
.detenido { color: var(--ambar); }
.sinsenal { color: var(--rojo); }

/* Pantalla de monitoreo */
.hmi-cab { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding-bottom: .8rem; margin-bottom: .9rem;
    border-bottom: 1px solid var(--borde); }
.hmi-volver { color: #fff; text-decoration: none; font-size: 1.5rem; line-height: 1; }
.hmi-empresa { font-size: 1.5rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
    padding-right: 1rem; border-right: 2px solid var(--borde); }
.hmi-nombre strong { display: block; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .04em; }
.hmi-nombre span { font-size: .8rem; text-transform: uppercase; color: var(--suave); }
.hmi-config { color: #fff; }
.hmi-rejilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.flujo-inst .tile-titulo { text-align: center; font-size: 1rem; }
.flujo-inst .tile-valor { font-size: 3.6rem; color: var(--verde); text-shadow: 0 0 14px rgba(61, 255, 122, .5); }
.flujo-inst .icono { color: var(--verde); }
.flujo-inst.apagado { background: var(--tile); border-color: var(--borde); box-shadow: inset 0 0 24px rgba(60, 140, 255, .12); }
.flujo-inst.apagado .tile-valor, .flujo-inst.apagado .icono { color: #fff; text-shadow: none; }
.hmi-estado { display: flex; align-items: center; gap: .8rem; font-size: 1.4rem; font-weight: 800; }
.hmi-estado i { width: 2.2rem; height: 2.2rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 14px currentColor; }
.hmi-fecha { display: flex; gap: 1.2rem; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; flex-wrap: wrap; justify-content: center; }
.actualizacion .tile-cuerpo { min-height: 4rem; }

.correa { grid-column: span 2; display: flex; align-items: center; }
.correa svg { width: 100%; height: auto; max-height: 190px; }
.c-texto { fill: var(--verde); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.c-flecha { stroke: var(--verde); stroke-width: 4; }
.c-punta { fill: var(--verde); }
.c-tolva { fill: #7C8794; stroke: #C9D2DC; stroke-width: 2; stroke-linejoin: round; }
.c-material-fijo { fill: #1C2026; }
.c-material { stroke: #1C2026; stroke-width: 13; stroke-linecap: round; stroke-dasharray: .1 15; fill: none; }
.c-banda { fill: #0B0F14; stroke: #56616E; stroke-width: 3; }
.c-polea { fill: #2B333D; stroke: #C9D2DC; stroke-width: 3; }
.c-rodillo circle { fill: #8E99A6; }
.c-puente { fill: #1E88FF; stroke: #9CCBFF; stroke-width: 1.5; }
.c-celda { fill: #0D5FD0; stroke: #9CCBFF; stroke-width: 1.5; }
.c-soporte { stroke: #56616E; stroke-width: 5; stroke-linecap: round; fill: none; }
.c-caida circle { fill: #1C2026; opacity: 0; }
.correa.andando .c-material { animation: mover .6s linear infinite; }
.correa.andando .c-caida circle { opacity: 1; }
@keyframes mover { from { stroke-dashoffset: 15.1; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .correa.andando .c-material { animation: none; } }

@media (max-width: 900px) {
    .hmi-rejilla { grid-template-columns: repeat(2, 1fr); }
    .correa { grid-column: span 2; }
    .actualizacion { grid-column: span 2; }
    .tile-valor { font-size: 2rem; }
    .flujo-inst .tile-valor { font-size: 2.6rem; }
    .hmi-empresa { font-size: 1.1rem; }
}
@media (max-width: 520px) {
    .hmi-rejilla { grid-template-columns: 1fr; }
    .correa, .actualizacion { grid-column: auto; }
}

/* Login */
.login-caja { max-width: 380px; margin: 9vh auto 0; background: var(--tile); border: 1px solid var(--borde);
    border-radius: 12px; padding: 2rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.login-marca { font-size: 2.1rem; font-weight: 800; letter-spacing: .06em; text-align: center; }
.login-sub { text-align: center; color: var(--suave); margin-bottom: 1.5rem; }

/* Formularios y tablas sobre fondo azul */
.form-control, .form-select { background-color: rgba(2, 18, 46, .6); border-color: var(--borde); color: #fff; }
.form-control:focus, .form-select:focus { background-color: rgba(2, 18, 46, .8); color: #fff; }
.form-text { color: var(--suave); }
.table { --bs-table-bg: transparent; --bs-table-color: #fff; --bs-table-border-color: rgba(120, 180, 255, .2);
    --bs-table-striped-bg: rgba(255, 255, 255, .04); --bs-table-striped-color: #fff; }
.table thead th { background: rgba(2, 18, 46, .7); color: #E3EEFF; font-weight: 700; font-size: .78rem;
    text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table td { font-variant-numeric: tabular-nums; vertical-align: middle; }
.clave { font-family: Consolas, monospace; font-size: .8rem; word-break: break-all; }

/* Reportes */
.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.resumen .panel { padding: .7rem 1rem; }
.etiqueta { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #E3EEFF; font-weight: 700; }
.valor { font-variant-numeric: tabular-nums; font-weight: 800; line-height: 1.2; font-size: 1.6rem; }
.valor .unidad { margin-left: .3rem; }
.resumen .principal .valor { color: var(--verde); }
.hmi-config { font-size: 1.7rem; line-height: 1; text-decoration: none; }
.col-nombre { min-width: 190px; }

/* Logo */
.logo-barra { height: 38px; width: auto; background: #fff; border-radius: 6px; padding: 2px 6px; }
.marca-texto span { color: var(--verde); }
.logo-login { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 1.2rem; background: #fff; border-radius: 8px; padding: 4px 10px; }
.marca > .marca-texto { color: #fff; }
.pie strong { color: #fff; letter-spacing: .04em; }
.pie { display: flex; align-items: center; justify-content: center; gap: .4rem; flex-wrap: wrap; }
.logo-fatval { height: 30px; width: auto; background: #fff; border-radius: 5px; padding: 2px 6px; }

/* Monitor sin carga en celda: la correa ocupa todo el ancho */
.correa { grid-column: 1 / -1; justify-content: center; }
.correa svg { max-width: 900px; }
.actualizacion { grid-column: auto; }
.actualizacion .tile-cuerpo { min-height: 5.2rem; }
@media (max-width: 900px) { .actualizacion { grid-column: 1 / -1; } }

/* Dashboard con un pesómetro elegido: estado de comunicación con la última lectura debajo */
.kpis .tile-valor.apilado { flex-direction: column; align-items: flex-start; gap: .25rem; font-size: 1.9rem; }
.kpis .tile-valor.apilado .unidad { font-size: .85rem; font-weight: 600; color: var(--suave); }

/* Ventana de envío de correo */
.modal-content { background: #072A5C; border: 1px solid var(--borde); color: #fff; }
.modal-header, .modal-footer { border-color: rgba(120, 180, 255, .25); }

/* Equivalente en metros cúbicos bajo cada valor en toneladas */
.tile-m3 { font-size: .95rem; font-weight: 700; color: var(--suave); margin-top: .35rem; font-variant-numeric: tabular-nums; }
.tile-valor .tile-m3 { margin-top: .3rem; }
.flujo-inst .tile-m3 { color: #C9FFD9; }
.flujo-inst.apagado .tile-m3, .tile.destacado .tile-m3 { color: #DCE9FF; }

.densidad { display: flex; align-items: center; gap: .5rem 1.2rem; flex-wrap: wrap; padding: .7rem 1rem; }

.destinatarios li { display: flex; justify-content: space-between; align-items: center; gap: .5rem;
    padding: .4rem 0; border-bottom: 1px solid rgba(120, 180, 255, .2); }

.turnos input[type=time] { max-width: 130px; }
.turnos input[name=nombre] { max-width: 220px; }
.turnos .nuevo td { background: rgba(255, 255, 255, .03); }
.turnos input.minutos { width: 80px; }

/* Filtro de reportes: fecha + hora */
.hora { max-width: 112px; flex: none; }
.destinatarios li .correo { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.destinatarios li .tipos-destinatario label { cursor: pointer; white-space: nowrap; }
