:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1b2233;
  --muted: #5a6478;
  --line: #dde2ec;
  --accent: #1d4f91;
  --accent-soft: #e8f0fb;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --err: #b3261e;
  --err-soft: #fdeceb;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 110px; }

/* ---------- Barra superior ---------- */
.topbar { background: var(--accent); color: #fff; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand-mark { flex: none; width: 38px; height: 38px; border-radius: 10px; background: #fff; color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-txt small { opacity: .85; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: none; background: rgba(255,255,255,.18); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 20px; margin-bottom: 18px; }
.card h1 { font-size: 27px; line-height: 1.25; margin: 4px 0 8px; }
.card h2 { font-size: 20px; line-height: 1.3; margin: 0 0 14px; color: var(--accent); }
.card h2 small { font-weight: 400; color: var(--muted); font-size: 15px; }
.hero { border-top: 5px solid var(--accent); }
.hero.center { text-align: center; padding: 38px 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: 12.5px; font-weight: 700; color: var(--accent); margin: 0; }
.lead { font-size: 18px; color: var(--ink); margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 15px; margin: 10px 0 0; }
.intro { background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
.meta { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.meta li { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 12px; font-size: 14px; font-weight: 600; }
.note { background: #fbfaf3; border-color: #ece6c6; }
.note summary { cursor: pointer; font-weight: 700; color: #6b5d12; }
blockquote { margin: 12px 0 0; padding: 0 0 0 14px; border-left: 4px solid #d8cf8f; color: #443d12; }
.check { width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 42px; line-height: 72px; margin: 0 auto 14px; }

/* ---------- Portada ---------- */
.cards3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.link-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); margin: 0; transition: transform .12s, box-shadow .12s, border-color .12s; }
.link-card:hover, .link-card:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(29,79,145,.13); outline: none; }
.link-card h2 { margin: 0; }
.link-card p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.tag { align-self: flex-start; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; border-radius: 6px; padding: 2px 9px; }
.meta-line { font-size: 13.5px; color: var(--muted); }
.go { font-weight: 700; color: var(--accent); }
.admin-link { text-align: center; margin-top: 26px; font-size: 14px; }
.admin-link a { color: var(--muted); }

/* ---------- Campos ---------- */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label, .q-open > label { display: block; font-weight: 600; margin-bottom: 8px; }
.label small { font-weight: 400; color: var(--muted); }
.req { color: var(--err); }
.grid2 { display: grid; gap: 4px 18px; grid-template-columns: 1fr 1fr; }
input[type="text"], input[type="date"], input[type="time"], input[type="password"], textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1.5px solid #c5ccdb; border-radius: 9px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, textarea:focus { outline: 3px solid rgba(29,79,145,.25); border-color: var(--accent); }
.sub { margin-top: 12px; }
.sub label { display: block; font-weight: 600; margin-bottom: 6px; }
.instr { margin: -4px 0 10px; color: var(--muted); }

/* ---------- Opciones tipo botón (radio / checkbox) ---------- */
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span { display: block; padding: 9px 16px; border: 1.5px solid #c5ccdb; border-radius: 9px; background: #fff; font-weight: 500; transition: background .1s, border-color .1s; }
.choice:hover span { border-color: var(--accent); }
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.choice input:focus-visible + span { outline: 3px solid rgba(29,79,145,.35); outline-offset: 1px; }
.choice input[type="checkbox"]:checked + span::before { content: "✓ "; }

/* ---------- Consentimiento ---------- */
.consent { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid #c5ccdb; border-radius: 10px; margin-top: 10px; cursor: pointer; background: #fff; }
.consent input { width: 22px; height: 22px; flex: none; margin: 2px 0 0; accent-color: var(--accent); }
.consent span { font-weight: 600; }

/* ---------- Preguntas ---------- */
.q { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 18px 0 6px; min-width: 0; }
.q:first-of-type { border-top: 0; }
.q legend, .q-open > label { display: flex; gap: 10px; align-items: flex-start; padding: 0; font-weight: 600; float: none; }
.q legend { width: 100%; margin-bottom: 12px; }
.q-num { flex: none; min-width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; margin-top: 1px; }
.q-num-txt { font-size: 12px; }
.q-text { flex: 1; }
.q-open textarea { margin-top: 2px; }
.q.unanswered { background: var(--err-soft); border-radius: 10px; padding-left: 10px; padding-right: 10px; }

/* Leyenda de escala (por sección) */
.legend { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: 14.5px; margin-bottom: 8px; }
.legend-i { display: inline-block; margin-right: 12px; white-space: nowrap; }

/* Escala 1-5: cada opción muestra número y significado */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.opt { position: relative; cursor: pointer; display: block; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt-box { height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 10px 6px; border: 1.5px solid #c5ccdb; border-radius: 10px; background: #fff; transition: background .1s, border-color .1s; }
.opt-n { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; }
.opt-t { font-size: 13.5px; line-height: 1.25; color: var(--muted); }
.opt:hover .opt-box { border-color: var(--accent); }
.opt input:checked + .opt-box { background: var(--accent); border-color: var(--accent); }
.opt input:checked + .opt-box .opt-n { background: #fff; color: var(--accent); }
.opt input:checked + .opt-box .opt-t { color: #fff; font-weight: 600; }
.opt input:focus-visible + .opt-box { outline: 3px solid rgba(29,79,145,.4); outline-offset: 2px; }

/* ---------- Alertas y botones ---------- */
.alert { border-radius: 10px; padding: 14px 18px; margin-bottom: 18px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-error { background: var(--err-soft); border: 1px solid #efb8b4; color: #6d1510; }
.alert-ok { background: #e8f6ee; border: 1px solid #b6dfc6; color: #124d2e; }
.actions { text-align: center; margin: 24px 0; }
.btn { display: inline-block; font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 14px 30px; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; font-size: 18px; }
.btn-primary:hover { background: #163d70; }
.btn-light { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); padding: 8px 16px; font-size: 15px; }
.btn-danger { background: var(--err); color: #fff; padding: 8px 16px; font-size: 15px; }

/* ---------- Barra de progreso fija ---------- */
.progress { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 9px 16px; display: flex; align-items: center; gap: 14px; z-index: 10; box-shadow: 0 -4px 14px rgba(0,0,0,.06); }
.progress-bar { flex: 1; height: 10px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.progress-txt { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }

.foot { color: var(--muted); font-size: 13px; text-align: center; padding-bottom: 90px; }

/* ---------- Administración ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: var(--accent-soft); color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 34px; color: var(--accent); line-height: 1.1; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.qa dt { font-weight: 700; margin-top: 14px; }
.qa dd { margin: 4px 0 0; white-space: pre-wrap; }
.qa .code { color: var(--accent); }
.scroll-x { overflow-x: auto; }

/* ---------- Móvil ---------- */
@media (max-width: 720px) {
  body { font-size: 16.5px; }
  .cards3, .stats { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 18px 16px 16px; }
  .card h1 { font-size: 23px; }
  .brand-txt small { display: none; }
  /* En pantallas angostas la escala se apila: número + significado en cada fila */
  .scale { grid-template-columns: 1fr; gap: 6px; }
  .opt-box { flex-direction: row; text-align: left; padding: 10px 12px; gap: 12px; }
  .opt-t { font-size: 15.5px; }
  .legend-i { display: block; margin: 0; }
}
