/* Recepta · Firma electrónica (firmas.js en la app y firmar.html, la página pública). Solo tokens.
   Cada persona que firma tiene su color (c-cobalto, c-menta, c-ambar, c-violeta, c-rosa) en los lugares de firma. */
.fma-c-cobalto { --fma-c: var(--cobalto); --fma-s: var(--cobalto-suave); }
.fma-c-menta { --fma-c: var(--menta-texto); --fma-s: var(--menta-suave); }
.fma-c-ambar { --fma-c: var(--ambar-texto); --fma-s: var(--ambar-suave); }
.fma-c-violeta { --fma-c: var(--pizarra); --fma-s: var(--perla-suave); }
.fma-c-rosa { --fma-c: var(--error); --fma-s: var(--error-suave); }

/* Las hojas del PDF y los lugares de firma encima */
.fma-hoja { position: relative; width: 100%; margin: 0 auto var(--esp-3); background: var(--hoja); box-shadow: var(--sombra); border-radius: var(--radio-chico); overflow: hidden; }
.fma-hoja canvas { display: block; width: 100%; height: 100%; }
.fma-campo { position: absolute; display: grid; place-items: center; border: 2px dashed var(--fma-c, var(--cobalto)); background: color-mix(in srgb, var(--fma-s, var(--cobalto-suave)) 80%, transparent);
  border-radius: var(--radio-chico); color: var(--fma-c, var(--cobalto)); font-size: clamp(9px, 1.6vw, 13px); font-weight: var(--peso-fuerte); padding: 0 var(--esp-1); overflow: hidden; touch-action: none; }
.fma-campo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.fma-campo button { position: absolute; top: 0; right: 0; border: 0; background: var(--fma-c, var(--cobalto)); color: var(--hoja); width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 0 0 0 var(--radio-chico); font-size: 11px; line-height: 1; cursor: pointer; }
.fma-campo.firmado { border-style: solid; background: transparent; }
.fma-campo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fma-campo.mio { border-color: var(--cobalto); color: var(--cobalto); background: var(--cobalto-suave); cursor: pointer; animation: fma-latido 1.6s ease-in-out infinite; }
@keyframes fma-latido { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--cobalto) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .fma-campo.mio { animation: none; } }
.fma-alerta { color: var(--error); }

/* App: lista y detalle */
.fma-progreso { display: inline-flex; gap: 3px; vertical-align: middle; }
.fma-progreso i { width: 10px; height: 10px; border-radius: 50%; background: var(--perla); }
.fma-progreso i.firmado { background: var(--menta); } .fma-progreso i.rechazado { background: var(--error); }
.fma-grilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: var(--esp-4); align-items: start; }
.fma-grilla > .panel { min-width: 0; }
.fma-listo { border-color: var(--menta); background: var(--menta-suave); color: var(--menta-texto); margin-bottom: var(--esp-4); }
.fma-personas { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--esp-3); }
.fma-personas > li { border: 1px solid var(--perla); border-left: 4px solid var(--fma-c, var(--cobalto)); border-radius: var(--radio); padding: var(--esp-3); display: grid; gap: var(--esp-2); }
.fma-persona-cab { display: flex; align-items: center; gap: var(--esp-3); }
.fma-persona-cab > div { flex: 1; min-width: 0; display: grid; }
.fma-persona-cab small { color: var(--pizarra); font-size: var(--texto-chico); overflow-wrap: anywhere; }
.fma-num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--fma-c, var(--cobalto)); color: var(--hoja); font-size: var(--texto-mini); font-weight: var(--peso-fuerte); }
.fma-registro { display: flex; flex-wrap: wrap; gap: var(--esp-2) var(--esp-4); margin: 0; }
.fma-registro dt { font-size: var(--texto-mini); color: var(--pizarra); }
.fma-registro dd { margin: 0; font-variant-numeric: tabular-nums; }
.fma-firma-img { max-width: 180px; max-height: 70px; background: var(--hoja); border: 1px solid var(--perla-suave); border-radius: var(--radio-chico); }
.fma-mandar { flex-wrap: wrap; }
.fma-vista { max-width: 560px; margin: 0 auto; }
.fma-hash { font-size: var(--texto-mini); overflow-wrap: anywhere; }

/* App: mandar a firmar */
.fma-nuevo { display: grid; gap: var(--esp-5); }
.fma-nuevo h3 { margin: 0 0 var(--esp-2); font-size: var(--texto-base); color: var(--tinta); }
.fma-subir { display: grid; justify-items: center; gap: var(--esp-1); text-align: center; padding: var(--esp-5) var(--esp-4); border: 2px dashed var(--perla); border-radius: var(--radio-tarjeta); margin-bottom: var(--esp-3); }
.fma-subir > span { font-size: var(--titulo); }
.fma-subir small { color: var(--pizarra); }
.fma-subir .acciones { justify-content: center; flex-wrap: wrap; margin-top: var(--esp-2); }
.fma-subir.listo { border-style: solid; border-color: var(--menta); }
.fma-subir b { overflow-wrap: anywhere; }
.fma-vinculo { display: grid; gap: var(--esp-1); }
.fma-vinculo-elegido { display: inline-flex; gap: var(--esp-3); align-items: center; flex-wrap: wrap; }
.fma-resultados { display: grid; gap: var(--esp-1); }
.fma-resultados button { text-align: left; border: 1px solid var(--perla); background: var(--hoja); border-radius: var(--radio-chico); padding: var(--esp-2) var(--esp-3); min-height: 40px; }
.fma-firmantes { list-style: none; margin: 0 0 var(--esp-2); padding: 0; display: grid; gap: var(--esp-2); }
.fma-firmantes li { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--esp-2); align-items: center; }
.fma-firmantes input { width: 100%; min-width: 0; }
.fma-chips { display: flex; flex-wrap: wrap; gap: var(--esp-2); margin-bottom: var(--esp-3); }
.fma-chips button { display: inline-flex; align-items: center; gap: var(--esp-2); border: 1px solid var(--perla); background: var(--hoja); border-radius: var(--radio-pildora); padding: var(--esp-1) var(--esp-3); min-height: 40px; }
.fma-chips button i { width: 12px; height: 12px; border-radius: 50%; background: var(--fma-c); }
.fma-chips button.activo { border-color: var(--fma-c); background: var(--fma-s); font-weight: var(--peso-fuerte); }
.fma-chips small { color: var(--pizarra); }
.fma-marcar { max-width: 660px; }
.fma-marcar .fma-hoja { cursor: crosshair; }
.fma-marcar .fma-campo { cursor: move; }

/* Pantalla de firma (app y página pública) */
.fma { max-width: 860px; margin: 0 auto; padding-bottom: 96px; }
.fma-cab h1 { margin: 0 0 var(--esp-2); font-size: var(--titulo); overflow-wrap: anywhere; }
.fma-de { color: var(--pizarra); margin: 0 0 var(--esp-1); }
.fma-mensaje { font-style: italic; color: var(--pizarra); }
.fma-quienes { list-style: none; padding: 0; margin: var(--esp-3) 0; display: flex; flex-wrap: wrap; gap: var(--esp-2); }
.fma-quienes li { display: inline-flex; align-items: center; gap: var(--esp-2); flex-wrap: wrap; border: 1px solid var(--perla); border-radius: var(--radio-pildora); padding: var(--esp-1) var(--esp-3); background: var(--hoja); }
.fma-quienes li small { color: var(--pizarra); font-size: var(--texto-chico); }
.fma-quienes li.firmado > span { color: var(--menta-texto); font-weight: var(--peso-fuerte); }
.fma-quienes li.rechazado > span { color: var(--error); }
.fma-estado { margin: var(--esp-3) 0 var(--esp-4); display: grid; gap: var(--esp-2); justify-items: start; }
.fma-estado p { margin: 0; }
.fma-ok { color: var(--menta-texto); font-weight: var(--peso-fuerte); }
.fma-hojas { display: grid; }
.fma-cargando { color: var(--pizarra); text-align: center; padding: var(--esp-6) 0; }
.fma-barra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: var(--esp-3); justify-content: center; padding: var(--esp-3) var(--esp-4) calc(var(--esp-3) + env(safe-area-inset-bottom)); background: var(--hoja); border-top: 1px solid var(--perla); box-shadow: var(--sombra-flotante); }
.fma-barra button { flex: 1; max-width: 320px; min-height: 52px; font-size: var(--texto-base); }
.fma-no { color: var(--error); }
.fma-en-app .fma-barra { left: auto; right: auto; position: sticky; border-radius: var(--radio-grande); }
.fma-capa { position: fixed; inset: 0; z-index: 100; background: var(--velo); display: grid; place-items: center; padding: var(--esp-3); }
.fma-ventana { width: min(560px, 100%); max-height: 94dvh; overflow-y: auto; background: var(--hoja); color: var(--tinta); border-radius: var(--radio-grande); padding: var(--esp-5); box-shadow: var(--sombra-flotante); display: grid; gap: var(--esp-3); }
.fma-ventana h2 { margin: 0; }
.fma-ventana label { display: grid; gap: var(--esp-1); }
.fma-ventana input:not([type=checkbox]), .fma-ventana textarea { width: 100%; }
.fma-tenue { color: var(--pizarra); margin: 0; }
.fma-lienzo { position: relative; }
.fma-lienzo canvas { width: 100%; height: auto; aspect-ratio: 600 / 220; display: block; background: #fff; border: 2px dashed var(--perla); border-radius: var(--radio); touch-action: none; cursor: crosshair; }
.fma-borrar { position: absolute; top: var(--esp-2); right: var(--esp-2); min-height: 32px; padding: var(--esp-1) var(--esp-3); }
.fma-acepto { display: flex !important; align-items: center; gap: var(--esp-2); }
.fma-acepto input { width: 22px; height: 22px; flex: none; }
.fma-error { color: var(--error); margin: 0; min-height: 1.2em; }
.fma-botones { display: flex; gap: var(--esp-3); justify-content: flex-end; flex-wrap: wrap; }
.fma-botones button { min-height: 48px; flex: 1; }

/* Solo la página pública (firmar.html) */
.fma-publica { margin: 0; background: var(--niebla); color: var(--tinta); font-family: var(--fuente); font-size: var(--texto-base); line-height: 1.5; }
.fma-publica *, .fma-publica *::before, .fma-publica *::after { box-sizing: border-box; }
.fma-publica button, .fma-publica input, .fma-publica textarea { font: inherit; color: inherit; }
.fma-publica button { border: 1px solid var(--perla); background: var(--hoja); border-radius: var(--radio); padding: var(--esp-2) var(--esp-4); min-height: 44px; cursor: pointer; }
.fma-publica button:disabled { opacity: 0.6; cursor: wait; }
.fma-publica .principal { background: var(--cobalto); border-color: var(--cobalto); color: #fff; font-weight: var(--peso-fuerte); }
.fma-publica input:not([type=checkbox]), .fma-publica textarea { border: 1px solid var(--perla); border-radius: var(--radio-chico); padding: var(--esp-3); background: var(--hoja); }
.fma-publica main { padding: var(--esp-5) var(--esp-4); }
.fma-marca { display: flex; justify-content: space-between; gap: var(--esp-3); padding: var(--esp-4) var(--esp-5); border-bottom: 1px solid var(--perla); background: var(--hoja); font-size: var(--texto-mini); letter-spacing: 0.08em; }
.fma-marca span:first-child { font-weight: 800; color: var(--cobalto); }
.fma-hoja-msj { max-width: 560px; margin: var(--esp-8) auto; text-align: center; }
.fma-mensaje-flotante { position: fixed; bottom: 84px; left: var(--esp-4); right: var(--esp-4); margin: 0 auto; max-width: 560px; background: var(--tinta); color: var(--hoja); border-radius: var(--radio); padding: var(--esp-3); z-index: 30; text-align: center; }
.fma-mensaje-flotante:empty { display: none; }

@media (max-width: 600px) {
  .fma-firmantes li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .fma-firmantes li input[data-campo='contacto'] { grid-column: 2; }
  .fma-firmantes li > :last-child { grid-row: 1; grid-column: 3; }
  .fma-marca { padding: var(--esp-3) var(--esp-4); }
  .fma-ventana { padding: var(--esp-4); }
}
/* El reloj de Proyectos (flota abajo a la derecha) no tapa la barra para firmar */
body:has(.fma-barra) .pr-reloj { bottom: 96px; }
