/* MRI electrónico – Air Nubeiro
   Mesma identidade que a web e o PDF: Raleway e azul #0070cb. */

@font-face { font-family: "Raleway"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fuentes/raleway-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Raleway"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fuentes/raleway-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Raleway"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("fuentes/raleway-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Raleway"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("fuentes/raleway-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --azul: #0070cb;
  --azul-escuro: #005199;
  --azul-veo: #e8f1fa;
  --tinta: #1c2630;
  --tinta-suave: #56616d;
  --neboa: #f2f2f2;
  --linea: #dce2e8;
  --papel: #ffffff;
  --marca: #ffe39a;
  --marca-activa: #ffb600;
  --panel: 19rem;
  --barra: 3.75rem;
  --fonte: "Raleway", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--barra) + 1.25rem); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; font-family: var(--fonte); color: var(--tinta); background: var(--papel);
  font-size: 1.0625rem; line-height: 1.7; font-variant-numeric: lining-nums; }
img { max-width: 100%; height: auto; }
a { color: var(--azul); text-underline-offset: .18em; }
a:hover { color: var(--azul-escuro); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; border-radius: 3px; }
svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip { position: absolute; left: 1rem; top: -3rem; z-index: 50; background: var(--azul); color: #fff;
  padding: .5rem 1rem; border-radius: 0 0 6px 6px; text-decoration: none; }
.skip:focus { top: 0; }

/* ---------- Cabeceira: a mesma franxa que o PDF ---------- */
.topbar { background: var(--neboa); border-top: 2px solid var(--azul); border-bottom: 2px solid var(--azul); }
.topbar-in { max-width: 88rem; margin: 0 auto; padding: .7rem 1.5rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: block; flex: none; line-height: 0; }
.brand img { width: 8.5rem; }
.brand-dept { margin: 0; padding-left: .9rem; border-left: 1px solid var(--azul); color: var(--azul);
  font-size: .72rem; line-height: 1.25; max-width: 13rem; }
.doc-name { margin: 0 0 0 auto; color: var(--azul); font-size: 1.15rem; text-align: right; }
.doc-name strong { font-weight: 700; }

/* ---------- Barra de ferramentas ---------- */
.toolbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--linea); backdrop-filter: saturate(1.4) blur(6px); }
.toolbar-in { max-width: 88rem; margin: 0 auto; min-height: var(--barra); padding: .55rem 1.5rem;
  display: flex; align-items: center; gap: .6rem; }
.btn-toc { display: none; align-items: center; gap: .45rem; border: 1px solid var(--linea); background: var(--papel);
  border-radius: 6px; padding: .45rem .75rem; cursor: pointer; font-weight: 600; }

.search { position: relative; flex: 1 1 auto; max-width: 34rem; display: flex; align-items: center;
  border: 1px solid #c9d2db; border-radius: 6px; background: var(--papel); padding: 0 .4rem 0 .7rem; }
.search:focus-within { border-color: var(--azul); box-shadow: 0 0 0 3px rgba(0,112,203,.15); }
.search-ico { color: var(--tinta-suave); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 1rem;
  padding: .55rem .6rem; color: var(--tinta); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-count { font-size: .8rem; color: var(--tinta-suave); white-space: nowrap; padding-right: .3rem; font-variant-numeric: tabular-nums; }
.search-step { border: 0; background: none; padding: .3rem; border-radius: 4px; cursor: pointer; color: var(--tinta); line-height: 0; }
.search-step:hover:not(:disabled) { background: var(--azul-veo); }
.search-step:disabled { opacity: .3; cursor: default; }
.search-key { font-family: inherit; font-size: .72rem; color: var(--tinta-suave); border: 1px solid var(--linea);
  border-radius: 4px; padding: 0 .4rem; margin-left: .2rem; }
.search:focus-within .search-key { display: none; }

.langs { display: inline-flex; border: 1px solid var(--azul); border-radius: 6px; overflow: hidden; flex: none; }
.langs button { border: 0; background: var(--papel); color: var(--azul); padding: .45rem .7rem; cursor: pointer;
  font-weight: 700; font-size: .85rem; letter-spacing: .03em; }
.langs button + button { border-left: 1px solid var(--azul); }
.langs button[aria-pressed="true"] { background: var(--azul); color: #fff; }
.langs button:hover:not([aria-pressed="true"]) { background: var(--azul-veo); }

.tool { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: none; color: var(--tinta);
  padding: .45rem .6rem; border-radius: 6px; cursor: pointer; font-size: .9rem; font-weight: 600; text-decoration: none; flex: none; }
.tool:hover { background: var(--azul-veo); color: var(--azul-escuro); }

/* ---------- Estrutura ---------- */
.layout { max-width: 88rem; margin: 0 auto; display: grid; grid-template-columns: var(--panel) minmax(0, 1fr); }
.panel { position: sticky; top: var(--barra); align-self: start; height: calc(100vh - var(--barra));
  overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--linea); padding: 1.5rem 1rem 3rem 1.5rem;
  font-size: .9rem; line-height: 1.45; }
.scrim { display: none; }

/* Índice */
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc-cover a { display: block; font-weight: 700; color: var(--tinta); text-decoration: none; padding: .35rem .6rem;
  border-left: 3px solid transparent; margin-bottom: .6rem; }
.toc-ch { margin-bottom: .15rem; }
.toc-ch-head { display: flex; align-items: flex-start; }
.toc-ch-head a { flex: 1; display: grid; grid-template-columns: 2.4rem 1fr; text-decoration: none; color: var(--tinta);
  padding: .4rem .3rem .4rem .6rem; border-left: 3px solid transparent; border-radius: 0 4px 4px 0; }
.toc-ch-head a:hover { background: var(--neboa); }
.toc-num { color: var(--azul); font-weight: 700; }
.toc-ch-title::first-letter { text-transform: uppercase; }
.toc-toggle { border: 0; background: none; cursor: pointer; padding: .45rem .35rem; color: var(--tinta-suave); line-height: 0; border-radius: 4px; }
.toc-toggle:hover { background: var(--neboa); }
.toc-toggle svg { width: 1rem; height: 1rem; transition: transform .15s; }
.toc-ch.is-open .toc-toggle svg { transform: rotate(90deg); }
.toc-secs { display: none; padding: .1rem 0 .5rem 3rem !important; }
.toc-ch.is-open .toc-secs { display: block; }
.toc-secs a { display: grid; grid-template-columns: 1.6rem 1fr; color: var(--tinta-suave); text-decoration: none;
  padding: .22rem .4rem; border-radius: 4px; }
.toc-secs a:hover { color: var(--tinta); background: var(--neboa); }
.toc-secs .toc-n { color: var(--tinta-suave); font-variant-numeric: tabular-nums; }
.toc a.is-current { border-left-color: var(--azul); color: var(--azul-escuro); background: var(--azul-veo); }
.toc-secs a.is-current { color: var(--azul-escuro); font-weight: 600; }
.toc-secs a.is-current .toc-n { color: var(--azul); }

/* Resultados */
.results-head { margin: 0 0 .8rem; font-weight: 700; color: var(--tinta); }
.results ol { list-style: none; margin: 0; padding: 0; }
.results li + li { margin-top: .35rem; }
.result { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: none; cursor: pointer;
  padding: .55rem .65rem; border-radius: 6px; line-height: 1.45; }
.result:hover, .result:focus-visible { background: var(--neboa); border-color: var(--linea); }
.result-where { display: block; font-size: .78rem; color: var(--azul); font-weight: 600; margin-bottom: .15rem; }
.result-snip { display: block; color: var(--tinta-suave); font-size: .86rem; }
.result-snip b { color: var(--tinta); background: var(--marca); font-weight: 600; border-radius: 2px; }
.results-empty { color: var(--tinta-suave); }

/* ---------- Documento ---------- */
.doc { padding: 2.5rem 3rem 5rem; min-width: 0; outline: none; }
.doc > * { max-width: 46rem; }
.noscript { background: var(--neboa); padding: 1rem 1.25rem; border-left: 3px solid var(--azul); }

/* Portada: o marco azul do PDF */
.cover { margin-bottom: 4rem; }
.cover-frame { border: 10px solid var(--azul); padding: 4.5rem 3rem 4rem; }
.cover-frame img { width: 11rem; display: block; margin-bottom: 2.75rem; }
.cover h1 { margin: 0; color: var(--azul); font-size: clamp(2.3rem, 5.2vw, 3.6rem); line-height: 1.05; font-weight: 300; letter-spacing: -.01em; }
.cover h1 span { display: block; }
.cover h1 strong { display: block; font-weight: 700; }
.cover-sub { margin: 1.1rem 0 0; color: var(--azul); font-size: 1rem; }
.doc-meta { margin: 1.5rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem;
  font-size: .82rem; color: var(--tinta-suave); line-height: 1.5; }
.doc-meta dt { font-weight: 700; color: var(--tinta); }
.doc-meta dd { margin: 0; }
.edition-note { margin: 1.25rem 0 0; font-size: .88rem; color: var(--tinta-suave); padding: .75rem 1rem; background: var(--neboa); border-left: 3px solid var(--azul); }

/* Capítulos */
.chapter { padding-top: 1rem; margin-top: 3.5rem; border-top: 2px solid var(--azul); }
.ch-title { margin: 1.25rem 0 1.75rem; color: var(--azul); font-weight: 300; font-size: clamp(1.55rem, 2.6vw, 2rem); line-height: 1.25; }
.ch-title strong { font-weight: 700; }
.ch-title .ch-num { font-weight: 700; }
.ch-intro { margin-bottom: 2rem; }

.apt { margin: 2.5rem 0 0; }
.apt-h { margin: 0 0 .9rem; font-size: 1rem; font-weight: 400; letter-spacing: .05em; color: var(--tinta); line-height: 1.5; }
.apt-h strong { font-weight: 700; letter-spacing: .02em; }
.apt-h a { color: inherit; text-decoration: none; position: relative; }
.apt-h a::after { content: "#"; position: absolute; right: -1.2em; top: 0; color: var(--azul); opacity: 0; font-weight: 700; transition: opacity .12s; }
.apt-h a:hover::after, .apt-h a:focus-visible::after { opacity: 1; }
.apt-target { animation: aviso 1.6s ease-out; }
@keyframes aviso { from { background: var(--azul-veo); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .apt-target { animation: none; } }

.doc p { margin: 0 0 .9rem; hyphens: auto; }
.doc h4 { margin: 2rem 0 .8rem; font-size: 1rem; font-weight: 600; color: var(--tinta); }
.doc u { text-decoration-thickness: 1px; text-underline-offset: .2em; text-decoration-color: var(--tinta-suave); }
.doc em { font-style: italic; }
.doc .note { font-size: .88rem; color: var(--tinta-suave); }
.doc .note::before { content: "* "; color: var(--azul); font-weight: 700; }
.doc .note.foot::before { content: "[*] "; }
.doc .pnum .pn { color: var(--azul); font-weight: 700; margin-right: .15rem; }
.xref { white-space: nowrap; }

/* Listas coa marca de cada tipo, como no PDF */
.doc ul, .doc ol { list-style: none; margin: 0 0 1.1rem; padding: 0; }
.doc li { position: relative; padding-left: 1.9rem; }
.doc li > p:last-child { margin-bottom: .55rem; }
.doc li::before { position: absolute; left: .15rem; top: 0; color: var(--azul); font-weight: 700; }
.l-dash > li::before { content: "–"; }
.l-circ > li::before { content: "○"; font-size: .7em; top: .3em; font-weight: 400; }
.l-num, .l-roman, .l-alpha, .l-alpha-par, .l-paren { counter-reset: item; }
.l-num > li, .l-roman > li, .l-alpha > li, .l-alpha-par > li, .l-paren > li { counter-increment: item; }
.l-num > li { padding-left: 2.2rem; }
.l-num > li::before { content: counter(item) "."; }
.l-roman > li::before { content: counter(item, lower-roman) "."; font-weight: 600; }
.l-alpha > li::before { content: counter(item, lower-alpha) "."; }
.l-alpha-par > li::before { content: counter(item, lower-alpha) ")"; }
.l-paren > li { padding-left: 2.2rem; }
.l-paren > li::before { content: "(" counter(item) ")"; font-weight: 600; }

/* Organigramas */
.doc figure { margin: 0; }
.org { margin: 1.5rem 0 1rem; display: grid; grid-template-columns: 7rem 1fr; align-items: center; }
.org-root { background: var(--azul); color: #fff; font-weight: 700; text-align: center; padding: .7rem .5rem; position: relative; }
.org-root::after { content: ""; position: absolute; right: -1.5rem; top: 50%; width: 1.5rem; border-top: 1.5px solid var(--azul); }
.doc .org-branches { margin: 0 0 0 1.5rem; padding: 0; border-left: 1.5px solid var(--azul); }
.doc .org-branches li { padding: .3rem 0 .3rem 1.4rem; color: var(--azul); font-size: .95rem; line-height: 1.35; }
.doc .org-branches li::before { content: ""; left: 0; top: 50%; width: 1.4rem; border-top: 1.5px solid var(--azul); }
.org-box { display: inline-block; border: 1.5px solid var(--azul); padding: .4rem .8rem; background: var(--papel); }

.doc .org-chain ol { margin: 1.5rem 0 1rem; display: inline-flex; flex-direction: column; align-items: stretch; gap: 1.6rem; }
.doc .org-chain li { padding: .55rem 1rem; border: 1.5px solid var(--azul); color: var(--azul); min-width: 16rem; text-align: center; line-height: 1.35; }
.doc .org-chain li:first-child { background: var(--azul); color: #fff; }
.doc .org-chain li::before { content: none; }
.doc .org-chain li + li::before { content: ""; left: calc(50% - 5px); top: -8px; border: 5px solid transparent; border-top: 7px solid var(--azul); border-bottom: 0; }
.doc .org-chain li + li::after { content: ""; position: absolute; left: 50%; top: -1.6rem; height: calc(1.6rem - 8px); border-left: 1.5px solid var(--azul); }

/* Anexos */
.annex { margin: 1rem 0 1.5rem; }
.annex a { display: block; line-height: 0; border: 1px solid var(--linea); box-shadow: 0 6px 18px rgba(28, 38, 48, .12); }
.annex img { width: 100%; }

/* Marcas da busca */
mark { background: var(--marca); color: inherit; border-radius: 2px; padding: 0 .05em; }
mark.is-active { background: var(--marca-activa); box-shadow: 0 0 0 2px var(--marca-activa); }

/* Pé, subir, aviso */
.foot { border-top: 1px solid var(--linea); padding: 1.5rem; text-align: center; font-size: .82rem; color: var(--tinta-suave); }
.foot p { margin: 0; }
.to-top { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 20; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 1px solid var(--linea); background: var(--papel); color: var(--azul); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 4px 14px rgba(28, 38, 48, .15); }
.to-top[hidden] { display: none; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 60; background: var(--tinta);
  color: #fff; padding: .55rem 1rem; border-radius: 6px; font-size: .9rem; }
.toast[hidden] { display: none; }

/* ---------- Pantallas medianas e móbiles ---------- */
@media (max-width: 1100px) {
  .brand-dept { display: none; }
  .tool span { display: none; }
}
@media (max-width: 900px) {
  :root { --barra: 6.4rem; }
  .topbar-in { padding: .6rem 1rem; }
  .brand img { width: 7rem; }
  .doc-name { font-size: .95rem; }
  .toolbar-in { flex-wrap: wrap; padding: .5rem 1rem; gap: .5rem; }
  .btn-toc { display: inline-flex; }
  .search { order: 5; flex: 1 1 100%; max-width: none; }
  .search-key { display: none; }
  .langs { margin-left: auto; }
  .layout { display: block; }
  .panel { position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; height: auto; width: min(22rem, 88vw);
    background: var(--papel); border-right: 1px solid var(--linea); box-shadow: 0 0 40px rgba(0,0,0,.2);
    transform: translateX(-105%); transition: transform .2s ease; padding-top: 1.25rem; align-self: auto; }
  .panel.is-open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(28, 38, 48, .35); }
  .scrim[hidden] { display: none; }
  .doc { padding: 1.75rem 1.1rem 4rem; }
  .cover-frame { border-width: 7px; padding: 2.5rem 1.4rem 2.25rem; }
  .cover-frame img { width: 8.5rem; margin-bottom: 1.75rem; }
  .org { grid-template-columns: 1fr; }
  .org-root { width: 7rem; }
  .org-root::after { right: auto; left: 1.5rem; top: 100%; width: 0; height: 1rem; border-top: 0; border-left: 1.5px solid var(--azul); }
  .org .org-branches { margin: 1rem 0 0 1.5rem; }
  .doc .org-chain li { min-width: 0; width: 100%; }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) { .panel { transition: none; } }
@media (max-width: 480px) {
  .doc-name { display: none; }
  .doc-meta { grid-template-columns: 1fr; }
  .doc-meta dd { margin-bottom: .4rem; }
}

/* ---------- Impresión ---------- */
@media print {
  .toolbar, .panel, .scrim, .to-top, .toast, .skip, .foot { display: none !important; }
  .layout { display: block; }
  .doc { padding: 0; }
  .doc > * { max-width: none; }
  body { font-size: 10.5pt; }
  .chapter { break-before: page; }
  .apt-h, .ch-title { break-after: avoid; }
  .annex { break-inside: avoid; }
  .annex a { box-shadow: none; }
  mark { background: none; box-shadow: none; }
  a { color: inherit; text-decoration: none; }
}
