Image caption Many public organisations are keen to know how post-Brexit immigration rules might affect their workforce

The potential loss of EU talent has emerged as a key concern of Scotland's public services, according to BBC research

Responses from Freedom of Information requests to 80 public bodies highlighted a range of issues, including that of EU migration.

The UK is due to leave the European Union on 29 March 2019.

Both the Scottish and UK governments have been intensifying their preparations with six months to go.

However, the BBC investigation discovered starkly different degrees of preparation among Scotland's 32 local authorities and other public bodies.

The country has about 235,000 EU nationals with an estimated 26,000 working in health, social care and public administration.

Edinburgh has the highest concentration of EU citizens in Scotland - with around 39,000 people according to the last census.

The city council has more than 1,000 employees (5.5%) from countries in the European single market, including many teachers and social care workers.

Brexit and public services How many EU nationals? 235,000 Number working in Scotland 26,000 Number in health, social care + public admin 39,000 EU citizens in Edinburgh

1,000 EU citizens at Edinburgh Council PA

A council report said "uncertainty over future immigration status and potential work permit regulations introduces a significant risk for the city".

Councils across the Highlands and Islands said EU free movement had helped sustain fragile communities.

They have jointly produced a population study that warns: "Any changes to migration policy that reduced inward migration in future would therefore be expected to lead to a decline in the population."

That could also lead to skills shortages in particular specialisms.

Of the 12 NHS consultants working in the Western Isles hospital in 2017, eight were from EU countries outside the UK.

EU nationals are also important in the tourism, food and drink and fish harvesting and processing sectors.

Shetland islands council highlighted the case of Grieg Seafood, the largest salmon farmer in the islands, which relies on EU nationals for 20% of its workforce.

Its managing director, Grant Cumming, said "we would really struggle without our EU workers".

Those living in the UK when Brexit happens should be allowed to stay but future immigration policy has yet to be decided.

Major local authorities like Edinburgh, Glasgow, Aberdeen and Dundee have produced detailed reports on Brexit. But many smaller councils have not, revealing a patchwork of preparation.

Inverclyde said "no preparations or assessments have been made". Stirling and West Dunbartonshire said they had "no recorded information" and East Ayrshire provided a "nil response".

Local government body Cosla is carrying out extensive work on behalf of all councils.

The body's president, Councillor Alison Evison said "real scenario planning" would only be possible "once agreement over the transition period had been reached and afterwards when we know better what the replacement trading arrangements are going to be".

What are public bodies doing to prepare for Brexit?

Over the summer, the Scottish government sent public bodies a workforce questionnaire to help assess their Brexit readiness.

The public spending watchdog, Audit Scotland, is due to publish an initial assessment of public sector preparedness this autumn.

It said it was important public bodies consider possible Brexit effects in their workforce planning.

The watchdog made clear: "Reductions in the number of EU27 workers in the public sector workforce will affect its ability to deliver 'business as usual'."

There are signs the Brexit vote has already made the UK a less attractive place for EU nationals to live and work.

EU net migration fell to 87,000 - the lowest level since 2012 - in the year to the end of March 2018.

In Perth and Kinross, the council noted a 13% drop in EU migration to the area in the year to September 2017.

Image copyright SPL Image caption A Scottish Funding Council briefing paper wanted to maintain the "strongest" possible academic talent to continue teaching at Scotland's universities

Scotland's universities compete internationally for students, academic staff and research specialists.

The Scottish Funding Council (SFC) said in a March 2017 paper that 23% of research-only staff in Scottish universities were from EU countries.

The SFC briefing for the Scottish government said that "post-referendum immigration policy will need to consider safeguards to permit hiring of the strongest possible talent" and prevent EU nationals leaving the UK.

The National Galleries said 55 staff (15%) were from EU countries while the National Museums employ 35 (8%) including around 4 in 10 of the highly skilled people looking after its collections.

Visit Scotland said the language skills and market knowledge of its 60 EU nationals "add to Scotland's ability to attract European visitors".

The registrar general's annual review of demographic trends made clear that "Scotland's future population growth is projected to be entirely reliant on migration" from across the UK, the EU and beyond.

Ticket price increases

In the EU referendum campaign, the UK cabinet minister, Michael Gove, suggested Brexit could see Holyrood having a greater degree of control over immigration.

In February, the Scottish government published a paper arguing for devolved control.

The UK government is considering future immigration policy and has said its new policy will be in the best interests of the whole UK.

It has asked the Migration Advisory Committee to report on the impact of EU workers in the UK which is due to be published during September.

BBC Scotland's FOI requests also revealed wider Brexit-related challenges and opportunities being considered by public bodies.

NHS Lanarkshire warned there was a "very high" risk that Brexit could disrupt healthcare services and was working with the Scottish government to identify and overcome problems.

Across the health service there are concerns about international cooperation and access to specialist medicines, equipment and doctors after the UK has left the EU.

The Scottish Funding Council has pointed out that Brexit could end the requirement for "equal treatment" of Scottish and EU students, potentially freeing about £95m in teaching grants and fees for other uses.

Image copyright Reuters Image caption Organisations have been looking at how Brexit might affect their revenue

Many local authorities are worried about future funding, with North Lanarkshire anticipating "further squeezing" of budgets and Highland considering the end of EU assistance a "significant risk".

Transport Scotland anticipates any new trading arrangements will require some additional checks on lorries at Channel ports, potentially making it impossible for Scottish hauliers to reach the continent without two drivers or an overnight stop.

Historic Environment Scotland has number crunched the impact a post-Brexit recession might have on its revenue and considered how that could be offset by a ticket price increase.

As well as considering potential Brexit downsides, the National Library sees a possible upside: - "renewed interest in Scottish literature, culture and events to support tourism" if Scotland's identity is repositioned on the world stage.

Scotland's Constitutional Affairs Secretary Mike Russell said: "The people of Scotland overwhelmingly rejected Brexit, but despite that the UK government is pressing ahead with plans which pose a direct threat to our public services, especially in terms of workforce planning and ensuring we have sufficient staff in our NHS and other frontline services."

The UK government spokesman said: "We firmly believe it is in the interests of both the EU and the UK to strike a deal and we are confident that this will be achieved.

"But it is the job of a responsible government to prepare for all scenarios, including the unlikely event that an agreement with the EU cannot be reached."