/* =========================================================
   Expedición de resoluciones · ISVIMED
   Identidad JAGA TECH: azul royal, gris, blanco y negro.
   Sin tipografías externas: la herramienta debe abrir aunque
   el equipo no tenga salida a internet.
   ========================================================= */

:root {
  --jaga: #0629C7;
  --jaga-osc: #041c8f;
  --jaga-claro: #e8ecfd;
  --gris: #808080;

  --tinta: #10131a;
  --tinta-2: #464c5a;
  --tenue: #6e7684;
  --linea: #dfe3ea;
  --linea-fuerte: #c3c9d4;
  --panel: #ffffff;
  --fondo: #f4f6fa;
  --fondo-2: #eceff5;

  --ok: #0f7a41;
  --ok-fondo: #e6f5ec;
  --alto: #b42318;
  --alto-fondo: #fdeceb;
  --aviso: #96650a;
  --aviso-fondo: #fdf3e2;

  --radio: 6px;
  --sombra: 0 1px 2px rgba(16, 19, 26, .08);
  --sombra-flota: 0 8px 24px rgba(16, 19, 26, .16);

  /* El documento es un papel oficial: se ve igual en cualquier equipo. */
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--fondo);
  color: var(--tinta);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.oculto { display: none !important; }

/* ---------------------------- botones ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio);
  background: var(--panel);
  color: var(--tinta);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--fondo-2); }
.btn:focus-visible { outline: 2px solid var(--jaga); outline-offset: 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primario { background: var(--jaga); border-color: var(--jaga); color: #fff; }
.btn.primario:hover:not(:disabled) { background: var(--jaga-osc); border-color: var(--jaga-osc); }

.btn.aprobar { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.aprobar:hover:not(:disabled) { filter: brightness(.92); }

.btn.rechazar { background: var(--panel); border-color: var(--alto); color: var(--alto); }
.btn.rechazar:hover:not(:disabled) { background: var(--alto-fondo); }

.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover:not(:disabled) { background: var(--fondo-2); }

.btn.chico { padding: 4px 9px; font-size: 12px; }

.enlace {
  background: none; border: 0; padding: 0;
  color: var(--jaga); font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* ---------------------------- acceso ----------------------------- */

.acceso {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #0a1642 0%, var(--jaga-osc) 55%, #0a1642 100%);
}

.acceso-caja {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 10px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(4, 12, 40, .45);
}

.acceso-marca {
  display: flex; align-items: center; gap: 11px;
  margin-bottom: 20px; padding-bottom: 18px;
  border-bottom: 1px solid var(--linea);
}
.acceso-marca img { width: 42px; height: 42px; object-fit: contain; border-radius: 5px; }
.acceso-marca h1 { font-size: 16px; line-height: 1.25; }
.acceso-marca p { margin: 2px 0 0; font-size: 11.5px; color: var(--tenue); }

.campo { margin-bottom: 14px; }
.campo label {
  display: block; margin-bottom: 5px;
  font-size: 12px; font-weight: 700; color: var(--tinta-2);
}
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio);
  background: var(--panel);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: 2px solid var(--jaga); outline-offset: -1px; border-color: var(--jaga);
}
.campo .pista { margin: 5px 0 0; font-size: 11.5px; color: var(--tenue); }

.aviso-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border: 1px solid #f3c0bd;
  border-left: 3px solid var(--alto);
  border-radius: var(--radio);
  background: var(--alto-fondo);
  color: #8d1a13;
  font-size: 13px;
}

/* ------------------------- barra superior ------------------------ */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.barra {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 52px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--linea);
  box-shadow: var(--sombra);
  z-index: 30;
}

.barra-marca { display: flex; align-items: center; gap: 9px; min-width: 0; }
.barra-marca img { width: 30px; height: 30px; object-fit: contain; border-radius: 4px; }
.barra-marca .titulo { font-size: 13.5px; font-weight: 700; line-height: 1.1; }
.barra-marca .sub { font-size: 11px; color: var(--tenue); }

.barra .separador { flex: 1 1 auto; }

.usuario-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--linea);
  border-radius: 20px;
  background: var(--fondo);
}
.usuario-chip .nombre { font-size: 12.5px; font-weight: 700; line-height: 1.15; }
.usuario-chip .rol { font-size: 11px; color: var(--jaga); font-weight: 700; }

/* -------------------------- selector de lote --------------------- */

.lote-selector {
  position: relative;
  min-width: 0;
}
.lote-boton {
  display: flex; align-items: center; gap: 9px;
  max-width: 420px;
  padding: 6px 11px;
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio);
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}
.lote-boton:hover { background: var(--fondo-2); }
.lote-boton .nombre {
  font-weight: 700; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lote-boton .meta { font-size: 11px; color: var(--tenue); }

.lote-lista {
  position: absolute; top: calc(100% + 6px); left: 0;
  width: 460px; max-height: 60vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--linea-fuerte);
  border-radius: 8px;
  box-shadow: var(--sombra-flota);
  padding: 6px;
  z-index: 40;
}
.lote-item {
  display: block; width: 100%;
  padding: 9px 10px;
  border: 0; border-radius: var(--radio);
  background: none; text-align: left; cursor: pointer;
}
.lote-item:hover { background: var(--fondo-2); }
.lote-item.activo { background: var(--jaga-claro); }
.lote-item .fila1 { display: flex; align-items: center; gap: 8px; }
.lote-item .nom { font-weight: 700; font-size: 13px; flex: 1 1 auto; }
.lote-item .fila2 { margin-top: 3px; font-size: 11.5px; color: var(--tenue); }

.pastilla {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px; font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pastilla.turno   { background: var(--jaga-claro); color: var(--jaga-osc); border-color: #c3ccf7; }
.pastilla.ok      { background: var(--ok-fondo);   color: var(--ok);       border-color: #bfe3cd; }
.pastilla.alto    { background: var(--alto-fondo); color: var(--alto);     border-color: #f3c0bd; }
.pastilla.aviso   { background: var(--aviso-fondo);color: var(--aviso);    border-color: #ecd7ab; }
.pastilla.neutra  { background: var(--fondo-2);    color: var(--tenue);    border-color: var(--linea); }

/* ---------------------------- cadena ----------------------------- */

.cadena {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--linea);
  overflow-x: auto;
}

.cadena-paso {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px 9px 0;
  margin-right: 16px;
  border-right: 1px solid var(--linea);
  white-space: nowrap;
}
.cadena-paso:last-child { border-right: 0; margin-right: 0; }

.cadena-num {
  display: grid; place-items: center;
  width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 50%;
  border: 1.5px solid var(--linea-fuerte);
  background: var(--panel);
  font-size: 11.5px; font-weight: 700; color: var(--tenue);
}
.cadena-paso.firmada .cadena-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.cadena-paso.activa  .cadena-num { background: var(--jaga); border-color: var(--jaga); color: #fff; }

.cadena-info .et { font-size: 12.5px; font-weight: 700; line-height: 1.15; }
.cadena-info .quien { font-size: 11px; color: var(--tenue); }
.cadena-paso.activa .cadena-info .quien { color: var(--jaga); font-weight: 700; }
.cadena-paso.bloqueada { opacity: .5; }

/* ---------------------------- bandeja ---------------------------- */

.cuerpo {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.bandeja {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.filtros {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
  padding: 9px 16px;
  background: var(--fondo);
  border-bottom: 1px solid var(--linea);
  overflow-x: auto;
}

.filtro {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 16px;
  background: var(--panel);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.filtro:hover { background: var(--fondo-2); }
.filtro[aria-pressed="true"] { background: var(--jaga); border-color: var(--jaga); color: #fff; }
.filtro .n {
  min-width: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--fondo-2);
  font-size: 11px; font-weight: 700; text-align: center;
}
.filtro[aria-pressed="true"] .n { background: rgba(255, 255, 255, .24); color: #fff; }

.buscador {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
}
.buscador input {
  width: 210px; padding: 5px 10px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 16px; background: var(--panel);
  font-size: 12.5px;
}

.tabla-caja {
  flex: 1 1 auto;
  overflow: auto;
  background: var(--panel);
}

table.hogares {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.hogares thead th {
  position: sticky; top: 0; z-index: 10;
  padding: 8px 10px;
  background: var(--fondo-2);
  border-bottom: 1px solid var(--linea-fuerte);
  font-size: 11.5px; font-weight: 700; text-align: left;
  color: var(--tinta-2); text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}

table.hogares tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--linea);
  vertical-align: middle;
}

table.hogares tbody tr { cursor: pointer; }
table.hogares tbody tr:hover { background: var(--fondo); }
table.hogares tbody tr.marcada { background: var(--jaga-claro); }
table.hogares tbody tr.marcada:hover { background: #dde3fb; }
table.hogares tbody tr.enfocada { box-shadow: inset 3px 0 0 var(--jaga); }
table.hogares tbody tr.rechazada .jefe { text-decoration: line-through; color: var(--tenue); }

td.sel, th.sel { width: 34px; text-align: center; padding-left: 12px; }
td.sel input, th.sel input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--jaga); }

td.num { width: 46px; color: var(--tenue); font-variant-numeric: tabular-nums; }
td.jefe { font-weight: 600; }
td.jefe .doc { display: block; font-size: 11.5px; font-weight: 400; color: var(--tenue); }
td.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
td.dinero { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Una celda con problema se marca en la celda, no en un panel aparte. */
.celda-mala {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 5px; margin: -1px -5px;
  border-radius: 3px;
  background: var(--alto-fondo);
  box-shadow: inset 0 -1.5px 0 var(--alto);
}
.celda-aviso {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 5px; margin: -1px -5px;
  border-radius: 3px;
  background: var(--aviso-fondo);
  box-shadow: inset 0 -1.5px 0 var(--aviso);
}

.estado-celda { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.punto { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.punto.pendiente { background: var(--gris); }
.punto.aprobado { background: var(--ok); }
.punto.rechazado { background: var(--alto); }

.vacio {
  padding: 60px 24px;
  text-align: center;
  color: var(--tenue);
}
.vacio h2 { font-size: 16px; color: var(--tinta); margin-bottom: 6px; }

/* ----------------------- barra de acciones ----------------------- */

/* Siempre visible: decidir no puede depender de volver al principio. */
.acciones {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid var(--linea-fuerte);
  box-shadow: 0 -2px 10px rgba(16, 19, 26, .06);
}

.acciones .conteo { font-size: 13px; font-weight: 700; }
.acciones .conteo .n { color: var(--jaga); }
.acciones .separador { flex: 1 1 auto; }
.acciones .ayuda-teclado { font-size: 11.5px; color: var(--tenue); }
.acciones kbd {
  display: inline-block; padding: 1px 5px; margin: 0 1px;
  border: 1px solid var(--linea-fuerte); border-bottom-width: 2px;
  border-radius: 4px; background: var(--fondo);
  font-family: inherit; font-size: 11px; font-weight: 700;
}

.sin-turno {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radio);
  background: var(--fondo-2);
  color: var(--tinta-2);
  font-size: 12.5px;
}

/* --------------------------- documento --------------------------- */

.doc-panel {
  flex: 0 0 auto;
  width: min(50vw, 720px);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--linea-fuerte);
  background: var(--fondo-2);
  min-height: 0;
}

.doc-cabeza {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--linea);
}
.doc-cabeza .titulo { font-size: 13px; font-weight: 700; }
.doc-cabeza .sub { font-size: 11.5px; color: var(--tenue); }

.doc-scroll { flex: 1 1 auto; overflow: auto; padding: 16px; }

/* La hoja conserva el aspecto de papel carta del documento oficial. */
.hoja {
  width: 816px;
  transform-origin: top left;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--linea-fuerte);
  box-shadow: var(--sombra);
  padding: 34px 40px 44px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11pt;
  line-height: 1.32;
  color: #000;
}
.hoja .c { text-align: center; }
.hoja p { margin: 0 0 9px; text-align: justify; }
.hoja table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 10pt; }
.hoja table td, .hoja table th { border: 1px solid #000; padding: 4px 6px; }

/* Resaltado de origen del dato: se puede apagar. */
.hoja .f { background: #fff1c2; box-shadow: inset 0 -1px 0 #b8860b; }
.hoja .f.hogar { background: #e3eefb; box-shadow: inset 0 -1px 0 #6c8fc7; }
.hoja.limpia .f { background: none; box-shadow: none; }

/* --------------------------- ventanas ---------------------------- */

.fondo-modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;              /* centrado real, en los dos ejes */
  padding: 16px;
  background: rgba(16, 19, 26, .55);
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--sombra-flota);
  padding: 20px;
}
.modal.ancho { max-width: 760px; }
.modal-cabeza {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 14px;
}
.modal-cabeza h2 { font-size: 16px; }
.modal-cabeza p { margin: 3px 0 0; font-size: 12.5px; color: var(--tenue); }
.modal-pie {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--linea);
}
.modal-pie .separador { flex: 1 1 auto; }

.motivos { display: grid; gap: 6px; margin-top: 8px; }
.motivo {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio);
  background: var(--panel);
  cursor: pointer; text-align: left; font-size: 12.5px;
}
.motivo:hover { background: var(--fondo-2); }
.motivo[aria-pressed="true"] { border-color: var(--jaga); background: var(--jaga-claro); }

.lista-simple { margin: 10px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.lista-simple li { padding: 6px 0; border-bottom: 1px solid var(--linea); }
.lista-simple li:last-child { border-bottom: 0; }
.lista-simple .cuando { color: var(--tenue); font-size: 11.5px; }

/* ----------------------------- avisos ---------------------------- */

.avisos {
  position: fixed; right: 16px; bottom: 16px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 380px;
}
.aviso {
  padding: 10px 14px;
  border-radius: var(--radio);
  background: var(--tinta);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--sombra-flota);
  animation: entra .16s ease-out;
}
.aviso.error { background: var(--alto); }
.aviso.exito { background: var(--ok); }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .aviso { animation: none; } }

.progreso {
  height: 4px; border-radius: 2px;
  background: var(--fondo-2); overflow: hidden;
  margin-top: 8px;
}
.progreso i { display: block; height: 100%; background: var(--jaga); width: 0; transition: width .2s; }

/* --------------------------- pantallas --------------------------- */

/* Tablet: el documento pasa a superponerse en vez de partir la pantalla. */
@media (max-width: 1100px) {
  .doc-panel {
    position: fixed; inset: 0 0 0 auto;
    width: min(94vw, 720px);
    z-index: 60;
    box-shadow: var(--sombra-flota);
  }
}

/* Celular: la tabla se vuelve una lista de tarjetas, que es lo que cabe. */
@media (max-width: 760px) {
  .barra { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .barra-marca .sub { display: none; }
  .lote-boton { max-width: none; width: 100%; }
  .lote-lista { width: calc(100vw - 24px); left: 0; }

  .cadena { padding: 0 12px; }
  .cadena-paso { padding: 7px 10px 7px 0; margin-right: 10px; }
  .cadena-info .et { font-size: 11.5px; }

  .filtros { padding: 8px 12px; }
  .buscador { margin-left: 0; width: 100%; }
  .buscador input { width: 100%; }

  table.hogares thead { display: none; }
  table.hogares, table.hogares tbody, table.hogares tr, table.hogares td { display: block; width: auto; }
  table.hogares tbody tr {
    position: relative;
    margin: 8px 12px;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--linea-fuerte);
    border-radius: 8px;
    background: var(--panel);
  }
  table.hogares tbody td { border: 0; padding: 2px 0; }
  table.hogares tbody td.sel { position: absolute; left: 12px; top: 12px; padding: 0; width: auto; }
  table.hogares tbody td[data-et]::before {
    content: attr(data-et) ": ";
    font-size: 11px; font-weight: 700; color: var(--tenue);
    text-transform: uppercase; letter-spacing: .03em;
  }
  td.dinero { text-align: left; }

  .acciones { flex-wrap: wrap; gap: 8px; }
  .acciones .ayuda-teclado { display: none; }

  .doc-panel { width: 100vw; }
  .doc-scroll { padding: 8px; }
}

@media print {
  .barra, .cadena, .filtros, .acciones, .doc-cabeza, .avisos { display: none !important; }
  .doc-panel { position: static; width: auto; border: 0; background: #fff; }
  .hoja { border: 0; box-shadow: none; width: auto; padding: 0; }
}

/* --------------------- ajustes de desplazamiento ------------------ */

/* La cadena y los filtros se desplazan, pero sin apilar barras grises. */
.cadena, .filtros, .tabla-caja {
  scrollbar-width: thin;
}
.cadena, .filtros {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cadena::-webkit-scrollbar,
.filtros::-webkit-scrollbar { height: 0; display: none; }

@media (max-width: 760px) {
  /* Cadena compacta: el paso activo completo, los demás solo con su número. */
  .cadena-paso { padding: 7px 8px 7px 0; margin-right: 8px; gap: 6px; }
  .cadena-paso:not(.activa) .cadena-info .et { font-size: 11px; max-width: 74px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cadena-paso:not(.activa) .cadena-info .quien { display: none; }

  /* El valor queda junto a su etiqueta en vez de saltar de línea. */
  table.hogares tbody td[data-et] { display: flex; align-items: baseline; gap: 6px; }
  table.hogares tbody td[data-et]::before { flex: 0 0 auto; }
  .estado-celda { display: inline-flex; }
  table.hogares tbody td.jefe { display: block; }
  table.hogares tbody td.jefe::before { display: block; }
}
