/* SERAPHIM · Mi app — estilos. Móvil primero; claro/oscuro según el dispositivo. Sin estilos en línea (la política de seguridad no los admite). */
:root {
  --bg: #f4f4f6; --panel: #ffffff; --ink: #1f2328; --muted: #646b78; --line: #e1e3e8;
  --acc: #b83d7c; --acc-ink: #ffffff; --acc-soft: #f9e7f1;
  --ok: #1d6a33; --ok-soft: #e1f2e6; --warn: #8a5a00; --warn-soft: #fff1d2; --err: #b3261e; --err-soft: #fbe6e3;
  --sombra: 0 1px 3px rgba(20, 24, 32, .08);
  --radio: 14px;
  --bar: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --panel: #1b1e24; --ink: #e8eaee; --muted: #9aa1ad; --line: #2c313a;
    --acc: #e072a6; --acc-ink: #1a0710; --acc-soft: #3a1f2d;
    --ok: #86d69c; --ok-soft: #173225; --warn: #ffc56b; --warn-soft: #3a2d12; --err: #ff9188; --err-soft: #3d201d;
    --sombra: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acc); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.app { min-height: 100%; display: flex; flex-direction: column; }
.cargando { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--acc); border-radius: 50%; animation: gira 0.9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.aviso-js { padding: 24px; text-align: center; }

/* estructura */
.cab { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.cab .atras { border: 0; background: none; font-size: 26px; line-height: 1; padding: 4px 8px 4px 0; color: var(--acc); }
.cab .tit { flex: 1; min-width: 0; }
.cab h1 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab .sub { color: var(--muted); font-size: 13px; }
.principal { flex: 1; padding: 16px 16px calc(var(--bar) + 24px + env(safe-area-inset-bottom)); width: 100%; max-width: 640px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--panel); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--bar); font-size: 12px; position: relative; }
.tabs a .ico { font-size: 22px; line-height: 1; }
.tabs a.on { color: var(--acc); font-weight: 600; }
.insignia { position: absolute; top: 6px; left: calc(50% + 8px); background: var(--err); color: #fff; border-radius: 10px; min-width: 18px; padding: 0 5px; font-size: 11px; line-height: 18px; text-align: center; }

/* tarjetas y bloques */
.tarjeta { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); margin-bottom: 14px; }
.tarjeta h2 { font-size: 15px; margin-bottom: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.estado { display: flex; align-items: center; gap: 12px; }
.estado .punto { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.estado.dentro .punto { background: var(--ok); }
.estado .t1 { font-size: 20px; font-weight: 700; }
.estado .t2 { color: var(--muted); font-size: 14px; }
.btn { display: block; width: 100%; border: 0; border-radius: var(--radio); padding: 14px 18px; font-weight: 700; text-align: center; background: var(--acc); color: var(--acc-ink); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sec { background: var(--panel); color: var(--acc); border: 1.5px solid var(--acc); }
.btn.peligro { background: var(--err-soft); color: var(--err); }
.btn.peq { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; }
.btn.fichar { font-size: 22px; padding: 26px 18px; margin: 14px 0 4px; letter-spacing: .02em; }
.btn.fichar.salida { background: var(--ink); color: var(--panel); }
.fila { display: flex; gap: 10px; align-items: center; }
.fila > * { flex: 1; }
.fila > .fijo { flex: none; }
.pie { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0; }

/* formularios */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.campo input, .campo select, .campo textarea { width: 100%; border: 1.5px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px 14px; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--acc); outline-offset: 1px; border-color: var(--acc); }
.campo textarea { min-height: 120px; resize: vertical; }
.campo input[type=checkbox] { width: auto; margin-right: 8px; vertical-align: middle; }
.campo input[type=date] { min-width: 0; }
.fila > .campo { min-width: 0; }
.campo label.inline { display: flex; align-items: center; color: var(--ink); }
.campo .ayuda { font-size: 12px; color: var(--muted); margin-top: 4px; }
.campo .contador { text-align: right; font-size: 12px; color: var(--muted); }
.mensaje { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; font-size: 15px; }
.mensaje.ok { background: var(--ok-soft); color: var(--ok); }
.mensaje.err { background: var(--err-soft); color: var(--err); }
.mensaje.aviso { background: var(--warn-soft); color: var(--warn); }
.mensaje.info { background: var(--acc-soft); color: var(--ink); }

/* login */
.entrada { max-width: 420px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 20px 28px; width: 100%; }
.entrada .logo { display: block; width: 120px; height: 120px; margin: 0 auto 8px; border-radius: 50%; background: #fff; }
.entrada h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.entrada .lema { text-align: center; color: var(--muted); margin-bottom: 22px; }

/* listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lista li:last-child { border-bottom: 0; }
.lista .grande { flex: 1; min-width: 0; }
.lista .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.lista .t2 { color: var(--muted); font-size: 14px; }
.lista .sin-leer .t1 { color: var(--acc); }
.lista .sin-leer::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--acc); flex: none; }
.lista a.fila-enlace { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; width: 100%; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--neutral, var(--line)); color: var(--ink); }
.chip.ent { background: var(--ok-soft); color: var(--ok); }
.chip.sal { background: var(--warn-soft); color: var(--warn); }
.dia { margin: 16px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* conversación */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.burbuja { max-width: 86%; padding: 10px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.burbuja.mio { align-self: flex-end; background: var(--acc-soft); border-color: transparent; }
.burbuja .meta { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* QR */
.qr-caja { background: #fff; border-radius: var(--radio); padding: 18px; margin: 0 auto; width: min(86vw, 340px); box-shadow: var(--sombra); }
.qr-caja canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-barra { height: 6px; background: var(--line); border-radius: 3px; margin: 14px auto 0; width: min(86vw, 340px); overflow: hidden; }
.qr-barra > div { height: 100%; background: var(--acc); width: 100%; }
.qr-num { text-align: center; font-size: 22px; letter-spacing: .08em; margin-top: 12px; font-weight: 700; }

/* puertas */
.puerta { display: flex; align-items: center; gap: 12px; }
.puerta .nom { flex: 1; font-weight: 600; font-size: 17px; }
.puerta .btn { width: auto; min-width: 110px; }
.estado-puerta { font-size: 14px; margin-top: 8px; }

/* estado de fichar (panel que sale al pulsar) */
.proceso { text-align: center; padding: 8px 0; }
.proceso .spinner { margin: 8px auto 12px; }
.proceso .grande { font-size: 20px; font-weight: 700; }
.resultado { text-align: center; padding: 6px 0 2px; }
.resultado .grande { font-size: 26px; font-weight: 800; }
.resultado.ok .grande { color: var(--ok); }

/* avisos flotantes */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--bar) + 18px + env(safe-area-inset-bottom)); z-index: 20; max-width: 560px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--panel); text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--err); color: #fff; }
.visor { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .86); display: flex; align-items: center; justify-content: center; padding: 16px; }
.visor img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 8px; }
.visor .cerrar { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; width: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tabla td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.progreso { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progreso > div { height: 100%; width: 0; background: var(--acc); }
.oculto { display: none !important; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }

/* logo de SERAPHIM de fondo (marca de agua) en todas las pantallas */
body::before { content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; background: url(../img/logo-seraphim.png) no-repeat center / min(86vw, 560px) auto; opacity: .12; }
@media (prefers-color-scheme: dark) { body::before { opacity: .18; } }
.app { position: relative; z-index: 1; }
.entrada .logo-h { display: block; width: min(78%, 300px); height: auto; margin: 0 auto 14px; }

/* instalar como app */
.instalar { background: var(--acc-soft); border: 1.5px solid var(--acc); border-radius: var(--radio); margin: 0 0 14px; }
.instalar.grande { padding: 16px; margin-bottom: 18px; }
.instalar.grande b { display: block; font-size: 17px; margin-bottom: 4px; }
.instalar.grande p { margin: 0 0 12px; color: var(--ink); }
.instalar.grande .btn + .btn { margin-top: 10px; }
.instalar.mini { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 14px; }
.instalar.mini .txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.instalar.mini .txt b { display: block; font-size: 15px; }
.instalar.mini .btn { flex: none; }
.instalar.mini .x { flex: none; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); padding: 8px 10px; }
.hoja-fondo { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.hoja { background: var(--panel); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
.hoja h2 { font-size: 20px; margin-bottom: 8px; }
.hoja h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 4px; }
.hoja p { margin: 0 0 12px; }
.hoja .btn { margin-top: 10px; }
.pasos { list-style: none; counter-reset: paso; margin: 8px 0 0; padding: 0; }
.pasos li { counter-increment: paso; display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pasos li:last-child { border-bottom: 0; }
.pasos li::before { content: counter(paso); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--acc); color: var(--acc-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pasos li span { flex: 1; min-width: 0; }
