:root {
  --fondo: #ffffff;
  --fondo-alt: #f6f7f9;
  --fondo-codigo: #f3f4f6;
  --texto: #1a1d21;
  --texto-suave: #545b64;
  --borde: #dfe3e8;
  --acento: #0b5c8a;
  --acento-suave: #e6f1f7;
  --marca: #b8442a;
  --ancho: 74ch;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fondo: #14171a;
    --fondo-alt: #1b1f24;
    --fondo-codigo: #1f242a;
    --texto: #e8eaed;
    --texto-suave: #a4acb6;
    --borde: #2c333b;
    --acento: #6cb6e0;
    --acento-suave: #17303f;
    --marca: #e58267;
  }
}
:root[data-tema="oscuro"] {
  --fondo: #14171a; --fondo-alt: #1b1f24; --fondo-codigo: #1f242a;
  --texto: #e8eaed; --texto-suave: #a4acb6; --borde: #2c333b;
  --acento: #6cb6e0; --acento-suave: #17303f; --marca: #e58267;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.saltar {
  position: absolute; left: -9999px; top: 0; background: var(--acento); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 6px 0;
}
.saltar:focus { left: 0; }
header.superior {
  position: sticky; top: 0; z-index: 50; background: var(--fondo);
  border-bottom: 1px solid var(--borde); padding: .6rem 1.1rem;
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
}
header.superior .marca { font-weight: 700; color: var(--marca); text-decoration: none; font-size: .95rem; }
header.superior nav { display: flex; gap: .9rem; flex-wrap: wrap; margin-left: auto; }
header.superior nav a { color: var(--texto-suave); text-decoration: none; font-size: .88rem; }
header.superior nav a:hover, header.superior nav a:focus { color: var(--acento); text-decoration: underline; }
button.tema {
  background: transparent; border: 1px solid var(--borde); color: var(--texto-suave);
  border-radius: 6px; padding: .25rem .55rem; cursor: pointer; font-size: .82rem;
}
.envoltorio { display: flex; gap: 2rem; max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.1rem 4rem; }
main { flex: 1 1 auto; min-width: 0; max-width: var(--ancho); }
aside.indice {
  flex: 0 0 240px; position: sticky; top: 4.2rem; align-self: flex-start;
  max-height: calc(100vh - 6rem); overflow-y: auto; font-size: .85rem;
}
aside.indice h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-suave); }
aside.indice ol { list-style: none; padding: 0; margin: 0; }
aside.indice li { margin: .28rem 0; }
aside.indice li.n3 { padding-left: .9rem; }
aside.indice a { color: var(--texto-suave); text-decoration: none; }
aside.indice a:hover, aside.indice a:focus { color: var(--acento); text-decoration: underline; }
@media (max-width: 940px) { aside.indice { display: none; } .envoltorio { padding-top: 1rem; } }
h1, h2, h3, h4 { line-height: 1.25; margin: 2rem 0 .7rem; font-weight: 650; }
h1 { font-size: 1.85rem; margin-top: .4rem; }
h2 { font-size: 1.35rem; padding-top: .5rem; border-top: 1px solid var(--borde); }
h3 { font-size: 1.1rem; }
h4 { font-size: .98rem; color: var(--texto-suave); }
a { color: var(--acento); }
a.ancla { opacity: 0; margin-left: .4rem; text-decoration: none; font-weight: 400; }
h1:hover a.ancla, h2:hover a.ancla, h3:hover a.ancla { opacity: .45; }
p { margin: .8rem 0; }
ul, ol { margin: .8rem 0; padding-left: 1.4rem; }
li { margin: .3rem 0; }
li.tarea { list-style: none; margin-left: -1.2rem; }
blockquote {
  margin: 1.2rem 0; padding: .7rem 1.1rem; border-left: 4px solid var(--acento);
  background: var(--acento-suave); border-radius: 0 6px 6px 0;
}
blockquote p { margin: 0; }
code {
  background: var(--fondo-codigo); padding: .12em .38em; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: .88em;
}
pre.codigo {
  background: var(--fondo-codigo); border: 1px solid var(--borde); border-radius: 8px;
  padding: .9rem 1rem; overflow-x: auto; font-size: .86rem; line-height: 1.5;
}
pre.codigo code { background: none; padding: 0; }
pre.mermaid {
  background: var(--fondo-alt); border: 1px dashed var(--borde); border-radius: 8px;
  padding: .9rem 1rem; overflow-x: auto; font-size: .82rem; color: var(--texto-suave);
}
.tabla-scroll { overflow-x: auto; margin: 1.1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { border: 1px solid var(--borde); padding: .5rem .65rem; vertical-align: top; }
th { background: var(--fondo-alt); text-align: left; font-weight: 620; }
tbody tr:nth-child(even) { background: var(--fondo-alt); }
.al-right { text-align: right; }
.al-center { text-align: center; }
hr { border: none; border-top: 1px solid var(--borde); margin: 2rem 0; }
.meta {
  font-size: .82rem; color: var(--texto-suave); background: var(--fondo-alt);
  border: 1px solid var(--borde); border-radius: 8px; padding: .55rem .8rem; margin: .8rem 0 1.4rem;
  display: flex; gap: 1.1rem; flex-wrap: wrap;
}
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; margin: 1.2rem 0; }
.tarjeta {
  border: 1px solid var(--borde); border-radius: 10px; padding: .9rem 1rem; background: var(--fondo-alt);
  text-decoration: none; color: inherit; display: block;
}
.tarjeta:hover, .tarjeta:focus { border-color: var(--acento); }
.tarjeta strong { display: block; margin-bottom: .3rem; color: var(--acento); }
.tarjeta span { font-size: .85rem; color: var(--texto-suave); }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin: 1.4rem 0; }
.cifra { border: 1px solid var(--borde); border-radius: 10px; padding: .8rem; text-align: center; }
.cifra b { display: block; font-size: 1.5rem; color: var(--marca); }
.cifra span { font-size: .78rem; color: var(--texto-suave); }
#buscador { width: 100%; padding: .6rem .8rem; border: 1px solid var(--borde); border-radius: 8px;
  background: var(--fondo); color: var(--texto); font-size: .95rem; margin: 1rem 0 .4rem; }
#resultados { list-style: none; padding: 0; margin: 0; }
#resultados li { padding: .45rem 0; border-bottom: 1px solid var(--borde); }
#resultados a { text-decoration: none; font-weight: 550; }
#resultados span { display: block; font-size: .8rem; color: var(--texto-suave); }
footer.pie {
  border-top: 1px solid var(--borde); padding: 1.4rem 1.1rem 3rem; text-align: center;
  color: var(--texto-suave); font-size: .84rem;
}
nav.paginacion { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem;
  border-top: 1px solid var(--borde); padding-top: 1.1rem; font-size: .9rem; flex-wrap: wrap; }
@media print {
  header.superior, aside.indice, nav.paginacion, footer.pie, .saltar, button.tema { display: none !important; }
  body { font-size: 11pt; color: #000; background: #fff; }
  .envoltorio { display: block; padding: 0; max-width: none; }
  main { max-width: none; }
  a { color: #000; text-decoration: underline; }
  h2 { page-break-after: avoid; }
  table, pre, blockquote { page-break-inside: avoid; }
}
