/* ============================================================
   EL LIBRO DE CUADRE — mundo visual
   Papel crema contable · tinta casi negra · rojo lápiz auditor
   ============================================================ */

:root {
  --paper: #f4efe4;
  --paper-deep: #ece5d4;
  --ink: #1e1b16;
  --ink-soft: #4c463b;
  --ink-faint: #635c4d;
  --audit-red: #c0392b;
  --audit-red-deep: #96271c;
  --rule: #c9c0ac;
  --rule-strong: #8f866f;
  --paper-card: #faf6ec;

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-text: 'Instrument Sans', system-ui, sans-serif;
  --font-num: 'IBM Plex Mono', ui-monospace, monospace;

  --measure: 66ch;
  --gutter: clamp(1.25rem, 4vw, 4rem);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* textura sutil de papel: grano horizontal de fibra */
  background-image: repeating-linear-gradient(
    0deg,
    rgba(30, 27, 22, 0.016) 0px,
    rgba(30, 27, 22, 0.016) 1px,
    transparent 1px,
    transparent 3px
  );
}

::selection {
  background: var(--audit-red);
  color: var(--paper);
}

/* ---------- estructura: el doble filete del libro mayor ---------- */

.sheet {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.rule-double {
  border: 0;
  border-top: 3px double var(--rule-strong);
  margin: 0;
}

.rule-single {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}

/* ---------- tipografía ---------- */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0;
}

.display-hero {
  font-size: clamp(3.4rem, 9.5vw, 8.2rem);
  font-style: italic;
}

.section-title {
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  margin-top: clamp(2.5rem, 6vw, 5rem);
}

p { margin: 0; max-width: var(--measure); }

.num, .tabular {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.label {
  font-family: var(--font-num);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

/* ---------- estados como marcas de auditor ---------- */

.mark {
  color: var(--audit-red);
  font-family: var(--font-num);
  font-weight: 600;
}

.tick::after {
  content: '✓';
  color: var(--audit-red);
  font-family: var(--font-num);
  font-weight: 600;
  margin-left: 0.4em;
}

/* ---------- enlaces y controles ---------- */

a { color: var(--ink); text-underline-offset: 0.18em; }
a:hover { color: var(--audit-red-deep); }

:focus-visible {
  outline: 2px solid var(--audit-red);
  outline-offset: 3px;
  border-radius: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-num);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  padding: 0.85em 1.5em;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  transition: background 160ms cubic-bezier(0.2, 0.9, 0.3, 1), color 160ms;
}
.btn:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary {
  background: var(--audit-red);
  border-color: var(--audit-red);
  color: var(--paper-card);
}
.btn-primary:hover {
  background: var(--audit-red-deep);
  border-color: var(--audit-red-deep);
  color: var(--paper-card);
}

/* ---------- tablas del libro mayor ---------- */

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.ledger th {
  font-family: var(--font-num);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  text-align: left;
  padding: 0.55em 0.75em;
  border-bottom: 1px solid var(--rule-strong);
}
.ledger td {
  padding: 0.8em 0.75em;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.ledger td.num, .ledger th.num { text-align: right; }
.ledger .total td {
  border-top: 3px double var(--rule-strong);
  border-bottom: 3px double var(--rule-strong);
  font-weight: 600;
  background: var(--paper-card);
}
.ledger .total .mark { font-size: 1.15em; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
