:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #5b6270;
  --line: #e2e0d8;
  --accent: #1d5c8c;
  --accent-soft: #e6f0f7;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --bad: #b23b2e;
  --bad-soft: #fbeae7;
  --warn-soft: #fff6dc;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
}
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.25; margin: 1.6em 0 .5em; }
h1 { font-size: 1.9rem; margin-top: .2em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; font-family: var(--sans); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: .5em 0 .9em; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner {
  padding: 10px 32px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-family: var(--serif); font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto; }
.brand small { display: block; font-family: var(--sans); font-weight: 400; font-size: .78rem; color: var(--muted); }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 7px 14px; border-radius: 999px; font-weight: 500; font-size: .95rem;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); }
.nav a.active { background: var(--accent); color: #fff; }

main { padding: 24px 32px 64px; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; }
footer a { color: var(--muted); }

/* ---------- layout secuencia ---------- */
.doc-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; align-items: start; }
.toc {
  position: sticky; top: 84px; font-size: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.toc strong { display: block; margin-bottom: 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 2px 0; }
.toc a { text-decoration: none; color: var(--ink); display: block; padding: 3px 6px; border-radius: 6px; }
.toc a:hover { background: var(--accent-soft); color: var(--accent); }
.toc .sub a { padding-left: 18px; color: var(--muted); font-size: .85rem; }
.toc .cta { margin-top: 12px; }

.paper {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 36px; min-width: 0;
}
.paper > section + section { border-top: 1px solid var(--line); margin-top: 32px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0; }

.session-head {
  background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0 20px;
}
.session-head dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0 0; }
.session-head dt { font-weight: 600; }
.session-head dd { margin: 0; }

.momento { border-left: 3px solid var(--accent); padding: 2px 0 2px 18px; margin: 28px 0; }
.momento h3 { margin-top: 0; }
.chip {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: middle; font-family: var(--sans);
}
.meta {
  background: var(--bg); border-radius: 8px; padding: 10px 14px; font-size: .92rem; margin: 12px 0;
}
.meta p { margin: 2px 0; }
.problem {
  font-family: var(--serif); font-size: 1.04rem; background: var(--warn-soft);
  border-radius: 8px; padding: 12px 16px; margin: 12px 0;
}
figure { margin: 16px 0; text-align: center; }
figure img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
figcaption { font-size: .85rem; color: var(--muted); margin-top: 6px; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--bg); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: center; white-space: nowrap; }

/* ---------- formulario ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 18px;
}
.card h2 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
label.field { display: block; font-weight: 600; font-size: .92rem; }
label.field span.hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=date], textarea {
  width: 100%; margin-top: 4px; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 12px;
}
.item.done { border-left: 4px solid var(--ok); }
.item.missing { border-color: var(--bad); background: var(--bad-soft); }
.item-head { display: flex; gap: 14px; align-items: flex-start; }
.item-n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700;
}
.item-text { margin: 0; font-family: var(--serif); font-size: 1.04rem; }
.item-dim { font-size: .82rem; color: var(--muted); }
.criterios { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 14px 0 8px; align-items: end; }
.criterio { border: 0; padding: 0; margin: 0; min-width: 0; }
.criterio legend { font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; text-align: center; cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 0; font-weight: 600; font-size: .9rem; user-select: none; }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg input:checked + span.yes { background: var(--ok); color: #fff; }
.seg input:checked + span.no { background: var(--bad); color: #fff; }
details.obs summary { cursor: pointer; color: var(--accent); font-size: .88rem; }
details.obs textarea { min-height: 60px; }

.radio-list label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.radio-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-list input { margin-top: 5px; }

.errors { background: var(--bad-soft); border: 1px solid var(--bad); color: var(--ink); border-radius: var(--radius); padding: 14px 20px; margin-bottom: 18px; }
.errors ul { margin: 6px 0 0; padding-left: 20px; }

.progress {
  position: sticky; bottom: 0; z-index: 5; margin-top: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 18px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 -4px 18px rgba(0,0,0,.06);
}
.bar { flex: 1; min-width: 120px; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--ok); transition: width .2s; }

.btn {
  display: inline-block; border: 0; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none;
  background: var(--accent); color: #fff; padding: 10px 20px; border-radius: 8px;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 6px 12px; font-size: .88rem; }

/* ---------- resultados ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.kpi .label { font-size: .82rem; color: var(--muted); }
.kpi .value { font-size: 1.8rem; font-weight: 700; font-family: var(--serif); }
td.good { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
td.low { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.legend { font-size: .85rem; color: var(--muted); }
.hbar { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.hbar .lbl { flex: 0 0 52%; font-size: .9rem; }
.hbar .track { flex: 1; height: 14px; background: var(--line); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); }
.hbar .count { width: 32px; text-align: right; font-weight: 600; }
.quote { border-left: 3px solid var(--line); padding: 4px 12px; margin: 8px 0; white-space: pre-wrap; }
.quote cite { display: block; font-size: .82rem; color: var(--muted); font-style: normal; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

.center { text-align: center; }

@media (max-width: 860px) {
  main, .topbar .inner { padding-left: 16px; padding-right: 16px; }
  .doc-layout { grid-template-columns: 1fr; }
  .toc { position: static; }
  .paper { padding: 20px 18px; }
  .criterios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card, .item { padding: 16px; }
  .hbar .lbl { flex-basis: 45%; }
}

@media print {
  .topbar, .toc, footer, .progress, .no-print { display: none !important; }
  body { background: #fff; }
  .paper, .card, .item { border: none; padding: 0; }
  .doc-layout { display: block; }
}
