/* Propuesta técnica de contabilidad de Matriz.
   Página de lectura con los tokens de la maqueta (dirección «Mesa»): papel frío, una hoja blanca,
   tinta como único acento y serif para la entrada. Todo color y toda fuente salen de aquí. */

:root {
  color-scheme: light;
  --f-ui: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --f-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --soft: #f2f3f5;
  --row-hover: #e7e9ed;
  --line: #e6e8ec;
  --line-btn: #d9dce2;
  --ink: #12161f;
  --ink2: #2b313c;
  --ink3: #4a5160;
  --muted: #5b6270;
  --primary: #12161f;
  --on-primary: #ffffff;
  --m-at: #12161f; --m-de: #9aa1ad; --m-luz: #ffffff;

  --r-card: 22px; --r-block: 18px; --r-field: 14px; --r-pill: 999px;
  --t-h1: clamp(1.875rem, 1.3rem + 2.2vw, 2.75rem);
  --t-h2: 1.625rem; --t-h3: 1.125rem;
  --t-entrada: 1.3125rem; --t-texto: 1rem; --t-tabla: .875rem; --t-ui: .875rem; --t-meta: .8125rem;
  --medida: 54ch;
  --ancho: 1200px;
  --top-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121316; --surface: #1b1c20; --soft: #24262b; --row-hover: #2a2c32;
    --line: rgba(255, 255, 255, .09); --line-btn: rgba(255, 255, 255, .16);
    --ink: #ececef; --ink2: #d0d1d6; --ink3: #a9abb3; --muted: #9a9ca6;
    --primary: #ececef; --on-primary: #121316;
    --m-at: #ececef; --m-de: #686a73; --m-luz: #ffffff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--line-btn) transparent; }
html { overflow-x: clip; scroll-padding-top: calc(var(--top-h) + 24px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: clip;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-ui); font-size: var(--t-texto); line-height: 1.6;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--muted); }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 9px; }
::selection { background: var(--row-hover); }
strong { font-weight: 600; }
summary { cursor: pointer; }

.salto { position: absolute; left: 16px; top: -48px; z-index: 50; padding: 8px 16px; border-radius: var(--r-pill); background: var(--primary); color: var(--on-primary); text-decoration: none; }
.salto:focus { top: 8px; }

/* —— Barra de arriba ———————————————————————————————————————————— */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: var(--ancho); margin: 0 auto; height: var(--top-h); padding: 0 24px; display: flex; align-items: center; gap: 20px; }
.marca { display: inline-flex; align-items: center; gap: 10px; font-size: var(--t-ui); font-weight: 600; text-decoration: none; }
.marca svg { width: 26px; height: 26px; flex: none; }
.m-at { fill: var(--m-at); } .m-de { fill: var(--m-de); } .m-luz { fill: var(--m-luz); }
.pest { display: flex; gap: 4px; margin-right: auto; }
.pest a { height: 36px; padding: 0 14px; border-radius: var(--r-pill); display: inline-flex; align-items: center; font-size: var(--t-ui); font-weight: 500; color: var(--ink3); text-decoration: none; }
.pest a:hover { background: var(--row-hover); color: var(--ink); }
.pest a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-btn); }
.btn { height: 36px; padding: 0 16px; border-radius: var(--r-pill); display: inline-flex; align-items: center; flex: none; background: var(--primary); color: var(--on-primary); font-size: var(--t-ui); font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { opacity: .88; }
.btn .corto { display: none; }

/* —— Página: índice a un lado y la hoja ———————————————————————————— */
.pagina { max-width: var(--ancho); margin: 0 auto; padding: 32px 24px 64px; display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 40px; align-items: start; }
.col { min-width: 0; }

.indice-lado { position: sticky; top: calc(var(--top-h) + 32px); max-height: calc(100vh - var(--top-h) - 64px); overflow-y: auto; padding: 4px; }
.indice-rot { padding: 0 12px 8px; font-size: var(--t-meta); font-weight: 600; color: var(--muted); }
.indice-lado ol, .indice-movil ol { list-style: none; padding: 0; margin: 0; }
.indice-lado a, .indice-movil a { display: block; padding: 6px 12px; border-radius: 10px; font-size: var(--t-ui); line-height: 1.35; color: var(--ink3); text-decoration: none; }
.indice-lado a:hover, .indice-movil a:hover { background: var(--row-hover); color: var(--ink); }

.indice-movil { display: none; margin-bottom: 12px; background: var(--surface); border-radius: var(--r-block); }
.indice-movil summary { padding: 12px 20px; font-size: var(--t-ui); font-weight: 600; border-radius: var(--r-block); }
.indice-movil ol { padding: 0 8px 12px; }

.hoja { background: var(--surface); border-radius: var(--r-card); padding: 56px 64px 72px; }

/* —— Texto ———————————————————————————————————————————————————— */
.cab { margin-bottom: 32px; }
h1 { font-size: var(--t-h1); line-height: 1.08; letter-spacing: -.028em; font-weight: 700; max-width: 18ch; text-wrap: balance; overflow-wrap: break-word; min-width: 0; }
.meta { margin-top: 16px; font-size: var(--t-ui); color: var(--muted); }

.hoja > p, .hoja > ul, .hoja > ol { max-width: var(--medida); }
.hoja > p { margin-bottom: 16px; color: var(--ink2); }
.hoja > .entrada { max-width: 58ch; margin-bottom: 8px; font-family: var(--f-serif); font-size: var(--t-entrada); line-height: 1.5; color: var(--ink); }

h2 { margin: 64px 0 20px; padding-top: 40px; border-top: 1px solid var(--line); font-size: var(--t-h2); line-height: 1.2; letter-spacing: -.02em; font-weight: 700; overflow-wrap: break-word; min-width: 0; }
h3 { margin: 40px 0 12px; font-size: var(--t-h3); line-height: 1.3; letter-spacing: -.01em; font-weight: 600; }
.cuenta { margin-left: 8px; font-size: var(--t-meta); font-weight: 500; letter-spacing: 0; color: var(--muted); white-space: nowrap; }

.hoja > ul, .hoja > ol { margin-bottom: 16px; padding-left: 1.3em; color: var(--ink2); }
.hoja li { margin: 8px 0; }
.hoja li::marker { color: var(--muted); }
.hoja strong { color: var(--ink); }
code { font-family: var(--f-mono); font-size: .86em; padding: 1px 6px; border-radius: 6px; background: var(--soft); color: var(--ink); overflow-wrap: anywhere; }

/* Lo que queda por cerrar: una casilla vacía por decisión. */
.hoja > .tareas { list-style: none; padding-left: 0; }
.tareas li { position: relative; padding-left: 30px; }
.tareas li::before { content: ''; position: absolute; left: 0; top: .28em; width: 17px; height: 17px; border: 1.5px solid var(--ink3); border-radius: 5px; }

/* —— Tablas ——————————————————————————————————————————————————— */
.tabla-caja { margin: 24px 0 32px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-tabla); line-height: 1.45; }
th, td { padding: 12px 20px 12px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { padding-right: 0; }
thead th { padding-top: 0; font-size: var(--t-meta); font-weight: 600; color: var(--muted); border-bottom-color: var(--line-btn); white-space: nowrap; }
tbody th { font-weight: 600; color: var(--ink); min-width: 8.5em; }
td { color: var(--ink2); }
.cols-3 { min-width: 560px; }
.cols-4 { min-width: 700px; }
.cols-5 { min-width: 760px; }

/* —— Diagrama ————————————————————————————————————————————————— */
.diagrama { margin: 28px 0 24px; }
.diagrama figcaption { margin-bottom: 12px; font-size: var(--t-ui); font-weight: 600; }
.diagrama-caja { overflow-x: auto; border-radius: var(--r-block); background: var(--soft); padding: 8px; }
.diagrama svg { display: block; width: 100%; min-width: 660px; height: auto; font-family: var(--f-ui); }
.dg-caja { fill: var(--surface); stroke: var(--line-btn); stroke-width: 1.25; }
.dg-modulo { stroke: var(--ink); stroke-width: 1.75; }
.dg-lineas path { fill: none; stroke: var(--ink3); stroke-width: 1.25; }
.dg-punta { fill: var(--ink3); }
.dg-t { fill: var(--ink); font-size: 13px; font-weight: 600; text-anchor: middle; }
.dg-d { fill: var(--muted); font-size: 11.5px; text-anchor: middle; }

/* —— Requisitos ———————————————————————————————————————————————— */
.hoja > .reqs { max-width: none; list-style: none; padding: 0; margin: 0 0 8px; }
.reqs li { display: grid; grid-template-columns: 6.25rem minmax(0, 1fr); gap: 20px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--top-h) + 16px); }
.reqs p { max-width: var(--medida); color: var(--ink2); }
.rid { align-self: start; padding-top: 2px; font-size: var(--t-meta); font-weight: 600; color: var(--ink3); text-decoration: none; white-space: nowrap; }
.rid:hover { color: var(--ink); text-decoration: underline; }
.reqs li:target { background: var(--soft); box-shadow: -16px 0 0 var(--soft), 16px 0 0 var(--soft); }
.reqs li:target .rid { color: var(--ink); }

.pie { padding: 24px 64px 0; font-size: var(--t-meta); color: var(--muted); }

/* —— Estrecho ————————————————————————————————————————————————— */
@media (max-width: 960px) {
  .pagina { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 48px; }
  .indice-lado { display: none; }
  .indice-movil { display: block; }
  .hoja { padding: 40px 32px 56px; }
  .pie { padding: 24px 32px 0; }
}
@media (max-width: 560px) {
  :root { --t-entrada: 1.1875rem; --t-h2: 1.5rem; }
  .top-in { padding: 0 16px; gap: 10px; }
  .marca span { display: none; }
  .pest a { padding: 0 11px; }
  .btn { padding: 0 14px; }
  .btn .largo { display: none; }
  .btn .corto { display: inline; }
  .hoja { padding: 28px 20px 40px; border-radius: var(--r-block); }
  .pie { padding: 20px 20px 0; }
  h2 { margin-top: 48px; padding-top: 32px; }
  .reqs li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .reqs li:target { box-shadow: -12px 0 0 var(--soft), 12px 0 0 var(--soft); }
}

@media print {
  .top, .indice-lado, .indice-movil, .salto { display: none; }
  .pagina { display: block; padding: 0; }
  .hoja { padding: 0; border-radius: 0; }
  .tabla-caja, .diagrama-caja { overflow: visible; }
  h2, h3 { break-after: avoid; }
  tr, .reqs li { break-inside: avoid; }
}
