/* Albar · Del papel al dato — estética industrial (grafito + ámbar) */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --page: #f4f1ec;
  --surface: #fcfbf8;
  --ink: #191612;
  --ink-2: #57503f;
  --muted: #8d8471;
  --grid: #e3ded4;
  --baseline: #c8c1b1;
  --border: rgba(25, 22, 18, .11);
  --acc: #c96f00;        /* ámbar obra */
  --acc-2: #8a5a00;
  --good: #2c6e49;
  --bad: #b3261e;
  --chip-bg: #ece7dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #141210;
    --surface: #1e1b17;
    --ink: #f4efe6;
    --ink-2: #c9c0ad;
    --muted: #8d8471;
    --grid: #2e2a24;
    --baseline: #3d382f;
    --border: rgba(244, 239, 230, .12);
    --acc: #f0982e;
    --acc-2: #f7b566;
    --good: #58b380;
    --bad: #e5695f;
    --chip-bg: #2a261f;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  background-image: radial-gradient(900px 300px at 50% -80px,
    color-mix(in srgb, var(--acc) 8%, transparent), transparent 75%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, .badge-demo, .chip, .btn { font-family: "Space Grotesk", "Inter", sans-serif; }

/* ── Cabecera ─────────────────────────────────────── */
header.top {
  position: relative;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 28px;
  border-bottom: 1px solid var(--grid);
  background: var(--surface);
}
header.top::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: repeating-linear-gradient(135deg, var(--acc) 0 14px, var(--ink) 14px 28px);
  opacity: .9;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; text-decoration: none; color: inherit; }
.marca { width: 40px; height: 40px; flex: none; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .17em; font-weight: 700; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.badge-demo {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); border: 1px dashed var(--baseline);
  padding: 5px 10px; border-radius: 6px;
}
.autor { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.autor a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--baseline); }
.autor a:hover, .autor a:focus-visible { color: var(--ink); border-bottom-color: var(--ink); }

/* ── Intro ────────────────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 30px 28px 48px; }
.intro { max-width: 68ch; margin-bottom: 24px; }
.intro h2 {
  font-size: clamp(26px, 4vw, 38px); font-weight: 700; letter-spacing: -.015em;
  margin: 0 0 10px; line-height: 1.15;
}
.intro .tachado { text-decoration: line-through; text-decoration-color: var(--acc); text-decoration-thickness: 3px; color: var(--muted); }
.intro p { margin: 0; color: var(--ink-2); font-size: 15.5px; }

/* ── Selector de documentos ───────────────────────── */
.selector {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.doc-mini {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 10px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
  font: inherit; color: inherit;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 4%, transparent);
}
.doc-mini:hover { border-color: var(--acc); }
.doc-mini.on { outline: 2px solid var(--acc); outline-offset: -1px; }
.doc-mini:focus-visible { outline: 2px solid var(--acc); }
.doc-mini img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top;
  border-radius: 8px; display: block; background: var(--chip-bg);
}
.doc-mini-titulo { font-weight: 650; font-size: 13.5px; font-family: "Space Grotesk", sans-serif; }
.doc-mini-sub { font-size: 11.5px; color: var(--muted); margin-top: -6px; }
.doc-mini.subir { align-items: center; justify-content: center; text-align: center; border-style: dashed; }
.subir-icono {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--chip-bg); color: var(--acc); font-size: 26px; font-weight: 600;
}
.doc-mini.subir.arrastrando { border-color: var(--acc); background: var(--chip-bg); }

/* ── Visor ────────────────────────────────────────── */
.visor { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; min-width: 0;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 4%, transparent);
}
.doc-panel { position: sticky; top: 16px; }
.doc-marco { border-radius: 8px; overflow: hidden; background: var(--chip-bg); }
.doc-marco img { width: 100%; display: block; }
.doc-panel .nota { margin: 10px 2px 0; }

.datos-cabecera { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  display: inline-block; padding: 4px 12px; border-radius: 99px;
  background: var(--chip-bg); font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
}
.chip.tipo { color: var(--acc-2); border-color: var(--acc); }
.chip.conf.alta { color: var(--good); }
.chip.conf.media { color: var(--acc-2); }
.chip.conf.baja { color: var(--bad); }
.chip.modo { color: var(--muted); }

.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 16px; margin-bottom: 16px; }
.campo { border-left: 3px solid var(--grid); padding: 2px 0 2px 10px; }
.campo .k {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; font-family: "Space Grotesk", sans-serif;
}
.campo .v { font-size: 14.5px; overflow-wrap: anywhere; }
.campo .v.vacio { color: var(--muted); font-style: italic; }

.datos-panel h3 {
  font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; font-weight: 650;
}
.tabla-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); }
th { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.check-ok { color: var(--good); }
td.check-mal { color: var(--bad); font-weight: 700; }

.totales {
  display: flex; gap: 10px 26px; flex-wrap: wrap; justify-content: flex-end;
  margin-top: 12px; padding: 12px 14px;
  background: var(--chip-bg); border-radius: 10px; font-size: 14px;
}
.totales b { font-variant-numeric: tabular-nums; }
.totales .total-final { font-family: "Space Grotesk", sans-serif; font-size: 16px; font-weight: 700; }

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.checks li { display: flex; gap: 9px; align-items: baseline; }
.checks .marca-check {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; transform: translateY(4px);
}
.checks .ok .marca-check { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.checks .mal .marca-check { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.checks .mal { color: var(--ink); font-weight: 550; }
.checks .campo-nombre { font-weight: 650; margin-right: 2px; }

.notas { font-size: 13px; color: var(--muted); font-style: italic; margin: 14px 0 0; }

.acciones { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 9px; border: 0;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; color: #fff; background: var(--acc);
  font-family: "Space Grotesk", sans-serif;
}
.btn:hover { filter: brightness(1.08); }
.btn.sec { background: transparent; border: 1px solid var(--baseline); color: var(--ink-2); }
.btn.sec:hover { background: var(--chip-bg); filter: none; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* animación de revelado de campos */
.revela { animation: revela .45s ease-out backwards; }
@keyframes revela { from { opacity: 0; translate: 0 8px; } }
@media (prefers-reduced-motion: reduce) { .revela { animation: none; } }

/* ── Estado de carga ──────────────────────────────── */
.cargando .lector { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.lector-linea {
  height: 3px; border-radius: 2px; margin: 0 auto 22px; max-width: 320px;
  background: linear-gradient(90deg, transparent, var(--acc), transparent);
  background-size: 200% 100%;
  animation: escaneo 1.3s infinite linear;
}
@keyframes escaneo { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .lector-linea { animation: none; } }
.dots span {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted); margin-left: 4px;
  animation: puntito 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes puntito { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.error-banner {
  background: color-mix(in srgb, var(--bad) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 14px;
}
.error-banner[hidden] { display: none; }
.error-banner button { border: 0; background: none; color: var(--ink-2); cursor: pointer; margin-left: auto; font-size: 14px; }

/* ── Cierre ───────────────────────────────────────── */
footer { max-width: 1200px; margin: 0 auto; padding: 0 28px 40px; color: var(--muted); font-size: 12.5px; }
footer .cierre {
  border-radius: 14px; background: #211d17; color: #f4efe6;
  padding: 28px 32px; margin-bottom: 16px;
  border-top: 3px solid var(--acc);
}
.cierre-titulo { font-family: "Space Grotesk", sans-serif; font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.cierre-sub { margin: 0 0 16px; font-size: 13.5px; color: rgba(244, 239, 230, .75); max-width: 64ch; }
.cierre-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.cierre .btn.sec { border-color: rgba(244, 239, 230, .35); color: #f4efe6; }
.cierre .btn.sec:hover { background: rgba(244, 239, 230, .1); }
footer .legal { margin: 0; }
footer .legal a { color: var(--ink-2); }

/* ── Móvil ────────────────────────────────────────── */
@media (max-width: 860px) {
  body { overflow-x: clip; }
  header.top { padding: 12px 16px; gap: 10px 14px; }
  .brand p { display: none; }
  .badge-demo { display: none; }
  main { padding: 20px 16px 40px; }
  .visor { grid-template-columns: 1fr; }
  .doc-panel { position: static; }
  .doc-marco { max-height: 46vh; }
  .doc-marco img { max-height: 46vh; object-fit: contain; }
  .selector { grid-template-columns: repeat(2, 1fr); }
  .cierre-texto { padding: 22px 18px; }
}
@media (pointer: coarse) {
  .btn { padding: 12px 20px; }
  .doc-mini { padding: 12px; }
}
