:root {
  --azul: #0b3d5c;
  --azul-2: #145a85;
  --acento: #0f9d8a;
  --fondo: #f2f5f8;
  --tarjeta: #ffffff;
  --texto: #14212b;
  --sutil: #5b6b78;
  --borde: #cfd8e0;
  --error: #c62828;
  --alerta: #b26a00;
  --ok: #1b7f3a;
  --radio: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }

.barra { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--azul); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.marca { display: flex; gap: 10px; align-items: center; min-width: 0; }
.marca strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marca small { display: block; opacity: .8; font-size: 12px; }
.logo-mini { font-size: 24px; }
.estado-red { display: flex; align-items: center; gap: 6px; font-size: 12px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.estado-red .punto { width: 9px; height: 9px; border-radius: 50%; background: #9aa5ae; }
.estado-red.online .punto { background: #3ddc84; }
.estado-red.offline .punto { background: #ffb020; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--sutil); margin: 26px 0 8px; display: flex; align-items: center; gap: 8px; }
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); padding: 22px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.centro { text-align: center; }
.tarjeta.centro label { text-align: left; }
.sutil { color: var(--sutil); margin: 4px 0 16px; }
.nota { color: var(--sutil); font-size: 13px; }
.error { color: var(--error); font-weight: 600; min-height: 1.2em; margin: 10px 0 0; }
.advertencia { color: var(--alerta); background: #fff4e0; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.aviso { background: #fff4e0; border: 1px solid #f0c27a; border-radius: var(--radio); padding: 12px; margin-top: 14px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 0; color: #2b3a46; }
.ast { color: var(--error); }

input, select, textarea { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 17px; color: var(--texto);
  padding: 12px; border: 1.5px solid var(--borde); border-radius: 10px; background: #fff; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul-2); box-shadow: 0 0 0 3px rgba(20,90,133,.15); }
.invalido { border-color: var(--error) !important; background: #fff5f5; }
.fila { display: flex; gap: 10px; }
.fila > label { flex: 1; min-width: 0; }
.fila > label.corto { flex: 0 0 34%; }
.signos { flex-wrap: wrap; }
.signos > label { flex: 1 1 calc(33% - 10px); }
.etiqueta { font-weight: 700; margin: 18px 0 0; }
.horas { margin-top: 12px; }
.campo-hora { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.campo-hora .lbl { font-weight: 600; font-size: 14px; color: #2b3a46; }
.lbl.req::after { content: " *"; color: var(--error); }
.campo-hora input { min-width: 0; }
.campo-hora .btn.mini { margin-top: 6px; min-height: 40px; }

.btn { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 13px 16px; min-height: 48px; cursor: pointer; }
.btn.primario { background: var(--acento); color: #fff; }
.btn.secundario { background: #e3e9ee; color: var(--azul); }
.btn.enlace { background: none; color: var(--azul-2); text-decoration: underline; padding: 8px; min-height: 0; }
.btn.peligro { color: var(--error); }
.btn.mini { margin-top: 5px; padding: 0 12px; background: #e3e9ee; color: var(--azul); font-size: 14px; }
.btn.grande { width: 100%; font-size: 19px; padding: 18px; }
.btn:disabled { opacity: .55; }
.tarjeta .btn.primario { width: 100%; margin-top: 18px; }
#btnSincronizar { width: 100%; margin-top: 8px; }

.cuenta { background: #dfe6ec; color: var(--azul); border-radius: 99px; padding: 1px 9px; font-size: 13px; }
.cuenta.alerta { background: #ffe6bf; color: #7a4800; }
.cuenta.ok { background: #d5f0dd; color: var(--ok); }
.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lista li { background: #fff; border-radius: 10px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.lista li.click { cursor: pointer; border-left: 4px solid var(--acento); }
.lista li .meta { font-size: 13px; color: var(--sutil); }
.lista li .err { font-size: 13px; color: var(--error); }
.lista .vacio { background: none; box-shadow: none; color: var(--sutil); font-size: 14px; padding: 4px 2px; }
.pie { display: flex; justify-content: space-between; margin-top: 30px; }

/* Formulario por pasos */
.pasos { position: sticky; top: 58px; z-index: 4; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--fondo); padding: 4px 0 10px; }
.pasos button { font: inherit; font-size: 13px; font-weight: 700; border: 0; border-bottom: 3px solid var(--borde); background: none; color: var(--sutil); padding: 8px 2px; }
.pasos button.activo { color: var(--azul); border-bottom-color: var(--acento); }
.pasos button.completo { color: var(--ok); }
fieldset { border: 0; margin: 0; padding: 4px 16px 18px; background: #fff; border-radius: var(--radio); }
legend { font-size: 19px; font-weight: 800; padding: 16px 0 0; float: left; width: 100%; }
legend + * { clear: both; }

.sino { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #edf1f4; font-weight: 600; }
.sino .seg { display: flex; border: 1.5px solid var(--borde); border-radius: 10px; overflow: hidden; flex: 0 0 auto; }
.sino .seg button { font: inherit; font-weight: 700; border: 0; background: #fff; padding: 10px 18px; min-width: 64px; color: var(--sutil); }
.sino .seg button + button { border-left: 1.5px solid var(--borde); }
.sino .seg button.sel-si { background: var(--acento); color: #fff; }
.sino .seg button.sel-no { background: #5b6b78; color: #fff; }

.chequeo { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; background: #f5f8fa; padding: 12px; border-radius: 10px; }
.chequeo input { width: 26px; min-height: 26px; height: 26px; flex: 0 0 26px; margin: 0; }
.chequeo.req::after { content: ""; }
.firma-caja { position: relative; border: 2px dashed var(--borde); border-radius: 12px; background: #fff; height: 230px; margin: 8px 0 10px; touch-action: none; }
.firma-caja canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.firma-guia { position: absolute; left: 16px; bottom: 34px; right: 16px; border-top: 1px solid #c3cdd5; color: #aab5be; font-size: 12px; padding-top: 2px; pointer-events: none; }

.acciones { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 8px; background: var(--fondo); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }
.acciones .btn { padding: 12px 6px; font-size: 15px; }
#btnEliminar { display: block; margin: 6px auto 30px; }

.modal { position: fixed; inset: 0; background: rgba(10,25,35,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal-caja { background: #fff; border-radius: 14px; padding: 20px; max-width: 420px; width: 100%; }
.modal-caja p { margin: 0 0 18px; white-space: pre-line; }
.modal-botones { display: flex; gap: 10px; justify-content: flex-end; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; background: #14212b; color: #fff; padding: 14px 16px; border-radius: 12px; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
