:root {
  --azul: #0b2545;
  --azul-claro: #13315c;
  --verde: #1c7c3e;
  --amarillo: #b8860b;
  --rojo: #b3261e;
  --gris: #f4f6f8;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Arial, sans-serif; background: var(--gris); color: #1a1a1a; }
.oculto { display: none !important; }

.topbar {
  background: white; color: var(--azul); padding: 12px 20px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #e2e2e2;
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.topbar-derecha { display: flex; gap: 14px; align-items: center; font-size: 0.85rem; }

.estado-conexion { padding: 4px 10px; border-radius: 12px; font-weight: 600; }
.estado-conexion.en-linea { background: #e3f5e9; color: #1c7c3e; }
.estado-conexion.offline { background: #fbe4e2; color: #b3261e; }

.topbar-logo { height: 54px; image-rendering: -webkit-optimize-contrast; }

.contenedor-login {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 20px; text-align: center; position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(79,195,247,0.15), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(30,95,191,0.25), transparent 45%),
    linear-gradient(160deg, #0b1a33 0%, #0b2545 55%, #082044 100%);
}
.contenedor-login::before {
  content: ''; position: absolute; inset: 0; opacity: 0.22; pointer-events: none;
  background-image:
    linear-gradient(rgba(79,195,247,0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,195,247,0.18) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 45%, transparent 18%, black 75%);
}

.red-nodos {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none;
}
.red-nodos line { stroke: #4fc3f7; stroke-width: 1; opacity: 0.28; }
.red-nodos .nodo { fill: #4fc3f7; opacity: 0.55; }
.red-nodos .nodo-pulso { fill: #7be0ff; animation: pulso-nodo 3.2s ease-in-out infinite; }
@keyframes pulso-nodo {
  0%, 100% { opacity: 0.4; r: 2.6; }
  50% { opacity: 1; r: 5; filter: drop-shadow(0 0 6px #7be0ff); }
}

.icono-decorativo-login {
  position: absolute; z-index: 0; width: 90px; height: 90px; stroke: #4fc3f7; fill: none;
  stroke-width: 1; opacity: 0.16; pointer-events: none;
}

.login-logo-unico { width: 100%; max-width: 600px; position: relative; z-index: 1; margin-bottom: 4px; }

.login-tarjeta {
  width: 100%; max-width: 380px; position: relative; z-index: 1; background: none; box-shadow: none; padding: 0;
}
.login-bienvenida { color: #cfe0f5; margin: 0 0 14px; font-size: 0.95rem; }

.login-tarjeta label { color: #cfe0f5; text-align: left; }
.campo-con-icono { position: relative; margin-top: 4px; }
.campo-con-icono .icono-campo {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; stroke: #8fb3da; fill: none; stroke-width: 1.7; pointer-events: none;
}
.campo-con-icono input {
  width: 100%; box-sizing: border-box; padding: 10px 12px 10px 38px; margin-top: 0;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); border-radius: 8px; color: white;
}
.campo-con-icono input::placeholder { color: #8fb3da; }
.login-tarjeta .nota { color: #9fb8d8; }
.login-tarjeta button[type="submit"] { width: 100%; background: #1a73b8; }
.login-tarjeta button[type="submit"]:hover { background: #4fc3f7; }
.login-tarjeta .mensaje-error { color: #ff8a80; }
.tarjeta { background: white; border-radius: 10px; padding: 24px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); margin: 16px; }

form label { display: block; margin-top: 10px; font-size: 0.85rem; font-weight: 600; color: var(--azul-claro); }
input, select, textarea {
  width: 100%; padding: 8px 10px; margin-top: 4px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.95rem;
}
button {
  margin-top: 16px; background: var(--azul); color: white; border: none;
  padding: 10px 18px; border-radius: 6px; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--azul-claro); }

.boton-flotante-guardar {
  position: sticky; bottom: 16px; left: 0; margin: 16px; padding: 14px 24px;
  font-size: 1rem; box-shadow: 0 4px 14px rgba(0,0,0,0.25); z-index: 5;
}

.mensaje-error { color: var(--rojo); font-size: 0.85rem; }
.nota { font-size: 0.78rem; color: #666; margin-top: 8px; }

.barra-usuario {
  background: white; padding: 10px 20px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid #ddd;
}
.contenido { flex: 1; min-width: 0; padding: 20px 28px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }

.resultado-evaluacion {
  margin-top: 16px; padding: 14px; background: var(--gris); border-radius: 8px; border: 1px dashed #bbb;
}
.etiqueta { font-weight: 600; color: var(--azul-claro); }
.condicion { font-weight: 700; }
.condicion-bueno { color: var(--verde); }
.condicion-regular { color: var(--amarillo); }
.condicion-malo { color: var(--rojo); }

.tabla { width: 100%; border-collapse: collapse; margin-top: 10px; }
.tabla th, .tabla td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e5e5; font-size: 0.9rem; }

.badge { padding: 3px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 700; }
.badge-sincronizado { background: #1c7c3e22; color: var(--verde); }
.badge-pendiente { background: #b8860b22; color: var(--amarillo); }
.badge-conflicto { background: #b3261e22; color: var(--rojo); }

.layout-con-sidebar { display: flex; align-items: flex-start; }

.tabs.sidebar {
  display: flex; flex-direction: column; gap: 2px; background: var(--azul); padding: 10px 0;
  border-right: 1px solid var(--azul); width: 220px; flex-shrink: 0; min-height: calc(100vh - 110px);
}
.tab-nav {
  background: none; color: #cfe0f5; border: none; margin: 0; padding: 12px 20px;
  border-left: 3px solid transparent; border-radius: 0; font-weight: 600; cursor: pointer; text-align: left;
}
.tab-nav.activo { border-left-color: #4fc3f7; background: var(--azul-claro); color: white; }
.tab-nav:hover { background: var(--azul-claro); color: white; }

.icono-menu, .icono-tipo {
  width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; margin-right: 6px; flex-shrink: 0;
}

.modulo.oculto { display: none; }

@media (max-width: 900px) {
  .layout-con-sidebar { flex-direction: column; }
  .tabs.sidebar {
    flex-direction: row; width: 100%; overflow-x: auto; border-right: none; border-bottom: 1px solid #ddd;
    min-height: auto;
  }
  .tab-nav { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .tab-nav.activo { border-left: none; border-bottom-color: var(--azul); }
}

.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { text-align: center; margin: 0; }
.kpi span { display: block; font-size: 1.8rem; font-weight: 800; color: var(--azul); }
.kpi label { font-size: 0.8rem; color: #555; }
.kpi-bueno span { color: var(--verde); }
.kpi-regular span { color: var(--amarillo); }
.kpi-malo span { color: var(--rojo); }

.grid-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 16px; }
.grid-checks label {
  font-weight: 500; color: #333; display: flex; align-items: center; gap: 8px;
  white-space: nowrap; justify-content: flex-start;
}
.grid-checks input[type="radio"] {
  margin: 0; width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--azul);
}

fieldset.bloque-tipo-equipo {
  border: 1px solid #ddd; border-radius: 8px; padding: 16px; margin-top: 16px; background: #fbfcfe;
}
fieldset.bloque-tipo-equipo legend { font-weight: 700; color: var(--azul); padding: 0 8px; }
fieldset.bloque-tipo-equipo h4 { margin-top: 14px; color: var(--azul-claro); }

@media (max-width: 720px) {
  .grid-2, .grid-4, .grid-checks, .grid-kpi { grid-template-columns: 1fr; }
}

.fila-clicable { cursor: pointer; }
.fila-clicable:hover { background: #eef2f8; }

.grid-reportes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.reporte-item h3 { margin-top: 0; color: var(--azul-claro); }
.reporte-botones { display: flex; gap: 8px; margin-top: 10px; }
.reporte-botones button { margin-top: 0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.oculto { display: none; }
.modal-caja { background: white; border-radius: 10px; padding: 24px; max-width: 640px; width: 90%; max-height: 85vh; overflow-y: auto; position: relative; }
.modal-caja-ancha { max-width: 920px; }
.btn-editar-fila { background: none; border: none; color: var(--azul); cursor: pointer; padding: 4px 8px; margin: 0; display: inline-flex; align-items: center; }
.btn-editar-fila:hover { background: var(--gris); border-radius: 6px; }
.btn-editar-fila .icono-tipo { margin-right: 0; }
.modal-cerrar { position: absolute; top: 10px; right: 14px; background: none; color: #555; font-size: 1.4rem; padding: 0; margin: 0; }
.modal-cerrar:hover { background: none; color: var(--rojo); }
.modal-caja h3 { color: var(--azul-claro); margin-top: 18px; }
.modal-caja table td:first-child { font-weight: 600; width: 45%; text-transform: capitalize; }

#form-busqueda-global { display: flex; gap: 8px; }
#form-busqueda-global input { flex: 1; margin-top: 0; }
#form-busqueda-global button { margin-top: 0; }

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

.ficha-acciones { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.ficha-acciones button { margin-top: 0; }
.btn-peligro { background: var(--rojo); }
.btn-peligro:hover { background: #8f1e18; }

.ficha-qr { text-align: center; margin: 10px 0; }
.ficha-qr img { border: 1px solid #ddd; border-radius: 6px; padding: 6px; background: white; }

@media print {
  .topbar, .barra-usuario, .tabs, .no-imprimir { display: none !important; }
  .modal { position: static; background: none; }
  .modal-caja { box-shadow: none; max-height: none; overflow: visible; width: 100%; }
  body { background: white; }
}

.boveda-clave-oculta { cursor: pointer; font-family: monospace; user-select: none; color: var(--azul-claro); }
.boveda-clave-oculta:hover { text-decoration: underline; }

.reporte-sensible { border: 1px solid var(--rojo); background: #fdf3f2; }
.reporte-sensible h3 { color: var(--rojo); }

.btn-secundario { background: transparent; border: 1px solid white; color: white; margin-right: 8px; }
.btn-secundario:hover { background: rgba(255,255,255,0.15); }
.barra-usuario div { display: flex; }
.barra-usuario .btn-secundario { background: var(--azul-claro); border: none; color: white; }

.permiso-check { display: flex; gap: 6px; align-items: center; font-weight: 500; margin-bottom: 4px; }
.permiso-check input { width: auto; margin: 0; }

.btn-mini { padding: 4px 8px; font-size: 0.78rem; margin: 0 2px 0 0; }

.fila-vencida td { color: var(--rojo); font-weight: 600; }

.fila-ip-ocupada { background: #fdecea; }
.fila-ip-ocupada td:nth-child(2) { color: #b3261e; font-weight: 700; }
.fila-ip-libre { background: #e6f7ec; }
.fila-ip-libre td:nth-child(2) { color: #1c7c3e; font-weight: 700; }
.fila-ip-temporal { background: #fff8e1; }
.fila-ip-temporal td:nth-child(2) { color: #8a6d00; font-weight: 700; }

.campo-con-boton { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.campo-con-boton input { margin-top: 0; flex: 1; }
.campo-con-boton button { margin-top: 0; white-space: nowrap; }

.grid-repuesto {
  display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px;
}
.grid-repuesto input { margin-top: 0; }

.btn-secundario-claro {
  background: white; border: 1px solid var(--azul); color: var(--azul); margin-top: 6px;
}
.btn-secundario-claro:hover { background: var(--gris); }

.paginacion { display: flex; align-items: center; gap: 12px; margin-top: 10px; justify-content: center; }
.paginacion button:disabled { opacity: 0.4; cursor: not-allowed; }

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

.separador-fino { border: none; border-top: 1px dashed #ddd; margin: 10px 0; }
.bloque-interfaz-red { margin-bottom: 8px; }
