:root {
  --fondo: #f3f1ee;
  --papel: #ffffff;
  --tinta: #1d1d1b;
  --suave: #6b6760;
  --linea: #e4e0da;
  --marca: #e35205;
  --marca-osc: #b94204;
  --ok: #1d7a3a;
  --ok-fondo: #eaf6ee;
  --no: #b42318;
  --no-fondo: #fdeceb;
  --pend: #8a6100;
  --pend-fondo: #fff6e0;
  --radio: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--marca-osc); }
code { background: #0000000d; padding: 1px 5px; border-radius: 4px; }

.contenedor { max-width: 860px; margin: 0 auto; padding: 28px 16px 60px; }
.contenedor.angosto { max-width: 600px; padding-top: 60px; }

.aviso-prueba {
  background: #fff3c4; border-bottom: 1px solid #e8d48a; color: #6b5300;
  padding: 8px 16px; font-size: 14px; text-align: center;
}

/* Encabezado del formulario */
.encabezado { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; }
.encabezado-logo { width: 150px; flex: none; }
.encabezado h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.01em; }
.encabezado p { margin: 0; color: var(--suave); }

/* Tarjetas */
.tarjeta {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 26px 28px; margin-bottom: 20px; box-shadow: 0 1px 2px #0000000a;
}
.tarjeta h1 { font-size: 22px; margin: 0 0 8px; }
.tarjeta p { margin: 0 0 10px; }
.centrada { text-align: center; }
.centrado { text-align: center; }
.suave { color: var(--suave); font-size: 14px; }

.icono-ok, .icono-no {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 28px; font-weight: bold; color: #fff;
}
.icono-ok { background: var(--ok); }
.icono-no { background: var(--no); }

.alerta {
  background: var(--no-fondo); color: var(--no); border: 1px solid #f3c1bc;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px;
}
.error-tecnico {
  text-align: left; white-space: pre-wrap; font-size: 12px; background: #f6f6f6;
  padding: 10px; border-radius: 6px; overflow: auto;
}
.link-prueba {
  background: #fff8db; border: 1px dashed #d9bf55; border-radius: 8px;
  padding: 10px 12px; font-size: 13px; word-break: break-all; text-align: left;
}

/* Formulario */
.formulario section { padding: 6px 0 18px; border-bottom: 1px solid var(--linea); margin-bottom: 18px; }
.formulario section:last-of-type { border-bottom: 0; margin-bottom: 0; }
.formulario h2 {
  font-size: 15px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.formulario h2 span {
  width: 24px; height: 24px; border-radius: 50%; background: var(--tinta); color: #fff;
  font-size: 13px; display: grid; place-items: center;
}
.grilla { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.ancho-2 { grid-column: 1 / -1; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label small { font-weight: 400; color: var(--suave); }

input, textarea {
  font: inherit; font-weight: 400; color: var(--tinta);
  padding: 10px 12px; border: 1px solid #cfcac2; border-radius: 8px; background: #fff; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--marca); outline-offset: 0; border-color: var(--marca); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--no); background: #fffafa; }
input.calculado { background: #f6f4f1; color: var(--suave); }

.ayuda { font-weight: 400; font-size: 12.5px; color: var(--suave); }
.error { font-weight: 500; font-size: 13px; color: var(--no); }

fieldset.opciones { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
fieldset.opciones legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; width: 100%; }
fieldset.opciones .error { width: 100%; }
label.opcion {
  flex-direction: row; align-items: center; gap: 8px; font-weight: 500;
  border: 1px solid #cfcac2; border-radius: 8px; padding: 9px 16px; cursor: pointer;
}
label.opcion input { width: auto; margin: 0; accent-color: var(--marca); }
label.opcion:has(input:checked) { border-color: var(--marca); background: #fff4ec; }

.acciones { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; flex-wrap: wrap; }

/* Botones */
.boton {
  display: inline-block; font: inherit; font-weight: 600; border: 0; border-radius: 8px;
  padding: 12px 24px; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--marca); color: #fff;
}
.boton:hover { background: var(--marca-osc); }
.boton.secundario { background: #fff; color: var(--tinta); border: 1px solid #cfcac2; }
.boton.secundario:hover { background: #f6f4f1; }
.boton.exito { background: var(--ok); }
.boton.exito:hover { background: #155c2b; }
.boton.peligro { background: #fff; color: var(--no); border: 1px solid #e7a29b; }
.boton.peligro:hover { background: var(--no-fondo); }

.barra-accion { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.barra-accion p:last-child { margin-bottom: 0; }
.barra-accion > :last-child { flex: none; }
.estado-aprobada { border-left: 5px solid var(--ok); }
.estado-rechazada { border-left: 5px solid var(--no); }
.estado-pendiente_aprobacion, .estado-pendiente_firma { border-left: 5px solid #d9a400; }
.decision { border-top: 4px solid var(--marca); }

/* La nota (simula la hoja) */
.nota {
  background: var(--papel); border: 1px solid var(--linea); border-radius: 4px;
  padding: 40px 56px 32px; box-shadow: 0 2px 12px #0000000f;
  font-family: Georgia, "Times New Roman", serif; font-size: 16.5px; line-height: 1.85;
}
.nota-logos {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding-bottom: 14px; border-bottom: 1px solid var(--linea);
}
.nota-logos img { height: 46px; width: auto; max-width: 18%; object-fit: contain; }
.nota-marca { text-align: right; margin: 14px 0 6px; }
.nota-marca img { height: 34px; }
.nota-fecha { text-align: right; margin: 0 0 22px; }
.nota p { margin: 0 0 14px; }
.nota .etq { font-weight: bold; }
.nota-cuerpo { text-align: justify; }
.dato {
  font-weight: bold; border-bottom: 1px dotted #9a958c; padding: 0 3px;
  font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: .93em;
}
.tachado { color: #a19c94; text-decoration-thickness: 2px; }

.firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 34px; }
.firma-titulo { font-size: 13px; font-weight: bold; margin-bottom: 8px; line-height: 1.4; }
.firma {
  font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 13px; line-height: 1.5;
  border: 1.5px solid; border-radius: 8px; padding: 12px 14px;
}
.firma.ok { border-color: var(--ok); background: var(--ok-fondo); }
.firma.no { border-color: var(--no); background: var(--no-fondo); }
.firma.pendiente { border-color: #d9c38a; border-style: dashed; background: var(--pend-fondo); }
.firma-sello { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin-bottom: 4px; }
.firma.ok .firma-sello { color: var(--ok); }
.firma.no .firma-sello { color: var(--no); }
.firma.pendiente .firma-sello { color: var(--pend); }
.firma-nombre { font-size: 15px; font-weight: 700; }
.firma-mail { font-weight: 600; word-break: break-all; }
.firma-meta { color: var(--suave); font-size: 12px; margin-top: 4px; }
.firma-obs { margin-top: 8px; padding-top: 8px; border-top: 1px solid #0000001a; }

.nota-pie {
  margin-top: 30px; padding-top: 12px; border-top: 1px solid var(--linea);
  font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 11.5px; line-height: 1.45;
  color: var(--suave); display: flex; flex-direction: column; gap: 4px;
}

/* Celular */
@media (max-width: 640px) {
  .encabezado { flex-direction: column; align-items: flex-start; gap: 10px; }
  .encabezado-logo { width: 120px; }
  .grilla, .firmas { grid-template-columns: 1fr; }
  .tarjeta { padding: 20px 18px; }
  .barra-accion { flex-direction: column; align-items: stretch; }
  .nota { padding: 24px 20px; font-size: 15px; }
  .nota-logos img { height: 30px; }
  .acciones .boton { flex: 1; }
}

/* Impresión / PDF */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .aviso-prueba, .tarjeta, .no-imprimir, .suave.centrado { display: none !important; }
  .contenedor { max-width: none; padding: 0; }
  .nota { border: 0; box-shadow: none; padding: 0; }
  .firma { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ================= Panel de historial ================= */
.contenedor.ancho { max-width: 1200px; }
.boton.chico { padding: 8px 14px; font-size: 14px; }
select {
  font: inherit; font-weight: 400; color: var(--tinta); padding: 10px 12px;
  border: 1px solid #cfcac2; border-radius: 8px; background: #fff; width: 100%;
}

.login { text-align: center; }
.login .login-logo { width: 150px; margin: 4px auto 14px; display: block; }
.login label { text-align: left; }
.login .acciones { justify-content: stretch; }
.login .acciones .boton { flex: 1; }

.panel-encabezado { justify-content: space-between; }
.panel-encabezado > div { flex: 1; }

.contadores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.contador {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 14px 16px; text-decoration: none; color: var(--tinta);
  display: flex; flex-direction: column; gap: 2px; border-top: 4px solid #cfcac2;
}
.contador b { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.contador span { font-size: 13px; color: var(--suave); }
.contador:hover { background: #fbfaf8; }
.contador.activo { outline: 2px solid var(--tinta); outline-offset: -1px; }
.c-pendiente_firma { border-top-color: #b8b2a7; }
.c-pendiente_aprobacion { border-top-color: #d9a400; }
.c-aprobada { border-top-color: var(--ok); }
.c-rechazada { border-top-color: var(--no); }

.filtros { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; padding: 18px 20px; }
.filtros label { min-width: 160px; }
.filtros .filtro-buscar { flex: 1; min-width: 220px; }
.filtros-acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.tabla-caja { padding: 0; overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--suave); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--linea);
  background: #faf9f7;
}
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: #fcfbfa; }
.tabla .fuerte { font-weight: 600; }
.tabla .sub { font-size: 12.5px; color: var(--suave); margin-top: 2px; }
.tabla .obs { font-style: italic; max-width: 220px; }
.tabla .col-accion { text-align: right; white-space: nowrap; }
.vacio { padding: 40px; text-align: center; color: var(--suave); margin: 0; }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.chip-pendiente_firma { background: #efede9; color: #5c5850; }
.chip-pendiente_aprobacion { background: var(--pend-fondo); color: var(--pend); }
.chip-aprobada { background: var(--ok-fondo); color: var(--ok); }
.chip-rechazada { background: var(--no-fondo); color: var(--no); }

.paginas { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; color: var(--suave); font-size: 14px; }

@media (max-width: 900px) {
  .contadores { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .contadores { grid-template-columns: repeat(2, 1fr); }
  .panel-encabezado { flex-direction: row; flex-wrap: wrap; justify-content: space-between; }
  .panel-encabezado > div { order: 3; flex-basis: 100%; }
  .panel-encabezado h1 { font-size: 22px; }
  .tabla thead { display: none; }
  .tabla, .tabla tbody, .tabla tr, .tabla td { display: block; width: 100%; }
  .tabla tr { padding: 10px 0; border-bottom: 1px solid var(--linea); }
  .tabla td { border: 0; padding: 4px 16px; }
  .tabla td[data-t]::before {
    content: attr(data-t); display: block; font-size: 11px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--suave);
  }
  .tabla .col-accion { text-align: left; padding-top: 8px; }
}

/* Casilla "No tengo correo" y firma validada por admin */
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--marca); flex: none; }
.apagado { opacity: .45; }
.firma.ok.admin { border-color: #3a6ea5; background: #eef4fb; }
.firma.ok.admin .firma-sello { color: #2d5b8c; }
.aviso-ok {
  background: var(--ok-fondo); color: var(--ok); border: 1px solid #b7dcc2;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px;
}
form.en-linea { display: inline; }
.acciones-fila { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 700px) { .acciones-fila { justify-content: flex-start; } }
.tabla td:first-child { white-space: nowrap; }

/* Parámetros */
.nav-panel { display: flex; gap: 8px; flex: none; }
.titulo-seccion { font-size: 18px; margin: 0 0 6px; }
.lista-correos { list-style: none; padding: 0; margin: 16px 0; border: 1px solid var(--linea); border-radius: 8px; }
.lista-correos li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--linea); word-break: break-all;
}
.lista-correos li:last-child { border-bottom: 0; }
.vacio-chico { background: var(--pend-fondo); color: var(--pend); padding: 10px 14px; border-radius: 8px; margin: 16px 0; }
.agregar-correos { margin-top: 8px; }
.agregar-correos .acciones { margin-top: 12px; }
.probar { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--linea); }
.avisos-envio { margin: 6px 0 10px; padding-left: 18px; font-size: 14px; }
.avisos-envio .mal { color: var(--no); }
.panel-encabezado > .nav-panel { flex: none; align-self: flex-start; }
@media (max-width: 700px) {
  .panel-encabezado > .nav-panel { order: 2; flex-basis: auto; }
}
.tabla.diag { margin: 12px 0; border: 1px solid var(--linea); border-radius: 8px; }

/* Limpiar base de datos */
.zona-peligro { border: 1px solid #f0b8b2; border-top: 4px solid var(--no); }
.zona-peligro .titulo-seccion { color: var(--no); }
.limpiar-bd { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.limpiar-bd label { flex: 1; min-width: 220px; }
.boton.peligro-lleno { background: var(--no); color: #fff; }
.boton.peligro-lleno:hover { background: #8f1c13; }
