:root {
  --navy: #16225a;
  --navy-2: #24357f;
  --rojo: #d42a1c;
  --fondo: #eef1f6;
  --card: #ffffff;
  --texto: #1b2233;
  --suave: #5d6781;
  --borde: #d5dae6;
  --ok: #17803d;
  --wa: #1fa855;
  --radio: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: 96px;
}

/* ---------- Barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--borde);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
}
.top img { height: 30px; width: auto; display: block; }
.top .titulo { font-weight: 700; color: var(--navy); font-size: 15px; line-height: 1.1; }
.top .estado { font-size: 12px; color: var(--suave); }
.top .estado.ok { color: var(--ok); }
.top .estado.err { color: var(--rojo); }
.top .espacio { flex: 1; }
.btn-menu {
  border: 1px solid var(--borde); background: #fff; border-radius: 10px;
  min-width: 44px; height: 40px; font-size: 20px; color: var(--navy);
}
.menu {
  position: absolute; right: 12px; top: 54px; background: #fff; border: 1px solid var(--borde);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.15); min-width: 220px; overflow: hidden;
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 14px 16px; border: 0; background: none;
  font: inherit; color: var(--texto); text-decoration: none; border-bottom: 1px solid var(--fondo);
}
.menu .peligro { color: var(--rojo); }

main { max-width: 760px; margin: 0 auto; padding: 12px; }

/* ---------- Secciones ---------- */
.card {
  background: var(--card); border-radius: var(--radio); padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 2px rgba(20,30,60,.06);
}
.card h2 {
  margin: 0 0 12px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--navy); display: flex; align-items: center; gap: 8px;
}
.card h2 .n {
  background: var(--navy); color: #fff; border-radius: 50%; width: 22px; height: 22px;
  display: inline-grid; place-items: center; font-size: 12px; letter-spacing: 0;
}
.sub { font-size: 13px; font-weight: 600; color: var(--suave); margin: 14px 0 6px; }

.grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 420px) { .grid.g-auto { grid-template-columns: 1fr; } }

label.campo { display: block; font-size: 13px; color: var(--suave); font-weight: 600; }
label.campo .req { color: var(--rojo); }
input[type=text], input[type=tel], input[type=date], input[type=time], input[type=password], input[type=search], textarea {
  width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--texto);
  border: 1px solid var(--borde); border-radius: 10px; padding: 11px 12px; background: #fbfcfe;
  min-height: 46px;
}
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 0; background: #fff; }
.campo.falta input, .campo.falta textarea { border-color: var(--rojo); background: #fff5f4; }
.contador { font-size: 11px; color: var(--suave); text-align: right; font-weight: 400; margin-top: 2px; }

.con-boton { display: flex; gap: 8px; align-items: flex-end; }
.con-boton > label { flex: 1; }
.btn-chico {
  height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--navy);
  background: #fff; color: var(--navy); font: inherit; font-weight: 600; font-size: 14px;
}

/* ---------- Opciones táctiles (checkbox / radio) ---------- */
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.opciones.col { flex-direction: column; }
.op { position: relative; }
.op input { position: absolute; opacity: 0; pointer-events: none; }
.op span {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 9px 14px;
  border: 1.5px solid var(--borde); border-radius: 10px; background: #fff; font-size: 15px;
  user-select: none; -webkit-user-select: none; cursor: pointer;
}
.op span::before {
  content: ""; flex: none; width: 20px; height: 20px; border: 2px solid #9aa3b8; border-radius: 5px;
  background: #fff center / 14px no-repeat;
}
.op input[type=radio] + span::before { border-radius: 50%; }
.op input:checked + span { border-color: var(--navy); background: #eef1fb; color: var(--navy); font-weight: 600; }
.op input:checked + span::before {
  border-color: var(--navy); background-color: var(--navy);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3 3 7-7' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.op input:focus-visible + span { outline: 2px solid var(--navy-2); }
.opciones.col .op span { width: 100%; }
.chips .op span { padding: 9px 12px; }
.chips .op span::before { width: 18px; height: 18px; }

.pregunta { padding: 10px 0; border-top: 1px solid var(--fondo); }
.pregunta:first-of-type { border-top: 0; }
.pregunta p { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.pregunta .opciones .op { flex: 1; }
.pregunta .opciones .op span { justify-content: center; }

/* ---------- Componentes ---------- */
.comp { border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.comp-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.comp-cab b { color: var(--navy); font-size: 14px; }
.comp-cab button { border: 0; background: none; color: var(--rojo); font: inherit; font-size: 14px; padding: 6px; }
.comp .grid { grid-template-columns: 70px 1fr; }
.btn-linea {
  width: 100%; min-height: 46px; border: 1.5px dashed var(--navy-2); border-radius: 10px;
  background: #fff; color: var(--navy); font: inherit; font-weight: 600;
}

/* ---------- Firmas ---------- */
.firma { margin-bottom: 14px; }
.firma-caja { position: relative; margin-top: 4px; }
.firma canvas {
  display: block; width: 100%; height: 170px; background: #fff; border: 1.5px solid var(--borde);
  border-radius: 10px; touch-action: none;
}
.firma-caja .linea { position: absolute; left: 8%; right: 8%; bottom: 38px; border-bottom: 1px dashed #b7bfd1; pointer-events: none; }
.firma-caja .hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 12px; color: #9aa3b8; pointer-events: none; }
.firma-caja.firmado .hint { display: none; }
.firma-caja button {
  position: absolute; top: 6px; right: 6px; border: 1px solid var(--borde); background: #fff;
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; color: var(--suave);
}

/* ---------- Barra inferior ---------- */
.accion {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff;
  border-top: 1px solid var(--borde); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.accion .in { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; }
.btn {
  flex: 1; min-height: 52px; border-radius: 12px; border: 0; font: inherit; font-weight: 700; font-size: 17px;
  background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; text-decoration: none; padding: 0 16px;
}
.btn:disabled { opacity: .6; }
.btn.sec { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.btn.wa { background: var(--wa); }
.btn svg { width: 22px; height: 22px; flex: none; }

/* ---------- Avisos y resultado ---------- */
.aviso { border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; font-size: 15px; }
.aviso.err { background: #fdecea; color: #8d1c12; }
.aviso.info { background: #eaf1fd; color: #1c3a8d; }

.velo {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,22,48,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.hoja {
  background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0;
  padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 560px) { .velo { align-items: center; } .hoja { border-radius: 18px; } }
.hoja .ok-ico {
  width: 54px; height: 54px; border-radius: 50%; background: #e3f5e9; color: var(--ok);
  display: grid; place-items: center; margin: 0 auto 8px;
}
.hoja h3 { text-align: center; margin: 0; font-size: 20px; color: var(--navy); }
.hoja .num { text-align: center; font-size: 30px; font-weight: 800; color: var(--rojo); margin: 2px 0 4px; }
.hoja .cli { text-align: center; color: var(--suave); margin: 0 0 16px; }
.hoja .btn { width: 100%; margin-bottom: 10px; }
.hoja .nota { font-size: 12px; color: var(--suave); text-align: center; margin: 4px 0 0; }

/* ---------- Login / listado ---------- */
.centro { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 26px 20px; box-shadow: 0 8px 30px rgba(20,30,60,.1); }
.login img { display: block; height: 48px; margin: 0 auto 10px; }
.login h1 { font-size: 18px; text-align: center; color: var(--navy); margin: 0 0 18px; }
.login .btn { width: 100%; margin-top: 14px; }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 12px; align-items: center; }
.lista .nro { font-weight: 800; color: var(--rojo); min-width: 64px; }
.lista .det { flex: 1; min-width: 0; }
.lista .det b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .det small { color: var(--suave); }
.lista a.ver { color: var(--navy); font-weight: 700; text-decoration: none; border: 1px solid var(--navy); border-radius: 8px; padding: 8px 12px; }

/* ---------- Utilidades (sin estilos inline, compatible con CSP) ---------- */
.mt0 { margin-top: 0; }
.mt8 { margin-top: 8px; }
.mt10 { margin-top: 10px; }
.mt12 { margin-top: 12px; }
.mb12 { margin-bottom: 12px; }
body.sin-barra { padding-bottom: 20px; }
.btn-volver { display: grid; place-items: center; text-decoration: none; height: 40px; }
.buscar { margin: 0 0 12px; }
